Cut HF completions before EOS so the last grid row is parsed

#2
by Eclipse-Senpai - opened

Symptom: If a model ends its answer with its EOS token right after the grid, the grid's last row is lost and a correct answer is scored wrong. parse_grid("1 0\n0 1<|im_end|>") returns [[1, 0]]. This hits chat models in particular, which usually end a turn straight after the answer (<|im_end|>), and any base model that emits EOS right after the grid.

Cause: HFModel.generate truncates each sequence after its first EOS and decodes with skip_special_tokens=False. The EOS text is therefore attached to the last row, that line fails _ROW, and parse_grid stops before it.

Fix: truncate before the first EOS. Batch padding is still removed, and <think> tokens are still decoded as written, so the think-block stripping is unchanged. --selftest passes.

FlameF0X changed pull request status to merged

Sign up or log in to comment