Fine-tuning
In short
Fine-tuning is a later training stage that takes a model already trained on a broad task and adjusts it on a smaller set of examples so it does one narrower job.
- Also called
- Finetuning
- Topic
- How models are trained
- Level
- Beginner
- First described
- Erhan and colleagues, Journal of Machine Learning Research, 2010, name the second stage of deep belief networks and stacked autoencoders "supervised fine-tuning", after layer-wise unsupervised pre-training1.
In 2010 Erhan and colleagues describe deep belief networks and stacked autoencoders as greedy layer-wise unsupervised pre-training followed by supervised fine-tuning1. Fine-tuning is the last phase, when gradient updates train the network on a labelled objective1.
For text, Howard and Ruder set out universal language model fine-tuning in 20182. A language model is trained on a broad corpus, then fine-tuned on the target task2. With only 100 labelled examples, they report, it matched training from scratch on 100 times more data2. The failure they report is overfitting on small datasets and catastrophic forgetting when a classifier is added2. Their remedies were a different learning rate per layer, a rate that rises then falls, and unfreezing layers one at a time from the top2.
Radford and colleagues use the same split with a Transformer3. After generative pre-training, they adapt the parameters on a labelled set, add a linear output layer, and maximise the probability of the correct label, while keeping some of the language-model loss3. BERT fine-tunes every pre-trained parameter, plus one new output layer, separately for each downstream task4.
Full fine-tuning updates the weights. Hu and colleagues define the ordinary method that way: adaptation is usually done via fine-tuning, which updates all the parameters of the pre-trained model5. LoRA freezes those weights and trains small added matrices. On GPT-3 with 175 billion parameters, they report 10,000 times fewer trainable parameters and one third of the GPU memory of full fine-tuning with Adam5. Prompting is separate. OpenAI lists prompt engineering and fine-tuning as different steps, and only fine-tuning trains on a dataset of examples6.
Ouyang and colleagues fine-tuned GPT-3 on labeler demonstrations with supervised learning, then again with reinforcement learning from human feedback, and called the result InstructGPT7. OpenAI's docs say the company is winding the fine-tuning platform down. New users cannot access it. Existing users can still create training jobs for the coming months, and a fine-tuned model stays available for inference until its base model is deprecated6. The same page still defines fine-tuning as taking a pre-trained base model and supplying the inputs and outputs you expect, including more examples than fit in one request6.
Example
In Howard and Ruder's text-classification experiments, fine-tuning on only 100 labelled examples matched a model trained from scratch on 100 times more labelled data2.
Why it matters
It is how a general model becomes a specialist, including the supervised step that turned GPT-3 into InstructGPT, without repeating the whole pre-training run37.
Questions people ask
What is fine-tuning?
It is extra training of a model that has already been trained. Erhan and colleagues describe it as the supervised phase after unsupervised pre-training1. In the 2018 GPT paper it means adapting the pre-trained parameters on a labelled dataset and adding a small output layer3.
Is fine-tuning the same as prompting?
No. A prompt is text you send with a request. Fine-tuning trains on examples and, in the ordinary form, updates the model's parameters5. OpenAI lists prompt engineering and fine-tuning as separate steps in the same workflow6.
Is LoRA the same as fine-tuning?
LoRA is a cheaper way to adapt a model, not full fine-tuning. Full fine-tuning updates every parameter. LoRA freezes those weights and trains small matrices beside them. On GPT-3 175B, Hu and colleagues report 10,000 times fewer trainable parameters5.
Can I still fine-tune an OpenAI model?
OpenAI says it is winding the fine-tuning platform down. New users cannot access it. Existing users can create training jobs for the coming months, and finished models keep running until the base model is deprecated6. Fine-tuning as a method is unaffected. It is not only an OpenAI service25.
Related terms
Sources
- Erhan et al. (2010), Why Does Unsupervised Pre-training Help Deep Learning?, JMLR 11:625-660
- Howard and Ruder (2018), Universal Language Model Fine-tuning for Text Classification, arXiv:1801.06146
- Radford et al. (2018), Improving Language Understanding by Generative Pre-Training, OpenAI
- Devlin et al. (2018), BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, arXiv:1810.04805
- Hu et al. (2021), LoRA: Low-Rank Adaptation of Large Language Models, arXiv:2106.09685
- OpenAI, Model optimization (fine-tuning platform)
- Ouyang et al. (2022), Training language models to follow instructions with human feedback, arXiv:2203.02155