Skip to main content

RAG evaluation

You cannot tune what you cannot measure. RAG evaluation scores the answers your crate gives along three axes, in the background, with a separate judge model, and shows the numbers on a Grafana panel and on an Evaluation page in the crate (visible to crate owners only). It is built for tuning: change the chunk size, switch on HyDE or contextual headers, and see what happens to the scores.

AxisQuestion it answersComparesScores
Context relevanceDid retrieval find the right chunks, and in a good order?question ↔ retrieved chunksPrecision@K, Recall@K, MRR, MAP, NDCG
FaithfulnessIs the answer grounded in what was retrieved?retrieved chunks ↔ answerFaithfulness
Answer relevanceDoes the answer address the question, and completely?question ↔ answerAnswer relevance, Completeness

Evaluation is off by default, is switched on per crate by the crate owner, and never changes or delays an answer.

How it runs​

  1. When an answer has been generated (chat, POST …/answers, the OpenAI-compatible endpoint and the MCP tool ask_crate all count), the answer service hands it over and returns immediately. The hand-over uses a small bounded queue of its own. If it is full, the answer is not evaluated and a counter goes up; the answer itself is never affected.
  2. If evaluation is enabled for the crate, a judge model is configured and the answer is selected by the sampling rate, a case is stored and a message for the pipeline stage EVALUATE is queued.
  3. A worker (role all or indexer) evaluates the dimensions one after another, each with its own judge calls, and stores the scores.
  4. Without per-question logging the text is removed right away and only the numbers remain.

The judge model​

The judge is configured per crate and separately from the answer model, by the crate owner, just like the answer model: either a shared model of type “Judge for RAG evaluation” (created by an administrator under Administration → Models, optionally as the default for new crates) or an own OpenAI-compatible endpoint with model and API key. A stronger model than the answer model usually gives more reliable scores; the judge is used wherever a number cannot be computed from the data itself (relevance of a chunk, support of a statement, coverage of a sub-question).

Every prompt follows the same protocol, which keeps the scores comparable:

  • One dimension per call. Relevance, support, similarity and coverage are never asked together.
  • Reasoning first, then the score. The judge must explain in one to three sentences, then give the score: {"reasoning": "…", "score": 2}.
  • Coarse scales. 0 to 3 for relevance, 0 to 2 for coverage and 0 or 1 for yes/no questions, never a 1 to 100 scale. Coarse scales are far more consistent between runs.
  • Untrusted data. Question, chunks and answers are passed as data, never as instructions.
  • Temperature 0. A reply that is not usable is asked for once more; after that the dimension is recorded as failed and the other dimensions are not affected.

Context relevance​

The judge grades every retrieved chunk for the question: 0 irrelevant, 1 marginal, 2 relevant, 3 highly relevant. Grades of 2 and 3 count as relevant. The grades are turned into ranking metrics for the top K chunks (K is a setting, default 5, and at most the number of chunks delivered).

MetricDefinitionReads as
Precision@Krelevant chunks in the top K ÷ KHow much of what the model sees is useful
Recall@Krelevant chunks in the top K ÷ all relevant chunks that existHow much of the useful material was found
MRR1 ÷ rank of the first relevant chunk (average over questions)How early the first good chunk appears
MAPaverage of the precision at each relevant rank ÷ all relevant chunks (average over questions)Quality of the whole ordering
NDCG@Kdiscounted gain with gain 2^grade − 1, divided by the best possible orderingWhether the best chunks are on top, using the 0 to 3 grades

How many relevant chunks exist is the part that cannot be known for free. Two sources are used:

  • With a context window the delivered text of a source is the whole window, so the judge grades what the model actually read; the candidate pool still consists of single chunks.
  • Live answers use the candidate pool: the same search is run for the question and its top results (default 20, setting Candidate pool) are judged once. Recall is then relative to the relevant chunks inside this pool. It is an estimate that tells you whether better chunks were available but not delivered, not an absolute recall.
  • Golden-set questions use the documents you declared as expected. Recall@K is then the share of expected documents found in the top K, a true recall.

A value that is mathematically undefined (for example recall when the pool holds no relevant chunk) is left out, not counted as 0 or 1.

Worked example. Top 5 grades [3, 0, 2, 1, 2], so 3 relevant chunks; the pool holds 4 relevant chunks in total. Precision@5 = 3/5 = 0.60. Recall@5 = 3/4 = 0.75. The first relevant chunk is at rank 1, so the reciprocal rank is 1. Average precision = (1/1 + 2/3 + 3/5) ÷ 4 = 0.57.

