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?
Keep reading
Related articles from the SudoSecurity blog.
Build Your Own AI Agent Stack: The Complete Self-Hosted Guide for 2026
Build a production-grade self-hosted AI agent from scratch using Docker Compose. Covers the full stack — Ollama, n8n, Flowise, Qdrant, SearXNG, Langfuse, and Redis.
AI Agents Are Breaking the Internet — And Nobody's Ready for the Bill
ChatGPT went down 28,000-report strong in February 2026. Claude had back-to-back outages within 24 hours in March. GitHub logged 37 incidents in a single month and is running at 90.21% uptime — one nine, not three. AI agents aren't just using infrastructure.
OpenClaw: The Lobster That Broke the Internet, Burned Through Every LLM's Compute Budget, and Started a War Between Anthropic and OpenAI
A retired Austrian developer built an open-source AI agent for fun in November 2025. Within 90 days, Jensen Huang called it the most successful open-source project in human history.
How AI Actually Works in Modern Video Games: FSMs to LLMs
Game AI isn't intelligent. It's state machines, search, and scoring arranged to feel like judgment, with real, runnable code from FSMs to local LLM dialogue.