Files
open-instruct/scripts/data/sft_v1_v2/prepare_science_data.py
74069db498 More systematic and reproducible conversion of SFT datasets (#387)
* Reorganize the data preparation scripts for tulu v1 and v2.

* Minor improvement

* Remove open_platypus_commercial subset from Daring-Anteater

* Use hard-coded examples repo.

* Fix some bugs.

* Add OpenMathInstruct.

* Add a few more v3.5.x SFT mix ablations for the cleaner datasets.

* More experiments on mixes.

* help merge

* prep for merge

* reapply changes

* fix naming

---------

Co-authored-by: Nathan Lambert <[email protected]>
2024-11-11 14:02:18 -08:00

44 lines
1.0 KiB
Python

"""
Mix together all datasets to create instruction tuning mix.
"""
from pathlib import Path
import json
import os
def write_jsonl(xs, fname):
with open(fname, "w") as f:
for x in xs:
print(json.dumps(x), file=f)
def load_jsonl(fname):
with open(fname) as f:
return [json.loads(line) for line in f]
names = [
"evidence_inference",
"qasper_truncated_4000",
"scifact_json",
"scitldr_aic",
"scierc_ner",
"scierc_relation"
]
# This is an instruction dataset about several science tasks that David and some other collaborators created.
# Please contact us if you want to use the raw files
data_dir = Path("../../davidw/proj/science-instruct/promptsource-sciit/prompts_davidw/tasks")
out_dir = Path("data/raw_train/science")
os.makedirs(out_dir, exist_ok=True)
full_dataset = []
for name in names:
ds = load_jsonl(data_dir / f"{name}_train.jsonl")
for entry in ds:
entry["dataset"] = name
full_dataset.append(entry)
write_jsonl(full_dataset, out_dir / "science_train.jsonl")