Retrieval Augmented Generation Best Practices
Errors in RAG systems originate in phase one and arrive silently in phase three.

Every RAG system, regardless of eventual complexity, shares the same three-phase skeleton: ingestion, retrieval, generation. Documents are chunked, embedded, and indexed; queries pull relevant chunks from that index; the LLM reasons over retrieved content to produce an answer.
The skeleton looks clean until you run real queries against it. What tends to happen is that a chunking decision made quickly during ingestion fragments a semantic unit, the resulting embedding misrepresents what that unit meant, retrieval surfaces the wrong content, and the LLM generates a confident answer from incoherent context. The error originates in phase one and arrives silently in phase three. Teams that treat each phase as an independent configuration problem usually discover this by finding an answer that is wrong in a way they cannot immediately explain. Tracing it back to a token boundary decision made three weeks earlier is not a pleasant afternoon.
The RAG taxonomy has expanded considerably since the original Lewis et al. formulation. Eden AI's 2026 landscape identifies distinct patterns including Traditional RAG, Long RAG, Self-RAG, Corrective RAG, Adaptive RAG, and GraphRAG, each addressing different complexity requirements. All of them sit on the same three-phase foundation. Reaching for a sophisticated variant without understanding that foundation is a reliable path to misdiagnosing failures when they occur.
The most consequential empirical finding shaping my thinking on pipeline design comes from Li et al.'s systematic study published at COLING 2025. Their analysis examined how factors across all three phases, including chunk size, retrieval stride, query expansion, and prompt design, interact to determine response quality. No single factor dominates in isolation. But what if you optimize chunk size without measuring the downstream effect on retrieval precision? That is not optimization; it is parameter tuning in the absence of a loss function.
Chunking decisions that determine what retrieval has to work with
The chunk is the fundamental unit of retrieval, and whatever the chunking strategy produces is the maximum resolution at which the model can ever access a corpus. A sentence split across two chunks will never be seen whole by the model. This is not an edge case to be handled later; it is a structural property of fixed-size chunking that most teams encounter within the first week of building anything serious.
Fixed-size chunking at roughly 512 tokens persists as a default for understandable reasons: it is fast, deterministic, and requires no language processing overhead. It also cuts sentences and arguments at arbitrary positions, severing units of meaning that belong together. For prototyping, the speed advantage justifies the imprecision. For production systems where the corpus carries legal, clinical, or financial weight, fixed-size chunking tends to become a liability that compounds quietly over time.
Semantic chunking splits on meaning boundaries rather than token count, and the difference shows up in recall. Production benchmarks cited by Introl in March 2026 document recall improvements of up to 9% over fixed-size chunking. Whether 9% is modest or significant depends entirely on what a missed fact costs in the deployment context.
Chunk sizing involves a genuine trade-off that most implementation guides flatten into a recommendation without explaining the reasoning behind it. Small chunks produce precise retrieval signals but strip the surrounding context the LLM needs to reason coherently; large chunks dilute the retrieval signal, matching many queries loosely rather than any query well. Li et al. explored retrieval stride and sentence-level Focus Mode as techniques for achieving fine-grained relevance without sacrificing reasoning context, and the results suggest these approaches are worth evaluating before settling on a fixed size.
One architectural pattern that resolves this tension is hierarchical or parent-child chunking: small chunks are indexed for precision retrieval, and when a small chunk surfaces, its larger parent chunk is passed to the LLM for generation. This decouples the granularity needed for retrieval from the granularity needed for reasoning. In practice it is among the higher-leverage structural decisions available at ingestion, and it remains underused relative to the payoff.
Metadata enrichment at ingestion is similarly underused. Attaching source, date, document type, and section heading to each chunk at index time enables filtered and hybrid queries against the knowledge base later that purely semantic search cannot perform. A query for "the 2023 policy update on contractor classification" can be filtered to the relevant document type and date range rather than relying on embedding similarity to surface the right chunk from among dozens of related ones. This investment returns compounding value as the corpus grows, because the alternative is a retrieval layer that gets noisier the more documents it contains.
The heuristic I keep coming back to: start with semantic chunking at a medium size, measure recall against a representative set of queries drawn from actual expected use, then adjust. Optimizing chunk size against an abstract quality criterion, disconnected from any real query distribution, is a form of precision without accuracy.
Embedding model selection and what the benchmarks actually show
The embedding model converts chunks and queries into vectors that can be compared for relevance, and the ceiling on retrieval quality is set at this step. No downstream technique recovers information the embedding model failed to represent. Most teams understand this in principle and then default to whatever embedding API they are most familiar with, which is an understandable shortcut that tends to surface its costs gradually rather than catastrophically, which makes it harder to catch.
The performance differences between models are not marginal. Introl's March 2026 benchmark analysis reports that Voyage-3-large outperforms OpenAI embeddings by 9.74% and Cohere embeddings by 20.71% on standard retrieval benchmarks, including MTEB. Voyage-3-large also supports a 32,000-token context window compared to OpenAI's 8,000-token limit. That gap matters in long-document domains. An embedding model capped at 8,000 tokens cannot represent a full legal contract or technical specification as a single vector, which means the chunking strategy is forced to create embeddings of fragments rather than of semantically complete units. The fragmentation compounds through every subsequent phase.
General-purpose embeddings predictably underperform on specialized corpora. Legal, medical, and financial language carries vocabulary and reasoning structures that vectors trained on general web text represent poorly, and the retrieval failures that follow can be genuinely difficult to attribute to the embedding layer rather than to chunking or query formulation. Fine-tuning addresses this directly but is expensive. Query adapters can close a portion of the gap at lower cost, and for many teams they represent a worthwhile intermediate step before committing to a full fine-tuning effort.
A finding from Superlinked's September 2025 analysis of the CUAD contract retrieval benchmark complicates the usual narrative about reranking: RAGLite achieved a MAP@10 of 65.2 without any reranking, outperforming configurations that depend on a reranker to reach comparable scores. That raises an important question: if strong embedding quality can substitute for downstream reranking in at least some domains, then the conventional investment sequence — embeddings first and reranking as an enhancement — may deserve more scrutiny than it typically receives.
The decision should be empirical. Benchmark at least two embedding models against a sample of your actual documents and your actual expected queries before committing. Defaults are not choices; they are deferred choices that accumulate into technical debt.
Building a retrieval layer that finds the right chunks, not just similar ones
Vector similarity is a proxy for relevance, not relevance itself. On conceptual questions the two track reasonably well; on specific factual queries they diverge in ways that matter. A chunk about a closely related topic can outscore the chunk containing the actual answer because the related topic shares more surface vocabulary with the query. This is a structural limitation of dense retrieval, not a tuning problem, and it accounts for more production failures than most teams expect before they see it firsthand.
Hybrid retrieval, combining dense vector search with sparse keyword search via BM25, addresses this directly. Sparse BM25 search recovers exact-match facts that dense search misses: proper nouns, identifiers, product codes, statute numbers, terminology that appears infrequently in training data but critically in documents. The combination consistently outperforms either approach in isolation. For most teams it should be the starting configuration rather than an advanced technique added after the baseline fails.
The retrieval layer can also reach beyond the vector store. Relational databases serve structured facts better than any vector index; Text-to-SQL retrievers allow the pipeline to query them from natural-language inputs without requiring the user to know SQL or the schema. Graph databases handle relationship traversal that neither vector nor keyword search supports; Text-to-Cypher fills the same role there. Self-query retrievers parse metadata filters directly from the query, enabling the filtered retrieval that metadata enrichment at ingestion makes possible.
Query expansion is less discussed than cross-encoder reranking and probably more impactful in aggregate. Most retrieval failures are not failures of the ranking model; they are failures of the query itself, which is ambiguous or underspecified in ways the user does not recognize. Strong pipelines generate multiple paraphrases of the incoming query and retrieve for each before merging results. Dev.to's January 2026 analysis of high-performing pipelines identifies query expansion as a consistent distinguishing feature. A single query phrasing misses chunks that a slightly different formulation would surface; running several formulations in parallel costs tokens and latency, both of which are usually worth it.
Reranking functions as a second-pass filter, re-scoring the top-K retrieved chunks using a cross-encoder model that compares query and chunk jointly rather than independently. Introl's March 2026 analysis reports precision improvements of 10 to 30% from reranking at a latency cost of 50 to 100 milliseconds. Morphik's July 2025 guidance suggests Precision@K targets of 0.85 for compliance and regulated content, 0.75 for general knowledge work, and 0.65 as a floor for exploratory research; whether reranking latency is acceptable depends on where your application sits against those targets.
Vector database selection is infrastructure, not an afterthought. Teams with limited operations capacity will find managed services like Pinecone or Weaviate Cloud appropriate; cost-sensitive teams with SRE capacity may prefer self-hosted Milvus or Qdrant. At scale, the storage implications are concrete: 10 million documents at 1,024-dimensional embeddings require roughly 40 gigabytes of vector storage, and Milvus leads on billion-vector indices. Latency requirements should also drive selection, with sub-100 milliseconds appropriate for interactive applications and sub-50 milliseconds required for real-time contexts. Compliance constraints narrow the field further; SOC 2 and HIPAA certifications are available from major managed providers, but on-premise mandates require self-hosted deployments regardless of operational cost.
Grounding generation in retrieved content without letting context degrade the answer
Retrieval quality is necessary but not sufficient. The generation step introduces its own failure modes, and they tend to be subtle enough to escape detection during early evaluation because they produce answers that look reasonable on the surface.
Context window management is a hard structural constraint that model vendors have an interest in underemphasizing. Research documented by Chroma in July 2025 identified what they term "context rot": model performance degrades measurably as input length grows. Databricks found that correctness begins dropping around 32,000 tokens, well before the theoretical limits of most current models. It is also worth considering whether the intuition that more context monotonically improves answers is actually correct; past a threshold, additional context introduces noise that competes with the relevant material, a dynamic the lost-in-the-middle problem makes structurally worse.
The lost-in-the-middle problem compounds this in a specific way. LLMs attend more strongly to content at the beginning and end of the context window; critical chunks buried in the middle are frequently ignored regardless of their retrieval rank. The ordering of retrieved chunks in the prompt is not a neutral implementation detail. Placing the highest-relevance chunks at the beginning and end, truncating or summarizing lower-ranked chunks rather than including them in full, are practical mitigations with documented effect on faithfulness.
Citation accuracy turns out to be a generation-quality metric in its own right. Research from the Allen Institute for AI indicates that citation accuracy in RAG systems averages only 65 to 70% without explicit attribution training, meaning systems that retrieve correctly still frequently fail to cite correctly. For domains where traceable claims matter operationally, that gap is not a cosmetic issue.
Li et al.'s COLING 2025 study identifies prompt design as material to RAG response quality, which is among the less glamorous findings in the RAG literature and among the most actionable. Instructions that require the model to ground its answer in provided context, and to flag explicitly when the retrieved content is insufficient rather than filling the gap from pretraining, improve faithfulness and reduce RAG hallucination in measurable ways. The mechanism is simple and the implementation cost is low; it is underused.
Faithfulness and relevance must be tracked as separate dimensions. A faithful answer stays within the retrieved context; a relevant answer addresses the user's actual question. A system can be faithful while irrelevant, consistently citing retrieved content that misses the point of the query. It can be relevant while unfaithful, accurately answering by drawing on model training rather than retrieved context. Collapsing them into a single quality metric obscures which phase of the pipeline is actually failing, and the remediation for each is completely different.
What real-time web retrieval adds to a RAG pipeline and where it changes the architecture
Even a well-indexed, well-maintained private document store has an inherent temporal lag. It cannot answer questions about events that occurred hours ago, and even routine maintenance cycles leave windows during which the index has drifted out of date. An arXiv preprint from April 2026 characterizes this as a structural limitation of pre-indexed retrieval architectures rather than an operational failure. The distinction matters because no amount of indexing discipline eliminates it; the architecture itself has to change.
Web search APIs address this by querying the live web at inference time. The distinction between a traditional SERP API and an AI-native search platform is more consequential than it initially appears. Traditional SERP APIs return titles, URLs, and 150 to 300-character snippets, which are adequate for orienting a human reader but insufficient for a language model that needs to reason over full document content. Raw web pages compound the problem further: they are 60 to 80% boilerplate, navigation, and advertising, and pipelines that skip content extraction spend context tokens on material that contributes nothing to the answer.
An AI-native search platform that performs content extraction in the same call as search is qualitatively different infrastructure, particularly for agentic workloads. The latency cost is real: Proxyway's 2026 search API benchmarks place index-based APIs at under 0.4 seconds and real-time crawling APIs at 0.6 to 0.7 seconds. Whether that difference is acceptable depends on whether freshness or raw speed is the tighter constraint in the deployment context.
Microsoft's retirement of the Bing Search APIs in August 2025 accelerated developer migration toward platforms designed specifically for AI workflows. The assumptions baked into search APIs designed for browser rendering do not translate cleanly to what LLM pipelines need, and that mismatch has been a persistent source of friction for teams that tried to adapt consumer search products rather than adopt purpose-built alternatives.
For most production RAG systems, the appropriate architecture combines a private document store for proprietary or domain-specific content with a live web search layer for current facts. These are complementary retrieval sources with different latency and freshness profiles. Treating them as competing alternatives forces a choice that the architecture does not require and the use case rarely justifies.
How agentic RAG replaces single-pass retrieval with iterative reasoning
Standard RAG retrieves once and generates once. For simple lookups, this is adequate. For multi-step questions, it breaks, because the answer to the first step determines what must be retrieved for the second, and a single retrieval pass made before any query decomposition or reasoning begins cannot anticipate that dependency. This is not a configuration problem to be tuned away; it is a design problem that requires a different architecture.
Agentic RAG embeds retrieval as a tool the LLM calls iteratively: plan, retrieve, reason over results, decide whether to retrieve again or act on what has been found. Toloka AI's 2025 analysis describes this as mirroring how a human analyst approaches a complex research task. The performance difference is concrete. Firecrawl's June 2026 benchmark reports that agentic RAG outperforms standard RAG by 14 percentage points on a HuggingFace benchmark, 86.9% versus 73.1%, which is a meaningful gap for anyone deploying against non-trivial queries.
Several architectural patterns have emerged as foundational within this space. Self-RAG and Corrective RAG introduce self-reflection on retrieved content quality, triggering fallbacks such as live web search when retrieved documents are insufficient. PlanRAG and Search-o1 separate high-level query decomposition from low-level retrieval execution, allowing more deliberate planning before retrieval begins. Search-R1 applies reinforcement learning to train the LLM to make autonomous search decisions rather than following a fixed retrieval protocol. Each represents a different answer to the same underlying question: how much of the retrieval strategy should be decided at design time versus resolved at inference time.
Enterprise deployments add requirements that prototype implementations sidestep. Multi-step reasoning across heterogeneous sources requires coherent context maintenance across retrieval turns, not independent retrieval events that the model treats as disconnected. Context window discipline becomes acutely important here; re-retrieving previously found content wastes both tokens and latency. Citations must be traceable at each reasoning step, not only in the final answer, because intermediate reasoning steps are often where the most consequential claims originate. Parallel processing across sources, discussed in an arXiv preprint from May 2026, is necessary for managing latency when an agent must synthesize across many sources within a single task.
The infrastructure requirements shift accordingly. An API that performs acceptably in a single-pass RAG pipeline can become a bottleneck when an agent must navigate, extract, and synthesize across dozens of pages within a single task. Platforms that support autonomous multi-step browsing, parallel requests, and structured output the agent can reason over without preprocessing are functionally different from those that do not, per Firecrawl's June 2026 analysis.
Evaluating a RAG pipeline with metrics that reflect production reality
Evaluation is where RAG pipelines most consistently deceive their builders. A pipeline that performs well on a curated benchmark can fail on the actual distribution of queries it receives, and the gap is usually larger than expected because the benchmark was implicitly constructed from the same assumptions that shaped the pipeline. Meta AI research, reported by Maxim AI in November 2025, demonstrates that evaluation datasets skewed toward simple queries overestimate production RAG quality, with accuracy dropping 25 to 30% on realistic query distributions. Building confidence on the wrong test set, then discovering the gap after deployment, is a specific and recurring failure mode.
Retrieval metrics form the foundation. Precision@K measures the fraction of retrieved chunks that are actually relevant; the calibrated thresholds from Morphik's July 2025 analysis, 0.85 for regulated content, 0.75 for general knowledge work, 0.65 for exploratory research, provide targets against which to measure. Recall@K measures whether relevant chunks were retrieved at all, and a low Recall@K is the correct diagnosis for pipelines that return confident but incomplete answers. A pipeline that retrieves precisely but incompletely produces confident answers with missing information, which is harder to catch than an outright wrong answer because it passes superficial review.
Generation metrics must track faithfulness and relevance as separate dimensions, for the reasons discussed earlier; evaluation frameworks such as RAGAS operationalize both as distinct scored dimensions. Citation accuracy belongs in its own measurement category. Response latency under realistic concurrency, not single-query benchmarks, belongs in the evaluation suite alongside quality metrics; systems that pass quality checks under light load frequently fail latency checks once more than a few users are active simultaneously.
The deeper principle is that the query distribution used for testing must reflect the actual distribution the pipeline will encounter. Constructing that distribution early, before optimization begins, shapes every subsequent decision. A recall target calibrated to real queries tells you how aggressively to invest in chunking and embedding quality. A latency budget derived from realistic concurrency testing tells you whether reranking is affordable. Evaluation is not a closing exercise; it is the frame within which every other decision is made. Treating it as something you do at the end, after the pipeline is built, is a reliable way to optimize confidently for the wrong thing.


