Search code examples
node.jsopenai-api

How to train openai model using fine tune in nodejs


I need to train my openai model using nodejs programming language.

I just got python script to train my openai model but I don't know the python programming language.

Is it possible to train my openai model using nodejs?

Can anyone please help me with that?


Solution

  • Yes you definitely can fine-tune your own OpenAI model using Nodejs. Use the openai npm package.

    Here are the steps.

    1. Create the training file

    This is a JSONL file (look up JSONL if you are not too familiar) with your training prompts and completions.

    1. Upload the file

    To upload the JSONL file use the method:

    openai.createFile 
    
    1. Create a fine-tunes model

    With the file uploaded you use another method to train your model:

    openai.createFineTune
    

    This will take some time and will eventually create a new fine-tuned model for you.

    1. Use the new model

    You will be able to use the new model in the completions endpoint by assigning the fine-tuned models name, to the model parameter.

    All of this information is provided in the OpenAI API docs found here:

    https://platform.openai.com/docs/api-reference/files/upload

    There are code examples provided for each step. It will display the code in CURL by default but you can use the dropdown to change it to nodejs.

    Good luck.