ag_news / create_dataset.py
lewtun's picture
lewtun HF staff
Add data
ca5ba61
raw
history blame
347 Bytes
from datasets import load_dataset
def main():
raw_dset = load_dataset("ag_news")
labels = raw_dset["train"].features["label"]
for split, dset in raw_dset.items():
dset = dset.map(lambda x: {"label_text": labels.int2str(x["label"])}, num_proc=4)
dset.to_json(f"{split}.jsonl")
if __name__ == "__main__":
main()