Faithfulness​

Faithfulness checks whether the answer says only what the retrieved chunks say.

  1. The judge splits the answer into atomic statements: one fact each, pronouns resolved, hedges and citation markers removed (at most 20 statements).
  2. For each statement a separate call asks whether it is supported by the chunks that were delivered to the answer model (1) or not (0). The judge may not use its own knowledge.
  3. Faithfulness = supported statements ÷ all statements.

A low score means the model said things the sources do not back up: tighten the system prompt, enable answer verification or strict grounding, or check whether grading removed the chunk that held the fact. An answer without statements is not scored.

Answer relevance and completeness​

Answer relevance. The judge writes three questions the answer clearly answers. Their similarity to the original question is the score: an answer that fits the question produces questions that look like it. Similarity is the cosine similarity of the crate's embedding model (clamped to 0–1) and averaged. If embeddings are not available, the judge rates each pair on a 0–3 scale instead (divided by 3). Off-topic or rambling answers score low.

Completeness. The judge breaks the question into up to six sub-questions and classifies them:

ImportanceMeaningWeight
CoreThe essential aspects the person asked for1.0
BackgroundSupporting context needed to understand the answer0.5
Follow-upExtensions a thorough answer would anticipate0.25

For each sub-question a separate call judges whether the answer addresses it: 0 not, 1 partly, 2 clearly. Completeness = Σ weight × (score ÷ 2) ÷ Σ weight. Missing core aspects hurt most; missing follow-ups hurt little.

Reference recall (golden set only). When a golden question has a reference answer, the reference is split into statements and the judge checks for each whether the generated answer contains it. The share found is the recall-like reference recall.

Ignoring questions​

Monitoring tools often send fixed questions, for example a LiteLLM health check asking "what is 1+1". Such messages would skew the averages, fill the list and show up as topics, so the owner can ignore them. Rules are per crate and are managed under Ignore rules on the evaluation page (or with GET/POST /api/v1/crates/{crateId}/evaluation/ignore-rules and DELETE .../ignore-rules/{id}).

RuleMatchesChecked
QuestionThe question text, ignoring case, extra spaces and a trailing ? . !. Optionally also when the question contains the text.Before anything else: the message is only counted, never sampled, queued or sent to the judge. Ignored questions cost nothing.
TopicThe stored topic, with the same normalization and the same optional "contains".Once the topic is known, so the message was already evaluated; it is then hidden.
TagA tag, exactly.Like topic rules.

You do not have to type rules: press Ignore next to a question, a topic or a tag in the list of latest answers, or next to a topic in the report (this ignores the topic and all the other wordings listed under it). A new rule also hides the messages it matches that already exist; removing a rule brings them back.

What ignoring does:

  • The list of latest answers hides ignored messages by default; Show ignored lists them, marked.
  • Ignored messages are left out of every figure: the averages, the daily trend, the topics and tags, the unanswered questions and the Prometheus evaluation metrics (for topic and tag rules the metrics were already recorded).
  • They are counted per rule. The report has a Show ignored summary button; it adds a section with each rule and how many messages it caught in the timeframe, and nothing more (no topics, scores or text).

A question rule stores the text you typed or clicked. Rule changes are written to the audit log without that text. Matching is by wording, not by meaning: a topic rule for "Simple arithmetic" does not catch "Basic maths questions". For health checks a question rule is the right choice, because it is applied before the judge is called.

The golden set​

The golden set is a list of questions you know the right answer to. It turns the judge-based estimates into measurements against ground truth, and it gives you a repeatable benchmark: run it before and after a change and compare. Each entry has:

  • a question (required),
  • expected documents: text that must appear in the source address of a relevant chunk, for example docs/oncall.md; one or more per question,
  • a reference answer (optional).

An entry needs expected documents, a reference answer, or both. Up to 200 questions per crate. Add them on the evaluation page or import a JSON array:

[
{
"question": "How do I escalate an incident?",
"relevantUris": ["docs/oncall.md", "docs/escalation.md"],
"referenceAnswer": "Page the secondary on-call if the primary does not acknowledge within five minutes."
}
]

Run golden set now queues one case per question. The worker asks each question through the normal answer path (these internal answers are not evaluated a second time) and scores it with the golden ground truth. The results appear as a separate Golden set line, apart from live traffic.

