| from datasets import load_dataset | |
| def main(): | |
| id2label = {0: "negative", 1: "positive"} | |
| raw_dset = load_dataset("amazon_polarity") | |
| for split, dset in raw_dset.items(): | |
| dset = dset.rename_column("content", "text") | |
| dset = dset.map(lambda x: {"label_text": id2label[x["label"]]}, num_proc=4) | |
| dset.to_json(f"{split}.jsonl") | |
| if __name__ == "__main__": | |
| main() | |