I have a nested python dictionary
create a nested dictionary
Dict = {‘train’: {‘id’: np.arange(len(train_texts)),
‘tokens’: train_texts,
‘tags’: train_tags},
‘val’: {‘id’: np.arange(len(val_texts)),
‘tokens’: val_texts,
‘tags’: val_tags},
‘test’: {‘id’: np.arange(len(test_texts)),
‘tokens’: test_texts,
‘tags’: test_tags}
}
My question how do I use the nested dictionary in transformers Dataset.from_dict() such that it gives me an output like the following:
DatasetDict({
train: Dataset({
features: [‘id’, ‘tokens’, ‘tags’],
num_rows: 6801
})
val: Dataset({
features: [‘id’, ‘tokens’, ‘tags’],
num_rows: 1480
})
test: Dataset({
features: [‘id’, ‘tokens’, ‘tags’],
num_rows: 1532
})
})