huggingface/transformers · error · ValueError
`input_starting_length` has to be a non-negative integer, bu
Error message
`input_starting_length` has to be a non-negative integer, but is {input_start_len} What it means
Error "`input_starting_length` has to be a non-negative integer, but is {input_start_len}" thrown in huggingface/transformers.
Source
Thrown at src/transformers/generation/logits_process.py:2202
This logits processor is exclusively compatible with
[Bark](https://huggingface.co/docs/transformers/en/model_doc/bark)'s fine submodel. See the model documentation
for examples.
</Tip>
Args:
input_start_len (`int`):
The length of the initial input sequence.
semantic_vocab_size (`int`):
Vocabulary size of the semantic part, i.e number of tokens associated to the semantic vocabulary.
codebook_size (`int`):
Number of tokens associated to the codebook.
"""
def __init__(self, input_start_len: int, semantic_vocab_size: int, codebook_size: int):
if not isinstance(input_start_len, int) or input_start_len < 0:
raise ValueError(f"`input_starting_length` has to be a non-negative integer, but is {input_start_len}")
self.input_start_len = input_start_len
self.semantic_vocab_size = semantic_vocab_size
self.codebook_size = codebook_size
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
curr_len = input_ids.shape[-1]
# even -> first codebook, odd -> second codebook
is_first_codebook = ((curr_len - self.input_start_len) % 2) == 0
scores_processed = scores.clone()
if is_first_codebook:
scores_processed[:, : self.semantic_vocab_size] = -float("inf")
scores_processed[:, self.semantic_vocab_size + self.codebook_size :] = -float("inf")
else:
scores_processed[:, : self.semantic_vocab_size + self.codebook_size] = -float("inf")
View on GitHub (pinned to a597f97485)
Solutions
- Pass a non-negative integer for `input_starting_length`.
- Use `input_ids.shape[-1]` for the actual prompt length.
When it happens
Trigger: Raised in ClassifierFreeGuidanceLogitsProcessor.__init__ when input_starting_length (or input_start_len) is negative or not an integer.
Common situations: Misconfigured CFG processor construction with a negative input_starting_length value.
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/00461c811aa6c5f1.
Report an issue: GitHub.