feat: add retrieval-quality + version A/B evaluation harness (#98)#110
Merged
Merged
Conversation
3faf2cf to
a3422b5
Compare
…ormat#98) Adds an evaluation harness that measures retrieval quality against a labeled query set and compares quality across dataset versions — the cross-version regression eval a stateless vector DB can't do. Core (`lance-context-core::eval`): - Eval dataset format: `EvalQuerySet` / `EvalQuery` / `RelevanceLabel`, referencing records by stable `external_id` with optional graded relevance, loadable from / serializable to JSONL. - Metrics: recall@k, precision@k, MRR, nDCG@k (linear gain), and hit-rate, as pure functions tested against hand-computed fixtures. - Runner: `ContextStore::evaluate(query_set, config)` scores a set at the current version for vector (`search`) or hybrid (`retrieve`) mode, with configurable `k`, filters, and lifecycle options; returns per-query and aggregate scores plus a manifest (query-set id, version, k, mode, distance metric) for reproducibility. - Version A/B: `ContextStore::evaluate_versions(..., baseline, candidate)` checks out each version, evaluates, restores the original version, and reports per-metric deltas. `MetricScores::delta` supports config A/B (two `evaluate` runs) as well. Python: - `Context.evaluate(queries, ...)` and `Context.evaluate_versions(queries, baseline, candidate, ...)` returning report dicts (query sets and reports are marshaled as JSON across the pyo3 boundary, reusing the serde types). Tests: - core: metric correctness (perfect / rank-2 / none / graded / precision), JSONL round-trip, vector + hybrid runners, filter and lifecycle handling, and the version-A/B mechanism (zero-delta + version restore). - python: `test_eval.py` covering vector mode, graded nDCG, config A/B, version A/B, and invalid-mode handling. README gains an eval + version-A/B example. Note: cross-version A/B with *differing data* isn't unit-tested because MemWAL-backed writes don't reliably advance the base-table manifest version (the same limitation `test_time_travel_checkout` xfails on); the A/B mechanism and metric deltas are covered via the same-version and config-A/B tests. Closes lance-format#98
a3422b5 to
9884c56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a retrieval-quality evaluation harness that measures
search/retrievequality against a labeled query set and compares quality across dataset versions — closing #98. Cross-version regression eval is the differentiator a stateless vector DB can't offer.This PR is independent of #108 (#100) and #109 (#102) — it branches from
mainand can be reviewed/merged on its own.Core (
lance-context-core::eval)EvalQuerySet/EvalQuery/RelevanceLabel, referencing records by stableexternal_idwith optional graded relevance, loadable from / serializable to JSONL.ContextStore::evaluate(query_set, config)scores a set at the current version for vector (search) or hybrid (retrieve) mode, with configurablek, filters, and lifecycle options. Returns per-query + aggregate scores and a manifest (query-set id, version, k, mode, distance metric).ContextStore::evaluate_versions(..., baseline, candidate)checks out each version, evaluates, restores the original version, and reports per-metric deltas.MetricScores::deltaalso enables config A/B (twoevaluateruns).Python
Context.evaluate(queries, *, k, mode, filters, include_expired, include_retired)→ report dict.Context.evaluate_versions(queries, baseline_version, candidate_version, ...)→{baseline, candidate, deltas}.Query sets and reports are marshaled as JSON across the pyo3 boundary, reusing the serde-derived core types.
Tests
test_eval.py— vector mode, graded nDCG, config A/B delta, version A/B, invalid-mode error.README gains an eval + version-A/B example.
Checks
cargo test -p lance-context-core --lib— 59 passedcargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warnings— cleanruff format --check,ruff check,pyright— cleantest_eval.py— 5 passedAcceptance criteria (#98)
Notes
test_time_travel_checkoutxfails on). The A/B mechanism (checkout both versions, restore, per-metric deltas) and metric-difference detection are covered via the same-version and config-A/B tests.grade / log2(rank+1)); documented onMetricScores.Closes #98