Evaluation and Doctor
Last verified against: commit 6f2f20b (v1.0)
Estimated Read Time: 7 min
Status: built
Locus provides an evaluation suite and an automated diagnostic engine (Doctor) to measure and improve retrieval quality across prompt, chunking, and ranking variants.
1. Retrieval Metrics & Statistics
Evaluations quantify retrieval and generation performance against labeled golden test sets:
| Metric | Interpretation | Target Direction |
|---|---|---|
recall@k | Fraction of ground-truth chunks retrieved in top-k results | Higher is better |
precision@k | Fraction of retrieved top-k chunks that are relevant | Higher is better |
context_precision_tokens@k | Signal-to-noise ratio of tokens injected into LLM prompt | Higher is better |
ndcg@k | Normalized Discounted Cumulative Gain accounting for rank positions | Higher is better |
mrr | Mean Reciprocal Rank of first relevant document | Higher is better |
hit@5 | Probability that at least one relevant chunk appears in top 5 | Higher is better |
false_refusal | Rate at which the assistant refuses an answerable question | Lower is better |
unsafe_answer | Rate at which the assistant answers an unanswerable question | Lower is better |
95% Paired Bootstrap Confidence Intervals
When comparing baseline and candidate variants, Locus computes paired bootstrap confidence intervals (1,000 resamples) and permutation p-values. A variant difference is designated meaningful only when zero falls outside the 95% confidence interval ($\alpha = 0.05$).
2. Doctor Rules (D1 – D9)
The Doctor diagnostics engine runs 9 automated rules across evaluation runs:
- D1: Route Slice Weakness
Detects if specific semantic query categories underperform compared to the overall run average. - D2: Depth Gap
Evaluates whether increasing candidate depth (candidates_n) from 5 to 20 captures relevant chunks missed at top 5. - D3: Broad Chunks
Detects chunks with excessive token counts that dilute prompt context precision. - D4: False Refusals
Identifies instances where sufficient evidence exists in retrieved context, but the assistant refused to answer. - D5: Unsafe Answers
Detects hallucinations where the assistant answered an unanswerable question without supporting citations. - D6: Citation Problems
Flags citations pointing to missing chunks or invalid document offsets. - D7: Temporal Stale Citations
Detects conflicts between multiple conflicting document versions where an older version was cited. - D8: Router Errors
Flags routing mismatches where structured queries fell back unnecessarily to semantic retrieval. - D9: Rerank No Gain
Identifies scenarios where cross-encoder reranking produced no statistically significant gain over hybrid search alone.
3. Evidence Levels
Every finding emitted by Doctor is classified into one of four evidence tiers:
observed: Direct measurement from current run results (e.g. observed false refusal count).counterfactual: What-if simulation evaluating alternative parameter thresholds on historical traces.measured_effect: Statistical comparison with paired bootstrap confidence intervals between two runs.hypothesis: Algorithmic suggestion requiring an experimental run to confirm.
When a recommended configuration change is deployed and an evaluation subsequently confirms improvement, the finding transitions to status verified_improved.
4. Running an Evaluation via API
To trigger an evaluation run programmatically:
# Run in terminal curl -X POST http://127.0.0.1:8000/evaluation/runs \ -H "Content-Type: application/json" \ -H "Authorization: Bearer locus_session_REPLACE_ME" \ -d '{ "dataset_id": 1, "variant": { "strategy": "hybrid_rerank", "top_k": 5, "min_score": 0.35 } }'