My account

Fine-tuning or not?

Fine-tuning trains a model a little more on your own examples. It is good at changing behavior: a format, a tone, a narrow task done the same way every time, or getting a small cheap model to do what a big one does. It is a poor way to teach facts that change, like prices or policies; that is what RAG is for. Try prompts and RAG first, build an eval set before you train, use LoRA to keep it cheap, and plan for retraining when the base model or your data changes.

Not reviewedWritten with AI helpReading time: 15 minShop help assistant example

Author: bezzad

Contents

The problem: “let’s train it on our policy”

The return policy changed from 14 to 30 days. A manager says: “The bot still makes mistakes about returns. Let’s fine-tune the model on our policy documents, so it really knows them.”

It sounds right, but it has three problems:

  1. Facts learned in training are fuzzy. The model may still mix our policy with the thousands of other policies it saw before.
  2. Policies change. Every change means a new training run, a new eval and a new deployment.
  3. No sources. A fine-tuned model cannot show which document it used, so nobody can check the answer.

Fine-tuning is a real tool. This lesson is about when it is the right one.

What fine-tuning changes

A trained model has billions of numbers (weights). Fine-tuning runs more training on your examples, so the weights move a little toward the answers you showed.

Fine-tuning is good for Fine-tuning is weak for
A fixed output format, every time Facts that change (prices, stock, policies)
A tone or style that prompts cannot hold Private data per customer
A narrow task, like sorting tickets into 12 types Answers that must show sources
Making a small, cheap model as good as a big one on one task Fixing bad retrieval

A short rule: RAG gives the model knowledge. Fine-tuning gives it habits.

Climb the ladder

1. Clear promptrules, output type2. Examples3 to 5 in the prompt3. RAGfacts from your documents4. Fine-tuninghabits, small fast modelmore cost to build and to keep
Each step up costs more to build and to keep. Go up only when the step below, measured on your eval set, is not enough.
  1. A clear prompt. Rules, the output type, a good system message.
  2. Examples in the prompt (few-shot). Three to five good examples often fix the format.
  3. RAG, when the answer depends on your documents or data.
  4. Fine-tuning, when the behavior is still wrong after all of the above, or when cost and speed need a smaller model.

Many teams use both: RAG for facts, and a fine-tuned small model that is good at reading the sources and answering in the shop’s style.

LoRA: train a small add-on

Full fine-tuning changes every weight. For a large model, that needs a lot of GPU memory and makes a full new copy of the model. LoRA (low-rank adaptation) keeps the original weights frozen and trains two small matrices next to each big one.

InputFrozen W4096 by 4096about 16.8 millionnot trainedABtrained, rank 8+OutputA and B together:about 65 thousand numbersa small file per task
The big weight matrix stays frozen. LoRA trains two thin matrices, A and B. Their product is added to the output. Only A and B are saved: a small file you can swap per task.

A quick count for one layer matrix of 4,096 × 4,096:

  1. Full matrix: about 16.8 million numbers.
  2. LoRA with rank 8: 4,096 × 8 + 8 × 4,096 = 65,536 numbers, about 0.4% of the matrix.

So training needs much less memory, and the result is a small adapter file. You can keep one base model and several adapters, for example one for ticket sorting and one for product descriptions. QLoRA goes further: the frozen base model is stored in 4 bits during training.

Hosted providers (like OpenAI or Azure OpenAI) also offer fine-tuning of some of their models. You upload examples and get a new model name; they choose the method.

Data is the real work

Training examples for a chat model are usually conversations in a JSON Lines file: one example per line, with the messages and the ideal answer.

{"messages": [{"role": "system", "content": "Sort the ticket. Reply with JSON."}, {"role": "user", "content": "My blender arrived broken"}, {"role": "assistant", "content": "{\"topic\":\"Returns\",\"needsHuman\":false}"}]}
  1. Quality beats quantity. A few hundred clean, checked examples often beat many thousands of noisy ones. Start small and add data where the eval says it is weak.
  2. Cover the real mix: short and long messages, Persian and English, angry customers, the rare types.
  3. Keep a test set apart. Never train on the examples you use to judge the result.
  4. No personal data in the training file unless you have a clear legal reason. A model can repeat what it saw in training.
  5. Write down where each example came from, so you can fix or remove it later.

Eval before and after

  1. Before training, run the eval set on your best prompt (and RAG) setup. This is the number to beat.
  2. After training, run the same set on the fine-tuned model.
  3. Check what got worse, not only what got better. A model trained hard on one task can get worse at others, and can forget safety habits.
  4. Count the whole cost: training, hosting a custom model, and your team’s time.

If the fine-tuned model is not clearly better on the set, do not ship it.

The upkeep nobody plans for

  1. Base models get old. Providers retire model versions. A fine-tune is tied to its base model, so you may need to train again on a new one.
  2. Your data changes. New ticket types mean new examples and a new run.
  3. Two systems to run. A custom model may need its own hosting, scaling and monitoring.

In an interview, mentioning this cost shows experience: fine-tuning is not a one-time job.

Common mistakes

Mistake Result Right way
Fine-tuning to teach changing facts Fuzzy, old answers with no sources. RAG for facts.
Training before trying prompts and examples Weeks of work a prompt could replace. Climb the ladder; measure each step.
No baseline eval Nobody knows if training helped. Same eval set before and after.
Testing on training examples Numbers look great; production does not. A held-out test set.
Personal data in the training file The model may repeat it. Clean the data; keep only what you may use.

Summary in six lines

  1. Fine-tuning changes habits (format, tone, narrow tasks), not changing knowledge.
  2. Prompt, then examples, then RAG, then fine-tuning; go up only when measured results ask for it.
  3. LoRA trains small adapters next to frozen weights; cheap to train and easy to swap.
  4. A few hundred clean, varied examples and a held-out test set matter more than size.
  5. Run the same eval before and after, and check what got worse.
  6. Plan for upkeep: base models retire and your data changes.

Done reading this lesson?Mark it as finished so it shows in your lessons list and report card.