v0.19.2: Fix TrainedVerifier input format#63
Merged
Conversation
NadirClaw's TrainedVerifier was passing the cheap answer as the bare
text_pair to the tokenizer. The model was trained on a structured format
with CHEAP:/EXPENSIVE: markers, matching what the Pro production backend
uses. Without that wrapper, scores are miscalibrated against the
production tau=0.80 threshold.
This patch wraps the input in the production format:
text_pair = f"CHEAP:\n{cheap}\n\nEXPENSIVE:\n{reference or ''}"
reference_answer is now used when provided (was previously documented as
ignored). Behavior with reference_answer=None matches production: empty
string substitution.
Aligns NadirClaw with:
- https://huggingface.co/nadirclaw/cascade-verifier-v1 (model card)
- getnadir.dev/backend/app/services/verifier_model.py (production)
Repo: https://github.com/NadirRouter/NadirClaw
Service: https://getnadir.com
216225c to
bc46c72
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
NadirClaw's
TrainedVerifier.score()was tokenizing with the bare cheap answer astext_pair. The released cross-encoder (nadirclaw/cascade-verifier-v1) was trained on a structured format:This matches the Pro production backend at
getnadir.dev/backend/app/services/verifier_model.py:195and the HF model card.Without the wrapper, the verifier's scores drift against the calibrated
tau=0.80acceptance threshold, which produced the RouterArena PR #112 numbers.Changes
nadirclaw/trained_verifier.py— wrap tokenizer input inCHEAP:/EXPENSIVE:format; foldreference_answerinto theEXPENSIVE:block (empty whenNone); update docstring (no longer "ignored").tests/test_trained_verifier.py— addtest_trained_verifier_wraps_input_in_production_formatcovering reference provided,None, and whitespace-only cases via a mock tokenizer.nadirclaw/__init__.py— bump__version__to0.19.2.Calibration impact
text_pair = cheap_answer(bare) — drifted scores vs tau=0.80text_pair = f"CHEAP:\n{cheap}\n\nEXPENSIVE:\n{ref or ''}"— matches productionReferences
getnadir.dev/backend/app/services/verifier_model.py:195Test plan
pytest tests/test_trained_verifier.py -v(9 passed, 1 slow-gated skip)pytest tests/ -v(773 passed, 1 skipped)text_pairwrapping for three cases (with ref,None, whitespace)