Fine-tuning OpenAI models

Gasby provides the OAI Finetune tool to help fine-tune your models (using OpenAI new's API). For more details, visit OpenAI Fine-tuning

At the moment, we only support fine-tuning OpenAI models. OpenAI supports fine-tuning gpt-3.5-turbo (recommended), babbage-002, and davinci-002 models

To fine-tune a model, you'll need:

  1. Prepare a data file (try JSON Geneartor)
  2. Upload the data file
  3. Run the fine-tuning process

Once completed, a new model will be created. You'll be able to config and use this model in the Provider settings

1. Prepare a fine-tuning data file (JSONL)

OpenAI accepts JSONL format for fine-tuning a model. JSONL is a multi-line data in JSON format. Note that not all models have the same data input.

For gpt-3.5-turbo model, the JSONL file will have the following format

{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who wrote 'Romeo and Juliet'?"}, {"role": "assistant", "content": "Oh, just some guy named William Shakespeare. Ever heard of him?"}]}
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "How far is the Moon from Earth?"}, {"role": "assistant", "content": "Around 384,400 kilometers. Give or take a few, like that really matters."}]}

For other models, the JSONL file will have the following format

{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}

Note that to finetune a large content, such as an article, a document, or a book, you should split the content into multiple chunks. Check out this discussion to learn more about fine-tuning books

Once you have prepared the fine-tuned data, save it into a jsonl file.

2. Upload the fine-tuned data file

  1. Navigate to OAI Finetune tool
  2. Under Your files, click on Upload file and select your JSONL file prepared earlier. It'll start uploading the file
  3. Once completed, the file should appear in the files table. Try Refresh if you don't see it

3. Start fine-tuning process

Make sure you have the correct file data format, and the filename should appear in the files table.

  1. Under the files table, navigate to your file and select Finetune. It'll open up the Start fine-tuning popup.
  2. Make sure the Finetune file, and your fine-tune Model are correct
  3. Click Start to start the fine-tuning process

Now, you'll be able to see the process in the Finetune jobs tab

Depending on how big your finetune data is, it might take a few minutes to hours to complete the finetune process. I've tried to fine-tune with a 12-line data file, it took around 20 minutes to complete the process.

4. Use fine-tuned model for chatting

In the OAI Finetune tool > Finetune job, you should be able to see the status of the process. Once the fine-tuning process is completed, you can use the fine-tuned model to chat.

To use the model for chatting:

  1. Locate your completed finetune process on the table
  2. Click on Use this model (message icon). It'll update your provider settings to OpenAI, and set the model name to the new fine-tuned model
© 2023 GasbyAI. All rights reservedNeed help? Join our Discord channel