SkillOpt icon indicating copy to clipboard operation
SkillOpt copied to clipboard

SearchQA scores each character when a gold answer is a single string

Open Shizoqua opened this issue 2 weeks ago • 0 comments

evaluate() in skillopt/envs/searchqa/evaluator.py, and the exact_match, f1_score and sub_em helpers it calls, iterate gold_answers. If an item's answers field is a single string instead of a list, they iterate its characters. The correct answer then scores 0, while a one-letter answer that happens to be in the string scores 1.

rollout.py sets hard from EM and soft from F1, so such items give an inverted training reward and wrong reported scores. materialize_searchqa.py produces lists, but custom data or a hand-written split can easily store "answers": "Paris". The DocVQA evaluator already accepts a single string gold answer.

Steps to reproduce

from skillopt.envs.searchqa.evaluator import evaluate

for response in ["<answer>P</answer>", "<answer>s</answer>", "<answer>Paris</answer>", "<answer>London</answer>"]:
    result = evaluate(response, "Paris")
    print(response, result["em"], result["f1"], result["sub_em"])

Expected

Only Paris scores 1.0 1.0 1.0; the others score 0.0 0.0 0.0.

Actual

<answer>P</answer> 1.0 1.0 1.0
<answer>s</answer> 1.0 1.0 1.0
<answer>Paris</answer> 0.0 0.0 1.0
<answer>London</answer> 0.0 0.0 0.0

Environment

Python 3.11.18, Linux, main at 45f65ca.

Shizoqua avatar Nov 11 '26 19:11 Shizoqua