RAG, agents or fine-tuning: which one your LLM feature needs

  • Reference
  • Bursano
  • Reviewed
  • Architecture patterns, Models and stack

The decision, in short

  • If the model needs your facts, start with retrieval: knowledge stays in your data, so it can change without retraining.
  • Use an agent, a model calling your tools in a loop, only when the job needs actions or several lookups a person would otherwise do by hand.
  • Fine-tune for form, not for facts: a fixed output format, a house tone, or a narrow classification at lower cost and latency.
  • Most production features are retrieval plus a little tool use. Fine-tuning, if it comes at all, comes after you have evals that can show it helped.

Ask the question in the right order

Most teams ask “which technique?” first. Ask these three questions instead, in this order:

  1. Does the model need information it was not trained on? Your documents, tickets, catalogue, or anything else that changes. If yes, you need retrieval.
  2. Does the job need the model to do something, not just say something? Look up an order, open a ticket, run a query. If yes, you need tool calls, and possibly an agent loop.
  3. Is the output wrong in form even when it is right in substance? Wrong format, wrong tone, too slow or too expensive for a narrow task. Only then consider fine-tuning.

Each step adds a part you have to test and run, so stop at the first one that solves the problem.

Retrieval

Retrieval (often called RAG, retrieval-augmented generation) finds the relevant passages in your own data and puts them in the prompt, so the model answers from them.

Use it when answers depend on documents that change, when you need to show the source, or when different users may see different data.

How it fails:

  • The right passage is never retrieved, and the model answers fluently anyway. Measure retrieval on its own before you judge the answers.
  • The index is stale: the policy changed last week, but the index still has the old one.
  • Permissions leak: retrieval returns a document the user was not allowed to read. Filter by permission at query time, not after.

What to test: whether the right source came back, and whether the answer stays within it.

Agents

An agent is a model that calls a tool, looks at the result and decides the next step. It repeats this until the job is done or something stops it.

Use it when the task has steps that depend on each other and a person would otherwise click through several systems to do it.

How it fails:

  • Errors compound: a wrong first step becomes a confident wrong last step.
  • Loops and cost: without a step limit and a budget, a stuck agent keeps calling tools.
  • Scope creep: a tool that can write can do damage. Give each tool the narrowest permission that works, and put a person in front of anything irreversible. Which decisions should stay out of the model has a test for which ones.

What to test: each tool call on its own, then whole runs on recorded cases, including the cases where the right answer is to stop and hand off.

Fine-tuning

Fine-tuning trains a model further on your examples, which changes how it answers by default.

Use it when you have many good examples of the exact output you want and prompting cannot hold the format or tone, or when a small fine-tuned model can replace a large one on a narrow, stable task.

How it fails:

  • Facts baked into weights go stale, and you cannot point to where an answer came from.
  • Every time you change the underlying model, you have to train again.
  • Without evals from before and after, you cannot tell whether it helped.

What to test: the same eval set before and after, on cases the training data did not contain.

The short table

What the feature needs Start with Add later if needed
Answers from your documents Retrieval Tool calls for live data
Actions in your systems Tool calls with a person approving An agent loop with a step limit
A fixed format or tone at scale Prompting with examples Fine-tuning
A cheap, fast narrow classifier A small model with good prompts Fine-tuning a small model

What this page does not cover

Choosing a model provider, sizing and pricing the feature, and building the eval set itself. For the cost, see the cost calculator. For the eval set, see Evals for LLM features. For choosing the model, see Choosing a model for an LLM feature.

How to cite

Licensed under CC BY 4.0. Every section has a link: hover a heading for its anchor.

Suggest a correction

Changelog

First draft, written for the author’s review.
Edited for clarity and findability.
Reviewed and approved by the author.