File size: 616 Bytes
5fa1a76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
For this task, load the accuracy metric (see the 🤗 Evaluate quick tour to learn more about how to load and compute a metric): import evaluate accuracy = evaluate.load("accuracy") Then create a function that passes your predictions and labels to [~evaluate.EvaluationModule.compute] to calculate the accuracy: import numpy as np def compute_metrics(eval_pred): predictions = np.argmax(eval_pred.predictions, axis=1) return accuracy.compute(predictions=predictions, references=eval_pred.label_ids) Your compute_metrics function is ready to go now, and you'll return to it when you setup your training. |