Datasets:
Add stratified mcq_carbon configuration
Browse files- README.md +42 -0
- mcq_carbon/train-00000-of-00001.parquet +3 -0
- scripts/create_mcq_carbon.py +142 -0
README.md
CHANGED
|
@@ -56,6 +56,28 @@ dataset_info:
|
|
| 56 |
num_examples: 2600
|
| 57 |
download_size: 4880581
|
| 58 |
dataset_size: 6130755
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
- config_name: eukaryote_cls
|
| 60 |
features:
|
| 61 |
- name: id
|
|
@@ -219,6 +241,10 @@ configs:
|
|
| 219 |
data_files:
|
| 220 |
- split: train
|
| 221 |
path: mcq/train-*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
- config_name: eukaryote_cls
|
| 223 |
data_files:
|
| 224 |
- split: train
|
|
@@ -298,6 +324,7 @@ headline score is needed.
|
|
| 298 |
| --- | ---: | --- |
|
| 299 |
| `binary` | 2,600 | Full benchmark in binary-choice format, with two ordered options per question. |
|
| 300 |
| `mcq` | 2,600 | Full benchmark in four-option multiple-choice format. |
|
|
|
|
| 301 |
| `binary_600` | 600 | Lower-cost binary subset with 100 examples from each of the six subtasks. |
|
| 302 |
| `mcq_600` | 600 | Lower-cost MCQ subset with 100 examples from each of the six subtasks. |
|
| 303 |
| `binary_eukaryote` | 170 | Binary `3_species_cls` questions whose target organism is eukaryotic. |
|
|
@@ -306,6 +333,11 @@ headline score is needed.
|
|
| 306 |
| `mcq_prokaryote` | 165 | MCQ `3_species_cls` questions whose target organism is prokaryotic. |
|
| 307 |
| `eukaryote_cls` | 1,000 | Auxiliary four-option eukaryotic taxonomy set stored separately from the original 5,200-example benchmark. |
|
| 308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
The `eukaryote_cls` configuration uses the `mcq` feature schema, including JSON-serialized `metadata`.
|
| 310 |
|
| 311 |
The `binary_600` and `mcq_600` configurations were sampled without replacement using seed 42 from source revision
|
|
@@ -365,3 +397,13 @@ python scripts/create_eukaryote_cls.py --source-revision 18f68fabbcd43e8c227869a
|
|
| 365 |
|
| 366 |
The script preserves the source rows, converts `metadata` from Python dictionary strings to JSON, and casts the
|
| 367 |
columns to the `mcq` feature schema. It publishes the Parquet file, this card, and the builder script in one commit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
num_examples: 2600
|
| 57 |
download_size: 4880581
|
| 58 |
dataset_size: 6130755
|
| 59 |
+
- config_name: mcq_carbon
|
| 60 |
+
features:
|
| 61 |
+
- name: id
|
| 62 |
+
dtype: int64
|
| 63 |
+
- name: subtask
|
| 64 |
+
dtype: string
|
| 65 |
+
- name: question
|
| 66 |
+
dtype: string
|
| 67 |
+
- name: options
|
| 68 |
+
list: string
|
| 69 |
+
- name: answer_index
|
| 70 |
+
dtype: int64
|
| 71 |
+
- name: answer_text
|
| 72 |
+
dtype: string
|
| 73 |
+
- name: metadata
|
| 74 |
+
dtype: string
|
| 75 |
+
splits:
|
| 76 |
+
- name: train
|
| 77 |
+
num_bytes: 25805371
|
| 78 |
+
num_examples: 2600
|
| 79 |
+
download_size: 11786125
|
| 80 |
+
dataset_size: 25805371
|
| 81 |
- config_name: eukaryote_cls
|
| 82 |
features:
|
| 83 |
- name: id
|
|
|
|
| 241 |
data_files:
|
| 242 |
- split: train
|
| 243 |
path: mcq/train-*
|
| 244 |
+
- config_name: mcq_carbon
|
| 245 |
+
data_files:
|
| 246 |
+
- split: train
|
| 247 |
+
path: mcq_carbon/train-*
|
| 248 |
- config_name: eukaryote_cls
|
| 249 |
data_files:
|
| 250 |
- split: train
|
|
|
|
| 324 |
| --- | ---: | --- |
|
| 325 |
| `binary` | 2,600 | Full benchmark in binary-choice format, with two ordered options per question. |
|
| 326 |
| `mcq` | 2,600 | Full benchmark in four-option multiple-choice format. |
|
| 327 |
+
| `mcq_carbon` | 2,600 | MCQ benchmark with the 500 `3_species_cls` rows replaced by 500 stratified `eukaryote_cls` rows. |
|
| 328 |
| `binary_600` | 600 | Lower-cost binary subset with 100 examples from each of the six subtasks. |
|
| 329 |
| `mcq_600` | 600 | Lower-cost MCQ subset with 100 examples from each of the six subtasks. |
|
| 330 |
| `binary_eukaryote` | 170 | Binary `3_species_cls` questions whose target organism is eukaryotic. |
|
|
|
|
| 333 |
| `mcq_prokaryote` | 165 | MCQ `3_species_cls` questions whose target organism is prokaryotic. |
|
| 334 |
| `eukaryote_cls` | 1,000 | Auxiliary four-option eukaryotic taxonomy set stored separately from the original 5,200-example benchmark. |
|
| 335 |
|
| 336 |
+
The `mcq_carbon` configuration preserves the other `mcq` rows and inserts 500 `eukaryote_cls` questions at the
|
| 337 |
+
original species-classification position. From source revision `ae30ecec16a7669f342f7d87439552142cdebe40`, seed 42 selects 300
|
| 338 |
+
`basic_class`, 100 `reverse_search`, and 100 `odd_one_out` rows, sampling approximately half of each taxon label
|
| 339 |
+
within each question type. See [`scripts/create_mcq_carbon.py`](scripts/create_mcq_carbon.py).
|
| 340 |
+
|
| 341 |
The `eukaryote_cls` configuration uses the `mcq` feature schema, including JSON-serialized `metadata`.
|
| 342 |
|
| 343 |
The `binary_600` and `mcq_600` configurations were sampled without replacement using seed 42 from source revision
|
|
|
|
| 397 |
|
| 398 |
The script preserves the source rows, converts `metadata` from Python dictionary strings to JSON, and casts the
|
| 399 |
columns to the `mcq` feature schema. It publishes the Parquet file, this card, and the builder script in one commit.
|
| 400 |
+
|
| 401 |
+
### mcq_carbon
|
| 402 |
+
|
| 403 |
+
To rebuild and publish `mcq_carbon` from the pinned source revision, run:
|
| 404 |
+
|
| 405 |
+
```bash
|
| 406 |
+
python scripts/create_mcq_carbon.py --source-revision ae30ecec16a7669f342f7d87439552142cdebe40 --output-dataset HuggingFaceBio/genomeqa --publish
|
| 407 |
+
```
|
| 408 |
+
|
| 409 |
+
The script publishes the Parquet file, this card, and the builder script together.
|
mcq_carbon/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6d0fbf76cbd38d212b8fce4c40cfd2f382ddfa6c3bd3cd22924f1858f4ed38d7
|
| 3 |
+
size 11786125
|
scripts/create_mcq_carbon.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Create GenomeQA mcq_carbon by replacing species classification questions."""
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
import random
|
| 6 |
+
from collections import defaultdict
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
from datasets import concatenate_datasets, load_dataset
|
| 10 |
+
from huggingface_hub import CommitOperationAdd, HfApi, hf_hub_download
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
DATASET_ID = "HuggingFaceBio/genomeqa"
|
| 14 |
+
SEED = 42
|
| 15 |
+
PARQUET_PATH = "mcq_carbon/train-00000-of-00001.parquet"
|
| 16 |
+
QUOTAS = {"basic_class": 300, "reverse_search": 100, "odd_one_out": 100}
|
| 17 |
+
LABEL_KEYS = {"basic_class": "true", "reverse_search": "target", "odd_one_out": "minority"}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main() -> None:
|
| 21 |
+
parser = argparse.ArgumentParser()
|
| 22 |
+
parser.add_argument("--source-revision", required=True)
|
| 23 |
+
parser.add_argument("--output-dataset", default=DATASET_ID)
|
| 24 |
+
parser.add_argument("--output-dir", type=Path, default=Path.cwd())
|
| 25 |
+
parser.add_argument("--publish", action="store_true")
|
| 26 |
+
args = parser.parse_args()
|
| 27 |
+
|
| 28 |
+
mcq = load_dataset(DATASET_ID, "mcq", split="train", revision=args.source_revision)
|
| 29 |
+
eukaryote = load_dataset(DATASET_ID, "eukaryote_cls", split="train", revision=args.source_revision)
|
| 30 |
+
if mcq.features != eukaryote.features:
|
| 31 |
+
raise ValueError("The source configurations must have matching features")
|
| 32 |
+
|
| 33 |
+
strata = defaultdict(lambda: defaultdict(list))
|
| 34 |
+
for index, metadata_text in enumerate(eukaryote["metadata"]):
|
| 35 |
+
metadata = json.loads(metadata_text)
|
| 36 |
+
dimension = metadata["dim"]
|
| 37 |
+
strata[dimension][metadata[LABEL_KEYS[dimension]]].append(index)
|
| 38 |
+
|
| 39 |
+
rng = random.Random(SEED)
|
| 40 |
+
selected = []
|
| 41 |
+
for dimension, quota in QUOTAS.items():
|
| 42 |
+
groups = strata[dimension]
|
| 43 |
+
if sum(len(indices) for indices in groups.values()) != 2 * quota:
|
| 44 |
+
raise ValueError(f"Expected {2 * quota} {dimension} source rows")
|
| 45 |
+
take = {label: len(indices) // 2 for label, indices in groups.items()}
|
| 46 |
+
odd_labels = sorted(label for label, indices in groups.items() if len(indices) % 2)
|
| 47 |
+
rng.shuffle(odd_labels)
|
| 48 |
+
for label in odd_labels[: quota - sum(take.values())]:
|
| 49 |
+
take[label] += 1
|
| 50 |
+
for label in sorted(groups):
|
| 51 |
+
selected.extend(rng.sample(groups[label], take[label]))
|
| 52 |
+
rng.shuffle(selected)
|
| 53 |
+
replacement = eukaryote.select(selected)
|
| 54 |
+
|
| 55 |
+
species_positions = [index for index, subtask in enumerate(mcq["subtask"]) if subtask == "3_species_cls"]
|
| 56 |
+
if len(species_positions) != 500 or species_positions != list(range(species_positions[0], species_positions[-1] + 1)):
|
| 57 |
+
raise ValueError("Expected one contiguous 500-row 3_species_cls block")
|
| 58 |
+
start = species_positions[0]
|
| 59 |
+
combined = concatenate_datasets([mcq.select(range(start)), replacement, mcq.select(range(start + 500, len(mcq)))])
|
| 60 |
+
|
| 61 |
+
parquet_path = args.output_dir / PARQUET_PATH
|
| 62 |
+
parquet_path.parent.mkdir(parents=True, exist_ok=True)
|
| 63 |
+
combined.to_parquet(parquet_path)
|
| 64 |
+
|
| 65 |
+
api = HfApi()
|
| 66 |
+
head = api.repo_info(args.output_dataset, repo_type="dataset").sha
|
| 67 |
+
card = Path(hf_hub_download(args.output_dataset, "README.md", repo_type="dataset", revision=head)).read_text()
|
| 68 |
+
if "- config_name: mcq_carbon\n features:" not in card:
|
| 69 |
+
info = f"""- config_name: mcq_carbon
|
| 70 |
+
features:
|
| 71 |
+
- name: id
|
| 72 |
+
dtype: int64
|
| 73 |
+
- name: subtask
|
| 74 |
+
dtype: string
|
| 75 |
+
- name: question
|
| 76 |
+
dtype: string
|
| 77 |
+
- name: options
|
| 78 |
+
list: string
|
| 79 |
+
- name: answer_index
|
| 80 |
+
dtype: int64
|
| 81 |
+
- name: answer_text
|
| 82 |
+
dtype: string
|
| 83 |
+
- name: metadata
|
| 84 |
+
dtype: string
|
| 85 |
+
splits:
|
| 86 |
+
- name: train
|
| 87 |
+
num_bytes: {combined.data.nbytes}
|
| 88 |
+
num_examples: {len(combined)}
|
| 89 |
+
download_size: {parquet_path.stat().st_size}
|
| 90 |
+
dataset_size: {combined.data.nbytes}
|
| 91 |
+
"""
|
| 92 |
+
card = card.replace("- config_name: eukaryote_cls\n features:", info + "- config_name: eukaryote_cls\n features:", 1)
|
| 93 |
+
config = """- config_name: mcq_carbon
|
| 94 |
+
data_files:
|
| 95 |
+
- split: train
|
| 96 |
+
path: mcq_carbon/train-*
|
| 97 |
+
"""
|
| 98 |
+
card = card.replace("- config_name: eukaryote_cls\n data_files:", config + "- config_name: eukaryote_cls\n data_files:", 1)
|
| 99 |
+
row = "| `mcq` | 2,600 | Full benchmark in four-option multiple-choice format. |\n"
|
| 100 |
+
new_row = "| `mcq_carbon` | 2,600 | MCQ benchmark with the 500 `3_species_cls` rows replaced by 500 stratified `eukaryote_cls` rows. |\n"
|
| 101 |
+
card = card.replace(row, row + new_row, 1)
|
| 102 |
+
note = f"""The `mcq_carbon` configuration preserves the other `mcq` rows and inserts 500 `eukaryote_cls` questions at the
|
| 103 |
+
original species-classification position. From source revision `{args.source_revision}`, seed {SEED} selects 300
|
| 104 |
+
`basic_class`, 100 `reverse_search`, and 100 `odd_one_out` rows, sampling approximately half of each taxon label
|
| 105 |
+
within each question type. See [`scripts/create_mcq_carbon.py`](scripts/create_mcq_carbon.py).
|
| 106 |
+
|
| 107 |
+
"""
|
| 108 |
+
card = card.replace("The `eukaryote_cls` configuration uses the `mcq` feature schema", note + "The `eukaryote_cls` configuration uses the `mcq` feature schema", 1)
|
| 109 |
+
|
| 110 |
+
if "### mcq_carbon" not in card:
|
| 111 |
+
card += f"""
|
| 112 |
+
### mcq_carbon
|
| 113 |
+
|
| 114 |
+
To rebuild and publish `mcq_carbon` from the pinned source revision, run:
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
python scripts/create_mcq_carbon.py --source-revision {args.source_revision} --output-dataset {args.output_dataset} --publish
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
The script publishes the Parquet file, this card, and the builder script together.
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
card_path = args.output_dir / "README.md"
|
| 124 |
+
card_path.write_text(card)
|
| 125 |
+
print(f"Prepared {len(combined)} rows ({len(replacement)} replacement rows) at {parquet_path}")
|
| 126 |
+
if args.publish:
|
| 127 |
+
commit = api.create_commit(
|
| 128 |
+
repo_id=args.output_dataset,
|
| 129 |
+
repo_type="dataset",
|
| 130 |
+
parent_commit=head,
|
| 131 |
+
commit_message="Add stratified mcq_carbon configuration",
|
| 132 |
+
operations=[
|
| 133 |
+
CommitOperationAdd(path_in_repo=PARQUET_PATH, path_or_fileobj=parquet_path),
|
| 134 |
+
CommitOperationAdd(path_in_repo="README.md", path_or_fileobj=card_path),
|
| 135 |
+
CommitOperationAdd(path_in_repo="scripts/create_mcq_carbon.py", path_or_fileobj=__file__),
|
| 136 |
+
],
|
| 137 |
+
)
|
| 138 |
+
print(f"Published {commit.commit_url}")
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
if __name__ == "__main__":
|
| 142 |
+
main()
|