SysArt
Book a briefing
SysArt

Explainer

What is fine-tuning for LLMs?

Fine-tuning changes how a language model behaves by training it further on your own examples. This explainer covers the methods, when fine-tuning beats prompting or retrieval, and the risks and obligations it brings.

Last reviewed by SysArt AI Architecture Team6 min readHow we review

In short

Fine-tuning trains a pretrained language model further on your own examples so that it follows a format, style, vocabulary or task more reliably. Methods such as LoRA train a small set of added weights instead of the whole model. Fine-tuning is good at changing behaviour but a poor way to add facts, which retrieval handles better.

DefinitionFine-tuning is the further training of a pretrained language model on a smaller, task-specific dataset, updating all of its weights or a small set of added parameters, so that it follows a desired format, style, vocabulary or task more reliably.

Key takeaways

  • Fine-tuning changes how a model behaves, such as its format, tone, terminology or skill at a narrow task; retrieval is usually better for adding or updating knowledge.
  • Parameter-efficient methods such as LoRA and QLoRA train small adapters on a frozen base model, cutting the GPU memory and storage that tuning needs.
  • Start with prompting and retrieval, and fine-tune when an evaluation shows a gap they cannot close.
  • Fine-tuning can weaken safety behaviour and expose training data, so curate the dataset and re-test safety and leakage before every release.
  • The base model's licence still applies, and under the EU AI Act fine-tuning makes you a general-purpose AI model provider only in exceptional cases.

What is fine-tuning for LLMs?

Fine-tuning is training a pretrained language model further on a smaller, curated dataset so that its behaviour shifts towards your task. The model starts from everything it learned in pretraining and adjusts to your examples.

Chat and instruction-following models have already been fine-tuned by their developers. The InstructGPT paper describes the pattern: supervised fine-tuning on demonstrations written by people, followed by reinforcement learning from human feedback. In its human evaluations, outputs of the 1.3-billion-parameter InstructGPT model were preferred to those of the 175-billion-parameter GPT-3, despite having 100 times fewer parameters. Tuning can change behaviour a great deal.

Three kinds of fine-tuning are common:

  • Supervised fine-tuning (SFT) on pairs of inputs and the outputs you want.
  • Preference tuning, which teaches the model which of two answers people prefer. Direct preference optimisation (DPO) does this with a simple classification loss on preference pairs, without training a separate reward model or using reinforcement learning.
  • Continued pretraining on large amounts of unlabelled domain text, such as technical documentation.

How does fine-tuning differ from prompting and RAG?

Prompting changes the instructions, retrieval-augmented generation (RAG) changes the information the model sees, and fine-tuning changes the model itself. They solve different problems and are often combined.

PromptingRAGFine-tuning
What changesInstructions and examples in each requestPassages retrieved for each questionThe model’s weights, or small adapters added to them
Best forFast iteration and general tasksKnowledge that changes, citations and access rulesFormat, tone, terminology and narrow tasks
What you needA few good examplesThe documents and a search pipelineA curated training set and a separate evaluation set
UpdatingEdit the promptRe-index the changed documentsTrain, evaluate and release a new version
Per-user permissionsPossible, if content is checked before it enters the promptEnforced during retrievalNot possible: what the model learned is available to every user
Main risksLong, brittle promptsRetrieval misses and prompt injectionWeaker safety behaviour, memorised data and forgotten skills

When should you fine-tune a model?

When prompting and retrieval are in place and an evaluation still shows a consistent gap in behaviour that examples can teach. Start with the cheaper options, and fine-tune when measurement justifies it.

Good reasons to fine-tune:

  • Outputs must follow a strict structure or template every time, and prompting alone is not reliable enough.
  • The model must use your domain’s terminology, style or classification scheme consistently.
  • A narrow, high-volume task, such as classification, extraction or routing, could run on a smaller tuned model instead of a large general one, saving latency and hardware.
  • Long prompts full of instructions and examples could be replaced by learned behaviour, reducing the cost of each request.

Poor reasons to fine-tune:

  • Adding facts that change. Ovadia and colleagues found that RAG consistently outperformed unsupervised fine-tuning for injecting knowledge, and that models struggle to learn new facts this way. Use retrieval-augmented generation for knowledge.
  • Keeping information from some users. Whatever is in the weights is available to everyone who can query the model.
  • No evaluation data. Without a test set, you cannot tell whether the tuned model is better than what you had.

What are LoRA and QLoRA?

They are parameter-efficient fine-tuning methods: the base model stays frozen and only a small set of added weights is trained, which cuts the GPU memory and storage that tuning needs.

  • LoRA (low-rank adaptation) injects small trainable matrices into each layer of the model. Its authors report that, compared with fully fine-tuning GPT-3 175B with the Adam optimiser, LoRA reduced trainable parameters by 10,000 times and GPU memory by three times, with on-par or better quality on the models they tested and no added inference latency.
  • QLoRA trains LoRA adapters on top of a base model quantised to 4 bits. Its authors fine-tuned a 65-billion-parameter model on a single 48 GB GPU while preserving the task performance of full 16-bit fine-tuning.

The trade-off is that adapters learn less. In “LoRA Learns Less and Forgets Less”, Biderman and colleagues found that, in standard low-rank settings, LoRA substantially underperformed full fine-tuning on programming and mathematics, but better preserved the base model’s performance on tasks outside the target domain.

Adapters are also practical to serve. An engine such as vLLM can serve several LoRA adapters on one base model, so many tuned variants share the same GPUs, and libraries such as Hugging Face PEFT implement these methods. Our explainer on LLM inference serving covers the serving side.

What does a fine-tuning project involve?

