Skip to content

Commit ea11d5b

Browse files
committed
refactor(mmou, rvos): write submissions under <output_path>/submissions/
Both tasks used to dump submission JSON to a hard-coded ./mmou_output/ or ./rvos_output/ directory (overridable via MMOU_OUTPUT_DIR / RVOS_OUTPUT_DIR env vars), which put them far from the sibling samples_*.jsonl produced by the evaluator. Switch to lmms_eval.tasks._task_utils.file_utils.generate_submission_file, same helper that charades_sta uses. Result: submissions land in <output_path>/submissions/<name>_<timestamp>.json alongside the per-model logs, and repeated runs no longer clobber each other. Aggregation signatures updated to accept (results, args) as required by the generate_submission_file helper. The mmou_test_mini branch already reports local accuracy so drop its extra submission dump.
1 parent 6bff4b9 commit ea11d5b

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

lmms_eval/tasks/mmou/utils.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ def mmou_process_results_scored(doc, results):
201201
return {"mmou_accuracy": data}
202202

203203

204-
def _write_submission(results, filename: str) -> str:
205-
output_dir = os.environ.get("MMOU_OUTPUT_DIR", "mmou_output")
206-
os.makedirs(output_dir, exist_ok=True)
207-
path = os.path.join(output_dir, filename)
204+
def _write_submission(results, filename: str, args) -> str:
205+
import datetime
206+
from lmms_eval.tasks._task_utils import file_utils
207+
208+
stem, _, ext = filename.rpartition(".")
209+
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
210+
file_name = f"{stem}_{ts}.{ext}" if stem else f"{filename}_{ts}"
211+
path = file_utils.generate_submission_file(file_name, args)
208212
submission = [{"question_id": r["question_id"], "answer": r["answer"]} for r in results]
209213
with open(path, "w", encoding="utf-8") as f:
210214
json.dump(submission, f, indent=2, ensure_ascii=False)
@@ -230,8 +234,8 @@ def _log_breakdown(results):
230234
eval_logger.info(f" {k}: {v}")
231235

232236

233-
def mmou_aggregate_submission(results):
234-
path = _write_submission(results, "mmou_submission.json")
237+
def mmou_aggregate_submission(results, args):
238+
path = _write_submission(results, "mmou_submission.json", args)
235239
eval_logger.info(
236240
f"MMOU submission saved to {path} ({len(results)} predictions). "
237241
"Upload to https://huggingface.co/spaces/nvidia/MMOU-Eval for scoring."
@@ -240,15 +244,13 @@ def mmou_aggregate_submission(results):
240244
return len(results)
241245

242246

243-
def mmou_aggregate_accuracy(results):
244-
path = _write_submission(results, "mmou_test_mini_submission.json")
247+
def mmou_aggregate_accuracy(results, args):
245248
total = len(results)
246249
if total == 0:
247250
return 0.0
248251
correct = sum(r["score"] for r in results)
249252
acc = correct / total * 100
250253
eval_logger.info(f"MMOU Test Mini Accuracy: {acc:.2f}% [{correct}/{total}]")
251-
eval_logger.info(f"MMOU predictions saved to {path}")
252254

253255
per_skill = {}
254256
for r in results:

lmms_eval/tasks/rvos/utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -494,39 +494,39 @@ def rvos_process_results(doc, results):
494494
# ---------------------------------------------------------------------------
495495

496496

497-
def _dump_submission(records: List[Dict[str, Any]]) -> str:
497+
def _dump_submission(records: List[Dict[str, Any]], args) -> str:
498+
import datetime
499+
from lmms_eval.tasks._task_utils import file_utils
500+
498501
task = records[0]["id"].split("_track_")[0] if records else "rvos"
499-
output_dir = os.environ.get("RVOS_OUTPUT_DIR", "rvos_output")
500-
os.makedirs(output_dir, exist_ok=True)
501-
path = os.path.join(output_dir, f"{task}_submission.json")
502+
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
503+
file_name = f"{task}_submission_{ts}.json"
504+
path = file_utils.generate_submission_file(file_name, args)
502505
with open(path, "w") as f:
503506
json.dump(records, f)
504507
return path
505508

506509

507-
_MEAN = {"f1": None, "precision": None, "recall": None, "HOTA": None}
508-
509-
510510
def _mean_metric(records: List[Dict[str, Any]], key: str) -> float:
511511
if not records:
512512
return 0.0
513513
return float(np.mean([r.get(key, 0.0) for r in records]))
514514

515515

516-
def rvos_aggregate_f1(results):
516+
def rvos_aggregate_f1(results, args):
517517
if results:
518-
path = _dump_submission(results)
518+
path = _dump_submission(results, args)
519519
eval_logger.info(f"[rvos] Submission saved to {path} ({len(results)} predictions).")
520520
return _mean_metric(results, "f1")
521521

522522

523-
def rvos_aggregate_precision(results):
523+
def rvos_aggregate_precision(results, args):
524524
return _mean_metric(results, "precision")
525525

526526

527-
def rvos_aggregate_recall(results):
527+
def rvos_aggregate_recall(results, args):
528528
return _mean_metric(results, "recall")
529529

530530

531-
def rvos_aggregate_hota(results):
531+
def rvos_aggregate_hota(results, args):
532532
return _mean_metric(results, "HOTA")

0 commit comments

Comments
 (0)