Beyond “The Answer Looks Right”: Reusable RAG Evaluation in .NET

RAG evaluation in .NET, showing answer citations traced to source documents through a magnifying glass.

A RAG application returns a confident answer with citations. The wording sounds reasonable. The documents appear relevant.

Is the answer supported?

That question requires more than reading the response and deciding whether it looks right. RAG evaluation in .NET needs to distinguish retrieval relevance, answer faithfulness, citation coverage, and citation support. Each reveals a different failure—and each depends on the quality of the evaluation itself.

In our SQL Server 2025 Express benchmark article, we examined retrieval performance. This article moves from speed to evidence.

The AInDotNet RAG-Phase-4 repository includes a reusable evaluation library, interfaces, reference cases, and tests. It is an experimental reference implementation requiring adaptation and review, rather than a dependable automated quality gate.

Four questions every RAG evaluation should separate

A single quality score can hide the reason an answer failed.

Evaluation dimensionQuestion it answersFailure it can reveal
Retrieval relevanceDid we retrieve the expected evidence?The answer generator received unsuitable context.
Answer faithfulnessAre the answer’s claims supported by retrieved evidence?The answer added an unsupported assertion.
Citation coverageWhich extracted claims have citations?An assertion has no reference attached.
Citation supportDoes the cited source support the associated claim?A citation points to material that does not establish the claim.

These measurements complement one another. Strong retrieval does not guarantee faithful generation. Extensive citation coverage does not guarantee supporting evidence.

The repository implements these concerns through separate components. Its RagEvaluator combines faithfulness and citation results; retrieval metrics are calculated separately by RetrievalEvaluator. Evaluation implementation.

Retrieval relevance: did the right evidence arrive?

The retrieval evaluator compares returned chunk IDs with expected IDs defined in a reference case.

It calculates three metrics:

  • Precision at K: how many selected results are expected matches, divided by K.
  • Recall at K: how many expected chunks appeared among those results, divided by the number of expected chunks.
  • Reciprocal rank: one divided by the position of the first expected match, or zero when none appears.

These calculations are deterministic once the expected IDs and retrieved IDs are fixed. Their usefulness still depends on the reference labels.

A relevant passage omitted from the expected set may be counted as irrelevant. A corpus change may invalidate stored chunk IDs. Good arithmetic cannot compensate for poor reference cases. Retrieval evaluator.

Walk one answer through the evaluation components

Consider this illustrative teaching example. The source snippets, answer, and scores below explain the method; they are not results from a live evaluation run.

The user asks:

How does our demonstration store embeddings, and does it implement the authorization required by our architecture guidance?

Assume retrieval returns:

SourceContent
S1Architecture guidance: enterprise RAG systems must enforce authorization controls.
S2Application description: the demonstration stores document embeddings in SQL Server.
S3An unrelated passage about deployment scheduling.

Suppose the reference case identifies S1 and S2 as relevant. They appear first and second in the three returned results.

For K = 3, precision is 2/3, recall is 1, and reciprocal rank is 1.

Now consider the generated answer:

The architecture guidance requires enterprise RAG systems to enforce authorization [S1]. Our demonstration implements those controls [S1]. The demonstration stores embeddings in SQL Server.

Retrieval found useful evidence. Generation still introduced an unsupported implementation assertion.

Answer faithfulness: which claims does the evidence support?

The faithfulness pipeline extracts claims, removes exact duplicates, applies semantic normalization, and evaluates the remaining claims against the retrieved sources.

The evidence verifier distinguishes:

  • Supported.
  • Contradicted.
  • Insufficient evidence.

The score is supported claims divided by evaluated claims. Those outcomes remain important alongside the score: missing evidence and explicit contradiction describe different problems. Faithfulness evaluator.

Assuming the example produces three distinct claims:

ClaimExpected assessment
The architecture guidance requires authorization.Supported by S1.
The demonstration implements authorization.Insufficient evidence.
The demonstration stores embeddings in SQL Server.Supported by S2.

The illustrative faithfulness score is 2/3.

The second claim is not established by the supplied evidence. That does not prove authorization is absent from the application. It means this evidence cannot justify the answer’s assertion.

Faithfulness is also bounded by the sources. An answer can faithfully repeat an outdated or incorrect document. Agreement with retrieved evidence is not independent verification of real-world truth.

Citation coverage: is a reference attached?

Two of the example’s three claims contain citation labels. Its illustrative citation coverage is therefore 2/3.

Coverage measures the presence of citations. It does not establish whether their sources support the claims—or even whether every label resolves to a known retrieved source.

