0
votes

I can't load metrics using DatasetDict.

from datasets import Dataset, DatasetDict, load_dataset, load_metric

datasets=DatasetDict({
        "train": Dataset.from_pandas(train),
        "test": Dataset.from_pandas(val)
        })


metric = datasets.load_metric("squad")

How can I do that ?

1

1 Answers

0
votes

You've already important load_metric, so you can just call it directly:

metric = load_metric("squad")

As an aside, you should avoid naming objects the same thing as packages you have imported (datasets is both the name of the HuggingFace package and the object you're creating). To avoid this confusion and potential accidental shadowing, give more descriptive names to objects you create.