Part 4 of 7 · AI and the craft

When should you use RAG, fine-tuning or a long context window?

Three ways to give a model what it needs to know, often confused: put the documents in the prompt, retrieve the relevant ones, or train the knowledge or behaviour in. What each one is good at, what it costs, how it fails, and the order to try them.

A black and white photo of a classical library and reading room building

The verdict, which the scenes below earn: try them in this order:

  1. A better prompt (clear instructions, a few examples, structured output).
  2. A long context window, if all the relevant material fits and changes per request: put it in the prompt.
  3. RAG (retrieval-augmented generation), when the knowledge is too big for the context, changes often, or must be cited and access-controlled: retrieve the relevant pieces and put only those in.
  4. Fine-tuning only when you need the model to behave differently (a format, a style, a narrow skill, a smaller cheaper model doing a big model’s job), not to know new facts.

Most production systems combine them: these aren’t rival suspects, they’re tools that fit together. A common shape is a fine-tuned or well-prompted model that answers from retrieved context, with prompt caching keeping the fixed parts cheap.

Case file

The case A fine-tuned model gets the policy wrong, a giant prompt makes the bill climb
Suspects Prompt engineering, long context, RAG, fine-tuning
Culprit Mixing up knowing (facts) with behaving (format, style)
The fix Prompt first, long context if it fits, RAG for big or changing knowledge, fine-tune for behaviour

The case #

A team fine-tunes a model on its handbook and gets back something that sounds sure of itself and gets the policy wrong. Another stuffs everything into a giant prompt and watches the bill climb. The mystery looks tangled until you notice the one clue that unlocks it: separate knowing from behaving. Each technique answers one of those, and almost none answers both. (New to the terms? The AI glossary defines them.)

This case compares the approaches by how they work; the costs and limits are described, not measured. Model prices, context sizes and fine-tuning options change every few months, so check your provider’s current numbers before you design around one.

The suspects side by side #

Here’s how the four compare on the same terms:

Prompt engineering Long context RAG Fine-tuning
How Better instructions and examples Put all the relevant documents in the prompt Search a knowledge base, put the top results in the prompt Train the model further on your examples
Good for Format, tone, task definition A few documents per request: a contract, a codebase file set, a long thread Large or changing knowledge, citations, per-user permissions Consistent behaviour or format, domain style, cheaper small models
New or changing facts No Yes, per request Yes: update the index, done Poor: facts get blurred, and retraining is slow
Cost driver Nothing extra Input tokens on every request (caching helps) Retrieval infrastructure + fewer input tokens Training runs, evaluation, hosting or a fine-tuned endpoint
Main failure Instructions ignored in edge cases “Lost in the middle”: details buried in long inputs get missed; slow, costly requests Retrieval misses the right passage, so the model answers without it or guesses Overfitting; forgetting general skills; stale knowledge baked in
Effort to change Minutes Minutes Re-index; tune chunking and retrieval Collect data, retrain, re-evaluate
Explainability - You can show the inputs Citations to the retrieved sources Hard to tell why it answered as it did
Flowchart: Better prompt + structured output + eval, Good enough?, Ship, keep the eval, Missing knowledge or behaviour?, Fits in context and changes per request?, Long context + prompt caching, RAG: retrieve, cite, filter by permission, Fine-tune…Flowchart: Better prompt + structured output + eval, Good enough?, Ship, keep the eval, Missing knowledge or behaviour?, Fits in context and changes per request?, Long context + prompt caching, RAG: retrieve, cite, filter by permission, Fine-tune…
Diagram source
flowchart TD
  P["Better prompt + structured output + eval"] --> Q1{"Good enough?"}
  Q1 -->|yes| DONE["Ship, keep the eval"]
  Q1 -->|no| Q2{"Missing knowledge or behaviour?"}
  Q2 -->|knowledge| Q3{"Fits in context and changes per request?"}
  Q3 -->|yes| LC["Long context + prompt caching"]
  Q3 -->|no| RAG["RAG: retrieve, cite, filter by permission"]
  Q2 -->|behaviour| FT["Fine-tune for format, style or a smaller model"]

Use case 1: answering questions from internal documents #

The scene: a support assistant or an internal “ask the handbook” tool over thousands of pages that change weekly, where some users may only see some documents.

What I’d use: RAG.

  • Thousands of pages don’t fit any context window affordably, and they change weekly. Re-indexing a changed page takes seconds; fine-tuning on it would take a training run, and still not reliably recall the exact policy.
  • Retrieval lets you filter by permission before anything reaches the model: a user can’t be told what’s in a document they couldn’t open.
  • Answers can cite their sources, which users and auditors trust. This is RAG’s most admirable trait: the answer arrives with its evidence attached, like a detective who shows their working.

