CER function does not work properly, even when one tries to execute the example in help. Code is below
from datasets import load_metric
cer = load_metric("cer")
predictions = ["this is the prediction", "there is an other sample"]
references = ["this is the reference", "there is another one"]
cer_score = cer.compute(predictions=predictions, references=references)
print(cer_score)
outputs
ValueError Traceback (most recent call last)
/tmp/ipykernel_5923/623465361.py in <module>
4 references = ["this is the reference", "there is another one"]
5
----> 6 cer_score = cer.compute(predictions=predictions, references=references)
7 print(cer_score)
/opt/conda/lib/python3.7/site-packages/datasets/metric.py in compute(self, predictions, references, **kwargs)
402 references = self.data["references"]
403 with temp_seed(self.seed):
--> 404 output = self._compute(predictions=predictions, references=references, **kwargs)
405
406 if self.buf_writer is not None:
~/.cache/huggingface/modules/datasets_modules/metrics/cer/4e547cc82fc2e597c84fe25f48ed77e3a9acfd354308fe654ccbc6ea9473a61a/cer.py in _compute(self, predictions, references, concatenate_texts)
132 prediction,
133 truth_transform=cer_transform,
--> 134 hypothesis_transform=cer_transform,
135 )
136 incorrect += measures["substitutions"] + measures["deletions"] + measures["insertions"]
/opt/conda/lib/python3.7/site-packages/jiwer/measures.py in compute_measures(truth, hypothesis, truth_transform, hypothesis_transform, **kwargs)
208 # Preprocess truth and hypothesis
209 truth, hypothesis = _preprocess(
--> 210 truth, hypothesis, truth_transform, hypothesis_transform
211 )
212
/opt/conda/lib/python3.7/site-packages/jiwer/measures.py in _preprocess(truth, hypothesis, truth_transform, hypothesis_transform)
327 raise ValueError(
328 "number of ground truth inputs ({}) and hypothesis inputs ({}) must match.".format(
--> 329 len(transformed_truth), len(transformed_hypothesis)
330 )
331 )
ValueError: number of ground truth inputs (21) and hypothesis inputs (22) must match.