tensorflow/models · error · ValueError
Reference and translation files have different number of lin
Error message
Reference and translation files have different number of lines (%d VS %d). If training only a few steps (100-200), the translation may be empty.
What it means
Error "Reference and translation files have different number of lines (%d VS %d). If training only a few steps (100-200), the translation may be empty." thrown in tensorflow/models.
Source
Thrown at official/nlp/metrics/bleu.py:177
else:
precisions[i] = 0.0 # pyrefly: ignore[unsupported-operation]
if max(precisions) > 0:
p_log_sum = sum(math.log(p) for p in precisions if p)
geo_mean = math.exp(p_log_sum / max_order)
if use_bp:
ratio = translation_length / reference_length
bp = 0. if ratio < 1e-6 else math.exp(1 -
1. / ratio) if ratio < 1.0 else 1.0
bleu = geo_mean * bp
return np.float32(bleu)
def bleu_on_list(ref_lines, hyp_lines, case_sensitive=False):
"""Compute BLEU for two list of strings (reference and hypothesis)."""
if len(ref_lines) != len(hyp_lines):
raise ValueError(
"Reference and translation files have different number of "
"lines (%d VS %d). If training only a few steps (100-200), the "
"translation may be empty." % (len(ref_lines), len(hyp_lines)))
if not case_sensitive:
ref_lines = [x.lower() for x in ref_lines]
hyp_lines = [x.lower() for x in hyp_lines]
ref_tokens = [bleu_tokenize(x) for x in ref_lines]
hyp_tokens = [bleu_tokenize(x) for x in hyp_lines]
return compute_bleu(ref_tokens, hyp_tokens) * 100
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/metrics/bleu.py:177 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/abd0856912a8fdd3.
Report an issue: GitHub.