Demonstration 03
RAG quality and evaluation
What it looks like to measure retrieval and answer quality, and why structure changes the numbers.
Illustrative demonstration. Every metric, chunk, score, and answer on this page is simulated sample data. No retrieval system or language model is running, and the numbers are not results from any real project.
Metric definitions and values (table)
| Metric | Baseline | Structured | Definition |
|---|---|---|---|
| Retrieval precision@5 | 52% | 78% | Share of the top 5 retrieved chunks that are relevant. |
| Recall@5 | 61% | 84% | Share of all relevant chunks that appear in the top 5. |
| Mean reciprocal rank | 48% | 76% | Average of 1/rank of the first relevant chunk. |
| Context relevance | 55% | 81% | How much of the retrieved context bears on the question. |
| Faithfulness | 71% | 92% | Share of answer claims supported by the retrieved context. |
| Answer correctness | 64% | 86% | Agreement of the answer with a reference answer. |
| Source attribution | 42% | 88% | Share of claims that cite the right source document. |
Worked example (structured)
“How do I authenticate requests to the Orders API in version 4.2?”
Retrieved chunks
- [1]
Orders API reference (v4.2) · Authentication
Authenticate every request by passing your token in the Authorization header as a Bearer token.
score 0.91relevant
- [2]
Getting started guide (v4.2) · Get an access token
Request a token from the OAuth 2.0 token endpoint using your client credentials.
score 0.86relevant
- [3]
Orders API reference (v4.2) · Errors
A 401 response means the token is missing, malformed, or expired; request a new token.
score 0.80relevant
- [4]
Orders API reference (v4.2) · Rate limits
…requests are limited per token; exceeding the limit returns 429…
score 0.70not relevant
- [5]
Getting started guide (v4.2) · First request
Send a test request with the Authorization header to confirm your token works.
score 0.68relevant
Generated answer (simulated)
Request an OAuth 2.0 access token with your client credentials [2], then send it on every request in the Authorization header as a Bearer token [1]. A 401 response means the token is missing or expired, so request a new one [3].
Evaluation note: Every claim cites a v4.2 source; the retrieval filter excluded the outdated v3.9 guide.
What a real implementation needs
A real evaluation needs a versioned test set of questions with known source documents (and ideally reference answers), the retrieval pipeline under test, a scoring harness for retrieval metrics (precision, recall, MRR), and an answer-quality method such as RAGAS-style metrics or human review. Results should be stored per change so regressions are visible.