Fix: evaluate_successor_liability returns ~0 on the HuggingFace answer format - #51
Conversation
`evaluate_successor_liability` parses the gold answer with
`str(answers[i]).split(",")`. That matches the canonical task TSVs
("de facto merger,mere continuation"), but the HuggingFace `nguha/legalbench`
mirror serializes the same field as a (sometimes double-quoted) Python list repr
("['de facto merger', 'mere continuation']"). Feeding the HF-loaded answers
straight into the scorer therefore yields ~0 F1 with no error, because the split
produces tokens like "['de facto merger'" that never match a CLASS.
Since the HF dataset is the primary distribution channel referenced in the
README, make the scorer robust to both serializations via a small
`_parse_answer_list` helper (bare comma-separated OR list-repr). Behavior on the
canonical TSV format is unchanged.
(Complements the dead-code fix that makes this F1 path reachable in the first
place; see the companion PR removing successor_liability from
EXACT_MATCH_BALANCED_ACC_TASKS.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reproduction (captured output)# repro.py — answer exactly as served by the HuggingFace `nguha/legalbench` mirror
from evaluation import evaluate_successor_liability
g = ["this is a de facto merger and a mere continuation"]
a = ["['de facto merger', 'mere continuation']"]
print("HF-format answer =", repr(a[0]))
print("F1 =", evaluate_successor_liability(g, a))BEFORE (upstream AFTER (this branch): (Run with the companion mis-routing fix so the F1 path is reached; the function itself is exercised directly here.) |
|
@neelguha Friendly ping — small follow-up in the same What it fixes: Scope: One commit — adds Relation to #50: Independent fix (answer parsing vs metric routing). Either order works; together they make HF + F1 evaluation behave as documented. Happy to fold into #50 or split differently if you’d rather one combined PR. Thanks for maintaining LegalBench! |
Problem
evaluate_successor_liabilityparses the gold answer withstr(answers[i]).split(","). That matches the canonical task TSVs (de facto merger,mere continuation), but the HuggingFacenguha/legalbenchmirror serializes the same field as a (sometimes double-quoted) Python list repr:Loading answers from HF and scoring with the official scorer yields ~0 F1 with no error, because the split produces tokens like
"['de facto merger'"that never match aCLASS.Since the README points users to the HF dataset as the primary distribution channel, the scorer should accept both serializations.
Fix
Add a small
_parse_answer_listhelper that handles bare comma-separated or list-repr answers, and use it inevaluate_successor_liability. Behavior on the canonical TSV format is unchanged.