Unlike Cohere and AI21 Labs, which allow fine-tuning to be performed from their platform with a simple interface, OpenAI offers fine-tuning through its API. This makes it difficult to create custom models for users unfamiliar with coding tools. That is why we have included in our application the ability to train your custom OpenAI models easily.
What is fine-tuning? #
According to what is specified in OpenAI documentation, fine-tuning allows you to get more out of the models available through its API, as it provides:
- Higher quality results than prompt design.
- Ability to train on more examples than can fit in a prompt.
- Token savings due to shorter prompts.
- Lower latency requests.
GPT-3 has been pre-trained on a vast amount of text from the open internet. When given a prompt with just a few examples, it can often intuit what task you are trying to perform and generate a plausible completion. This is often called “few-shot learning.”
Fine-tuning improves on few-shot learning by training on many more examples than can fit in the prompt, letting you achieve better results on a wide number of tasks. Once a model has been fine-tuned, you won’t need to provide examples in the prompt anymore. This saves costs and enables lower-latency requests.
How to create a fine-tuning model in OpenAI? #
Below, we will explain step-by-step how to create a fine-tuning model in OpenAI:
Prepare your training data
The training data represents the data you want your model to learn. This information should be in JSONL format, where each line is a question-answer pair corresponding to a training example. For example:
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
...
You can review best practices for preparing your dataset at this link.
Load your training data
Before training our fine-tuning model, we must load the training data, to do so in the Fine-Tuning section, we select OpenAI. Then click on the “Upload File” button.
In the pop-up window, we will load our file. If there is any error in the file data you will see a warning message and until it is fixed you will not be able to continue.
If everything is OK, click on Upload. This will send your training data directly to your OpenAI account. We only act as an intermediary, so we do not keep any copies of the files you upload.
When finished, we will see our file in the list of all the files uploaded to our OpenAI account. From this list, you can also delete them directly from your OpenAI account.
Note: The maximum size allowed to upload a file is 4 MB.
Training the model
To train the model, we will use the file uploaded in the previous step. First, click on the “Create Fine-tune” button. In the pop-up window, we will add the following data:
- Suffix: A string of up to 40 characters that will be added to your fine-tuned model name. For example, a suffix of “custom-model-name” would produce a model name like ada:ft-your-org:custom-model-name-2022-02-15-04-21-04.
- Model: We will select the base model for our fine-tuning. You can also use as base a fine-tuning previously created when you want to update your model with more training data.
- Training File: Select the file with the training data for your fine-tuning.
You can also configure the hyperparameters of your model by modifying the advanced options; however, we recommend not modifying them and keeping their default values. You can find more information about these values here.
Clicking on “Create” will start the fine-tuning process. This may take a few minutes, depending on the amount of data and the base model used. Refresh the page to see the current status of your newly created model.
Once completed, it will be marked as “Succeeded” and you will be able to view the results of it by clicking on the “Data” button.
Using your Fine-Tuning models in AI Content Labs #
Finally, to add your fine-tuning models to our platform, check the corresponding checkbox and click Save.
Now, when you select OpenAI as your provider, you will have your fine-tuned models available.