Why
RAG exists because early context windows (2–4K tokens) could not hold enough of a document to answer a question, so Lewis et al.'s 2020 paper wired a retriever to a generator: fetch the relevant passages first, then generate from them. That constraint is largely gone — Gemini's 1M–2M-token windows and Claude's 1M-token window (2025) can hold a mid-size codebase or a few hundred pages outright — so the reflex "always RAG" is now often wrong, and the reflex "always long-context" is wrong in a different way. Getting the choice wrong either burns money and latency stuffing irrelevant tokens into every call, or produces a system that answers confidently from whichever chunk scored highest on cosine similarity while the chunk that actually held the fact sat one rank lower and was never fetched. That second failure has no error, no stack trace, nothing to grep for — it just looks like a correct answer that happens to be wrong.
How it works
The case for long context
- No pipeline. Skip document parsing, chunking heuristics, embedding models, a vector database, and cross-encoder re-rankers — stream the raw text into the prompt.
- No retrieval lottery. Vector search can miss the right chunk on vocabulary mismatch or a weak embedding, and the model never sees the fact it needed. That is a silent failure, not a crash.
- Whole-document synthesis. A question that needs two non-contiguous sections compared — an early spec against a later release note — needs the model attending over both at once. Retrieval returns fragments of each but not the gap between them, and the gap is usually the answer.
The case for RAG
- The rereading tax. Feeding 500k tokens on every query means paying quadratic self-attention cost on every request. Prompt caching only discounts a static prefix; a corpus that changes turn to turn gets no discount.
- Attention dilution. Even at 1M+ tokens, needle-in-a-haystack recall on a specific fact buried in a huge context measurably drops — the effect behind "Lost in the Middle" (Liu et al., 2023) and the broader NIAH benchmark family. RAG hands the model pure signal instead of signal plus haystack.
- Enterprise scale. A 1M-token window holds roughly 750k words. Enterprise data is measured in terabytes to petabytes. No window holds a corporate data lake, so an index is mandatory, not optional.
Decision matrix
| Factor | Long context | RAG |
|---|---|---|
| Data scope | bounded (a contract, a book) | unbounded, dynamic |
| Reasoning type | global synthesis, cross-document comparison | targeted fact lookup, Q&A |
| Cost profile | high per-query compute, high latency | low per-query cost, upfront indexing |
| Infrastructure | a direct API call | embeddings + vector DB + re-rankers |
Read this as a cost curve, not a rulebook: RAG pays once, at index time, and charges little per query; long context pays a little to set up and charges more on every single query. Below a certain corpus size, or above a certain reasoning complexity, the curves cross.
The hybrid: filter, then attend
Use RAG as a coarse filter over the unbounded corpus, narrowing it to a 50k–100k-token cluster of plausibly relevant material, then run a long-context pass over just that cluster. The model gets to do real cross-section reasoning inside the cluster instead of stitching disconnected fragments together. The vector index does not disappear in this pattern — it stays the semantic warehouse for the whole corpus, it just stops being the last step before an answer. Chunk boundaries should still follow semantic units (a function, a doc section) rather than a fixed character count, because a boundary that splits a unit in half degrades both the retrieval step and whatever the long-context pass does with the result afterward.
Where it lands in Jayverse
- alice: an index.md plus grep-before-add is the RAG half of the pattern. Before writing a new Knowledge Notes item, grep the existing markdown for the topic and check a generated index instead of re-skimming 1,300 files; that index is the retrieval layer, and the new item is what a long-context pass would need read whole anyway.
- Auditor: rules never get RAG'd. A rule that is not retrieved is a rule that is not checked, and that failure is silent — no error, just an unaudited change slipping through. Rules are small; they belong whole in context on every run, never behind a similarity search that can miss.
- Knowledge Notes: the add script needs an "already covered?" check. That is the retrieval-lottery risk made concrete — adding a new item is itself a RAG query against 550+ existing ones, and a missed hit produces a silent duplicate, not an error.
- Eng: "when would you not use RAG" is a real interview question now. The honest answer is the decision matrix above — bounded data and cross-document synthesis argue for long context, unbounded data and targeted lookups argue for RAG, and most production systems need both.
Verified and unverified
Verified on 2026-09-21: IBM Technology is a real YouTube channel and this video exists (youtube.com/watch?v=UabBYexBD4k, 11:10); frontier context windows of 1M+ tokens are real and shipped (Gemini 1.5/2.x, Claude with a 1M-token window in 2025); "Lost in the Middle" (Liu et al., 2023) and needle-in-a-haystack benchmarks document attention dilution over long contexts as a measured, reproducible effect; prompt caching for static prompt prefixes is offered by both Anthropic and OpenAI; the RAG architecture traces to Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" (2020). Taken from the video summary and not independently checked: the specific 50k–100k-token figure given for the hybrid filter step, and any exact numbers or timestamps the video itself uses beyond the general claims above (no timestamps were given in the source summary for this item). Sources: YouTube — IBM Technology, "Is RAG Still Needed? Choosing the Best Approach for LLMs" · Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks," 2020 · Liu et al., "Lost in the Middle: How Language Models Use Long Contexts," 2023 · related items: Tech #62 (learning greed — raw layer plus generated index.md), Tech #109 (code graph, Graft), Tech #102 (first silent failure, MLflow).
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| RAG | Retrieval-Augmented Generation(검색 증강 생성, 검색기+생성기 결합 아키텍처) · 이 항목 전체의 주제. "Is RAG Still Needed?" |
| LLM | Large Language Model(거대 언어 모델) · 컨텍스트 윈도우 논의의 대상. "Choosing the Best Approach for LLMs" |
| NIAH | Needle-In-A-Haystack(건초더미 속 바늘 찾기, 긴 컨텍스트 회상 벤치마크) · 주의 희석을 측정하는 표준 테스트군. "the broader NIAH benchmark family" |
| rereading tax | 다시 읽기 세금(같은 텍스트를 매 요청마다 다시 처리하는 비용) · 긴 컨텍스트의 핵심 단점을 부르는 말. "a quadratic 'rereading tax' on every request" |
| retrieval lottery | 검색 로또(맞는 청크가 뽑힐지 운에 달린 상황) · RAG의 조용한 실패 모드를 가리키는 표현. "No retrieval lottery." |
| silent failure | 조용한 실패(에러 없이 틀린 결과가 나오는 것) · 이 항목에서 가장 중요한 위험 개념. "That is a silent failure, not a crash." |
| attention dilution | 주의 희석(컨텍스트가 커질수록 특정 사실에 대한 집중이 흐려지는 현상) · RAG를 옹호하는 핵심 근거. "measurable attention dilution on needle-in-a-haystack lookups" |
| needle-in-a-haystack | 건초더미 속 바늘 찾기(거대한 컨텍스트 속 특정 사실 회상 과제) · NIAH 벤치마크의 별칭이자 관용구. "needle-in-a-haystack lookups" |
| cosine similarity | 코사인 유사도(두 벡터 방향의 유사성 측정값) · 벡터 검색의 표준 유사도 지표. "whichever chunk scored highest on cosine similarity" |
| cross-encoder re-ranker | 크로스 인코더 재순위화기(검색 결과를 다시 정밀하게 순위 매기는 모델) · RAG 파이프라인의 마지막 단계. "cross-encoder re-rankers" |
| quadratic cost | 제곱 비용(입력 길이의 제곱에 비례하는 연산 비용) · 셀프어텐션의 근본적 한계를 설명하는 말. "quadratic self-attention cost on every request" |
| prompt caching | 프롬프트 캐싱(고정된 프롬프트 앞부분을 재사용해 비용을 아끼는 기법) · 긴 컨텍스트 비용을 부분적으로 완화하는 수단. "Prompt caching only discounts a static prefix" |
| context window | 컨텍스트 윈도우(모델이 한 번에 볼 수 있는 토큰 범위) · 이 논쟁 전체를 가능하게 만든 변수. "frontier context windows reach 1–2 million tokens" |
| vector database | 벡터 데이터베이스(임베딩을 저장하고 유사도 검색하는 저장소) · RAG 인프라의 중심 구성요소. "a vector database" |
| chunking | 청킹(문서를 검색 단위로 잘게 나누는 작업) · RAG 파이프라인의 첫 단계이자 흔한 실패 지점. "chunking heuristics" |
| decision matrix | 의사결정 매트릭스(선택 기준을 표로 정리한 것) · RAG vs 긴 컨텍스트 선택을 위한 도구. "### Decision matrix" |
| hybrid pattern | 하이브리드 패턴(두 접근을 순서대로 결합하는 설계) · 이 항목이 최종적으로 권하는 답. "a hybrid pattern" |
| semantic unit | 의미 단위(함수, 절 등 의미가 온전한 최소 덩어리) · 좋은 청킹 기준. "chunk boundaries should still follow semantic units" |
| index time | 색인 시점(질의 시점이 아니라 데이터를 미리 색인해 두는 단계) · RAG의 비용이 발생하는 시점. "RAG pays once, at index time" |
| coarse filter | 성긴 필터(정밀하지 않아도 되는 1차 거르기 단계) · 하이브리드 패턴에서 RAG의 역할. "Use RAG as a coarse filter over the unbounded corpus" |