Conversation
nltk returns None for undefined recall, and we were scoring that as 0. An empty gold is bad eval data, not a model miss. Empty preds stay 0. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for picking this up. I filed #1353, and this fixes the case I reported: an empty gold no longer scores as a model miss, and an empty prediction still scores 0.0. One thing I hit when I ran it. A small change would keep the fix without that: skip references whose normalised bag of words is empty inside results = []
for gold in golds:
for pred in predictions:
item = self.compute_one_item(gold=gold, pred=pred)
if item is not None:
results.append(item)
if not results:
raise ValueError("F1_score: every gold reference is empty after normalization; invalid evaluation data.")
return self.aggregation_function(results)with How I checked: I ran the The check was run with an AI coding assistant (Claude Code). The script is short and I can paste it if useful. |
Raising inside compute_one_item aborted samples that also had a usable gold. compute() now ignores empty bags of words and only errors when none are left.
|
|
Fixes #1353
F1_scoremaps nltk'sNoneonto0.0. That's fine when the prediction bag is empty (undefined precision → miss). It's wrong when the gold bag is empty after normalize — that's bad reference data, not a model failure, andnp.meanthen treats it like a real zero.Raise
ValueErrorfor empty gold. Empty pred still scores0.0.