sungguk's picture
Release visual answerability benchmark v1.0.0
e1ced61 verified
Raw History Blame Contribute Delete
2.39 kB
"""MMMU importer — dev/validation rows, one config per subject.
MMMU ships 30 subjects, each with a 5-row ``dev`` and 30-row ``validation``
split (``docs/01`` §3.3). The subject is the Hugging Face config name, recorded
as ``source_config``. ``base_id`` is content-addressed (``docs/02`` §3.1) and
therefore excludes ``source_config``: two MMMU rows share an ID only when their
question, choices, and image family match — subject is metadata, not identity.
Only ``dev`` and ``validation`` are ingested; these are *limited* train
candidates that may enter silver training only after the full evaluation
registry is frozen and an explicit allowlist clears them of eval collisions
(enforced in P3).
"""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
from .base import (
Choice,
ImageResolver,
ImageStore,
IngestError,
NormalizedItem,
Policy,
canonicalize_mc_answer,
make_item,
mc_choices,
)
NAME = "mmmu"
POLICY: Policy = "c2_train_candidate"
ALLOWED_SPLITS = ("dev", "validation")
def normalize(
row: Mapping[str, Any],
images: ImageStore,
resolve: ImageResolver,
*,
revision: str,
split: str,
config: str = "default",
) -> NormalizedItem:
"""Normalize one MMMU native row to a :class:`NormalizedItem`."""
if split not in ALLOWED_SPLITS:
raise IngestError(f"mmmu: only splits {ALLOWED_SPLITS} may be ingested, got {split!r}")
question = str(row["question"])
option_texts = [str(o) for o in row["options"]]
choices: list[Choice] = mc_choices(option_texts)
answer_raw = str(row["answer"])
answer_canonical = canonicalize_mc_answer(answer_raw, choices)
image_ref = str(row["image"])
rel, digest = images.store(resolve(image_ref))
subject = str(row.get("subject", config))
native_id = str(row.get("id", row.get("index")))
return make_item(
source=NAME,
source_revision=revision,
source_config=subject, # MMMU config == subject
source_split=split,
source_native_id=native_id,
question=question,
choices=choices,
answer_raw=answer_raw,
answer_canonical=answer_canonical,
answer_type="multiple_choice",
image_paths=(rel,),
image_sha256=(digest,),
policy=POLICY,
native_row=row,
subject=subject,
)