RAG evaluation framework
An evaluation harness for the retrieval layer of an enterprise AI knowledge assistant. A golden set of real questions with known answers is scored for context precision and context recall, and the scores decide what to improve next. It is growing into nightly, domain-specific runs with alarms when quality drops.
- Role
- Co-architect & developer
- Type
- Internal platform
- Timeline
- 2026 — present
- Stack
- RAGAS · Python · Amazon Bedrock Knowledge Bases · Amazon CloudWatch
The problem
The enterprise AI knowledge assistant answers questions from Confluence and about 80 code repositories. Every change (how documents are chunked, how repositories are summarised, adding a reranker) could make answers better or worse, and without a measure, the only evidence was whether a few answers looked right.
We needed a repeatable score for the retrieval layer that could tell us whether a change helped, and where to look when it didn’t.
The approach
A golden dataset of 50 real questions, each with a reference answer, is run against the knowledge base. RAGAS scores the retrieved passages on two metrics:
- Context precision: of the passages we retrieved, how many were relevant, and were the relevant ones ranked near the top?
- Context recall: of the facts the reference answer needs, how many appear somewhere in the retrieved passages?
Low precision means noise, so we tune ranking and result counts. Low recall means missing evidence, so we look at chunking, query handling and gaps in the content. The latest run showed precision around 0.80 and recall around 0.56: what we retrieve is mostly relevant, but we often miss passages a full answer needs. That made recall the clear next priority.
The harness also measured the reranking step. Because the managed reranker is not available in the region the data must stay in, we added an LLM-based reranker and used the evaluation to judge whether it was worth its cost.
What comes next
- Multiple golden datasets, one per domain area, so a drop in one part of the knowledge base isn’t hidden by an average.
- Nightly runs that publish scores as CloudWatch metrics, with alarms when quality falls below the baseline, so a bad content change is caught the next morning instead of by users.
- Run metadata recorded with every result: the configuration, the content version and which pipeline steps were on.
What I learned
- Measure before tuning. Without the golden set, we would have tuned ranking. The numbers showed recall was the real gap.
- Record the setup with the score. Our early history didn’t record whether the reranker was on for each run, so some results can’t be compared fairly. Every run now needs its configuration saved alongside it.
- Treat knowledge quality like a production service. Content changes every day, so evaluation has to run continuously, with alarms, not once before launch.
Key decisions
Score retrieval on its own
The knowledge assistant only retrieves, and the client model writes the answer. Scoring the retrieved passages, not the final answer, isolates the part we own, so a chunking problem is not mistaken for a prompt problem.
Trade-off: It says nothing about how well the client model uses the passages. Answer quality still needs a separate check.Real questions with known answers
The golden set is built from real questions people asked, each with a reference answer, rather than synthetic questions generated from the documents.
Trade-off: Writing reference answers takes time from people who know the domain, so the set grows slowly.An LLM as the judge
RAGAS uses an LLM to decide whether each retrieved passage is relevant and whether each fact in the reference answer is covered, which scales far beyond manual review.
Trade-off: The judge can be wrong, so its verdicts need spot checks against human judgement, and every run costs tokens.An append-only run history
Every run is appended to a history file, so scores can be compared over time and a change can be checked against the previous baseline.
Trade-off: A score without the configuration behind it is hard to explain later. Each run now needs to record what was switched on, such as the reranker.