#11251·PaddleNLP

MMLU-Pro grader scores unparseable predictions with a random guess instead of "wrong", and a reload-clobber bug means the buggy tally always overwrites the correct one in the saved summary

Author: shaurya416Created Sep 24, 2026Updated Sep 24, 2026

llm/benchmark/mmlu_pro/evaluate_from_api.py:301-306, inside update_result() (lines 288-315):

python
if not each["pred"]:
    x = random.randint(0, len(each["options"]) - 1)
    if x == each["answer_index"]:
        category_record[category]["corr"] += 1
    else:
        category_record[category]["wrong"] += 1
elif each["pred"] == each["answer"]:
    category_record[category]["corr"] += 1
else:
    category_record[category]["wrong"] += 1

When each["pred"] is falsy -- i.e. extract_answer/extract_again/extract_final all failed to find an answer letter in the model's reply (empty output, off-topic text, a refusal, anything that doesn't match the expected patterns) -- this code does not record the row as wrong. It draws random.randint(0, n_options - 1) and credits "corr" whenever that random draw happens to equal answer_index, a 1/n_options chance per unparseable row.

update_result() is not a one-off helper. evaluate() calls it at the top of the subject loop (line 339), again after every single API response (line 352), and again immediately after each save_summary() call (line 369) -- and it is this last, discarded-tally-replacing call whose return value is what the loop uses for the next row and what the final save_summary() after the loop (lines 370-371) writes to *_summary.json.

The same file already scores this situation correctly, seven lines below the bug, in evaluate():

python
if pred is not None:
    if pred == label:
        category_record[category]["corr"] += 1
    else:
        category_record[category]["wrong"] += 1
else:
    category_record[category]["wrong"] += 1

But because update_result() is called again right after this correct branch runs (line 369), the correct in-memory tally is thrown away and replaced by a fresh recompute off the JSON on disk -- which re-enters the random.randint path for the same unparseable rows.

What happens (reproduced on the real module)

In llm/benchmark/mmlu_pro/evaluate_from_api.py, update_result() (lines 288-315) scores any row where each['pred'] is falsy by drawing random.randint(0, n_options-1) and crediting 'corr' on a lucky match (lines 301-306), instead of scoring it 'wrong'. A falsy pred means extract_answer/extract_again/extract_final (lines 182-206) all failed to find an answer letter.

evaluate() (lines 329-372) computes the correct tally in memory via the right branch at lines 359-365 (pred is None -> wrong), but immediately discards it by calling update_result() again at line 369. That call reloads the file from disk and re-applies the random-guess scoring to every unparseable row seen so far.

This reload happens on every iteration (also at line 352) and once more after the loop, through the final save_summary(category_record, ...) at line 371. As a result, the *_summary.json written for a subject is always derived from the recomputed tally with the random-guess scoring, never the correct live one.

Scope and status:

  • extract_final can return None on real model output, so this path is reachable in ordinary use, not only in contrived cases.
  • No test in the repo touches update_result or mmlu_pro.
  • The file has had exactly one commit since its introduction (PR #10023) and is unmodified since; it matches current develop HEAD.
  • No existing GitHub issue or PR covers this.

Suggested fix: replace the if not each['pred']: x = random.randint(...); ... block in update_result() with the same branch evaluate() already uses at lines 359-365 (falsy pred -> wrong, no random draw). This also eliminates the divergence between the two call sites caused by the reload.

Happy to open the PR.