Skip to content

Fine-tuning

Also called: fine-tune, fine-tuned, finetuning

Published:

How does fine-tuning work?

Google's machine learning course explains that turning a general-purpose foundation model into something that fits an application's needs takes fine-tuning. The model gets additional training on examples specific to the task the application will perform [1]. Engineers can sometimes get there with only a few hundred or a few thousand training examples [1]. A team that wants a model to sort contract clauses by type could, for instance, fine-tune a foundation model on a few thousand labelled clauses.

Standard fine-tuning updates every parameter. Parameter-efficient tuning adjusts only a subset of parameters on each backpropagation step, which makes it cheaper [1]. Either way, a fine-tuned model has the same number of parameters as the model it started from; producing a smaller model is the job of distillation [1].

Why is fine-tuning large models hard?

The authors of the LoRA paper note that full fine-tuning, which retrains all of a model's parameters, becomes less feasible as models grow [2]. Their method, low-rank adaptation, can cut the number of trainable parameters by 10,000 times and GPU memory requirements by three times compared with fine-tuning GPT-3 175B using Adam [2].

How is fine-tuning different from prompt engineering?

Prompt engineering leaves the model's parameters untouched and works only by shaping the input. Fine-tuning changes the weights [1].

Frequently asked questions

How much data does fine-tuning need?

It depends on the task. Google's course says a few hundred or a few thousand examples are sometimes enough.

Is LoRA a type of fine-tuning?

Yes. LoRA is a parameter-efficient fine-tuning method that trains small added low-rank matrices instead of all of the model's weights.

Sources

  1. LLMs: Fine-tuning, distillation, and prompt engineering — Google for Developers
  2. LoRA: Low-Rank Adaptation of Large Language Models — arXiv