How to load our annotations into a Hugging Face Dataset object

I am following a tutorial, but when I try:

from datasets import Dataset
dataset = Dataset.from_list(annotations_as_ner)

I get this error:

AttributeError: type object ‘IterableDataset’ has no attribute ‘from_list’

How could I get this?

Hi! The above code cannot produce this error since it imports Dataset and not IterableDataset.

And to get the same effect as calling from_list on IterableDataset, you can do the following:

def gen(ls):
    yield from ls

IterableDataset.from_generator(gen, gen_kwargs={"ls": list_of_dicts})