The compute_metrics signature
Trainer calls compute_metrics(pred) at every eval_steps. pred.predictions is the raw logits/predictions; pred.label_ids is the gold. You return a dict; Trainer logs and tracks it.
The evaluate library
HF's evaluate library wraps standard metrics: accuracy, F1, BLEU, ROUGE, METEOR, BERTScore, perplexity, exact_match, and dozens more. Each is loaded from the Hub like a dataset: evaluate.load("accuracy"). The metric object exposes compute() for a one-shot eval and add_batch() for streaming aggregation.
Pick metrics that match your loss surface
Accuracy is for balanced classification. F1 is the right call on imbalanced classes. BLEU/ROUGE for translation/summarization but they're correlated weakly with human judgment for short responses — pair with semantic-similarity metrics (BERTScore, embedding cosine) for chat eval.