diff --git a/metrics/accuracy/accuracy.py b/metrics/accuracy/accuracy.py index aa5a0732..98d0cbe1 100644 --- a/metrics/accuracy/accuracy.py +++ b/metrics/accuracy/accuracy.py @@ -99,6 +99,15 @@ def _info(self): ) def _compute(self, predictions, references, normalize=True, sample_weight=None): + if len(predictions) != len(references): + raise ValueError( + f"Predictions and references must have the same length, " + f"got {len(predictions)} and {len(references)}." + ) + + if len(predictions) == 0: + raise ValueError("Predictions and references must not be empty.") + return { "accuracy": float( accuracy_score(references, predictions, normalize=normalize, sample_weight=sample_weight) diff --git a/metrics/meteor/__init__.py b/metrics/meteor/__init__.py new file mode 100644 index 00000000..e69de29b