{"record":{"id":"2b13d19033c0a12e","repo":"tensorflow/models","slug":"for-training-each-question-should-have-exactly-1-2b13d1","errorCode":null,"errorMessage":"For training, each question should have exactly 1 answer.","messagePattern":"For training, each question should have exactly 1 answer\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/data/squad_lib.py","lineNumber":210,"sourceCode":"            doc_tokens.append(c)\n          else:\n            doc_tokens[-1] += c\n          prev_is_whitespace = False\n        char_to_word_offset.append(len(doc_tokens) - 1)\n\n      for qa in paragraph[\"qas\"]:\n        qas_id = qa[\"id\"]\n        question_text = qa[\"question\"]\n        start_position = None\n        end_position = None\n        orig_answer_text = None\n        is_impossible = False\n        if is_training:\n\n          if version_2_with_negative:\n            is_impossible = qa[\"is_impossible\"]\n          if (len(qa[\"answers\"]) != 1) and (not is_impossible):\n            raise ValueError(\n                \"For training, each question should have exactly 1 answer.\")\n          if not is_impossible:\n            answer = qa[\"answers\"][0]\n            orig_answer_text = answer[\"text\"]\n            answer_offset = answer[\"answer_start\"]\n            answer_length = len(orig_answer_text)\n            start_position = char_to_word_offset[answer_offset]\n            end_position = char_to_word_offset[answer_offset + answer_length -\n                                               1]\n            # Only add answers where the text can be exactly recovered from the\n            # document. If this CAN'T happen it's likely due to weird Unicode\n            # stuff so we will just skip the example.\n            #\n            # Note that this means for training mode, every example is NOT\n            # guaranteed to be preserved.\n            actual_text = \" \".join(doc_tokens[start_position:(end_position +\n                                                              1)])\n            cleaned_answer_text = \" \".join(","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/data/squad_lib.py#L192-L228","documentation":"Error \"For training, each question should have exactly 1 answer.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/data/squad_lib.py:210 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"}