Datasets:
File size: 2,393 Bytes
e1ced61 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | """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,
)
|