When fine-tuning beats RAG, and when it doesn't

AINORYX engineering team Published: 8 min read

Context and when this applies

The RAG-versus-fine-tuning question usually arrives framed as a technology choice. In practice it is a diagnosis question: what exactly is the model getting wrong? The two techniques change different things, and choosing the wrong one adds cost and maintenance without fixing the failure.

Retrieval-augmented generation changes what the model can see at inference time. The original formulation by Lewis et al. (2020) paired a parametric generator with a non-parametric retrieval index, motivated partly by the difficulty of updating and attributing knowledge stored in model weights. In production systems, RAG means fetching relevant passages from your own data and placing them in the prompt.

Fine-tuning changes the model’s weights using examples of inputs and desired outputs. It shifts behavior: format, style, decision boundaries for a narrow task. Parameter-efficient methods such as LoRA reduce the cost of adapting large open-weight models by training a small number of additional parameters instead of the full model.

This framework applies to teams with a defined task, real or realistic inputs, and the ability to label expected outputs. Without those, neither technique can be evaluated.

Decision procedure

Step 1: Write down the failure

Collect 50 to 100 failing examples from real usage and categorize each one. Typical categories:

Failure type Example Usual first fix
Missing knowledge Answers lack facts from internal documents Retrieval or adding context
Stale knowledge Answers reflect an outdated policy version Retrieval with versioned metadata
Wrong format JSON breaks schema, sections out of order Structured output, prompt, then fine-tuning
Inconsistent judgment Same ticket classified differently across runs Clearer criteria, examples, then fine-tuning
Style or tone Output does not match house style Prompt and examples, then fine-tuning
Task too complex Multi-step reasoning fails Task decomposition, tools, stronger model
Retrieval miss Right document exists but is not retrieved Fix chunking, metadata, ranking

If most failures land in the first two rows, you are looking at a knowledge problem. If they land in rows three to five, it is a behavior problem. Row six is a design problem that neither technique solves well. Row seven means you already have RAG and it needs engineering, not replacement.

Step 2: Establish a prompt-only baseline

OpenAI’s model optimization guide describes a loop that starts with evals and prompt engineering, and notes that prompting may be all a use case needs. Build a held-out eval set and score a carefully written prompt with clear instructions and a few examples. This baseline is the bar any other technique must beat.

Step 3: Check whether long context is enough

If the knowledge base is small and changes slowly, placing it directly in the prompt can be simpler than building retrieval. Anthropic’s contextual retrieval write-up makes this point for small knowledge bases and notes that prompt caching makes the approach faster and cheaper. With a stable prefix, provider prompt caching reduces the cost of resending the same documents. Score it on the eval set and compare latency and cost.

Step 4: Apply the decision criteria

Choose RAG when one or more of these hold:

  • Knowledge changes faster than you would retrain a model.
  • The corpus is too large for the context window, or too costly to send in full.
  • Answers must cite sources, or users need to verify them.
  • Different users may see different documents, so access control must be enforced per request.
  • You need to remove information quickly (a withdrawn document, a deletion request).

Consider fine-tuning when one or more of these hold, and the prompt-only baseline falls short:

  • The output must follow a strict format or style that prompting does not reliably produce.
  • The task is narrow and repetitive (classification, extraction, routing) with clear labels.
  • Long few-shot prompts are needed for acceptable quality, and removing them would lower cost and latency at high volume.
  • You want a smaller model to match a larger one on one task to lower inference cost.

Choose both when the task needs current knowledge and a specialized behavior, for example citing internal documents in a strict structured format. In that case fine-tune on examples that include retrieved context, so the model learns to use evidence rather than memorize it.

Choose neither when failures come from ambiguous task definitions, missing tools, or tasks that should be split into smaller steps.

Step 5: Compare on the same held-out set

For each candidate, record quality, latency and cost on the same held-out examples:

For each option o in {prompt_only, long_context, rag, fine_tuned, rag + fine_tuned}:
    pass_rate(o)       = passed_cases(o) / total_cases
    p95_latency(o)     = 95th percentile end-to-end latency
    cost_per_success(o) = (inference_cost(o) + amortized_fixed_cost(o)) / passed_cases(o)

amortized_fixed_cost(fine_tuned) =
    (data_prep_cost + training_cost + eval_cost) / expected_tasks_before_retrain

The amortization term matters. A fine-tuned model that is cheaper per call can still cost more per successful task if it must be retrained often or the task volume is low.

Limitations and alternatives

Fine-tuning is an unreliable way to add facts. Weights do not provide citations, cannot be updated per document, and do not enforce access control. If the knowledge changes, you retrain.

RAG moves the problem to retrieval. Many RAG systems that underperform have retrieval failures: poor parsing, chunks that split the relevant passage, missing metadata, or no reranking. Measure retrieval recall on labeled queries before blaming the generator.

Managed fine-tuning availability changes. Provider fine-tuning offerings, supported base models and timelines change. At the time of access, OpenAI’s supervised fine-tuning guide states that it is winding down its fine-tuning platform, with training jobs available to eligible existing customers until a stated cutoff. Check current availability before planning, and weigh the portability of open-weight models with parameter-efficient training against the operational cost of serving them yourself.

Fine-tuned models need a lifecycle. When the base model is deprecated or a better one appears, you repeat data preparation, training and evaluation. Budget for it.

Overfitting can hide in averages. A tuned model can improve on the training distribution and regress on inputs outside it. Hold out data the model never sees, and keep a probe set for general behavior.

Data rights and sensitivity. Training data may contain personal or confidential information. Review and minimize it before training, and confirm you have the right to use it for that purpose.

What to measure

  • Held-out pass rate for every option, scored with the same graders.
  • Per-category performance, to catch gains in one area that hide regressions in another.
  • Retrieval recall@k for RAG options, on queries with labeled source passages.
  • Citation accuracy and groundedness where answers must be traceable to sources.
  • p95 latency, since retrieval and reranking add steps and long context adds prefill time.
  • Cost per successful task, including amortized training and data preparation for fine-tuned options.
  • Time to update knowledge: how long it takes for a corrected document to be reflected in answers.

Assumptions

  • The task can be specified with pass criteria that a grader (deterministic, model-based or human) can apply consistently.
  • A held-out eval set exists and is not used during prompt iteration or training.
  • Provider features, supported fine-tuning models and availability are taken from official documentation at the time you check and change over time.
  • Training data is permitted for this use and has been reviewed for sensitive content.
  • Cost comparisons use current official pricing and your own volumes; this article lists no prices.
  • Model quality differences are measured on your data; public benchmarks are not used as a proxy for your task.

Sources

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Lewis et al., 2020) — accessed November 23, 2026
  2. LoRA: Low-Rank Adaptation of Large Language Models (Hu et al., 2021) — accessed November 23, 2026
  3. OpenAI model optimization guide — accessed November 23, 2026
  4. OpenAI supervised fine-tuning guide — accessed November 23, 2026
  5. Anthropic: Introducing Contextual Retrieval — accessed November 23, 2026
  6. Anthropic prompt caching documentation — accessed November 23, 2026