Zenaique

Explain choosing RAG, fine-tuning, or long context for a knowledge feature

Short answer·Hard·4.0 · 0·~3 min·Asked atAmdMercorOracle·Relevant atSambanova
Attempt it

A product needs the model to answer from company specific knowledge. How you'd decide between RAG, fine-tuning, and long context: and why they're often combined rather than chosen exclusively.

Free · 2 AI evals / day
TL;DR

Classify the gap first: fresh, large, citable knowledge → RAG; stable behavior or format → fine-tuning; small per-request docs → long-context. Mature systems combine all three.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine teaching a new employee to handle your company's questions. If the answers live in a handbook that changes every week, you don't make them memorize it — you let them look it up each time, so they're never out of date. That's RAG. If they keep filling out forms wrong, you train them once so the right format becomes second nature. That's fine-tuning. And if a customer hands them one document for a single task, they just read it on the spot. That's long-context. A good system uses all three at once, because each fixes a different kind of problem.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Almost every team building a knowledge feature on top of an LLM hits this decision, and almost every interview that touches LLM system design asks some version of it. The framing — 'RAG, fine-tuning, or long-context?' — is a trap baked into the question, because it implies you must pick one. The strongest answers reject that framing and treat it as an allocation problem.

The reason the exclusive framing misleads is that the three tools don't compete for the same job. Fine-tuning changes how the model behaves. RAG changes which facts it can reach at query time. Long-context changes what it sees in this single prompt. Those are three different levers on three different gaps, and a real feature usually has more than one gap.

This deep dive builds a decision procedure that scales from the simple case to the combined one. We'll start with the gap classifier, then dig into the cost and failure mode that actually bites each option in production, then cover the handoff thresholds where one tool gives way to another, and finally show why mature systems run all three together.

Step one: decompose the feature into gaps

The first move a strong candidate makes is to refuse to answer 'which one' until the feature is broken into its gaps. A feature is rarely one need; it's a bundle.

There are two kinds of gap. A behavior gap is when the model knows enough but acts wrong — it ignores your output schema, drifts off your house tone, or handles a domain task clumsily. A knowledge gap is when the model lacks facts — your policies, current prices, a specific customer's records.

These map to different tools because they're different failures. You can't fix a behavior gap by handing the model more documents, and you can't fix a knowledge gap by changing how the model writes. So before choosing anything, list the gaps: 'it formats inconsistently' is behavior; 'it doesn't know our refund policy' is knowledge; 'the user pastes a log we must analyze' is per-request knowledge.

This decomposition is what makes the eventual 'combine them' answer principled rather than hand-wavy. You're not combining tools for the sake of sounding thorough; you're assigning one tool per gap because each gap has exactly one right kind of fix. The candidates who skip this step are the ones who get cornered into defending a single tool against a need it was never meant to address.

Step two: route knowledge gaps by freshness and volume
Step three: the cost that actually bites each option
Step four: handoff thresholds and combining all three
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
DimensionRAGFine-tuningLong-context
Gap it closesKnowledge (large, fresh, citable)Behavior / format / styleSmall per-request knowledge
FreshnessLive — update the indexStale until retrainedFresh per request
Update costReindex (cheap)Training run (expensive)None
CitationsNative (returns sources)NonePossible if docs in prompt
Main cost / limitRetrieval quality ceilingUpdate cycle latencyLinear tokens; mid-prompt recall

Real products, models, and research that use this idea.

  • An enterprise assistant fine-tunes for a strict response schema, uses RAG over a docs index refreshed continuously, and drops user-pasted logs into long-context.
  • Coding assistants combine RAG over a codebase with long-context for the open file and fine-tuning for diff/edit format conventions.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QYour RAG answers are wrong even though the documents contain the right facts. Where do you look first?
A

The retriever, not the generator — check chunking, embedding quality, and reranking; if the right chunk never reaches the prompt, the best model still can't answer.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Framing it as a single exclusive choice — 'should we RAG or fine-tune?' — when the gaps are orthogonal and a real system layers all three on the parts each one fits.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Why the question's exclusive framing is itself a trap

  • The two-step classifier: gap type, then volume and freshness

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What does LoRA do, and why is it popular for fine-tuning?
MCQ·Medium