Skip to content

Fine-Tuning

Continuing to train a pretrained model on your own examples to specialize it. LoRA does this cheaply by training small add-on matrices instead of all the weights.

Also full fine-tuning · domain adaptation

Fig. / How it works
Pretrained modelPretrained modelYour examplesYour examplesSmall weight updatesSmall weight updatesSpecialised modelSpecialised model
Role · kind
TrainingTechnique
Level
Intermediate

Hu et al. (LoRA), 2021

A chef who already knows how to cook takes a short course in one cuisine. LoRA is like giving them a small recipe card to clip onto their existing knowledge rather than retraining them from scratch.

Where it fits

+All relationships as a list

See it on the full map

How it works

A pretrained model already knows a lot. Fine-tuning adapts it with your own examples, a form of transfer learning: show input-output pairs, compute the loss, and update with gradient descent, usually with a small learning rate so it does not forget what it knew.

Updating every weight of a billion-parameter model is expensive, and each fine-tuned copy is as big as the original. LoRA (low-rank adaptation) avoids both:

  1. Freeze the original weights.
  2. Next to selected weight matrices, add two thin matrices, B and A, whose product is a correction to that weight.
  3. Train only B and A.

Because they are thin (the “rank” might be 8 or 16), they hold a tiny fraction of the parameters, often well under 1%. The resulting adapter is a small file you can swap in and out. QLoRA goes further by keeping the frozen base model quantized to 4 bits.

When to choose what: fine-tuning shapes behavior (format, tone, a narrow skill); RAG supplies knowledge that changes or must be cited; good prompting is the cheapest first try.

The math

For a frozen weight W∈Rd×kW \in \mathbb{R}^{d \times k}, LoRA learns B∈Rd×rB \in \mathbb{R}^{d \times r} and A∈Rr×kA \in \mathbb{R}^{r \times k} with r≪min⁡(d,k)r \ll \min(d, k):

h=Wx+BAxh = W x + B A x

Trainable parameters drop from dkdk to r(d+k)r(d + k).

Everyday use cases

  • Case 01

    Company tone and format

    Teach a model to write in a house style or output a specific structured format.

  • Case 02

    Specialist tasks

    Classify legal clauses or extract fields from medical notes with a few thousand examples.

  • Case 03

    Turning base models into assistants

    Supervised fine-tuning on example conversations is the first step of post-training.

Strengths, weaknesses and when to use it

Strengths

  • Specializes behavior and format more reliably than prompting alone.
  • LoRA makes it affordable on a single GPU, and adapters are small to store and swap.

Weaknesses

  • Needs good examples; bad data teaches bad habits.
  • Poor at adding lots of new factual knowledge; retrieval is usually better for facts.

When to use itWhen prompting is not consistent enough and you have a few hundred or more good examples of the desired behavior.

Compare with

Check yourself

  1. Q01

    What does LoRA train?

    Show answer

    A: Small low-rank matrices added to frozen weights

  2. Q02

    You need answers about documents that change weekly. What is usually better?

    Show answer

    A: Retrieval-augmented generation

Go deeper