The library also calculates factual citation coverage using a claim classifier. That introduces another dependency: the classifier’s decision about which claims belong in the factual category.

Keep the counts and classifications visible. A percentage without its denominator can conceal what was evaluated.

Citation support: does that particular source establish the claim?

The citation verifier checks each claim–citation pair against its associated source.

For our example:

  • The requirement claim paired with S1 is supported.
  • The implementation claim paired with S1 is unsupported: the architecture requirement does not establish application behavior.

Under those illustrative judgments, citation accuracy is 1/2, or 50%, while citation coverage remains approximately 67%.

The uncited storage claim can still be faithful because S2 supports it. It simply lacks a citation in the answer.

The implementation also distinguishes unknown source labels. Its CitedClaimSupportRate asks whether each grouped cited claim has at least one supporting citation; CitationAccuracy evaluates all claim–citation pairs. Those denominators answer different questions. Citation verification and metrics.

A more defensible answer would say:

The demonstration stores embeddings in SQL Server [S2]. The architecture guidance requires authorization controls [S1], but the supplied sources do not establish whether the demonstration implements them.

Preserve source attribution and implementation status

Claim extraction can change meaning before evidence verification begins.

Compare:

The architecture document recommends authorization.

with:

The application implements authorization.

They concern different subjects and make different assertions. Removing a reporting phrase can also turn an attributed statement into an unqualified claim.

Our citation pipeline retains the original answer passage and validates whether an extracted claim preserves its meaning. This is separate from checking whether the external evidence supports that claim.

A faithfully extracted claim can still be unsupported. The example’s implementation assertion accurately reproduces what the answer said; its problem is the missing supporting evidence.

The pipeline can optionally attempt one bounded repair of invalid extracted claims, followed by revalidation. This repairs an extraction—not the original answer or the application. Invalid results can still fail evaluation. Citation verifier.

Requirements, verified implementation, explicit nonimplementation, and missing implementation evidence must remain distinct throughout this process.

Reusable .NET evaluation through interfaces and fakes

The library separates responsibilities through interfaces including IClaimExtractor, IClaimNormalizer, IClaimEvidenceVerifier, IFaithfulnessEvaluator, and ICitationVerifier.

That separation allows tests to substitute known responses for live model calls.

A fake evidence verifier can return a predetermined support outcome. A fake citation verifier can supply a fixed result. Tests can then check orchestration, score calculations, evidence scope, and failure handling without asking a model to repeat the same judgment.

For example, the repository tests that RagEvaluator invokes its dependencies and combines their results. Those checks verify code behavior. They do not demonstrate that a live judge understands evidence correctly. Evaluator tests.

Reuse also has practical boundaries. The evaluation project targets .NET 10 and references the Application project. Tests, fakes, and reference cases remain in the test project.

Adapting it requires mapping application answers and sources into its evaluation types and supplying appropriate dependencies. The console’s ask command displays answers and citations; it does not automatically execute the full evaluator. Repository structure and scope.

Evaluation limitations: inspect the evaluator too

Extraction and normalization determine which assertions reach verification.

If extraction misses a claim, that claim may disappear from the denominator. If semantic normalization treats distinct assertions as duplicates, a resulting score may misrepresent the answer.

The normalizer requires selected claims to match input strings verbatim. That helps detect invented or rewritten output, but it cannot prove every distinct meaning survived. Claim normalizer.

Live judges can also return inconsistent decisions. Earlier project runs exposed contradictory attribution judgments and loss of a distinct requirement during normalization.

On November 16, our selected groups passed: 213 deterministic tests and 52 live-evaluation tests. Those results describe that run. They do not erase earlier failures or establish that the evaluator is consistently reliable. Separate database-integration and performance test categories were outside those two group results. Saved test evidence.

How to apply this approach in your own RAG application

Start with a small, reviewed reference set containing supported claims, unsupported assertions, missing citations, misleading citations, and questions the sources cannot answer.

Retain the question, answer, retrieved evidence, original passages, extracted claims, normalized claims, judge explanations, and run configuration. The supplied run object does not capture every model and prompt detail automatically; add the metadata your review process needs.

Run deterministic checks separately from live evaluations. Preserve failures rather than repeating runs until only a passing result remains.

Most importantly, inspect individual cases alongside aggregate scores. A reviewer should be able to explain why an assertion was supported, rejected, or left unresolved.

That is the engineering value of reusable RAG evaluation in .NET: making the path from answer to evidence inspectable, testable, and open to challenge.

Explore the RAG-Phase-4 evaluation library and adapt its reference cases to your workload. At AInDotNet, we treat that evidence as part of the AI engineering and delivery lifecycle—with human review where automated judgments remain uncertain.

