Building-block guide · Performance and cost

Fine-tuning vs RAG vs prompting

A decision guide for when to stay with prompting, when to add retrieval, when to fine-tune (SFT, LoRA and QLoRA, preference tuning, reinforcement fine-tuning) and when to distil, with the data, cost, refresh and eval evidence each choice needs and how to govern a tuned model.

Draft for review · researched 30 Nov 2026

Contents
  1. At a glance
  2. Scope and where it sits
  3. When to use what
  4. Decision criteria
  5. Reference patterns
  6. Recommended defaults
  7. Anti-patterns
  8. Sizing and cost notes
  9. Security and compliance hooks
  10. Test and eval checklist
  11. Related plan sections and inventory
  12. Unverified or needs review
  13. Sources

At a glance

  • CoE decision (30 November 2026): tuning on client data is not allowed above the lowest risk tier without the client's written consent.
  • Climb the ladder in order: prompting, then retrieval or long context, then tuning. Each step adds data work, cost and lock-in. Most teams never need to tune; in one 2025 survey 57% of organisations did not fine-tune at all [12].
  • Knowledge goes in retrieval, behaviour goes in tuning. Research shows retrieval beats unsupervised fine-tuning for injecting knowledge, and that teaching new facts through fine-tuning is slow and raises hallucination [7][8]. Fine-tuning "doesn't replace retrieval for current information or application-level safety controls" [1].
  • Small, stable corpora can skip RAG. Under about 200,000 tokens, putting the whole knowledge base in a cached prompt is an option worth testing first [9].
  • Pick the tuning method by the signal you have: demonstrations (SFT), preferred versus rejected answers (DPO or preference tuning), or a grader that can score answers (RFT) [1][6].
  • Prove the choice with an eval that compares all candidates on a held-out set: prompt-only baseline, RAG, tuned and tuned plus RAG, plus regression checks on safety and general capability.
  • Treat a tuned model as a governed artefact with lineage (base model version, dataset version, method, hyperparameters, evals), an owner, a retirement plan tied to its base model and a portability plan [2][10].
  • Plan for provider change. One major provider ends self-serve fine-tuning job creation on 15 Dec 2026 and retires fine-tunes with their base models [10]; prefer methods and data you can re-run elsewhere.

Scope and where it sits

This guide covers the choice between prompt engineering, retrieval-augmented generation (RAG) and long-context prompting, parameter-efficient and full fine-tuning, preference and reinforcement fine-tuning, and distillation. It covers the data each needs, cost, refresh cadence, the evals that prove the choice and governance of tuned models.

In the 10-layer reference architecture (plan section 4):

Layer Responsibility
5 Model layer and routing Tuned models as catalogue entries with pinned base versions
6 Context engineering Prompting, few-shot examples, long-context with caching
7 Memory and knowledge Retrieval pipelines and indexes
9 Trust, safety and policy Safety behaviour preserved after tuning
10 Observability, evaluation and governance Comparative evals, lineage, registry entries

In the Anatomy of an AI Agent crosswalk this spans The library (system 15: retrieval and knowledge), Cortex (system 1: model portfolio, where tuned models live) and Clinical examination (system 13: the evals that justify the choice).

Related guides: Prompt assembly and context engineering covers prompting and few-shot layout; Document ingestion, Chunking, Embeddings, Vector stores and hybrid retrieval and Reranking cover the RAG pipeline; Model selection and routing covers how a tuned model joins the approved list; Evaluations covers eval design; Cost and latency engineering covers inference cost.

When to use what

Option Use when Avoid when Cost and latency notes
Prompting and few-shot Task is within model capability; behaviour can be described or shown in a few examples Instructions grow beyond what the model follows reliably Cheapest to change; cached prompts keep cost down [13]
Long context with caching Stable corpus under about 200,000 tokens [9] Large or fast-changing corpora; permission filtering per user No index to run; cost and latency fall with caching [9][13]
RAG Knowledge is large, changes, needs citations or per-user permissions Failures are about format, tone or reasoning, not missing facts Index and retrieval costs; extra latency per retrieval
Supervised fine-tuning (SFT) You can demonstrate the desired output for many inputs (format, style, narrow skill) [1] Goal is new or changing knowledge [7][8] Training charged on tokens times epochs, plus hosting [2]
LoRA or QLoRA (open weights) SFT on open models with limited GPU budget You need provider-hosted closed models LoRA cuts trainable parameters about 10,000x versus full tuning of GPT-3 175B, with no added inference latency [4]; QLoRA tunes a 65B model on one 48 GB GPU [5]
Preference tuning (DPO) You have pairs of preferred and rejected answers (tone, completeness) [1] You only have single good examples Simpler than RLHF: no reward model or RL loop [6]
Reinforcement fine-tuning (RFT) Several valid solutions exist and a grader can score quality [1] No reliable grader; grader can be gamed Grader design is the main cost; watch reward hacking [1]
Distillation A large model does a narrow task well and you need it cheaper or faster Task is broad or still changing Teacher generation cost plus student training [2]
Tuned model plus RAG Need both domain behaviour and current facts Either alone meets the bar Highest build and run complexity

