Skip to main content
In this lesson, you’ll learn how to fine-tune an OpenAI model using the CLI. We’ll cover:
  • Preparing your dataset
  • Uploading and formatting data
  • Launching and monitoring a fine-tune job
Although OpenAI is deprecating older fine-tuning models by January 4th and announcing GPT-3.5/GPT-4 support soon, the core workflow remains the same.
Most existing fine-tuning models (e.g., older Curie, Davinci) will retire by January 4th. It’s recommended to wait for GPT-3.5/GPT-4 fine-tuning, but you can continue experimenting with Ada, Babbage, Curie, and Davinci until then.
The image shows a webpage from OpenAI's documentation about fine-tuning models, detailing the deprecation of certain models and the benefits of fine-tuning. It includes a sidebar with navigation links and a highlighted announcement about model updates.
Pricing for fine-tuning varies by model. Ada remains the most cost-effective, while Davinci is the most expensive. Regardless of your budget, the process is identical across models.
The image shows a webpage from OpenAI detailing pricing for fine-tuning and embedding models, including costs for different models like Ada, Babbage, Curie, and Davinci.

Use Case: State of the Union Q&A Chatbot

We’ll build a simple chatbot that answers questions about President Biden’s February 7, 2023 State of the Union address. Since GPT-3.5’s knowledge cutoff is 2021, it won’t know this speech. We’ll fine-tune using a publicly available summary from the European Parliament.

1. Prepare the Raw JSONL Dataset

First, convert your prompt/completion pairs into JSON Lines format. Example qna.jsonl:
Save qna.jsonl alongside your PDF source:

2. Upload and Prepare the Dataset

Use the OpenAI CLI to validate, dedupe, and add separators:
Verify the new file:

Sample Entries in qna_prepared.jsonl

3. Create the Fine-Tuning Job

Select a base model (ada, babbage, curie, or davinci) and start fine-tuning:
You’ll see upload progress and receive a fine-tune ID:

Model Comparison

4. Monitor and Complete

Follow the job status:
Example output:
After completion, note the recommended openai api completions.create command in the CLI output to invoke your fine-tuned model.

5. Invoke Your Fine-Tuned Model

Once the job succeeds, run:
The model will respond based on your custom SOTU Q&A dataset. Adjust the model choice and epochs to balance accuracy vs. cost.

Watch Video