~/articles/fine-tuning-vs-rag-vs-prompting-decision-framework
Beginner

The Decision Ladder: Fine-Tuning vs RAG vs Prompting

A concrete decision framework for when prompting, RAG, or fine-tuning pays off — grounded in real cost, latency, and data trade-offs, not vendor marketing.

12 min readupdated 2026-07-02Ironclad Academy
// DEPTH
the full breakdown — requirements, capacity, evolution, trade-offs

A team at a mid-size company spent three months and $40K on a fine-tuned customer support model. Tickets still got wrong answers 30% of the time. The root cause turned out to be knowledge staleness: the model had learned the right tone and format, but the product had shipped eight major updates since the training cutoff. A $200/month RAG pipeline on their existing documentation would have solved the actual problem in two weeks. The fine-tuning was not wasted — it gave them better formatting — but the sequencing was backwards.

This article is about not making that mistake.

The three tools and what they actually do

Prompt engineering is instruction at inference time. You tell the model what to do — persona, format, constraints, examples — in the context window. Changes take effect immediately, no infrastructure, no training. The model's underlying weights never change.

RAG (retrieval-augmented generation) adds a retrieval step before generation. Instead of asking the model to recall facts from its weights, you pull relevant documents from an index and pack them into the context window alongside the query. The model reasons over supplied evidence rather than memory. You can read a full treatment in RAG from Scratch.

Fine-tuning changes the weights themselves by continuing training on task-specific examples. The model internalizes patterns from your data distribution. Post-training methods range from full fine-tuning (all parameters move) to LoRA and QLoRA, where small adapter matrices are trained alongside frozen base weights.

These are not competing strategies. They target different axes of the problem. The mistake is treating them as alternatives and picking one based on what sounds most advanced.

Start with prompting: it solves more than you think

The first question is not "should I fine-tune?" — it is "have I actually tried good prompting?" Not the first system prompt you wrote in ten minutes, but the prompt you get to after iterating with real failure cases.

Good prompt engineering includes: a specific system persona with explicit output format, chain-of-thought instruction when reasoning is needed, two to four diverse few-shot examples that cover your edge cases, and negative examples showing what to avoid. In most cases, the model already has the capability — it just needs the instruction context to activate it.

Prompt caching makes this even more attractive. If your system prompt is stable and 2,000+ tokens, prefix caching cuts that prompt's cost by 80–90% on Anthropic and OpenAI APIs. A well-engineered prompt with caching often costs less per query than the retrieval overhead of a RAG pipeline.

Prompting does fail. The ceiling is real. You hit it when:

  • The task requires behavioral consistency that the model cannot reliably produce from instruction alone across thousands of queries (1 in 50 responses reverts to the wrong format; prompting cannot tighten that to 1 in 5,000).
  • The model lacks the domain vocabulary — your company uses internal terminology or a specialized notation the base model does not know.
  • Latency requirements exclude frontier-model APIs entirely; you need a sub-50ms response that only a small self-hosted model can give.

When you hit any of these, record the failure mode precisely before escalating. The failure mode determines which rung to climb to.

When RAG is the right rung

RAG solves one problem well: the model is working with stale, missing, or insufficient knowledge. The failure is factual, not behavioral. The model would give the right answer if it had the right document in front of it.

sequenceDiagram
    participant U as User query
    participant R as Retriever
    participant I as Vector Index
    participant L as LLM

    U->>R: "What's the refund policy for orders placed after March 1?"
    R->>I: embed query → ANN search
    I-->>R: top-3 policy document chunks
    R->>L: [system prompt] + [3 chunks] + [user query]
    L-->>U: answer grounded in retrieved policy text
    Note over L: No weight changes. Knowledge updates<br/>require only an index update.

The critical operational advantage of RAG is update velocity. When your refund policy changes, you update the document in the index — minutes, not a training run. When you launch a new product, add the documentation. The model's weights are irrelevant; the retrieval layer carries all factual currency.

