Skip to content

bug(evaluator): JSONL 缺少 file/timestamp 欄位(違反 §10),導致 --resume 完全失效 #145

Description

@lianghsun

問題

eval_results_{timestamp}_run{N}.jsonl 的每一行都缺少 filetimestamp 欄位,違反 CLAUDE.md §10 的輸出格式規範,並導致 --resume 完全失效。

規範 vs 實作

CLAUDE.md §10 規定每行必須包含:

timestampfile(資料集路徑)、question_idquestioncorrect_answerpredicted_answeris_correct

實際輸出(results/eval_results_20260410_1631_run0.jsonl 第一行):

['question_id', 'sample_id', 'question', 'image_path', 'correct_answer',
 'llm_output', 'llm_reasoning_output', 'predicted_answer', 'is_correct',
 'usage_completion_tokens', 'usage_prompt_tokens', 'usage_total_tokens']

runners/evaluator.py 中所有 detailed_results.append({...}) 都沒有寫入 filetimestamp(該檔 grep "file" 零命中)。

連帶後果:--resume 一題都不會跳過

main.py:608-610{file}|{question_id} 組出已完成紀錄的 key:

file_id = record.get("file", "")
q_id = str(record.get("question_id", ""))
completed[run_key].add(f"{file_id}|{q_id}")

file 不存在 → file_id 恆為 "" → key 恆為 "|0""|1""|2"

比對端 runners/standard.py:192

if rec.startswith(f"{file_path}|")

file_path 是真實資料集路徑,永遠不會匹配 "|0" 這種 key。因此 completed_for_file 恆為 0,completed_for_file >= ds_len 恆為 False,沒有任何檔案會被跳過

實測既有輸出檔:

產生的 key 樣本: ['|0', '|1', '|10']
是否有任何 key 以真實檔案路徑開頭: False

使用者執行 --resume 的預期是「接續未完成的部分」,實際得到的是「整輪重新評測,並 append 到同一個 JSONL」,產生重複列且浪費全部的 API 成本與時間。對長時間評測(--resume 存在的唯一理由)而言,這等於功能不存在。

建議修法

evaluator.pyevaluate_file() 內,為每筆 detailed_results 補上 file(即 file_path 參數)與 timestamp。這同時滿足 §10 規範並修好 --resume

新增欄位,不改動既有欄位名稱,向下相容(原則 F)。舊的 JSONL 檔案在 resume 時仍無法匹配,但那些本來就已經是壞的。

建議一併補一個 --resume 的端到端測試——這個 bug 能存活到現在,代表該路徑沒有測試覆蓋。

相關

cc @teds-lin @lianghsun

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions