Engineer comparing three architecture options on a whiteboard for an LLM product

Fine-Tuning vs RAG vs Agents: Definitive Decision Guide

Pick RAG when the model is missing facts, fine-tuning when it is missing habits, and agents when it is missing actions. That one-line routing rule settles most arguments about fine-tuning vs RAG vs agents, and the rest of this guide is the evidence, the exceptions, and a way to run the decision without a three-week debate.

Our earlier overview, RAG vs fine-tuning vs agents, explains what each approach is. This post is the deeper playbook: it starts from the symptom you can see in logs, maps it to the lever that actually moves it, and shows what each choice costs when you need to change your mind later.

Start from the symptom, not the architecture

Teams usually choose a technique first and then hunt for a problem it can solve. Reverse that. Pull fifty failed conversations, label each one with a single root cause, and count. The labels tend to collapse into three piles.

  • Knowledge gaps: the answer was wrong because the model never saw the policy, price, or ticket history.
  • Behavior gaps: the facts were available but the answer arrived in the wrong shape, tone, language, or schema.
  • Capability gaps: the task needed a lookup, a calculation, a write to another system, or several steps in order.

Each pile has a different owner and a different fix. If forty of your fifty failures are knowledge gaps, no amount of fine-tuning rescues you, and an agent loop will just retrieve badly with extra steps. The label count is the cheapest experiment in this entire decision, and it is the one teams skip most often.

The routing table

What you see in failuresLeverWhy it fitsWhat it will not fix
Wrong or outdated factsRAGKnowledge lives outside weights, so you can edit it in minutesTone, schema drift, multi-step errors
Right facts, wrong format or voiceFine-tuning (SFT, then maybe preference tuning)Habits are learned from examples, not retrievedNew facts that change weekly
Needs live data, calculators, or writesAgent with toolsActions happen at runtime under your controlPoor base-model judgment on every step
Long, fuzzy instructions ignoredPrompt work first, fine-tune if it stays flakyCheapest to testHard knowledge gaps
Latency or cost too high on a stable taskFine-tune or distill a smaller modelShort prompts on a small modelTasks the small model cannot do at all

Read the table row by row against your labeled failures. If two rows apply, you probably need a combination, and the section on combos below covers the order to build them in.

Five questions that decide most cases

Run these in order and stop at the first decisive answer.

  1. How often does the truth change? Daily or weekly facts belong in an index you can re-embed, not in weights you must retrain. If you need citations, retrieval is close to mandatory. Chunking and ranking details live in RAG chunking strategies and hybrid search for RAG.
  2. Can you write down what a perfect answer looks like? If yes, in 300 or more example pairs, you have the raw material for supervised fine-tuning. If you can only say “we will know it when we see it,” you are not ready to train anything.
  3. Does the task require touching the outside world? Sending a refund, running SQL, or opening a pull request needs tools, permissions, and stop conditions. That runtime is an agent harness, and its design matters more than the model’s weights.
  4. Who needs to change the behavior, and how fast? A support lead can fix a bad document in an index before lunch. Fixing a bad habit baked into an adapter means new data, a training run, an evaluation, and a canary. Match the lever to the speed of the person who owns the problem.
  5. What happens when you are wrong? A bad prompt rolls back in seconds. A bad index rolls back with a snapshot. A bad adapter rolls back by unloading it, provided you kept the previous one. A bad autonomous agent action may not roll back at all.

What each choice really costs to change later

Initial build effort is the number everyone quotes and the one that matters least. The cost that bites is change cost over the next year.

RAG has a cheap change path for content and an expensive one for architecture. Updating documents is trivial. Swapping embedding models means re-indexing everything and re-validating retrieval quality, which is why what embeddings are is worth understanding before you commit to a vendor.

Fine-tuning has the opposite shape. Day-one cost is data collection and a training run. After that, every change to the desired behavior is a data change, so you want your examples versioned like source code. The detailed setup is in the LoRA fine-tuning guide.

Agents shift cost to operations. Every tool you add widens the surface for failures, and every failure needs a trace to debug. Budget for observability from the first day, and read harness engineering in practice before you let a loop run unattended.

Five scenarios, five different answers

A support assistant for a SaaS product. The failure pile is mostly stale or missing answers. Build RAG over docs and resolved tickets, add a reranker, measure with RAGAS. Fine-tune only if tone is still off after the retrieval is clean.