The twist that surprises people: the work is in retrieval quality, not the model:

  • chunk along the document’s own structure (headings, sections);
  • combine keyword and semantic search, because exact terms such as product codes and error messages matter;
  • re-rank the top results;
  • evaluate retrieval separately (“was the right passage in the top 5?”), because if retrieval misses, nothing downstream can recover. The evals case covers how.

Use case 2: a fixed output format and a house style #

The scene: turning free-form inputs into a strict structure with domain-specific conventions. For example, extracting purchase orders where “pcs”, “nos” and “ea” all mean the same unit, or writing release notes in your company’s exact voice.

What I’d use: prompt engineering with structured output first. A JSON schema enforced by the API, plus a handful of examples, gets a long way. My document-ingestion pipeline sends the schema and the document as clearly delimited data, and validates everything that comes back; the confidence-routing case shows what happens to the rows it isn’t sure about.

Fine-tune when prompts plus examples still aren’t consistent enough at your volume, or when you want a smaller, cheaper model to do the job reliably: fine-tuning a small model on a few thousand good examples (often produced and checked with a larger model) is a common cost play. Keep the eval set fixed, so you can prove the fine-tuned model is at least as good.

Use case 3: domain language #

The scene: legal, medical or industrial text full of jargon, abbreviations and conventions a general model handles imperfectly.

What I’d use:

  • First, give the model the vocabulary: a glossary in the prompt (cached), or retrieved definitions for the terms that appear.
  • Then RAG for the reference material: standards, catalogues, past decisions.
  • Fine-tune only if, after both, the model still misreads domain conventions consistently, and you have enough good examples to teach the pattern rather than a list of facts.

Use case 4: one long document per request #

The scene: “summarise this 80-page contract”, “review this pull request with its related files”, “answer questions about this one report”.

What I’d use: long context. When the whole document fits, retrieval would only add a step that can lose information. Two practical cautions:

  • Position matters: many models are better at using information near the start and end of long inputs. Put the instructions and the question where they’re easy to find, and ask the model to quote the passages it relied on.
  • Cost and latency grow with length: if the same document is asked many questions, use prompt caching so the document is processed once and reused.

False leads people follow #

  • Fine-tuning doesn’t reliably add knowledge. It changes how a model responds more than what it can accurately recall. Teams that fine-tune on their documentation and expect a search engine get a model that sounds confident about half-remembered facts.
  • RAG fails silently when retrieval misses. The model answers fluently from nothing, or from the wrong passage. Instrument retrieval, and allow (and test for) “I don’t know”.
  • Long context isn’t free memory. Cost is per token, per request. A 100,000-token prompt sent 10,000 times a day is a line item, and caching or retrieval may cut it by an order of magnitude.
  • All three need evals. Every choice above is a hypothesis until a golden set says otherwise.
  • Security changes with each: retrieved documents and long inputs can contain prompt injection, so treat them as data, not instructions. A fine-tuned model can leak training data, so don’t fine-tune on secrets or personal data you couldn’t show to every user.

Remember this

  • Separate knowing from behaving.
  • RAG adds knowledge you can update and cite, fine-tuning changes behaviour.
  • Every choice is a hypothesis until an eval says otherwise.

What I’d do on Monday #

  1. Prompt + structured output + a few examples, with an eval, before anything else.
  2. Long context when the material is per-request and fits; prompt caching when it repeats.
  3. RAG for anything large, changing, permissioned or needing citations, with retrieval measured on its own.
  4. Fine-tuning for behaviour, format or cost (a smaller model), with the same eval proving it helps.
  5. Combine them deliberately, and re-run the eval whenever any part (model, prompt, index, fine-tune) changes.

What I like about this order is its modesty: each step is cheap to try and easy to measure before you reach for the next. Start simple, and let the eval tell you when you’ve outgrown it; a good prompt often goes further than you’d expect.

Describes approaches as commonly practised in late 2026; context sizes, prices and fine-tuning offerings differ by provider and change frequently, so check current documentation before designing around a specific limit.

Like (sign in first) 0 likes 💬 0

Written by

Vishal Kumar

Associate Director at CapGrid, running product and engineering in a CPTO capacity. 10+ years building distributed, multi-tenant SaaS and AI platforms. AWS Certified Solutions Architect - Professional. Based in Gurugram.

Comments

No comments yet.

Sign in to comment. We'll email you a link; no password needed.