{"record":{"id":"6255068d063e3fe6","repo":"huggingface/transformers","slug":"expected-eos-token-id-to-be-a-positive-integer","errorCode":null,"errorMessage":"Expected `eos_token_id` to be a positive integer, found {eos_token_id} instead.","messagePattern":"Expected `eos_token_id` to be a positive integer, found (.+?) instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/logits_process.py","lineNumber":3097,"sourceCode":"    <Tip warning={true}>\n\n    This logits processor is exclusively compatible with\n    [Dia](https://huggingface.co/docs/transformers/en/model_doc/dia).\n\n    </Tip>\n\n    Args:\n        num_channels (`int`):\n            Number of audio codebooks. Simplifies access to the first channel on the logits.\n        eos_token_id (`int`):\n            The id of *end-of-sequence* token.\n    \"\"\"\n\n    def __init__(self, num_channels: int, eos_token_id: int):\n        if num_channels < 1:\n            raise ValueError(f\"Audio codebooks need at least one channel, but found {num_channels} channels.\")\n        if eos_token_id < 1:\n            raise ValueError(f\"Expected `eos_token_id` to be a positive integer, found {eos_token_id} instead.\")\n\n        self.num_channels = num_channels\n        self.eos_id = eos_token_id\n\n    @add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING)\n    def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:\n        # Reshape for easier channel indexing [B, C, V]\n        scores = scores.reshape(-1, self.num_channels, scores.shape[-1])\n\n        # EOS filter\n        # 1. Condition: Only the first channel can generate the EOS token\n        # Side condition of disabling generation of special tokens (e.g. audio pad, bos, ...)\n        # (Assumes them to be greater than audio eos token position)\n        scores[:, 1:, self.eos_id :] = torch.full_like(\n            scores[:, 1:, self.eos_id :],\n            fill_value=-float(\"inf\"),\n        )\n        scores[:, 0, self.eos_id + 1 :] = torch.full_like(","sourceCodeStart":3079,"sourceCodeEnd":3115,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/logits_process.py#L3079-L3115","documentation":"Thrown by the audio codebook logits processor's __init__ when eos_token_id < 1. The processor forces EOS to be producible only on the first codebook channel, so the EOS id must be a valid positive vocab index. Note the strictness: eos_token_id=0 is also rejected, even though 0 can be a legitimate token id in some vocabularies.","triggerScenarios":"Passing eos_token_id=0 or a negative value; reading eos id from a config key that does not exist and defaults to 0; using -1 as a sentinel for 'no EOS'.","commonSituations":"Custom audio checkpoints where EOS is token 0 (pad/bos id); configs where the field is named differently (eos_token_id vs end_of_sequence_id) and the lookup silently returns 0.","solutions":["Pass the real EOS token id from generation_config.eos_token_id (must be >= 1).","If your vocabulary genuinely uses 0 as EOS, remap or pick another dedicated EOS token — the processor cannot accept 0.","Guard config reads: eos = getattr(cfg, 'eos_token_id', None); validate before use."],"exampleFix":"# before\nprocessor = AudioEosLogitsProcessor(num_channels=4, eos_token_id=0)\n\n# after\nprocessor = AudioEosLogitsProcessor(num_channels=4, eos_token_id=model.generation_config.eos_token_id)","handlingStrategy":"validation","validationCode":"eos = getattr(model.generation_config, \"eos_token_id\", None)\nassert isinstance(eos, int) and eos >= 1, f\"eos_token_id must be a positive int, got {eos!r}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read eos_token_id from generation_config rather than duplicating constants.","Be aware the check rejects 0: vocabularies with EOS=0 need a different EOS token with this processor."],"tags":["audio-generation","eos-token","config-validation","logits-processor"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}