Introduction
OpenAI's language models, like GPT-3.5, are incredibly capable out of the box. However, they can become even more powerful when fine-tuned on data specific to your business needs. In this post, we'll cover:
- What is fine-tuning,Â
- How it works with OpenAI models,Â
- When it makes economic sense for businesses, andÂ
- The pricing model.
What is Fine-Tuning?
Fine-tuning is further training a pre-trained large language model on new data. This process is used to customize it for a specific task or domain. For example, GPT-3.5 was trained by OpenAI on a huge dataset of text from the internet. By fine-tuning it on data related to your industry, use case, or workflow, you can specialize the model to generate more relevant and higher-quality outputs.
How Does Fine-Tuning Work?
Fine-tuning OpenAI models involves providing additional training examples as {prompt, completion} pairs. These new examples help the model learn the nuances of your domain by updating the internal parameters.
First, you prepare a dataset of prompt-completion examples demonstrating your desired behavior. The prompts should include any instructions or context needed, while the completions are the ideal responses.
Once your dataset is ready, you initiate a fine-tuning job through the OpenAI API, specifying the model, your training examples, and hyperparameters like the number of training epochs. OpenAI runs the job in the cloud to update the model’s parameters.
The result is a specialized model tuned for your specific needs. You can then integrate and query that custom model through the API to generate tailored outputs.
When Does Fine-Tuning Make Economic Sense?
Fine-tuning requires an upfront investment in preparing training data and model training. However, improved performance and reduced prompt engineering costs can pay off in the long run.
Some key factors to consider:
- Volume of queries: The more queries you plan to run with the model, the more fine-tuning pays off by amortizing the upfront costs.
- Cost savings from smaller prompts: Fine-tuned models often need less explicit prompting, saving on token costs.
- Value of performance gains: Certain use cases, like unreliable output formatting, may be blockers without fine-tuning.
As a rule of thumb, fine-tuning is likely worth investigating if you are doing at least 25,000+ queries per month and care about reliability, accuracy, or branding. The performance lift can justify 10x higher pricing over base models.
Pricing Model
The pricing model for fine-tuning has two main components: training and usage costs.Â
Here are the costs to fine-tune GPT-3.5 Turbo (at the time of publication):
- Training cost: $0.008 per 1k tokens of training data, paid once upfront
- Usage cost: $0.012 per 1k input tokens, $0.016 per 1k output tokens
So, for example, with 100k training tokens and 20k monthly requests, the costs would be:
- Upfront training: 100k * $0.008 = $800
- Monthly usage: 20k * ($0.012 + $0.016) = $560
In many cases, the long-term usage cost savings from smaller prompts can offset the upfront training investment in just a few months.
Summary
In summary, fine-tuning adapts general OpenAI models into customized solutions for your business needs. When you have specific behaviors and outputs you want to teach, fine-tuning can provide strong ROI through performance gains and prompting efficiencies.