Frequently Asked Questions

What is RAG evaluation in .NET?

RAG evaluation in .NET assesses how well a retrieval-augmented generation application retrieves evidence and produces supported answers. Useful checks include retrieval relevance, answer faithfulness, citation coverage, and citation support. These measurements answer different questions and should be inspected separately.

What is the difference between retrieval relevance and answer faithfulness?

Retrieval relevance asks whether the application found the expected evidence. Answer faithfulness asks whether the generated claims are supported by the evidence it retrieved.

An application can retrieve the right passages and still generate an unsupported answer. It can also faithfully summarize retrieved material that does not adequately answer the user’s question.

What is the difference between citation coverage and citation support?

Citation coverage measures how many extracted claims have citations. Citation support checks whether the cited sources establish those claims.

An answer can have complete citation coverage while citing sources that do not support its assertions. Attaching a reference does not make a claim correct.

How does the library calculate answer faithfulness?

The faithfulness pipeline extracts claims, removes duplicates, applies semantic normalization, and checks the remaining claims against retrieved evidence. Its faithfulness score is the number of supported claims divided by the number of evaluated claims.

That score depends on the pipeline preserving the answer’s distinct assertions. A missed or incorrectly removed claim can distort the result.

What retrieval metrics does the reference implementation calculate?

The retrieval evaluator calculates precision at K, recall at K, and reciprocal rank using expected and retrieved chunk IDs.

Precision measures the proportion of the selected K results that match the expected set. Recall measures how much of the expected set was retrieved. Reciprocal rank reflects the position of the first expected match. Their usefulness depends on accurate reference labels.

Does a faithful RAG answer have to be factually correct?

Faithfulness establishes support relative to the supplied evidence. It does not independently establish real-world truth.

An answer can faithfully repeat an outdated policy or an incorrect source document. Source quality, freshness, authority, and suitability therefore require attention alongside answer evaluation.

Why does source attribution matter during claim extraction?

Attribution identifies who made an assertion and preserves its scope.

“The architecture document recommends authorization” is different from “the application implements authorization.” If extraction removes or changes the attribution, the evaluator may judge a claim the original answer did not make.

How should an evaluator distinguish a requirement from an implemented feature?

A requirement describes what should or must happen. An implementation claim describes what the system actually does.

A document requiring authorization does not establish that a particular application enforces it. Evaluation should preserve requirements, verified implementation, explicit nonimplementation, and missing implementation evidence as distinct meanings.

Is insufficient evidence the same as a contradiction?

No. Insufficient evidence means the supplied material does not establish the claim. A contradiction means the evidence conflicts with it.

If no retrieved passage confirms that authorization is implemented, the evaluator should not conclude that authorization is absent. The supported conclusion is that implementation status remains unestablished from those sources.

How do interfaces and fakes make RAG evaluation reusable?

Interfaces separate extraction, normalization, evidence verification, and evaluation orchestration. Tests can substitute fakes that return predetermined outcomes, allowing repeatable checks of calculations, dependency calls, and failure handling.

Those tests verify defined code behavior. They do not establish that a live language-model judge makes accurate or consistent decisions.

Can I reuse the library in another .NET application?

Yes, with adaptation. The evaluation project targets .NET 10 and references the repository’s Application project. Tests, fakes, and reference cases remain in the test project.

You will need to map your application’s answers and sources into the evaluation types, configure the dependencies, and create reference cases appropriate to your documents and questions. It is an experimental reference implementation rather than a standalone production-ready package.

Does the demonstration automatically evaluate every generated answer?

No. The console’s ask command generates an answer and displays citations. It does not automatically execute the full evaluation pipeline.

The evaluation components are exercised through tests and require explicit integration into another application’s workflow. Repository scope and usage.

Can an LLM judge reliably approve RAG answers for production?

The project does not establish that level of reliability. Live evaluations have exposed inconsistent attribution judgments and normalization that removed a distinct claim.

The November 16 run passed 213 deterministic tests and 52 live-evaluation tests, but one passing run does not erase earlier failures or guarantee future judgments. Treat automated evaluations as evidence requiring review, rather than a dependable production approval gate. Saved test evidence.

What should we save when a RAG evaluation fails?

Preserve the question, generated answer, retrieved sources, original answer passages, extracted claims, normalized claims, judge outcomes, and explanations.

Also record the code version, model configuration, prompt version, and timestamp where available. These details help distinguish application defects, extraction errors, judge inconsistencies, and unsuitable reference cases.

author avatar
Keith Baldwin