Notes:

  • Tuning and RAG are not rivals. RAG supplies facts; tuning shapes how the model uses them. Combine only when evals show each adds value.
  • Agents change the calculus. Many agent failures come from tool use and planning, not knowledge. Better tool descriptions and context assembly often fix what teams hope tuning will fix.

Decision criteria

  1. Does a well-engineered prompt with examples meet the bar on the eval? Yes: stop. No: diagnose why it fails before choosing a fix.
  2. Is the failure about missing, private or changing knowledge? Yes: retrieval, or long context with caching for small stable corpora [9]. Fine-tuning is the wrong tool for facts [7][8].
  3. Does the answer need citations or per-user permissions? Yes: RAG with permission-aware retrieval; tuned weights cannot cite or enforce ACLs.
  4. Is the failure about format, style, domain language or a narrow skill you can demonstrate? Yes: SFT, or LoRA and QLoRA on open weights [1][4][5].
  5. Do you have judgements between good and bad answers rather than gold answers? Yes: preference tuning such as DPO [1][6].
  6. Can a program or rubric score answers reliably? Yes, and several answers are valid: RFT [1]. Validate the grader first.
  7. Is the goal lower cost or latency on a narrow task that a large model already does well? Yes: distillation into a smaller model [2].
  8. How fast does the knowledge or behaviour change? Daily or weekly: RAG. Quarterly or slower: tuning is viable if you can afford to re-tune and re-evaluate on each base-model change.
  9. Can the tuned model be supported for its life? If the base model retires within a year or the provider's tuning service is winding down, prefer prompting or RAG, or open weights you control [10].

Reference patterns

1. The escalation ladder with a comparative eval

Problem. Teams jump to fine-tuning because a demo failed, then cannot show it helped.

How it works. Build the eval first, with a held-out test set the tuning data never touches. Run, in order: the best prompt with few-shot examples; RAG or long context; then a tuned model; then tuned plus RAG. Record pass rate, cost per successful task, latency and safety metrics for each. Advance a rung only when the previous one fails the bar for a diagnosed reason. Microsoft's guidance is to evaluate on held-out data and compare against a baseline [1].

When to use. Every request to tune.

Pitfalls. Comparing a tuned model with a weak prompt exaggerates the gain. Test sets drawn from the same distribution as training data overstate generalisation.

2. RAG first for knowledge

Problem. Domain knowledge is large, private and changes.

How it works. Index the corpus with a retrieval pipeline (ingestion, chunking, embeddings, hybrid search, reranking). Research found RAG consistently outperformed unsupervised fine-tuning for knowledge injection, and that exposing the model to many paraphrases of each fact improved what fine-tuning could learn [7]. A separate study found models learn new facts slowly through fine-tuning and that, as they do, hallucination rises roughly linearly [8]. Anthropic's contextual retrieval adds a short context to each chunk before embedding, cutting retrieval failures by 49%, or 67% with reranking, at a one-off cost of about $1.02 per million document tokens with prompt caching [9].

When to use. Any knowledge-heavy agent.

Pitfalls. Retrieval quality, not the model, is usually the bottleneck; evaluate retrieval separately. Permission filtering must happen at retrieval time.

3. Parameter-efficient SFT for behaviour

Problem. The model knows enough but will not reliably follow a house format, domain style or narrow procedure.

How it works. Collect demonstrations of input and ideal output. On open-weight models, train a LoRA adapter: LoRA freezes the base weights and trains small low-rank matrices, cutting trainable parameters by about 10,000x and GPU memory by about 3x versus full fine-tuning of GPT-3 175B, with no extra inference latency once merged [4]. QLoRA adds 4-bit quantisation (NF4) so a 65B model can be tuned on a single 48 GB GPU while matching 16-bit fine-tuning performance [5]. On hosted models, use the provider's SFT service [1][2].

# Illustrative SFT job record (generic)
base_model: <provider-or-hub>/<model>@<pinned-version>
method: lora            # or qlora, full, provider-sft
dataset: sft-claims-format@v3   # versioned, PII-scrubbed, licence-checked
holdout: sft-claims-format-test@v3
epochs: 3
eval_gate: {format_pass: ">=0.98", safety_regression: "none", general_regression: "<=1pt"}

