feat(savings): support NER/extraction traffic in rulechef-savings#28
Open
AZERDSQ131 wants to merge 1 commit into
Open
feat(savings): support NER/extraction traffic in rulechef-savings#28AZERDSQ131 wants to merge 1 commit into
AZERDSQ131 wants to merge 1 commit into
Conversation
rulechef-savings only understood classification traffic (comparing a
rule's label to llm_label). A traffic row with {text, llm_entities}
was silently treated as unanswered, even though that's exactly the
TAB-style NER use case the tool targets.
Auto-detect NER traffic from the first row's llm_entities key. For
NER: 'answered' means the rules produced a non-empty entity list,
and 'agreement' is corpus-level micro-F1 against llm_entities (reusing
_match_entities from rulechef.evaluation, mode='text') instead of
exact string comparison. Per-rule 'agreement' is that rule's
precision (share of its produced entities that matched gold) --
recall isn't attributable per-rule since unmatched gold entities have
no producing rule.
Closes KRLabsOrg#19
Contributor
|
Reviewed — the NER path looks right: micro-F1 vs llm_entities as the fidelity number is the honest way to score span traffic, and the FP test with hand-computed 67% is exactly the kind of test I want here. Two notes, neither blocking: (1) first-row auto-detection is fine but worth a warning if later rows have the other shape; (2) gold_label support for NER traffic can be a follow-up. Now that #21 is merged, chef.export_traffic() produces NER traffic natively, so this closes the loop end-to-end. Blocking item is just the rights checkbox in the PR body (the failing required check) — tick it and this merges. |
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.
Problem
rulechef-savingsonly understood classification traffic — it compares a rule'slabelstring to the observedllm_label. A traffic row shaped{"text": ..., "llm_entities": [...]}was silently treated as unanswered, even though that's exactly the TAB-style NER use case the tool targets.Fix
llm_entitieskey.llm_entities, computed by reusing_match_entitiesfromrulechef.evaluation(mode"text": type + text match, position-agnostic) instead of exact string comparison, per the issue's suggestion.llm_label) is unchanged.Tests
test_savings_cli_ner_trafficintests/test_reports.py, next to the existingtest_savings_cli: a 2-row NER traffic file (one true positive, one false positive) asserting 100% coverage and 67% fidelity (micro-F1: TP=1, FP=1, FN=0 → P=.5, R=1, F1=.667).pytest tests/ -q→ 312 passed, 1 skipped.ruff checkandmypy rulechef/savings.pyclean.Closes #19