Skip to content

Lesson 9 of 13 · 18m

Fine-Tuning Changes Behavior, Not Facts

RAG supplies knowledge with citations; fine-tuning supplies format and behavior — choose by what your evals say is failing.

Fine-tuning and RAG get confused because both "make the model know your stuff". They do completely different things. Fine-tuning adjusts the weights — behavior, format, style, decision boundaries. RAG supplies facts at query time — knowledge with citations and an updated_at. Picking between them is easy once you stop treating them as substitutes.

What fine-tuning actually does

You train on example input/output pairs; gradient descent nudges the weights toward your distribution. The model gets better at the shape of the task — a fixed output format, a classification taxonomy, a house style, a narrow domain's conventions. LoRA made it cheap: train small adapter matrices — under 1% of parameters — instead of the full model; QLoRA pushed it to 4-bit NF4 quantization, fine-tuning a 65B model on a single 48GB GPU in the original paper. On APIs it's a managed job: OpenAI's fine_tuning.jobs endpoint takes a JSONL of examples and returns a custom model ID.

What it doesn't do is teach facts the way you mean it. Knowledge baked into weights has no citations, no freshness, and no delete button — update a doc and you retrain; the model can also paraphrase your examples into confident nonsense outside their coverage. Catastrophic forgetting is real: push hard on one distribution and general capability degrades.

What RAG actually does

Retrieval keeps knowledge outside the model entirely: chunk → embed → store → retrieve at query time → paste into context. Update a doc, re-index, done — the next answer cites the new text. Freshness, citations, and per-user access control come free because the knowledge lives in a store you govern, not in weights you can't audit.

The decision

  • Knowledge changes → RAG. Always. "Fine-tune on my docs" is the most common wrong answer in this field; it gives you stale facts with no citations and a retraining pipeline on your critical path.
  • Format, behavior, or style gap → fine-tune. If evals show a capable model failing on how it answers rather than what it knows, examples in the weights fix it better than more instructions in the prompt.
  • Narrow task, high volume → fine-tune a small model. A distilled specialist can beat a generalist at one job for a fraction of the price — but only after your eval fixtures prove the task is stable.
  • Both is legitimate. Fine-tune the format, RAG the knowledge. They compose cleanly.

The training file is the contract — each line is one example of the job:

{"messages": [{"role": "system", "content": "Classify the ticket."},
              {"role": "user", "content": "charged twice for march invoice"},
              {"role": "assistant", "content": "{\"category\": \"billing\", \"confidence\": 0.97}"}]}

Write these the way you'd write unit tests: covering the space, including the ugly inputs, not cherry-picking the ones that look clean.

The honest tradeoffs

Fine-tuning buys you a behavior change you can't unship easily, a training-data pipeline to maintain, and — on some providers — different inference pricing on the custom model. RAG buys you an index to keep fresh, a retrieval layer to tune, and a context tax on every call. Neither is free; the question is which maintenance burden matches the thing that actually fails in your evals.

Field notes

  • Hundreds of good example pairs beat thousands of scraped ones; label noise teaches noise.
  • Keep the training JSONL in git next to the eval fixtures. The dataset is the artifact; the model is its output.
  • A fine-tuned model still needs the same evals, the same schema enforcement, and the same guardrails. Training changes weights, not physics.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.