{"record":{"id":"178ea27d19ad666b","repo":"huggingface/transformers","slug":"must-have-at-least-1-token-to-score-after-the-fi","errorCode":null,"errorMessage":"Must have at least `1` token to score after the first min_prefix_len={self.processor.context_width} tokens required by the seeding scheme.","messagePattern":"Must have at least `1` token to score after the first min_prefix_len=(.+?) tokens required by the seeding scheme\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/watermarking.py","lineNumber":218,"sourceCode":"                    The watermark generated text. It is advised to remove the prompt, which can affect the detection.\n                z_threshold (`Dict`, *optional*, defaults to `3.0`):\n                    Changing this threshold will change the sensitivity of the detector. Higher z threshold gives less\n                    sensitivity and vice versa for lower z threshold.\n                return_dict (`bool`,  *optional*, defaults to `False`):\n                    Whether to return `~generation.WatermarkDetectorOutput` or not. If not it will return boolean predictions,\n        ma\n                Return:\n                    [`~generation.WatermarkDetectorOutput`] or `np.ndarray`: A [`~generation.WatermarkDetectorOutput`]\n                    if `return_dict=True` otherwise a `np.ndarray`.\n\n        \"\"\"\n\n        # Let's assume that if one batch start with `bos`, all batched also do\n        if input_ids[0, 0] == self.bos_token_id:\n            input_ids = input_ids[:, 1:]\n\n        if input_ids.shape[-1] - self.processor.context_width < 1:\n            raise ValueError(\n                f\"Must have at least `1` token to score after the first \"\n                f\"min_prefix_len={self.processor.context_width} tokens required by the seeding scheme.\"\n            )\n\n        num_tokens_scored, green_token_count = self._score_ngrams_in_passage(input_ids)\n        z_score = self._compute_z_score(green_token_count, num_tokens_scored)\n        prediction = z_score > z_threshold\n\n        if return_dict:\n            p_value = self._compute_pval(z_score)\n            confidence = 1 - p_value\n\n            return WatermarkDetectorOutput(\n                num_tokens_scored=num_tokens_scored,\n                num_green_tokens=green_token_count,\n                green_fraction=green_token_count / num_tokens_scored,\n                z_score=z_score,\n                p_value=p_value,","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/watermarking.py#L200-L236","documentation":"Error \"Must have at least `1` token to score after the first min_prefix_len={self.processor.context_width} tokens required by the seeding scheme.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in watermarking score computation when fewer than one token remains after the seeding scheme's required min_prefix_len context.","commonSituations":"Watermark detection on very short texts shorter than the processor's context_width requirement.","solutions":["Generate at least one token beyond the processor's `context_width` (min_prefix_len).","Lower `context_width` or increase `min_new_tokens` so scoring has tokens to work on."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}