When to use. Stable behaviour you can demonstrate, high volume where shorter prompts pay back, or smaller models that need a narrow skill.

Pitfalls. Tuning on unreviewed outputs bakes in errors. Tuning can weaken safety behaviour; re-run the safety suite. Adapters tie you to one base model version.

4. Preference and reinforcement fine-tuning

Problem. Good answers vary, and what matters is which answer is better, or whether it passes a check.

How it works. With pairs of preferred and rejected responses, use DPO, which optimises directly on preferences without a separate reward model or reinforcement learning, and matched or beat PPO-based RLHF in its authors' experiments [6]. With a grader that scores responses (unit tests, a rubric, a checker), use RFT: the model generates, the grader scores and training raises the probability of high-scoring answers [1][2]. Microsoft notes RFT fits tasks with several valid solutions and warns that a rising reward can mean the model is exploiting the grader [1].

When to use. Tone, completeness or policy adherence (DPO); verifiable reasoning or tool-use tasks (RFT).

Pitfalls. Grader bugs become model behaviour. Hold out a human-reviewed test set the grader never sees. Availability varies: at one provider RFT on its newest models is by invitation only [1].

5. Distillation into a smaller model

Problem. A large model performs a narrow, high-volume task well, but costs too much or is too slow.

How it works. The teacher generates responses for representative prompts; the student is fine-tuned on them [2]. Evaluate the student against the teacher on the held-out set and route only the narrow task to it (see Model selection and routing).

When to use. Stable, narrow tasks at high volume.

Pitfalls. Check the teacher's terms allow using outputs to train another model. The student inherits teacher errors and does not generalise beyond the distilled task.

6. Tuned model lifecycle and portability

Problem. A tuned model is a new artefact with its own risks, and its life is bounded by the base model and the provider's service.

How it works. Register each tuned model in the agent registry as a distinct model with lineage: base model and version, dataset versions and their provenance, method and hyperparameters, eval results, owner, intended use and risk tier. Keep training data and scripts so the tune can be re-run on a successor or another provider. Track the base model's retirement: at one provider fine-tuned models follow their base model's shutdown, and self-serve job creation ends for all organisations on 15 Dec 2026, while inference on existing fine-tunes continues until the base model retires [10]. Bedrock bills custom models for training (tokens times epochs) and monthly storage per model [2].

Under the EU AI Act general-purpose AI guidelines, an organisation that modifies a GPAI model becomes a provider of the modified model only if the modification uses more than one third of the original model's training compute, and then its obligations cover the modification [11]. Typical LoRA or SFT runs fall far below that, but record the compute used.

When to use. Every tuned model.

Pitfalls. Tuned models nobody can re-create; datasets with personal data and no deletion path; forgetting to re-tune when the base model changes.

Setting Default Range or options Why
Starting point Prompting with few-shot examples Escalate only on diagnosed failure Practitioner default
Knowledge RAG, or long context with caching under about 200k tokens Never fine-tune for facts Sourced [7][8][9]
Behaviour and format SFT after prompting fails LoRA or QLoRA on open weights; provider SFT on hosted Sourced [1][4][5]
Preference data DPO or provider preference tuning RFT where a grader exists Sourced [1][6]
Graded tasks RFT with a validated grader and human-reviewed holdout Only where offered Sourced [1]
Cost reduction on narrow tasks Distillation into an approved small model Route only the narrow task Sourced [2]
Eval design Held-out set; compare prompt, RAG, tuned, tuned plus RAG Add safety and general-capability regression Sourced [1]; comparison set is practitioner default
Release gate for tuned models No safety regression; general capability within 1 point of base Tighter for regulated use Practitioner default
Re-tune trigger Base model change, drift in eval, or quarterly review Event-driven Practitioner default
Training data Versioned, provenance-checked, PII-minimised, licence-checked Synthetic data labelled as such Practitioner default
Portability Keep data and scripts to re-run on another base or provider Prefer open weights for long-lived tunes Sourced [10]; practitioner default
Registry Tuned model registered as a distinct model with lineage Per risk tier Practitioner default (plan 13)

