RAG vs. Fine-Tuning vs. Long Context
Send a small, stable corpus in the prompt, retrieve from a large, changing or permissioned one, and fine-tune only to change behavior. Never fine-tune to keep facts current.
4 min read / Updated / Last checked
- Format
- Decision guide · Intermediate
- Who it is for
- Founders and the builders they hire
- You leave with
- Choose how an AI product accesses domain knowledge, estimate the monthly cost of each option, and prove the choice with a 20-question test.
The problem
As of November 2026, OpenAI's supervised fine-tuning guide opens with a notice: the fine-tuning platform "is no longer accessible to new users." Eligible existing customers can create training jobs until January 6, 2027, and fine-tuned models run only until their base model shuts down. For gpt-4.1-nano-2025-04-14 that date was October 23, 2026 [5].
A team that taught its company facts to a hosted fine-tuned model now has a retirement date on its knowledge. That is an extreme case of a common mistake: treating three different techniques as interchangeable ways to make a model "know the business."
The question a founder actually faces is concrete. The product has policies, product records or documentation. Some of it changes monthly. Some of it is private to one customer or one team. How should the application use it, so that answers are current, permitted and checkable? Take a retailer whose assistant answers return-policy questions, where the policy changes monthly and differs by region. The wrong choice either invents a return window, shows one region's rules to another, or costs many times what it should.
How it works
Long context means sending the source documents in the prompt with every question. It is the simplest option and needs no index. Anthropic's guidance is direct: if a knowledge base is smaller than 200,000 tokens, about 500 pages, include all of it and skip retrieval [2]. Prompt caching makes this cheaper on repeat questions. On most Claude models a cached read costs 0.1 times the base input price, a 5-minute cache write costs 1.25 times, and the default cache lifetime is five minutes [6]. The limit is attention, not just window size. In the RULER benchmark, all 17 tested models claimed at least 32,000 tokens of context, but only half kept satisfactory performance at that length [4].
Retrieval-augmented generation (RAG) searches an external corpus at question time and sends only the relevant passages. It handles corpora far larger than any window, picks up a policy change as soon as the document is reindexed, and can enforce access: Microsoft's guidance lists security trimming so that users and agents retrieve only content they are authorized to see [1]. Its weak point is the search itself. A passage that is not retrieved cannot be used.
Fine-tuning adjusts a model's weights with examples. It changes behavior: output format, classification, tone, following a house style. It is a poor way to add facts. A study comparing knowledge injection, revised in January 2024, found that RAG consistently outperformed unsupervised fine-tuning, for knowledge seen in training and for entirely new knowledge [3]. OpenAI's guide recommends starting with 50 well-crafted examples and investing only after evals are in place [5]. On open-weight models, LoRA (training small added matrices instead of all weights) cut trainable parameters by 10,000 times against full fine-tuning of GPT-3 175B [7].
Three ways a model gets your knowledge
Fig. 01| Dimension | Long context | RAG | Fine-tuning |
|---|---|---|---|
| Best for | Small, stable corpus | Large or changing corpus | Format, style, labels |
| Fresh facts | Next request | After reindex | After retraining |
| Access control | Per prompt | Filter before search | None per user |
| Main failure | Lost in long input | Wrong passage found | Stale or invented facts |
| First cost | Tokens per question | Index and search | Data, training, evals |
By the numbers
- about 500 pages: below this, Anthropic suggests sending the whole knowledge base [2]
- 200,000 tokens
- the base input price of a cached prompt read on most Claude models [6]
- 0.1x
- of 17 long-context models kept satisfactory performance at 32,000 tokens in RULER, though all claimed at least that [4]
- Half
- examples OpenAI recommends to start a fine-tune with, against a minimum of 10 [5]
- 50
- fewer trainable parameters with LoRA than full fine-tuning of GPT-3 175B [7]
- 10,000x
| Corpus size | Long context, 90% cache hits | RAG, 8 chunks of 800 tokens |
|---|---|---|
| 50,000 tokens | $645.00 | $384.00 |
| 150,000 tokens | $1,935.00 | $384.01 |
| 500,000 tokens | $6,450.00 | $384.05 |
The table is a model, not a quote. It assumes 90% of questions hit a warm cache, which needs steady traffic inside the five-minute lifetime [6]. Even so, the shape holds: long-context cost grows with the corpus on every question, while RAG cost grows with the passages retrieved. At 50,000 tokens the gap is small enough that simplicity wins. At 500,000 tokens, well past Anthropic's 200,000-token rule of thumb [2], long context costs about 17 times as much as RAG in this model.
The RULER and knowledge-injection results point the same way from the quality side [3][4]. Larger inputs are not read evenly, and training is not a reliable way to store facts.
Implementation
Price the options with your own numbers before building. The calculator below takes the corpus size, monthly questions and prices you copy from your provider's pricing page.
"""Monthly input-token cost: whole corpus in every prompt (cached) vs retrieved chunks.
Prices are inputs. Copy them from your provider's pricing page; the defaults are placeholders.
"""
def long_context_cost(corpus_tokens, questions, price_per_m, cache_hit_rate=0.0,
write_mult=1.25, read_mult=0.10):
"""Every question sends the full corpus. Cached reads are billed at read_mult."""
hits = questions * cache_hit_rate
misses = questions - hits # a miss writes the cache again at write_mult
tokens = misses * corpus_tokens * write_mult + hits * corpus_tokens * read_mult
return tokens / 1_000_000 * price_per_m
def rag_cost(chunk_tokens, chunks_per_question, questions, price_per_m,
embed_tokens_per_month=0, embed_price_per_m=0.0):
"""Each question sends only the retrieved chunks, plus embedding new or changed text."""
prompt = questions * chunk_tokens * chunks_per_question / 1_000_000 * price_per_m
return prompt + embed_tokens_per_month / 1_000_000 * embed_price_per_m
if __name__ == "__main__":
PRICE, EMBED_PRICE = 3.00, 0.10 # placeholders, USD per million tokens
for corpus in (50_000, 150_000, 500_000):
lc = long_context_cost(corpus, questions=20_000, price_per_m=PRICE, cache_hit_rate=0.9)
rag = rag_cost(chunk_tokens=800, chunks_per_question=8, questions=20_000,
price_per_m=PRICE, embed_tokens_per_month=corpus, embed_price_per_m=EMBED_PRICE)
print(f"corpus {corpus:>9,} tokens: long context ${lc:>9,.2f} RAG ${rag:>7,.2f}")Run python knowledge_cost.py and replace the placeholders. Output tokens cost the same under every option, so the script leaves them out.
Then apply the rules to the retailer. The return policy is about 30 pages and changes monthly, but it differs by region, and staff notes must never reach customers. Start with RAG over a versioned document store, filter by region and audience before searching, and show the source passage with each answer. If no approved passage matches, the assistant says it cannot confirm and hands off to a person. If the policy were one short page for one region, sending it whole in a cached prompt would be simpler and just as current. If, with good passages in hand, the assistant still mislabels return reasons into the wrong categories, that is a behavior gap, and a fine-tune on a few hundred labeled examples is worth testing then.
Test it
Choose with a fixed question set, written before anything is built, and rerun it whenever the knowledge base changes.
# Knowledge eval: 20 questions
Corpus version: ______ Option tested: long context / RAG / fine-tuned
| # | Question | Type | Approved source (doc, section) | Pass rule |
|---|----------|------|-------------------------------|-----------|
| 1-10 | Real user questions | supported | named passage | correct and cites it |
| 11-15 | Vague or two-part questions | ambiguous | named passage(s) | asks or answers both parts |
| 16-20 | Questions the corpus cannot answer | unanswerable | none | says it cannot confirm |
Also record per run: wrong-region or staff-only source used (must be 0),
median and p95 response time, input tokens per question.Expected result for a good choice: at least 9 of 10 supported questions correct with the right citation, all 5 unanswerable questions declined, zero restricted sources used. If a fine-tune is on the table, OpenAI's guide says to hold out part of the data and compare against the base model [5]. Do the same for any option: the result that matters is the difference on your questions.
Decision
Use the simplest option that passes your 20 questions.
- Under 200,000 tokens, stable, one audience: long context with prompt caching [2][6].
- Larger, changing monthly, or permissioned: RAG with filters applied before search and a citation on every answer [1].
- Behavior gap that remains with good context: fine-tune for that task only, after an eval exists, and plan for the base model's retirement date [5]. Prefer open-weight models with LoRA where you need control over that date [7].
- Before anything else, list 20 questions users will ask and the approved source for each. If no source exists, no architecture will make the answer trustworthy. For managed memory products in the RAG slot, see Cortex Memory vs. Custom RAG.
Sources
- [1]RAG and generative AI in Azure AI Search (opens in a new tab)Microsoft Learn, August 2026
- [2]Contextual retrieval in AI systems (opens in a new tab)Anthropic, September 2024
- [3]Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs (opens in a new tab)Ovadia et al., arXiv, January 2024
- [4]RULER: What's the Real Context Size of Your Long-Context Language Models? (opens in a new tab)Hsieh et al., COLM, August 2024
- [5]Supervised fine-tuning (opens in a new tab)OpenAI API documentation, November 2026
- [6]Prompt caching (opens in a new tab)Claude Platform Docs, November 2026
- [7]LoRA: Low-Rank Adaptation of Large Language Models (opens in a new tab)Hu et al., arXiv, October 2021
Technical guidance, not legal or security certification.
Related resources
Need a technical review of an AI-built MVP?
Discuss your build