Privacy​

ContextCrate otherwise does not keep questions or answers. Evaluation needs them for a short time, so it is designed to hold them as briefly as possible:

  • The pipeline message contains only the id of the case, never text. Completed messages stay in the pipeline table, so this matters.
  • The case row holds the question, the delivered chunks and the answer only until it is evaluated. Then the text is removed and only the numeric scores remain.
  • Cases that are never evaluated are deleted after one hour.
  • With Log every question the text, the judge's reasoning and the statements are kept for each case until the retention period ends (default 30 days, then the whole case is deleted).
  • With Store request topic and/or Store tags the judge additionally rewrites each live question into a short neutral topic (names and addresses are to be left out, but this depends on the judge model) and assigns up to 5 tags. These are kept independently of Log every question, until the retention period ends, so the report can show what users ask about without raw questions. If even a rewritten topic is too sensitive for a crate, leave both options off.
  • With Track unanswered questions the judge also receives the question and the answer once more (to classify them), and for every question that was not or only partly answered a neutral topic and tags are stored, even when "Store request topic" and "Store tags" are off. The raw question is still removed unless "Log every question" is on.
  • Building the report sends the stored topic wordings to the crate's embedding model, or to the judge model if there are none. The summary sends aggregated scores, topics and tags to the judge model.
  • The judge model receives the question, the retrieved chunks and the answer. Use a provider you trust with the content of the crate, with TLS.
  • The settings, the scores and the logged text are visible to the crate owners only (and to an administrator with an active elevation). Editors, viewers and crate API keys cannot see or change anything.
  • Evaluation data is not part of crate exports. Settings changes and golden-set runs are written to the audit log (never with keys or question text).

Cost and performance​

  • Nothing runs on the answer path. The only work there is a hand-over that returns immediately.
  • The judge calls per evaluated answer are roughly: K (chunk grades) + the pool size − K extra chunks + 1 + statements (faithfulness) + 1 + 3 (answer relevance, +3 without embeddings) + 1 + sub-questions (completeness). With the defaults that is on the order of 40 to 60 short calls. Reduce the cost with a lower sampling rate, a smaller candidate pool (set it equal to K to skip the pool), or by switching dimensions off.
  • Start with a sampling rate of 0.1 to 0.25 on busy crates. A few hundred evaluated answers give stable averages.
  • Evaluation shares the workers with ingestion but runs at the lowest priority. In a distributed installation it runs on the indexer role.

Settings​

All of these are on the crate's Evaluation page (sidebar, below Operations, owners only; /crates/{id}/evaluation) or in the REST API.

SettingDefaultMeaning
EnabledoffEvaluate answers of this crate
Sampling rate1.0Share of answers that are evaluated (0.01 to 1)
K5Chunks judged for the ranking metrics (1 to 20)
Candidate pool20Results judged to find all relevant chunks, not below K (up to 100)
Dimensionsall onContext relevance, faithfulness, answer relevance, completeness
Log every questionoffKeep text and judge reasoning per case
Keep cases30 daysRetention of cases (1 to 365)
Track unanswered questionsoffClassify every question as answered, partly or not answered; keep a topic for the ones that were not
Store request topicoffThe judge rewrites each live question into a neutral topic; only the rewrite is kept
Store tagsoffThe judge assigns up to 5 category tags (for example development, python)
Judge model–Shared judge model or own endpoint, model and key; nothing is evaluated without one

The evaluation page​

The page shows the averages for the last day, week, month or quarter, a daily trend, the golden-set results, and the latest evaluated answers with their scores. With per-question logging on, every row expands to the answer, the delivered sources and the judge's reasoning, so you can read why a score is low. With topics and tags switched on, the topic and tags are shown for every answer, also without per-question logging.

The report​

Open report leads to a page for a chosen timeframe (last 7, 30 or 90 days, or a custom date range, in UTC). It shows the summary metrics, a daily faithfulness chart, the most requested topics and most used tags (with how often they were asked and their average scores), the questions asked and an explanation of every metric. Topics that mean the same are counted together even when worded differently ("Deploy with Docker" and "Docker deployment steps"). This happens when the report is built, using the crate's embedding model (topics with a cosine similarity of at least 0.80 are merged) or, without embeddings, the judge model, and finally the exact text (ignoring case and trailing punctuation). The report says which method was used and lists the other wordings under each topic. Tags are merged only when spelled the same.

