{"record":{"id":"aab93d87d4017074","repo":"tensorflow/models","slug":"unexpected-negative-label-id-s","errorCode":null,"errorMessage":"Unexpected negative label_id: %s","messagePattern":"Unexpected negative label_id: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/data/tagging_data_lib.py","lineNumber":228,"sourceCode":"  def get_labels(self):\n    return [\n        \"ADJ\", \"ADP\", \"ADV\", \"AUX\", \"CCONJ\", \"DET\", \"INTJ\", \"NOUN\", \"NUM\",\n        \"PART\", \"PRON\", \"PROPN\", \"PUNCT\", \"SCONJ\", \"SYM\", \"VERB\", \"X\"\n    ]\n\n  @staticmethod\n  def get_processor_name():\n    return \"udpos\"\n\n\ndef _tokenize_example(example, max_length, tokenizer, text_preprocessing=None):\n  \"\"\"Tokenizes words and breaks long example into short ones.\"\"\"\n  # Needs additional [CLS] and [SEP] tokens.\n  max_length = max_length - 2\n  new_examples = []\n  new_example = InputExample(sentence_id=example.sentence_id, sub_sentence_id=0)\n  if any([x < 0 for x in example.label_ids]):\n    raise ValueError(\"Unexpected negative label_id: %s\" % example.label_ids)\n\n  for i, word in enumerate(example.words):\n    if text_preprocessing:\n      word = text_preprocessing(word)\n    subwords = tokenizer.tokenize(word)\n    if (not subwords or len(subwords) > max_length) and word:\n      subwords = [_UNK_TOKEN]\n\n    if len(subwords) + len(new_example.words) > max_length:\n      # Start a new example.\n      new_examples.append(new_example)\n      last_sub_sentence_id = new_example.sub_sentence_id\n      new_example = InputExample(\n          sentence_id=example.sentence_id,\n          sub_sentence_id=last_sub_sentence_id + 1)\n\n    for j, subword in enumerate(subwords):\n      # Use the real label for the first subword, and pad label for","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/data/tagging_data_lib.py#L210-L246","documentation":"Error \"Unexpected negative label_id: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/data/tagging_data_lib.py:228 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"}