RAG also scales to knowledge bases far too large for any context window. A 10,000-page documentation corpus cannot fit in even the largest context window, but the right 5 pages can always fit. See Long Context vs RAG for when the context-stuffing alternative actually wins.

RAG has its own failure modes. Retrieval quality gates generation quality: if the wrong chunks come back, the model reasons over bad evidence and hallucinates confidently. Hybrid search (BM25 plus dense retrieval, then a reranker) significantly tightens retrieval precision. Hybrid Search: BM25 Plus Dense Retrieval Plus Reranking covers that in depth.

The latency budget matters. Retrieval adds roughly 50–200 ms on top of the LLM call you were already making: embedding the query (~10 ms self-hosted, more like 50–100 ms through a hosted embedding API once you count the network), ANN search (~20–50 ms in a managed vector DB), plus the extra prefill time from the chunks you stuffed into the context window. If your p99 latency target is 200 ms total, RAG is structurally too slow.

When fine-tuning actually pays off

Fine-tuning earns its place when the problem is behavioral, not factual. You need the model to behave differently — not just know different things.

The clearest signal: you have a formatting or style requirement that prompting cannot make consistent at the reliability level you need. Legal document extraction that must output exactly a JSON schema with 20 specific fields, zero hallucinated keys, across 10,000 queries. Medical transcription that must use ICD-10 coding conventions throughout. Multilingual support where the model keeps slipping back to English mid-sentence. These are behavioral failures. You are not asking the model to recall a fact; you are asking it to reliably execute a pattern.

Inference cost is the second forcing function. Self-hosting a QLoRA-fine-tuned 7B or 8B model costs roughly $0.0003–0.001 per 1K tokens — 5–20× cheaper than frontier API pricing (illustrative, as of mid-2026). If you are running 10M+ queries per month, that delta is real money, and fine-tuning pays off regardless of whether the task is behaviorally complex.

There is a fork here that the economics depend on. Hosted fine-tuning APIs — training a provider's small model through their platform — get you a fine-tuned model with zero serving infrastructure: no GPUs to rent, no serving stack, no on-call. The trade is a per-token surcharge over the base model's price and lock-in to that provider's model family. Self-hosted QLoRA is the cheapest per token at high volume, but you own the GPU (a provisioned A100-class card runs ~$1.5–2K/month if it must stay warm 24/7), the serving stack, and the pager. For a team without GPU ops experience, the hosted route is the realistic first fine-tune; self-hosting starts to win when sustained volume makes the per-token savings larger than the operational cost you just signed up for.

The third case is domain vocabulary. Some domains have language the base model does not speak well — highly specialized legal corpora, proprietary scientific notation, code in an internal DSL. Fine-tuning on domain examples teaches the model to speak that language without requiring the instruction to define every term.

What fine-tuning does not fix: hallucinations caused by the model lacking knowledge. This deserves emphasis because it is the most common and costly mistake in the field. SFT on correct examples can reduce hallucination rate modestly, but it bakes the training distribution into the weights with higher confidence. A model that learned incorrect facts during pretraining will now state those incorrect facts more fluently. If the failure mode is "the model makes things up," the fix is RAG — not more training.

The data quality gate

Before any fine-tuning decision, ask whether you have the data to do it right. For most style and format tasks, 500–2,000 curated examples with verified correct outputs are enough. For domain adaptation with complex patterns, 10K–50K examples are typical. And noisy data is strictly worse than fewer clean examples — more volume is not a substitute for quality filtering.

Synthetic data generation (Magpie-style pipelines) can supply training data cheaply at ~$0.01 per sample, but requires quality filtering and contamination checks against your eval sets. SFT and Instruction Tuning covers the data curation pipeline in full detail, including the research behind why quality dominates volume.

If you do not have the data yet, collecting it should happen before any training run. Rushing a fine-tune on 200 examples you scraped from Slack will produce something worse than the baseline model. Wait until you have 1,000+ verified examples, then train.

Stacking all three: the production reality