Anti-patterns

  • Fine-tuning to teach facts. Fix: use RAG or long context; tuning on new facts raises hallucination [7][8].
  • Tuning before trying good prompts. Fix: run the escalation ladder with a comparative eval.
  • Evaluating on training-distribution data only. Fix: a held-out, human-reviewed test set plus out-of-distribution cases.
  • Trusting a rising RFT reward. Fix: check for grader exploitation with a holdout the grader never sees [1].
  • Dropping the safety suite after tuning. Fix: run the full guardrail and red-team suite on every tuned model.
  • Tuning on raw production logs. Fix: curate, de-identify and review data; record consent and licence basis.
  • Tuned models with no owner or lineage. Fix: register in the agent registry with base version, dataset version and evals.
  • Ignoring the base model's retirement. Fix: tie the tuned model's migration plan to the base model's notice period [10].
  • Using RAG to fix formatting problems. Fix: prompting first, SFT if needed; retrieval cannot teach format.
  • Distilling from a model whose terms forbid it. Fix: legal check of teacher terms before generating training data.

Sizing and cost notes

Cost components.

Approach Build cost Run cost Refresh cost
Prompting Prompt and eval work Tokens per call (cache the prefix) Edit and re-run evals
Long context with caching Corpus preparation Large cached prefix per call [9][13] Rewrite cache on change
RAG Ingestion, chunking, embeddings, index Retrieval plus extra input tokens Incremental re-indexing
SFT or LoRA Data curation, training tokens times epochs [2] Hosting tuned model or adapter; shorter prompts Re-tune on data or base change
DPO or RFT Preference data or grader build, training As SFT As SFT, plus grader maintenance
Distillation Teacher generation plus student training Small-model inference Re-distil on teacher change

Illustrative break-even for SFT. If tuning removes 3,000 tokens of instructions and examples from every call, at an illustrative $3 per million input tokens that saves $0.009 per call before caching. With caching at 0.1x reads [13], the saving falls to under $0.001 per call, so a tuning project costing $20,000 in data and engineering needs tens of millions of calls to pay back on token savings alone. Hosted tuned models can also carry different inference or hosting prices [2]. Tuning is usually justified by quality or latency, not prompt savings.

Contextual retrieval build cost. About $1.02 per million document tokens for generating chunk context with caching [9]; a 50-million-token corpus is about $51 one-off (illustrative arithmetic).

GPU sizing for open weights. QLoRA fits a 65B model's fine-tuning on one 48 GB GPU [5]; LoRA cuts GPU memory about 3x versus full fine-tuning in its authors' experiments [4].

Data volume. Providers rarely publish minimums that guarantee quality. Practitioner default: start with a few hundred carefully reviewed examples per behaviour, measure, then add data where the eval shows gaps.

Security and compliance hooks

Threat OWASP mapping Controls
Poisoned training or preference data LLM04 Data and Model Poisoning [14] Data provenance, review, versioning, anomaly checks, holdout evals
Poisoned or over-shared retrieval content LLM08 Vector and Embedding Weaknesses; ASI06 Memory and Context Poisoning [14][15] Source allowlists, permission-aware retrieval, ingestion scanning
Training data memorised and disclosed LLM02 Sensitive Information Disclosure [14] PII minimisation, de-identification, extraction tests on tuned models
Tuned model or adapter from an untrusted source LLM03 Supply Chain; ASI04 Agentic Supply Chain [14][15] Signed artefacts, hash pinning, licence and provenance review
Safety behaviour lost after tuning LLM01 Prompt Injection; LLM05 Improper Output Handling [14] Full red-team and guardrail suite before release
Hallucination from tuning on new facts LLM09 Misinformation [14] Keep knowledge in retrieval; factuality evals [8]

Data protection. Training data is processing in its own right: establish a lawful basis, minimise personal data, record retention, and note that removing a person's data from tuned weights generally means re-training. RAG indexes can delete documents directly, which makes erasure simpler (plan sections 9 and 11).

Audit evidence to keep. Decision record showing the ladder and comparative eval; dataset datasheets with provenance and licence; training configuration and compute used; eval and red-team results; registry entry; retirement and migration plan.

Governing plan sections. 10 (poisoning and supply-chain threats), 10A (identity of training and serving pipelines), 10B (policy on which data may train which models), 11 (privacy, EU AI Act GPAI modifier rules [11]), 13 (registry, risk tier, model documentation), 14 (human review of training data and tuned-model releases) and the ROE (to be defined, plan section 12), which may restrict tuning for regulated outcomes.

Test and eval checklist

