| """ |
| {{PAPER_TITLE}} — Evaluation Metrics |
| |
| Paper: https://arxiv.org/abs/{{ARXIV_ID}} |
| Implements: Metric computation for {{METRICS_LISTED}} |
| |
| Section references: |
| {{§SECTION}} — {{evaluation methodology description}} |
| |
| NOTE: This file provides metric computation functions only. |
| It does NOT handle data loading or model inference. |
| Pass predictions and targets to compute metrics. |
| """ |
|
|
| from typing import Dict, List, Optional |
|
|
| import torch |
| import numpy as np |
|
|
|
|
| def compute_{{METRIC_1}}( |
| predictions: torch.Tensor, |
| targets: torch.Tensor, |
| ) -> float: |
| """§{{SECTION}} — Compute {{metric name}}. |
| |
| "{{Quote from paper about evaluation metric}}" |
| |
| Args: |
| predictions: model output — shape: (batch, {{dims}}) |
| targets: ground truth — shape: (batch, {{dims}}) |
| |
| Returns: |
| {{metric_name}} score as a float |
| |
| NOTE: {{any caveats about metric implementation, e.g., |
| "Different BLEU implementations give different numbers. |
| We use sacrebleu for reproducibility."}} |
| """ |
| |
| pass |
|
|
|
|
| def compute_all_metrics( |
| predictions: torch.Tensor, |
| targets: torch.Tensor, |
| ) -> Dict[str, float]: |
| """Compute all evaluation metrics reported in the paper. |
| |
| §{{SECTION}} — "We report {{metric_1}}, {{metric_2}}, and {{metric_3}}" |
| |
| Args: |
| predictions: model output — shape: (batch, {{dims}}) |
| targets: ground truth — shape: (batch, {{dims}}) |
| |
| Returns: |
| Dict mapping metric name to value |
| """ |
| return { |
| "{{metric_1}}": compute_{{METRIC_1}}(predictions, targets), |
| |
| } |
|
|