Skip to content
New Year BoostTop up
Apixo
Blog
news· 4 min read· via Towards AI

Why Production RAG Demands Decoupled Testing for Retrieval and Generation

Engineers from Goldman Sachs and TestMu AI explain why isolating retrieval metrics, index freshness, and atomic claim verification is essential for reliable enterprise RAG.

Why Production RAG Demands Decoupled Testing for Retrieval and Generation

When an automated credit card assistant told a cardholder their interest rate was four percent, the bot sounded entirely confident. In reality, the underlying documentation had been updated the week before to state that rates reach "up to 4 percent." Because the retrieval pipeline pulled stale context and the generation layer converted a qualified range into a firm guarantee, the system made an unauthorized promise in an industry where inaccurate disclosures carry severe compliance consequences.

According to Vijay Kumar Sridharan, VP of Software Engineering at Goldman Sachs, this incident came directly from work on the conversational AI backing Apple Card’s voice and chat support, which handles queries for more than 12 million US cardholders. Standard demos failed to expose the discrepancy because they relied on fresh, curated queries. Without continuous grounding checks across lower-volume intents, the discrepancy persisted until someone noticed the error manually.

To prevent such failures, engineering teams operating retrieval-augmented generation (RAG) architectures are moving away from monolithic evaluation, choosing instead to test index freshness, retrieval accuracy, and generated claims as distinct components.

Isolating Retrieval, Freshness, and Generation

Treating RAG as a single black box tends to obscure where an answer breaks down. Sridharan notes that retrieval issues, generation errors, and stale indexes behave completely differently, requiring dedicated instrumentation and distinct owners.

Before modifying prompts to fix bad output, teams must verify that the retrieval layer actually supplies the right source text. This is measured via context recall—evaluating whether the specific chunk holding the correct answer appears in the top k results for a benchmark set of queries. If the model never receives the source passage, prompt engineering cannot resolve the issue.

Equally important is index freshness. A source document can easily be edited without being re-embedded into the vector database. By generating a cryptographic hash (such as SHA-256) for raw documents and comparing it against metadata in the vector store before running evaluation suites, teams can flag stale entries and re-embed them immediately.

Once retrieval is validated, the generation layer must be evaluated for faithfulness. Instead of assigning an arbitrary aggregate score from 1 to 5, Sridharan's approach splits the generated response into discrete, atomic claims. Each claim is evaluated against the retrieved context using natural language inference (NLI) models, which categorize the relationship as Entailed, Contradicted, or Neutral. If an answer contains even a single Contradicted or Neutral statement, the entire response fails.

Treating the Knowledge Base as a Software Release

While engineering teams routinely enforce strict continuous integration (CI) gates on source code, documentation updates often bypass automated checks entirely. Shahid Ali Khan, Principal Engineer for DevOps at TestMu AI (formerly LambdaTest), observes that content changes alter what end users encounter just as much as an application deployment.

Khan advocates deploying vector indexes through identical pipelines used for application code. Teams can build a new index alongside the active one, run automated evaluation gates against it, and switch traffic using vector store aliases—a feature supported by engines like OpenSearch and Qdrant. If metrics fall short, the pipeline halts before updating the alias; if issues arise post-release, reverting the pointer provides a one-step rollback.

To strengthen these gates, Khan recommends generating adversarial evaluation queries from document diffs. When text is deleted or modified in a policy page, automated routines or reviewers can construct questions targeting the removed statements. This verifies that the updated bot no longer answers based on deprecated terms.

Finally, to catch drift between releases, Goldman Sachs rescores a rolling sample of 2 to 5 percent of production traffic, redacting personal customer data before evaluation. Khan notes that if grounding scores drop in production, the alert should notify on-call engineers under the same protocols as a service outage.

What it means for developers

For engineering teams building or maintaining production RAG systems, these operational practices provide a blueprint for minimizing hallucinations and stale answers:

  • Decouple testing layers: Measure retrieval context recall and context precision independently from model generation. Do not try to solve retrieval gaps by altering prompts.
  • Automate freshness tracking: Compute hashes for source documents to ensure vectors update as soon as source text changes.
  • Validate claims with NLI: Break model outputs into atomic statements and reject responses containing neutral or contradictory claims.
  • Gate index updates via aliases: Never publish knowledge-base edits directly into production vector stores. Run an automated evaluation gate against a parallel index before shifting pointer aliases in engines like Qdrant or OpenSearch.
  • Generate diff-based queries: Use removed phrases from documentation updates to build adversarial regression tests that confirm old policies are no longer served.

As developers experiment with different LLMs for generating atomic claims or synthesizing context, they can try top AI models cheaply through one API at https://apixoai.online to benchmark evaluation costs and inference quality across providers without managing separate integration contracts.


Source: RAG Systems Need Separate Tests for Retrieval and Generation — Towards AI. Written by the Apixo team from that report.

#ai-news#rag#machine-learning#devops#llm#vector-search
Try it with your own tools

One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.

Get your API key

Keep reading