ID Stage Check Pass criteria Priority
TUNE-01 Design Failure diagnosed before choosing a fix Root cause recorded (knowledge, format, reasoning, tool use) Must
TUNE-02 Design Comparative eval designed Held-out set; prompt, RAG, tuned and combined arms defined Must
TUNE-03 Design Support life checked Base model notice period and provider tuning availability recorded Must
TUNE-04 Build Prompt-only baseline run Best prompt result recorded before any tuning Must
TUNE-05 Build Training data provenance and licence Datasheet complete; no unlicensed or unconsented data Must
TUNE-06 Build PII minimisation De-identification applied; residual PII scan clean Must
TUNE-07 Build Holdout isolation No overlap between training and test sets Must
TUNE-08 Test Tuned model beats baseline Pass-rate gain meets agreed threshold on holdout Must
TUNE-09 Test General capability regression Within tolerance of base model Should
TUNE-10 Test Safety regression Red-team and guardrail suite pass rate not lower than base Must
TUNE-11 Test Factuality and hallucination No increase versus RAG baseline Must
TUNE-12 Test Training data extraction No verbatim leakage of sensitive training records Should
TUNE-13 Test RFT grader validity Grader agrees with human review on holdout; no exploitation found Must
TUNE-14 Test RAG retrieval quality Retrieval recall and grounding metrics meet target Must
TUNE-15 Test Distilled student parity Student within tolerance of teacher on narrow task Should
TUNE-16 Release Registry entry with lineage Base version, dataset version, method, evals, owner recorded Must
TUNE-17 Release Reproducibility Tune can be re-run from stored data and scripts Should
TUNE-18 Run Drift monitoring Eval re-run on schedule; alert on drop Should
TUNE-19 Run Base model retirement watch Migration plan started on notice Must
TUNE-20 Run Erasure handling Process to remove data from RAG and to re-tune when required Should

Governing policies and procedures

From the CoE policy set (draft; control IDs on the policy crosswalk):

Unverified or needs review

  • Google's tuning page was read only at navigation level; method availability per Gemini model (SFT, preference tuning, RL tuning, distillation for open models) was not verified in detail [3].
  • OpenAI's reinforcement fine-tuning availability after the self-serve wind-down was not confirmed; the deprecation page covers job creation and inference [10].
  • Microsoft's statement that RFT on its newest hosted models is by invitation only may change [1].
  • The 57% figure comes from a vendor survey of 1,340 respondents run in late 2025 [12]; treat it as indicative.
  • The data-volume starting point, the 1-point general-capability tolerance and the re-tune triggers are practitioner defaults for the CoE lead to confirm.
  • Decided on 30 November 2026: tuning on client data is not allowed above the lowest risk tier without the client's written consent.

Sources

  1. Fine-tuning considerations, Microsoft Learn (Microsoft Foundry), https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/fine-tuning-considerations, accessed 30 Nov 2026.
  2. Customize your model to improve its performance for your use case, Amazon Bedrock User Guide, AWS, https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html, accessed 30 Nov 2026.
  3. Tuning, Google Cloud documentation, https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/tuning, accessed 30 Nov 2026.
  4. LoRA: Low-Rank Adaptation of Large Language Models, Hu et al., arXiv 2106.09685, https://arxiv.org/abs/2106.09685, accessed 30 Nov 2026.
  5. QLoRA: Efficient Finetuning of Quantized LLMs, Dettmers et al., arXiv 2305.14314, https://arxiv.org/abs/2305.14314, accessed 30 Nov 2026.
  6. Direct Preference Optimization: Your Language Model is Secretly a Reward Model, Rafailov et al., arXiv 2305.18290, https://arxiv.org/abs/2305.18290, accessed 30 Nov 2026.
  7. Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs, Ovadia et al., arXiv 2312.05934, https://arxiv.org/abs/2312.05934, accessed 30 Nov 2026.
  8. Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?, Gekhman et al., arXiv 2405.05904, https://arxiv.org/abs/2405.05904, accessed 30 Nov 2026.
  9. Introducing Contextual Retrieval, Anthropic, https://www.anthropic.com/news/contextual-retrieval, accessed 30 Nov 2026.
  10. Deprecations, OpenAI API docs, https://developers.openai.com/api/docs/deprecations, accessed 30 Nov 2026.
  11. Guidelines for providers of general-purpose AI models (FAQ), European Commission, https://digital-strategy.ec.europa.eu/en/faqs/guidelines-obligations-gpai-providers, accessed 30 Nov 2026.
  12. State of Agent Engineering, LangChain, https://langchain.com/state-of-agent-engineering, accessed 30 Nov 2026.
  13. Prompt caching, Anthropic (Claude Platform docs), https://platform.claude.com/docs/en/build-with-claude/prompt-caching, accessed 30 Nov 2026.
  14. OWASP Top 10 for LLM Applications 2025, OWASP GenAI Security Project, https://genai.owasp.org/llm-top-10/, accessed 30 Nov 2026.
  15. OWASP Top 10 for Agentic Applications, OWASP GenAI Security Project, https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications/, accessed 30 Nov 2026.
↑