Repository navigation
fix(eval): evaluate, benchmark and answers generate retrieve docs through DocTreatment - #997
Conversation
Answerer._retrieve_docs had its own copy of the arms stack's retrieval. It now builds a DocTreatment with the Answerer's top_k, reranker and keep of 3, and passes its retrieval budget as the new optional DocTreatment retrieval_tokens (sent as max_tokens). The arms commands leave it unset, so their request is unchanged; the pipeline's request is unchanged too (max_results=top_k, max_tokens=4000). One case changes numbers: when the reranker raises, the context arm now answers from the first 3 raw docs, as arms runs do, instead of the no-docs placeholder (intel#228 D3). ANSWERING_METHOD_VERSION becomes 3. The --debug-retrieval metadata keeps raw_count, after_rerank, top_score and fallback_triggered; avg_score is gone (no reader), and arm_kind, library_id and error come from DocTreatment. The parity test's D1 and D3 rows become shared; the arms default of no retrieval budget stays visible as an "only" row. Refs intel#228 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…t have --max-tokens evaluate has no --max-tokens flag; the pipeline always sends 4000. Refs intel#228 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
The q-rerank judge-context row is D5 now, and the D9 delta moved with D3 in step 3. Refs intel#228 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…efault Answerer.__init__ had its own copy of the semantic-else-lexical choice. It now calls DocTreatment._default_reranker, so a change to the arms stack's reranker reaches the pipeline too. The DocTreatment itself stays per call: its retrieval_tokens comes with each generate_answers call, and the questions run on several threads. Refs intel#228 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 10 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #997 +/- ##
==========================================
- Coverage 95.92% 95.92% -0.01%
==========================================
Files 449 449
Lines 59444 59425 -19
Branches 10246 10244 -2
==========================================
- Hits 57020 57001 -19
+ Misses 1506 1503 -3
- Partials 918 921 +3
🚀 New features to boost your workflow:
|
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
vchamarthi
left a comment
There was a problem hiding this comment.
🔴 Changes needed: 1 must-fix · reviewed 94582e7
Next: @vlad-perevezentsev: fix the 1 must-fix finding; then push for a re-review.
Follow-ups, not blocking (1)
dokimi/dokimi/commands/answers.py:168–answers generate --max-tokenstakes any int (type=int, no positive check), so-5reaches the doc source asmax_tokens= -5 on main:_retrieve_docswith a budget of -5 sendsmax_tokens-5 (main has it too).
Verified on 94582e7: ✅ changed tests: 61 passed, fail on main · ✅ full suite with main merged in: 23943 passed · ✅ merges onto main · ✅ 3 broken variants of the changed code: 3 caught by the tests · 2 mutations tried · 3 edge inputs tried
8 checks behind it, each with its evidence
| Area | What holds | How |
|---|---|---|
| Retrieval request | The Answerer and DocTreatment send identical get_library_docs arguments and keep the same docs for one config: the changed tests pass on the head (61 passed) |
tests on the head |
| Main failures | The changed tests fail on main (8 failed), including the shared-request, rerank-failure and retrieval-failure tests | same tests on main |
| Full ci | The full make ci-local run passes with main merged in |
full suite, main merged in |
| Merge | The PR merges onto main with no conflict | merge onto main |
| Numbers | Answerer(top_k=0) sends max_results 0 with no error, and with no docs returns none with raw_count 0 |
ran it, edge input (numbers) |
| None budget | DocTreatment(retrieval_tokens=None) sends no max_tokens, so the client default applies, and keeps the doc that passes the rerank |
ran it, edge input (none) |
| Budget mutation | Sending max_tokens when no budget is set fails test_doc_treatment_without_a_budget_leaves_the_client_default, so the None branch is pinned |
broke the code, tests caught it, edge input (none) |
| Fallback flag | Negating the fallback_triggered check fails the changed tests (3 failed), so the flag is pinned |
broke the code, tests caught it |
antonwolfy
left a comment
There was a problem hiding this comment.
LGTM. The Answerer now retrieves through DocTreatment with the same request and the same kept docs as the arms stack, and the one behaviour change (D3, raw docs kept when the reranker raises) is stamped as method_version 3 and named in the changelog fragment. No findings of my own.
I agree with @vchamarthi that top_score is 0 instead of None when the reranker raises. New evidence: an Answerer with two raw docs that carry no relevance_score and a reranker that raises returns top_score: 0, after_rerank: 2, error: rerank_failed. It only affects the --debug-retrieval metadata, so I do not count it as blocking.
What I ran, on a Linux review host at 94582e7:
make ci-local: 36 passed, 0 failed, 14 skipped (docker and network steps). 23,888 tests passed, 19 skipped. Changed-line coverage 100% (14 lines). Mutation of changed lines: 12 of 12 killed.- The parity and retrieval test files (11 tests) and the 214 tests that match answerer, answering or retrieval, all pass.
- A reproduction of the rerank-failure case with the doc source and reranker mocked.
Checked, no issues
- Request:
DocTreatment.preparesendsmax_tokensonly whenretrieval_tokensis set, so the arms commands send what they sent before and the Answerer sendsmax_results=top_kplus its budget. - Versioning:
ANSWERING_METHOD_VERSIONis 3, and the unstamped (v1) and v2 handling is unchanged. The commits are all signed off. - Changelog: the
Changedfragment names the commands and the runs that are not comparable.
Dismissed: a Must fix comment from @vchamarthi (discussion_r4638717522) is still open, so this PR should not read as approved.
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…cs carry no score The rerank-failure path read a raw doc's missing relevance_score as 0, so the --debug-retrieval metadata said top_score 0 where main said None (and the arms docs arm said 0 too). Only scores that exist count now. Refs intel#228 Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
@vchamarthi Thanks. On the follow-up: |
@antonwolfy Thanks for the check and the reproduction. The top_score point is fixed in d9a54b3 (see the inline thread). |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head d9a54b3)
- Contract: changed (count signal only, no file:line)
- Responsibility: none
- Dependency: candidate (count signal only, no file:line)
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
I found no additional blocker in the changed behavior. Checked the shared retrieval request, reranking failure and empty results. Focused tests on d9a54b372: 10 passed.
The method-version bump covers raw-document fallback when reranking raises. The debug metadata now leaves an unscored top result null and drops avg_score, as the PR description specifies.
Summary
#228 step 3: Stack P (
Answerer, used byevaluate,benchmark runandanswers generate) now retrieves docs throughtreatments/arms.pyDocTreatment, the path Stack A (ArmRunner) uses.Answerer._retrieve_docswas its own copy of that path. Refs #228._retrieve_docsbuilds aDocTreatmentwith the Answerer'stop_k, its reranker andkeep=3, and returns the arm's injected docs. The reranker comes fromDocTreatment._default_reranker(semantic, else lexical), soAnswerer.__init__no longer has its own copy of that choice.max_results=top_k, plusmax_tokenswhen the caller has a retrieval budget.DocTreatmentgets an optionalretrieval_tokens:budgetis{"max_tokens": retrieval_tokens}, or empty when it isNone. The arms commands leave it unset, so their request does not change and the client default (8000) applies. The Answerer passes its retrieval budget (--max-tokensinanswers generateandbenchmark run, default 4000;evaluatealways sends 4000). So one config gives one request on both stacks. The default gap (P 4000, A 8000) remains, because the arms commands have no retrieval-budget flag. That is Answering stack: one implementation for evaluate/benchmark/answers and arms/subjects #228 D7, which step 5 / feat(cli): split --max-tokens and --budgets by meaning (F1b tokens) #954 moves.max_resultscame with step 2, fix(answers,pipeline,judge,gate): Stack P fixes, step 2 of #228 #274;max_tokensstays 4000). So the Context7 cache key does not change, and the "first runs slower" risk in Answering stack: one implementation for evaluate/benchmark/answers and arms/subjects #228 does not apply to this step.DocTreatmentdoes, instead of recording the[FALLBACK: No relevant documentation found]placeholder. Keeping P's old behaviour would need a mode flag on the shared path, so D3 goes with D1.ANSWERING_METHOD_VERSIONbecomes 3, and theChangedfragment names the runs that are not comparable. Unstamped (v1) and v2 answers files still read and keep their version.--debug-retrievalmetadata.raw_count,after_rerank,top_scoreandfallback_triggeredstay.avg_scoreis gone: nothing in the repo reads it. The metadata now also hasarm_kind,library_idand, when a step failed,error(retrieval_failed,rerank_failed).tests/test_answering_stack_parity.py):shared: A's docs arm runs with P's budget of 4000 and sends("max_results", "max_tokens"), 3, 4000, the same as P.retrieval.max_tokens.unset_on_a(4000 vs 8000), pins the default gap.shared. The q-rerank judge context row is D5; the D2 judge calls (11/12) and the D9 pairs/deltas follow.RESOLVEDlists D1 and D3. The table check requires a row for every other difference and none for a resolved one.Changed output
answers.v1/eval.v1:method_version3 (was 2). With--debug-retrieval,retrieval_metadatabefore → after:A question whose reranker raised now has a model answer in
with_docsinstead of the placeholder, and it gets judged.arms.v1does not change.Evidence
tests/test_answerer_retrieval.py(new) on main's code: 6 of 9 fail. On main, the test of the shared request and kept docs (two configs), the test of a rerank failure, the test of a retrieval failure and the test of the shared reranker choice fail, and so does the test of A's request with no budget, becauseDocTreatmenttakes noretrieval_tokens. The parity test fails on its D1/D3 rows. On the branch, all pass. The file checks that the Answerer andDocTreatmentsend identicalget_library_docsarguments and keep the same docs for one config, and that both keep the raw docs when the reranker raises. It also checks the debug metadata flags (fallback_triggeredwith six docs and with one, but not with an empty source) and that the reranker choice is shared.Mutations, each failing a new test and then reverted:
DocTreatment, or from the Answererkeep=5raw_count > 0→>= 0, and> 1[]SimpleRerankerCI's mutation step: 12 of 12 mutants killed.
make ci-local --offline: 0 failed, 25 passed, 20 skipped (network-only steps). Full suite: 23719 passed, 79 skipped.python scripts/check_growth.py: clean.Not run: a live
answers generate/evaluateagainst a real model and doc source.Not in this PR
verbatim(feat(questions): run Inspect, OpenAI evals, skill-creator and promptfoo sets on the answers track #214) is still Stack P only (answerer.pyprompt templates). Step 4 must carry it to Stack A, as one style of the shared prompt builder.--max-tokensbecomes--retrieval-tokens(a merge of main and its parity-test edit).get_library_docscallers keep their own request:questions/ragas_seed.py(question seeding) andtreatments/tools.py(the agentic arm's tool). Neither is an answering path.Checklist
pytestpasses:tests/test_answerer_retrieval.pynew; the parity, step-2 and method-version tests updated; 23719 passedruff,mypy, and schema checks pass:make ci-local --offlinestatic and typecheck rows pass,schema_compatpassesdocs/methodology.md:161(debug metadata: counts, scores, fallback) still holds;knowledge-runs.mdandevaluating-treatments.mdsay nothing about the retrieval requestAGENTS.md: mutations above, other call sites listed aboveraise/exit and test names the doc, contract or issue it traces to: no newraise; the tests cite Answering stack: one implementation for evaluate/benchmark/answers and arms/subjects #228 step 3 and D3