SkillOpt icon indicating copy to clipboard operation
SkillOpt copied to clipboard

DocVQA scores a correct answer as ANLS 0 when a stray <answer> follows it

Open Shizoqua opened this issue 2 weeks ago • 0 comments

extract_answer in skillopt/envs/docvqa/evaluator.py takes the last <answer> and the last </answer> and only uses them when the closing tag comes after the opening one. If the response mentions <answer> again after the final answer, the pair is rejected and the last line of text is scored instead. A correct answer then gets ANLS 0.

ANLS is the DocVQA soft score and hard is ANLS >= 0.999, so both the training reward and reported scores drop. SearchQA's extractor returns 42 for all three examples below.

Steps to reproduce

from skillopt.envs.docvqa.evaluator import evaluate, extract_answer

for text in [
    "<answer>42</answer> (formatted with the <answer> tag as asked)",
    "The total is <answer>42</answer>\nNote: only one <answer> block.",
    "<answer>42</answer>\n<answer>",
]:
    print(repr(extract_answer(text)), evaluate(text, ["42"])["anls"])

Expected

'42' 1.0 for all three.

Actual

'<answer>42</answer> (formatted with the <answer> tag as asked)' 0.0
'Note: only one <answer> block.' 0.0
'<answer>' 0.0

Environment

Python 3.11.18, Linux, main at 45f65ca.

Shizoqua avatar Nov 11 '26 19:11 Shizoqua