A text-to-SQL helper for analysts. Facts (the schema) are small enough to put in the prompt. The failures are in query style and dialect quirks, which are habits. Supervised fine-tuning on validated query pairs helps, and execution checks make the data easy to verify.

A contract-clause extractor returning strict JSON. Pure behavior problem. Start with structured-output prompting and a validator. If invalid-JSON rate stays above your tolerance, a small adapter trained on corrected outputs usually closes the gap. No retrieval needed unless clauses reference external definitions.

An on-call triage bot. Needs live metrics, runbooks, and the ability to page someone. That is an agent over retrieval, with the tool permissions kept narrow. Fine-tuning is a late optimization, if ever.

A brand-voice writer for marketing teams. Voice is a habit. Collect approved copy, tune an adapter, and put the product facts in retrieval so campaigns do not bake outdated claims into weights.

Combos and the order to build them

Most production systems end up with two levers, occasionally three. The order matters because each layer makes the next one cheaper to evaluate.

  1. Prompt and schema first. It costs an afternoon and tells you how far the base model gets alone. See prompt engineering.
  2. Add retrieval if failures are knowledge gaps, and stabilize it before touching weights. Fine-tuning on top of a broken retriever teaches the model to ignore context.
  3. Add tools when the work requires actions, keeping each tool small and each permission explicit. The connection layer is covered in MCP vs API function calling.
  4. Fine-tune last, on the residual behavior failures, using real production traces. The method comparison is in QLoRA fine-tuning and the SFT playbook.

A common trap is training the model on retrieved passages and then calling the result “domain knowledge.” The model learns the style of the passages and a handful of facts, hallucinating the rest with confidence. Keep knowledge in the index.

A one-page decision memo

Before anyone books GPUs or provisions a vector store, write a memo with five lines: the top failure label and its share, the lever you chose, the evaluation set that will judge it, the rollback plan, and the date you will revisit the choice. If you cannot fill in the evaluation line, stop. Shipping process matters here as much as technique, and the LLMOps production guide covers how those gates fit into releases. Avoid the opposite mistake as well, using fine-tuning as a reflex when the cheaper fixes have not been tried.

For reference on the training side, the Hugging Face PEFT documentation and the TRL documentation are the official sources for adapter methods and trainers. The original retrieval paper, Lewis et al. on retrieval-augmented generation, is still the clearest statement of why external memory beats parametric memory for knowledge-heavy tasks.

FAQ: choosing between fine-tuning, RAG, and agents

Is fine-tuning better than RAG for domain knowledge?

Usually not. Fine-tuning teaches style, format, and recurring patterns more reliably than it teaches specific facts. For domain knowledge that changes or must be cited, retrieval is easier to update, audit, and roll back.

Can I combine RAG and fine-tuning in one system?

Yes, and many mature systems do. Use retrieval for facts and an adapter for output habits such as schema, tone, and refusal behavior. Stabilize retrieval first, then tune on real traces so the model learns to use retrieved context rather than ignore it.

When is an agent overkill?

When a single prompt plus one retrieval call answers the question, a loop adds latency, cost, and failure modes without adding capability. Add agent behavior only when the task requires tool calls, multiple dependent steps, or writes to other systems.

How much data do I need before fine-tuning makes sense?

For a narrow behavior such as a fixed JSON schema, a few hundred clean, validated examples can move the needle. Broader style or domain shifts need thousands. More important than count is that each example matches production inputs and your evaluation set is held out.

Which option is cheapest to try first?

Prompting, then retrieval, then tools, then tuning. Each step is more expensive to build and change than the last. Spending a day on prompt and schema work often shows whether the problem is knowledge, behavior, or capability.

How do I know I chose the wrong lever?

Your metrics stall while your costs climb. If retrieval quality is high but answers are still malformed, you need behavior work. If answers are well formed but factually wrong, you need knowledge work. Re-label fresh failures every few weeks and compare the piles.

Related reading

About Mudasir Syed

Check Also

Finance dashboard splitting monthly AI spend by product feature and customer

Cost Attribution for LLM Apps: Tokens, Tools, and Tenants

LLM cost attribution is the practice of tying every token, tool call, and GPU-second to …

Leave a Reply