Questions the knowledge base could not answer​

With Track unanswered questions on, the report has its own section for the gaps in the knowledge base. Every live question is classified:

  • Not answered, nothing found - retrieval returned no passage at all. This includes questions that strict grounding refused to answer ("No answer was found in the knowledge base."), which are always recorded, even with a low sampling rate, and cost no scoring calls.
  • Not answered, not in the documents - passages were found, but the answer says the information is missing or only talks about something else.
  • Partly answered - some parts of the question were covered, others were not.

The section shows the counts and the share of assessed questions, the topics without a good answer (merged by meaning like the other topics, with how often they were asked, why they failed, their tags and when they were last asked), and the latest unanswered questions (the neutral topic, and the raw question while it is still stored). The list shows the ten most asked topics without a good answer. Analyze gaps asks the judge model for an analysis: which themes are missing, likely causes, and what to write or add next. It receives only the clustered topics with counts and reasons, no questions or answers, and is cached for an hour like the summary. The printable view includes it when it was generated (&gaps=true on the JSON endpoint). The classification is a judgement of the judge model, not proof that the documents lack the content: check the listed topics before writing new documentation.

Generate summary asks the judge model to read the figures of the report and write what people searched for, which topics were answered well, which were not, what the retrieval metrics say, what the unanswered questions reveal and what to improve (up to ten points per list). The judge receives only aggregated numbers (including retrieval metrics, trend and gap counts), the topic wordings and the tags - no questions or answers. The summary is kept for an hour per timeframe, so reloading or opening the printable view does not ask again; the printable view includes it when it was generated. Check it against the tables; topics with fewer than three answers are marked as too few to judge. The report covers at most 5000 answers; for longer timeframes it says so.

Printable view opens the same report without navigation, in black on white. Use the browser's print dialog and choose Save as PDF. The normal page prints cleanly as well. The same data is available as JSON at GET /api/v1/crates/{crateId}/evaluation/report?days=30 (add &summary=true for the summary).

Metrics and Grafana​

MetricMeaning
contextcrate_evaluation_context_precision_at_k, …_recall_at_k, …_mrr, …_map, …_ndcgContext relevance per evaluated answer (average = sum ÷ count)
contextcrate_evaluation_faithfulness, …_answer_relevance, …_completeness, …_reference_recallThe other scores
contextcrate_evaluation_cases_total{outcome,source}done, failed, skipped (not sampled) or dropped (hand-over full or error); source live or golden
contextcrate_evaluation_duration_secondsTime to evaluate one answer
contextcrate_evaluation_judge_failures_total{dimension}Dimensions whose judge reply could not be used
contextcrate_llm_requests_total / llm_duration_seconds with purpose="judge"The judge calls

The Grafana dashboard has a RAG evaluation section with the averages, the trends, outcomes, the duration of an evaluation and the judge's latency. Scores are summaries without per-question labels, so they carry no question text.

Tuning with the scores​

Low scoreLikely causeWhat to try
Precision@KNoise in the resultsGrading, reranking, a smaller maximum sources, contextual headers
Recall@K, NDCGGood chunks exist but rank low or are not deliveredHyDE, query transformation, hybrid retrieval, a larger source limit, smaller chunks
MRRThe first useful chunk is far downReranking, contextual headers
FaithfulnessThe model adds facts the sources do not containAnswer verification, strict grounding, a stronger answer model
Answer relevanceThe answer wanders off the questionThe system prompt and history handling, query rewriting
CompletenessParts of the question are not answeredA larger source limit or context budget, sub-queries

Change one thing at a time, use the golden set for the comparison, and look at a few hundred answers before concluding anything.

Troubleshooting​

SymptomLikely causeWhat to do
Nothing is evaluatedEvaluation is off, no judge is configured, or the sampling rate is lowCheck the page for the “No judge model” notice and the settings
Many failed outcomesThe judge is down, too small, or does not return JSONCheck evaluation_judge_failures_total by dimension and use a more capable judge
dropped outcomesThe hand-over queue was full (a burst of answers)Lower the sampling rate
Cases stay waitingNo worker with role all or indexer is runningCheck the queue depth of the EVALUATE stage in Operations
Recall@K is missingNo relevant chunk was found in the poolIncrease the pool, or use a golden set
No text in the listPer-question logging is off, or the case is older than the retention periodSwitch on Log every question