Datasets:
Release Acting Challenge Dataset with source provenance and balanced reference view
bfcf8b9 verified Download build_dataset.py from laion/acting-challenge-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.12 kB
-
https://huggingface.co/datasets/laion/acting-challenge-dataset/resolve/main/build_dataset.py
- Command line
-
hf download hf://datasets/laion/acting-challenge-dataset/build_dataset.py
-
curl -L -o build_dataset.py https://huggingface.co/datasets/laion/acting-challenge-dataset/resolve/main/build_dataset.py
4.12 kB
| """Rebuild the published viewer files from the pinned upstream JSON snapshot. | |
| The original source files remain in source/. This script adds uniform-family | |
| sampling weights and a deterministic, 200-per-family reference view; it does | |
| not generate new acting challenges or claim the source families are independent. | |
| """ | |
| from collections import Counter, defaultdict | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| SOURCE = ROOT / "source" | |
| DATA = ROOT / "data" | |
| SOURCE_COMMIT = "e3b0d5281558f7f73e1118c6a9b4c149bb8c0621" | |
| EXPECTED = { | |
| "laions_got_talent": 278, | |
| "haiku_batch": 1000, | |
| "voicenet_extension": 200, | |
| "eric_morris_inspired": 4030, | |
| "existing_challenge_inspired": 7390, | |
| "situation_inspired": 5749, | |
| "extreme_physical": 600, | |
| } | |
| def load(name): | |
| return json.loads((SOURCE / name).read_text(encoding="utf-8")) | |
| def rank(row): | |
| key = f'{row["source"]}:{row["id"]}' | |
| return hashlib.sha256(key.encode()).hexdigest() | |
| def grouped_reference(rows, key_name, count=200): | |
| if key_name is None: | |
| return sorted(rows, key=rank)[:count] | |
| by_group = defaultdict(list) | |
| for row in rows: | |
| by_group[row.get(key_name) or "unlabelled"].append(row) | |
| for group in by_group: | |
| by_group[group].sort(key=rank) | |
| keys = sorted(by_group) | |
| chosen = [] | |
| while len(chosen) < count: | |
| advanced = False | |
| for key in keys: | |
| if by_group[key] and len(chosen) < count: | |
| chosen.append(by_group[key].pop(0)) | |
| advanced = True | |
| if not advanced: | |
| raise ValueError("Insufficient examples for balanced reference") | |
| return chosen | |
| master = load("all_acting_challenges.json") | |
| assert len(master) == 19247 | |
| assert Counter(row["source"] for row in master) == EXPECTED | |
| assert len({row["id"] for row in master}) == len(master) | |
| extreme = load("acting_challenges_extreme_physical.json") | |
| extreme_by_text = {(row["title"], row["instruction"]): row for row in extreme} | |
| assert len(extreme_by_text) == 600 | |
| rows = [] | |
| for raw in master: | |
| row = dict(raw) | |
| if row["source"] == "extreme_physical": | |
| details = extreme_by_text[(row["title"], row["instruction"])] | |
| for key in ("category_code", "category_name", "subcategory", "scenario", | |
| "emotions_sampled", "speaker_gender", "speaker_age", "item_id"): | |
| row[key] = details.get(key) | |
| row["family_sampling_weight"] = 1 / (len(EXPECTED) * EXPECTED[row["source"]]) | |
| rows.append(row) | |
| DATA.mkdir(exist_ok=True) | |
| with (DATA / "all_challenges.jsonl").open("w", encoding="utf-8") as out: | |
| for row in rows: | |
| out.write(json.dumps(row, ensure_ascii=False) + "\n") | |
| reference = [] | |
| for source in EXPECTED: | |
| group = [row for row in rows if row["source"] == source] | |
| key_name = { | |
| "eric_morris_inspired": "inspired_by", | |
| "existing_challenge_inspired": "inspired_by", | |
| "situation_inspired": "situation_dim", | |
| "extreme_physical": "category_code", | |
| }.get(source) | |
| reference.extend(grouped_reference(group, key_name)) | |
| reference.sort(key=rank) | |
| assert len(reference) == 1400 | |
| assert Counter(row["source"] for row in reference) == {key: 200 for key in EXPECTED} | |
| with (DATA / "family_balanced_reference.jsonl").open("w", encoding="utf-8") as out: | |
| for row in reference: | |
| out.write(json.dumps(row, ensure_ascii=False) + "\n") | |
| manifest = { | |
| "source_commit": SOURCE_COMMIT, | |
| "source_master_sha256": hashlib.sha256((SOURCE / "all_acting_challenges.json").read_bytes()).hexdigest(), | |
| "full_count": len(rows), | |
| "source_counts": EXPECTED, | |
| "reference_count": len(reference), | |
| "reference_counts": dict(Counter(row["source"] for row in reference)), | |
| "reference_selection": "deterministic SHA-256 order; 200 per family, round-robin over available source groups", | |
| "source_title_uniqueness": len({row["title"].strip().casefold() for row in rows}), | |
| "arena_tasks_included": False, | |
| } | |
| (ROOT / "MANIFEST.json").write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| print(json.dumps(manifest, indent=2)) | |