TL;DR: RAG pipelines break at different stages, so end-to-end scores alone can hide whether retrieval, context assembly, or generation caused a regression, according to Braintrust. The practical lesson is that teams need representative datasets, stage-level scoring, and release gates before shipping changes.
At a glance
What this is: This is a practical guide to testing RAG pipelines with separate retrieval and generation evaluation, then validating complete runs before release.
Why it matters: It matters because identity, security, and AI teams need to know whether a failure sits in data retrieval, model behaviour, or release gating before they trust the pipeline in production.
By the numbers:
- Braintrust recommends starting with 5 to 10 representative examples that cover core use cases.
👉 Read Braintrust's guide to testing a RAG pipeline before and after shipping
Context
RAG testing often fails because teams treat retrieval and generation as one problem. In practice, the retriever can return weak or incomplete evidence while the generator still produces a fluent answer, which means a single end-to-end score hides the real fault line. For security and identity practitioners, that distinction matters whenever a RAG workflow relies on governed documents, policy text, or operational knowledge that must be retrieved correctly before it can be trusted.
The article argues for a versioned, representative dataset and separate span-level evaluation before release, then production scoring after deployment to catch new failure modes. That approach aligns with how teams should govern AI-assisted systems that depend on controlled context, including NHI-backed data access and retrieval paths. It is most relevant to practitioners who need to know whether a pipeline change altered the corpus, the ranker, the prompt, or the model.
The starting position described here is typical for teams that have instrumentation but not a full evaluation discipline. The gap is not model quality alone, but control over how evidence is selected, assessed, and approved for use.
Key questions
Q: How should security teams test a RAG pipeline before release?
A: Test the retriever, context assembly, and generator separately before you trust the full pipeline. Use a representative dataset, pin the configuration under test, and compare each change against a baseline. Then run the complete pipeline with release thresholds and case-level review so one improved average does not hide regressions in critical queries.
Q: Why do RAG systems need separate retrieval and generation scoring?
A: Because a fluent answer can still be built on weak evidence, and a retrieval regression can be masked by a stronger prompt or model. Separate scoring shows whether the system selected the right context, used it correctly, or failed earlier in the pipeline. That makes root cause analysis and release approval far more reliable.
Q: How can security and AI teams know if RAG evaluation is actually working?
A: Evaluation is working when test results change predictably after controlled updates and when failures map to a specific component, such as retrieval, chunking, or the generation layer. If tests only produce a pass or fail without isolating the cause, the programme is measuring noise rather than control quality. The best signal is repeatable detection of regressions before production users do.
Q: What should teams do when a RAG change improves the average score but breaks key cases?
A: Prioritise the critical cases. Average scores can hide concentrated regressions in authentication, policy, or high-risk operational queries. A release should be blocked if must-pass cases fail, even if the aggregate score moves up. Good governance means deciding in advance which failures are unacceptable and enforcing that rule consistently.
Technical breakdown
Why end-to-end RAG scores miss the real failure mode
A RAG pipeline has at least three distinct failure surfaces: retrieval, context assembly, and generation. End-to-end metrics compress those stages into one number, so a score regression tells you something changed but not where it changed. Separate spans let you score the retrieved documents, the assembled context, and the final answer independently. That is the difference between knowing the system failed and knowing which control point failed. In practice, this is how teams avoid overcorrecting prompts when the actual issue is weak retrieval or stale corpus indexing.
Practical implication: Instrument retrieval and generation as separate spans so the failing stage is visible before you change prompts, rankers, or models.
What a golden dataset must contain for RAG evaluation
A golden dataset is not just a list of questions. It needs representative queries, expected documents or reference answers where appropriate, and metadata that records query type, source, and holdout status. Production logs matter because synthetic prompts rarely capture ambiguity, typos, or real user phrasing. The article also distinguishes label-based retrieval tests from reference-based generation tests and assertion-based checks. That allows teams to evaluate what matters for each case rather than forcing every test into one scoring model. The result is a dataset that can support iteration without losing release confidence.
Practical implication: Build separate test rows for retrieval labels, reference answers, and holdout cases so one dataset can support both tuning and release checks.
How CI gating turns RAG testing into a release control
CI gating makes evaluation a control, not an afterthought. The article recommends running smoke tests on pull requests, then running the full suite before merge or release. That matters because LLM judges and retrieval metrics can move in ways that are invisible in manual review. Change one variable at a time, preserve baseline runs, and define acceptance thresholds before you compare results. In a governed pipeline, the release decision should depend on score movement, case-level regressions, and whether required queries still pass after the change.
Practical implication: Enforce score thresholds in CI so retrieval and generation changes cannot ship without passing the agreed test set.
NHI Mgmt Group analysis
Separate evaluation is now a governance requirement, not a testing preference. The article shows that end-to-end RAG scoring can conceal whether the retriever, the context assembly layer, or the generator caused the failure. That is a control problem, not just a measurement problem, because teams cannot govern what they cannot isolate. For identity and access teams, the parallel is clear: the system that fetches evidence needs the same scrutiny as the system that answers with it. The practitioner conclusion is to treat stage-level evaluation as part of model governance.
Representative production traffic is the right foundation for RAG quality control. Synthetic test questions often miss the ambiguity and operational noise that appear in live traffic. The article's use of production logs and holdout sets reflects a broader security truth: real user behaviour reveals edge cases faster than curated examples do. This also matters for NHI-governed data paths, because the trust boundary is not only the model but also the credentials and sources that feed it. Practitioners should build datasets from actual usage patterns, not assumptions.
Configuration provenance is a named concept teams should start tracking. The article shows why corpus version, embedding model, reranker settings, prompt version, and generation model all need to be pinned for each run. Without that provenance, score changes are hard to attribute and release decisions become anecdotal. This is especially relevant when AI systems depend on governed access to internal content through service accounts or other non-human identities. The practitioner conclusion is to make configuration lineage part of the evaluation record.
RAG release control should be judged by regression behavior, not by average score alone. A small aggregate improvement can hide a cluster of failures in critical queries, and a small decline can still be acceptable if the regressions are minor while core cases improve. That is why case-level review belongs in the release decision. For practitioners, the implication is to define must-pass queries, permitted regressions, and thresholds by query class before any model or retrieval change reaches production.
The identity bridge here is real: retrieval systems are governed access systems. Once RAG draws from controlled corpora, the question becomes who or what can read, rank, and inject evidence into the model. That makes access control, source provenance, and span-level traceability relevant to IAM and NHI programmes, even when the article is framed as an AI testing guide. The practitioner conclusion is to align RAG evaluation with the same governance discipline used for sensitive data access.
What this signals
RAG evaluation should now be treated as part of broader access governance, because the quality of retrieved context depends on what the system can reach, rank, and reuse. In environments where AI workflows rely on governed data sources, the same discipline used for service accounts and other non-human identities should apply to retrieval paths and traceability.
Configuration provenance: the corpus version, prompt version, reranker, embedding model, and generation model together define the system under test. If those elements are not pinned, teams cannot tell whether they are measuring quality change or configuration drift, which makes release governance fragile.
Operationally, this means security and AI teams need evaluation records that are as auditable as change records. When a retrieval pipeline touches sensitive content, traceability and least-privilege access to the underlying sources become part of the control set, not just a model tuning concern.
For practitioners
- Instrument retrieval and generation separately Record retrieval and generation as distinct spans in the same trace so you can score document selection and answer quality independently.
- Build a holdout dataset from production queries Use production logs to capture real phrasing, ambiguity, and edge cases, then reserve a holdout set for release checks that should not be used during tuning.
- Pin every evaluation dependency Store corpus or index version, document-processing settings, embedding model, retrieval parameters, reranker configuration, generation model, and prompt version with each run.
- Gate releases on case-level regressions Define thresholds for aggregate scores, must-pass queries, and allowed regressions before CI runs, then block release when critical cases fail even if the average score rises.
- Review low-scoring production traces into the dataset After deployment, add confirmed failures from production scoring back into the golden dataset so the next release test covers newly exposed failure modes.
Key takeaways
- RAG quality breaks at different layers, so one aggregate score is not enough to govern release risk.
- Production logs, holdout data, and pinned configuration metadata are the foundation of repeatable evaluation.
- CI gating only works when teams define must-pass cases and tolerated regressions before they ship changes.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST AI RMF, NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the technical controls, while ISO/IEC 27001:2022 define the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST AI RMF | MEASURE | The article is about evaluating AI system performance and reliability before release. |
| NIST CSF 2.0 | GV.OV-01 | RAG testing is a governance and oversight problem with release risk implications. |
| NIST SP 800-53 Rev 5 | SI-4 | Production scoring and regression detection align with system monitoring and anomaly detection. |
| ISO/IEC 27001:2022 | A.8.29 | Testing changes before release aligns with secure development and system change control. |
Apply secure change control to RAG updates so model, prompt, and retrieval changes are tested before production.
Key terms
- Golden Dataset: A curated set of expected inputs and outputs used to test whether an AI system behaves consistently across changes. In governance terms, it becomes evidence that model or workflow changes did not introduce regressions that would affect reliability, safety, or access-related behaviour.
- Recall: The share of real weaknesses that the scanner successfully identifies. High recall reduces the chance of missed vulnerabilities, but if it is achieved by over-reporting, teams can become overwhelmed and stop trusting the results.
- Answer Correctness: Answer correctness measures whether a generated response matches the expected answer or accepted outcome. It is useful when a dataset contains reliable reference answers, but it must be judged alongside faithfulness and relevancy because a correct-looking answer can still be unsupported.
- Holdout Set: A holdout set is a reserved subset of test cases kept out of tuning so it can be used for independent release checks. It helps teams confirm that a change generalises beyond the examples used during iteration and avoids overfitting to the same benchmark.
What's in the full article
Braintrust's full blog post covers the operational detail this post intentionally leaves for the source:
- Step-by-step examples for building golden datasets from production logs and holdout cases.
- Metric selection guidance for recall@k, precision@k, NDCG, ContextRecall, and AnswerCorrectness.
- CI workflow patterns for smoke testing pull requests and running full release checks after merge.
- Trace and scoring examples that show how to pin corpus, prompt, and model versions across experiments.
Deepen your knowledge
The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, IAM, and secrets management. It helps practitioners connect identity controls to the broader security programmes that depend on them.
Published by the NHIMG editorial team on August 18, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org