flowchart LR
    Q[User query] --> SP[System prompt\nbehavioral policy + persona]
    SP --> RET[RAG retriever\ncurrent knowledge]
    RET --> FTM[Fine-tuned model\nstyle + format + domain vocab]
    FTM --> OUT[Response]

    style SP fill:#0e7490,color:#fff
    style RET fill:#a855f7,color:#fff
    style FTM fill:#00e5ff,color:#0a0a0f
    style OUT fill:#15803d,color:#fff

The best production AI systems do not pick one rung — they stack all three. Each layer handles a different axis:

  • The system prompt controls immediate behavior: persona, output structure, what to do when uncertain, how to cite sources.
  • RAG supplies factual currency: the three most relevant documentation chunks, the customer's account history, the product inventory state.
  • The fine-tuned model handles style and format: it has internalized the output schema so it never invents extra JSON keys, and it speaks the domain vocabulary without being reminded.

This is not overengineering. Each layer was added to fix a specific failure mode that the layer below could not address. The prompting layer existed first, RAG was added when factual staleness created support tickets, fine-tuning was added when format inconsistency at scale created downstream parsing failures.

What breaks

Fine-tuning on the wrong failure mode. The most expensive failure: you spend two weeks and $15 training a model, discover that the real problem was retrieval quality or prompt structure, and have to start over. Before fine-tuning, run an ablation: give the model the perfect answer in the context window and ask it to regenerate in the desired format. If it can do it perfectly with that context but not without, the problem is retrieval, not weights.

Knowledge decay in a fine-tuned model. Fine-tuned models freeze their factual knowledge at training cutoff. If your domain has frequent updates — pricing, policies, product specs — the fine-tuned model will confidently state outdated information because it was rewarded for that information during training. The fix is to not use the fine-tuned model's weights as a knowledge source. Pair it with RAG and instruct it to treat retrieved context as authoritative.

Catastrophic forgetting. Fine-tuning on a narrow domain degrades general capabilities. A model fine-tuned heavily on medical records starts to struggle with basic reasoning tasks it handled before. LoRA significantly reduces this (frozen base weights), but full fine-tuning requires careful regularization. Monitor performance on your general eval suite alongside your task-specific metrics.

RAG retrieval failures at query time. RAG pipelines fail silently. When the retriever returns the wrong chunks, the model gets bad evidence and generates a confident wrong answer. This looks exactly like a hallucination from the outside. Instrument your retrieval recall separately from generation quality — Ragas can decompose the two. Do not attribute retrieval failures to model quality.

The data quality trap. You have 50,000 support chat transcripts. This seems like a fine-tuning goldmine. In practice it is usually contaminated with agents giving wrong answers, policy exceptions they should not have made, and off-topic conversations. Training on this produces a model that confidently gives wrong answers with excellent customer service tone. Data quality gates everything. Filter aggressively before you ever see a training run.

The decision in practice

Here is the actual heuristic, with the qualifying questions to ask at each step:

Use prompting if: The model can produce acceptable output when the context is right and failure rate with a well-engineered prompt is below your threshold. Spend at least one full day on prompt iteration with real failure cases before concluding this rung is insufficient.

Add RAG if: The failures are factual — the model's knowledge is stale or absent. You can verify this by checking whether providing the correct document in the prompt fixes the failure. RAG infrastructure requires a vector store, an embedding pipeline, and an ingestion workflow; plan for two to four weeks of engineering work to do it properly, not two days.

Fine-tune if: You have a stable task definition, a behavioral failure mode (not factual), at least 500 curated examples with verified correct outputs, and the economics make sense. For most teams, LoRA or QLoRA is the right method — full fine-tuning is rarely necessary and always more expensive. Expect the task definition to need locking down before training, because retraining every time requirements shift costs time and money.

Stack all three if: Your production volume justifies the operational overhead and you have distinct failure modes that each layer addresses. Measure each layer's contribution separately with your eval pipeline before adding the next one — otherwise you will not know which layer is doing the work.

{ "type": "token-cost", "title": "Where the monthly token bill comes from: volume, caching, model tier" }

