{"record":{"id":"abd0856912a8fdd3","repo":"tensorflow/models","slug":"reference-and-translation-files-have-different-num-abd085","errorCode":null,"errorMessage":"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.","messagePattern":"Reference and translation files have different number of lines \\((.+?) VS (.+?)\\)\\. If training only a few steps \\(100-200\\), the translation may be empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/metrics/bleu.py","lineNumber":177,"sourceCode":"    else:\n      precisions[i] = 0.0  # pyrefly: ignore[unsupported-operation]\n\n  if max(precisions) > 0:\n    p_log_sum = sum(math.log(p) for p in precisions if p)\n    geo_mean = math.exp(p_log_sum / max_order)\n\n  if use_bp:\n    ratio = translation_length / reference_length\n    bp = 0. if ratio < 1e-6 else math.exp(1 -\n                                          1. / ratio) if ratio < 1.0 else 1.0\n  bleu = geo_mean * bp\n  return np.float32(bleu)\n\n\ndef bleu_on_list(ref_lines, hyp_lines, case_sensitive=False):\n  \"\"\"Compute BLEU for two list of strings (reference and hypothesis).\"\"\"\n  if len(ref_lines) != len(hyp_lines):\n    raise ValueError(\n        \"Reference and translation files have different number of \"\n        \"lines (%d VS %d). If training only a few steps (100-200), the \"\n        \"translation may be empty.\" % (len(ref_lines), len(hyp_lines)))\n  if not case_sensitive:\n    ref_lines = [x.lower() for x in ref_lines]\n    hyp_lines = [x.lower() for x in hyp_lines]\n  ref_tokens = [bleu_tokenize(x) for x in ref_lines]\n  hyp_tokens = [bleu_tokenize(x) for x in hyp_lines]\n  return compute_bleu(ref_tokens, hyp_tokens) * 100\n","sourceCodeStart":159,"sourceCodeEnd":187,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/metrics/bleu.py#L159-L187","documentation":"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.","triggerScenarios":"Thrown at official/nlp/metrics/bleu.py:177 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}