Five steps, of which only one is the training run; the data and the evaluation decide whether it works.

  1. Define the target behaviour and the baseline. Measure the best prompt-and-retrieval set-up first, on an evaluation set that is never used for training.
  2. Build the dataset. Collect representative inputs with correct outputs, reviewed by domain experts. Check that you have the right to use each example, and remove personal and confidential data that the task does not need.
  3. Train. Choose the method, whether LoRA, QLoRA or full fine-tuning, and record the data version, code, settings and base model.
  4. Evaluate broadly. Compare task quality with the baseline, and re-test general capabilities, safety behaviour and leakage of training data.
  5. Release and maintain. Register the model or adapter as a versioned artefact, roll it out gradually with a way back, and repeat the cycle when the base model changes.

Our insight on fine-tuning small language models on domain data goes deeper into data preparation and training infrastructure.

What are the risks of fine-tuning?

Four matter most: weaker safety behaviour, memorised training data, forgotten skills and the cost of maintaining tuned versions.

  • Safety regression. Qi and colleagues jailbroke the safety guardrails of GPT-3.5 Turbo by fine-tuning it on only 10 adversarial examples, at a cost of less than 0.20 US dollars, and found that fine-tuning on benign, commonly used datasets can also degrade safety. Re-run safety and refusal tests after every tuning run.
  • Memorisation. Language models can memorise and reveal training data: Carlini and colleagues extracted hundreds of verbatim sequences, including personal information, from GPT-2, and found larger models more vulnerable. Assume the same could happen with your fine-tuning data, minimise sensitive content and test for leakage.
  • Forgetting. Training on a narrow task can degrade other abilities. Parameter-efficient methods reduce this but do not remove it.
  • Maintenance. Each tuned version is an artefact to evaluate, secure, document and eventually retire, and a new base model means tuning again.

Does fine-tuning change your licence or EU AI Act obligations?

It can. The base model’s licence still applies to the tuned version, and in exceptional cases fine-tuning makes you the provider of a general-purpose AI model.

  • Licences. Read the base model’s terms before tuning. Meta’s Llama 3.1 Community License, for example, requires that a model created or fine-tuned with Llama materials, if it is distributed or made available, include “Llama” at the beginning of its name. Our guide to open-weight model licences compares the main terms.
  • General-purpose AI models. The European Commission’s guidelines treat a downstream modifier as the provider of a modified general-purpose AI model only if the modification significantly changes the model’s generality, capabilities or systemic risk. The indicative criterion is training compute for the modification above one third of the compute used to train the original model, and the Commission notes that few modifications currently meet it. A modifier that does become a provider has obligations limited to the modification. Our page on GPAI obligations covers the details.
  • AI systems. The obligations for the system you build on the tuned model, for example if it is used for a high-risk purpose, depend on its intended use and your role, not on whether you fine-tuned the model.
  • Personal data. If the training data includes personal data, the GDPR applies to that processing, so involve your data protection officer early.

This explainer is general information, not legal advice. Our private LLM service covers model selection and licence review for models that run on infrastructure you control.

Frequently asked questions

What is fine-tuning in simple terms?

Fine-tuning means training an existing language model a little further on your own examples, so that it responds the way you need: in a particular format, tone or vocabulary, or on a narrow task. The model starts from what it learned in pretraining, and the extra training shifts its behaviour towards your examples.

Is fine-tuning better than RAG?

They solve different problems. RAG supplies knowledge at question time, keeps it current by re-indexing, enforces access rights and can cite sources. Fine-tuning changes behaviour, such as format, tone or task skill. For adding facts, Ovadia and colleagues found that RAG consistently outperformed unsupervised fine-tuning. The two can be combined, with a tuned model answering over retrieved passages.

What is LoRA?

LoRA, short for low-rank adaptation, keeps a model's original weights frozen and trains small additional matrices in each layer. Its authors report that, compared with fully fine-tuning GPT-3 175B with the Adam optimiser, it cut trainable parameters by 10,000 times and GPU memory by three times, with on-par or better quality and no added inference latency.

How much data do you need to fine-tune an LLM?

There is no reliable universal number, because it depends on the task and the method. Narrow changes to format or style need fewer examples than teaching a new skill. What matters most is that the examples are correct, representative of real inputs and reviewed by domain experts, with a separate evaluation set that is never used for training.

Can fine-tuning make a model less safe?

Yes. Qi and colleagues jailbroke the safety guardrails of GPT-3.5 Turbo by fine-tuning it on only 10 adversarial examples, at a cost of less than 0.20 US dollars, and found that fine-tuning on benign, commonly used datasets can also degrade safety. Re-run safety and refusal tests after every tuning run, not only task-quality tests.

Can a fine-tuned model leak its training data?

It can. Carlini and colleagues extracted hundreds of verbatim sequences, including personal information, from the training data of GPT-2, and found larger models more vulnerable than smaller ones. Keep personal and confidential data out of training sets unless the task needs it, restrict who can query the tuned model, and test for memorised content before release.

Does fine-tuning an open-weight model make us a provider under the EU AI Act?

Usually not of a general-purpose AI model. The Commission's guidelines treat a modifier as the provider of the modified model only if the modification significantly changes its generality, capabilities or systemic risk, with an indicative threshold of more than a third of the original training compute. Obligations for the AI system you build still depend on its use and your role.

Can fine-tuning run on-premises?

Yes. With open-weight models, parameter-efficient methods make fine-tuning feasible on limited GPU capacity: the QLoRA authors fine-tuned a 65-billion-parameter model on a single 48 GB GPU. Training data then stays inside your boundary, and engines such as vLLM can serve several LoRA adapters on one base model, so tuned variants share the same hardware.

Find out whether fine-tuning is worth it

Bring a task and a sample of real inputs. We set up an evaluation, compare prompting, retrieval and fine-tuning on it, and recommend the simplest option that meets the bar.