(pred: EvalPrediction)
| 94 | return rouge |
| 95 | |
| 96 | def translation_metrics(pred: EvalPrediction) -> Dict: |
| 97 | pred_str, label_str = decode_pred(pred) |
| 98 | bleu: Dict = calculate_bleu(pred_str, label_str) |
| 99 | gen_len = np.round(np.mean(lmap(non_pad_len, pred.predictions)), 1) |
| 100 | bleu.update({"gen_len": gen_len}) |
| 101 | return bleu |
| 102 | |
| 103 | compute_metrics_fn = summarization_metrics if "summarization" in task_name else translation_metrics |
| 104 | return compute_metrics_fn |
nothing calls this directly
no test coverage detected