from datasets import load_metric import numpy as np # define metrics and metrics function accuracy_metric = load_metric( "accuracy") def compute_metrics(eval_pred): predictions, labels = eval_pred predictions = np.argmax(predictions, axis=1) acc = accuracy_metric.compute(predictions=predictions, references=labels) return { "accuracy": acc["accuracy"], }