{"record":{"id":"5e87a62eb357bc9f","repo":"tensorflow/models","slug":"max-predictions-per-seq-must-be-set","errorCode":null,"errorMessage":"`max_predictions_per_seq` must be set.","messagePattern":"`max_predictions_per_seq` must be set\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/data/pretrain_dataloader.py","lineNumber":505,"sourceCode":"      - 'single_token': Samples individual tokens as prediction targets.\n      - 'token_span': Samples spans of tokens as prediction targets.\n      - 'whole_word': Samples individual words as prediction targets.\n      - 'word_span': Samples spans of words as prediction targets.\n\n    Args:\n      inputs: The input tokens.\n      boundary: The `int` Tensor of indices indicating whole word boundaries.\n        This is used in 'whole_word' and 'word_span'\n\n    Returns:\n      The sampled `bool` input mask.\n\n    Raises:\n      `ValueError`: if `max_predictions_per_seq` is not set or if boundary is\n        not provided for 'whole_word' and 'word_span' sample strategies.\n    \"\"\"\n    if self._max_predictions_per_seq is None:\n      raise ValueError('`max_predictions_per_seq` must be set.')\n\n    if boundary is None and 'word' in self._sample_strategy:\n      raise ValueError('`boundary` must be provided for {} strategy'.format(\n          self._sample_strategy))\n\n    if self._sample_strategy == 'single_token':\n      return self._single_token_mask(inputs)\n    elif self._sample_strategy == 'token_span':\n      return self._token_span_mask(inputs)\n    elif self._sample_strategy == 'whole_word':\n      return self._whole_word_mask(inputs, boundary)\n    elif self._sample_strategy == 'word_span':\n      return self._word_span_mask(inputs, boundary)\n    else:\n      raise NotImplementedError('Invalid sample strategy.')\n\n  def _get_factorization(self, inputs: tf.Tensor, input_mask: tf.Tensor):\n    \"\"\"Samples a permutation of the factorization order.","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/data/pretrain_dataloader.py#L487-L523","documentation":"Error \"`max_predictions_per_seq` must be set.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/data/pretrain_dataloader.py:505 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"}