from datasets import load_dataset # + def main(): raw_dset = load_dataset("go_emotions", "simplified") labels = raw_dset["train"].features["labels"].feature def create_labels(row): labels_columns = {} for _label in labels.names: labels_columns.setdefault(_label, 0) labels_columns.update({labels.int2str(_l):1 for _l in row['labels']}) return labels_columns for split, dset in raw_dset.items(): dset = dset.map(lambda x: create_labels(x), num_proc=4) dset = dset.remove_columns(["id", "labels"]) dset.to_json(f"{split}.jsonl") # - if __name__ == "__main__": main()