Two of the sliders above map straight onto the ladder: cache hit rate is the prompting rung (a stable, cached system prompt is what pushes it up), and model tier is the fine-tuning rung (a fine-tuned small model is how you drop tiers without losing task quality). The three-way cost comparison itself lives in the back-of-envelope block in the summary.

The ladder metaphor is useful because it captures the key property: each rung is harder to change than the one below it. Prompting changes in seconds. RAG index updates take minutes. Fine-tuning changes take days. Climb only as high as your actual problem demands.

The teams that get this right are the ones who treat "should we fine-tune?" as a diagnosis question — and answer it with evidence from their eval set rather than enthusiasm about the technique. The evidence tells you where the failure lives. The ladder tells you which rung fixes it.

For the mechanics of what happens after you decide to fine-tune, the next stop is SFT and Instruction Tuning: Data Is the Job.

// FAQ

Frequently asked questions

When should I use fine-tuning instead of RAG or prompting?

Fine-tune when you need deep behavioral change that prompting cannot reliably produce — consistent output format, domain-specific style, or a task where the model needs to internalize a pattern rather than recall a fact. Fine-tuning is also the right call when latency requirements exclude retrieval hops (sub-50ms end-to-end) or when your task quality ceiling has stalled despite strong prompt engineering. For factual knowledge that changes frequently, RAG beats fine-tuning almost every time because updating a vector index is hours, not days of retraining.

How much does it cost to fine-tune a 7B model vs run a RAG pipeline?

A QLoRA fine-tune of a 7B model on 50K examples runs roughly $10–15 on a single A100 80 GB in 6 hours (as of mid-2026 cloud GPU pricing). Inference on a self-hosted 7B model runs $0.0003–0.001 per 1K tokens depending on the serving setup. By contrast, a simple RAG pipeline using a hosted embedding model and a managed vector database (Pinecone, Qdrant Cloud) costs roughly $70–300/month at moderate traffic, with per-query API costs for generation on top. The training cost is one-time, but self-hosted inference carries its own ongoing infrastructure cost — a GPU provisioned 24/7 runs roughly $1.5–2K/month — so at low query volume the RAG stack is cheaper. Which wins depends on your query volume and how often the knowledge changes.

Can you combine fine-tuning, RAG, and prompt engineering in the same system?

Yes, and production systems commonly do. The typical stack is a fine-tuned model that has internalized the right style, format, and domain vocabulary, paired with RAG for dynamic factual grounding, and wrapped with a system prompt that sets persona and behavioral guardrails. Each layer handles a different axis: prompting controls immediate behavior, RAG supplies current knowledge, and fine-tuning shapes the model identity and output format. The layers are additive, not competing.

How many training examples do I need to fine-tune an LLM?

Quality matters far more than quantity. 500–2,000 curated, high-quality examples are enough for most style and format tasks. AlpaGasus showed that filtering Alpaca from 52K to 9K clean examples improved downstream benchmark scores — more noise is strictly worse. For domain adaptation with complex reasoning patterns, 10K–50K examples are typical. Synthetic data generation (Magpie-style pipelines) can supply this quantity cheaply at $0.01/sample compared to $1+ for human annotation, but requires quality filtering and contamination checks against your eval sets.

Does fine-tuning fix hallucinations?

No. This is one of the most expensive misconceptions in LLM engineering. Fine-tuning teaches the model to produce outputs in a particular style or format, but it does not give the model new factual knowledge it can reliably trust at inference time — it just bakes in the training distribution with higher confidence. If the model hallucinates facts, the correct fix is RAG: ground every response in retrieved source documents and put citation pressure on generation. SFT on correct facts can reduce the rate, but it does not eliminate it and can silently increase confident-sounding errors.

What is the right order to try these approaches?

Prompting first, always. Spend 1–2 days on system prompt design, few-shot examples, and output format instructions before considering anything else. If quality stalls at an unacceptable ceiling after serious prompt engineering, add RAG if the problem is factual grounding with dynamic data. Only escalate to fine-tuning if you have hit the quality ceiling of the best prompting + RAG stack, have a stable task definition with enough curated data, and the cost of fine-tuning amortizes over your expected query volume.

// RELATED

You may also like