AI infrastructure
RAG vs long context: choose a document-answering architecture
Choose between retrieval augmented generation and long-context prompting with practical rules for corpus size, latency, freshness and verification.
The architecture choice
Document-answering systems usually start with a simple question: should you put all relevant text into the prompt, or retrieve only the best pieces first? Long context means the model receives a large bundle of text directly. Retrieval augmented generation, or RAG, means you chunk documents, index them, search for relevant chunks at question time and pass only selected context to the model. Anthropic's contextual retrieval article describes the basic RAG flow and why retrieval becomes useful as knowledge grows. The choice is not ideological. It is about size, freshness, latency, auditability and failure tolerance.
Use long context when the set is small and stable
Long context is attractive when the source set is small enough to fit comfortably, changes slowly and benefits from cross-document reasoning. Example: a lawyer reviewing one contract packet, a product manager summarizing ten interview notes, or an engineer comparing a design doc with one incident report. The benefit is fewer moving parts. There is no chunking strategy, embedding pipeline or vector database to debug. The risk is cost, latency and attention dilution. The more irrelevant text you include, the easier it is for an answer to cite the wrong paragraph or overlook the key one.
Use RAG when the corpus moves
RAG fits when documents are numerous, frequently updated or too large to send each time. It also helps when you need source snippets attached to answers. A typical pipeline has ingestion, cleaning, chunking, embedding, indexing, retrieval, ranking and answer generation. Qdrant describes collections as groups of vectors plus payload in its collections documentation, and its search documentation covers nearest-neighbor retrieval and filtering concepts. The hard part is not calling a vector database. The hard part is making the retrieved text truly answer the question.
Decision table
| Condition | Prefer | Why |
|---|---|---|
| Ten short documents, same task once | Long context | Fast to set up and easy to inspect. |
| Thousands of changing docs | RAG | Retrieval keeps prompts smaller and fresher. |
| Need exact policy citation | Either, with source IDs | Retain document and section references, then verify the cited passage. |
| Need holistic reasoning across a fixed packet | Long context | The model can see the whole packet at once. |
Concrete example
Suppose a company wants an assistant for employee handbook questions. If the handbook is one PDF updated twice a year, long context may be enough for an internal prototype. If the assistant must cover handbook pages, benefit plans, location-specific policies and weekly HR memos, use RAG. Each chunk should carry payload such as document title, effective date, department and URL. At answer time, retrieve candidates, filter by region when known, rank for relevance and show the sources used. If the source is missing or outdated, the assistant should say so rather than improvising.
Problems to check
- Bad chunks: headings are separated from the paragraphs they explain, so retrieved snippets lack meaning.
- Embedding-only search: exact terms such as product codes, law names or error messages may need keyword search as well.
- Stale indexes: users assume the answer reflects today's document, but ingestion is behind.
- Long-context dumping: unrelated documents fill the prompt and the model treats weak evidence as relevant.
- No abstention path: the system answers even when retrieval returned nothing useful.
Next steps
Build the smallest honest version. For long context, create a prompt that includes the document packet and asks the model to cite section names from the provided text. For RAG, create twenty representative questions, manually label the source chunks that should answer them and measure whether retrieval finds those chunks before you judge final prose. Retrieval quality is the foundation; generation polish cannot rescue missing evidence.
Hybrid is common
Many useful systems mix both approaches. They retrieve a small set of chunks, then use a long-enough context window to include instructions, the question, source snippets and a concise conversation summary. The goal is not architectural purity. The goal is enough evidence for the model to answer and enough structure for a human to verify the answer afterward.
Separate retrieval errors from answer errors
For a hypothetical handbook pilot, prepare questions with known source passages. When an answer fails, first inspect the evidence supplied to the model. If the correct leave-policy section was absent, repair retrieval, filtering or ingestion. If it was present and the answer still contradicted it, investigate the prompt and generation step. Include a question whose answer is absent from every document. Both architectures should acknowledge that gap. Finally, change one policy in the source set and repeat the same question after refreshing the system. This exposes stale-document behavior that a one-time accuracy score would miss.
Sources and further reading
Documentation checked October 4, 2026. Product features and availability can change.
