2noise/ChatTTS · error · ValueError
repetition_penalty must be in (0, 2], got {self.repetition_p
Error message
repetition_penalty must be in (0, 2], got {self.repetition_penalty}. What it means
SamplingParams._verify_args enforces repetition_penalty in the range (0, 2] (open at zero). A repetition_penalty of exactly 0 or negative is meaningless — it would zero all logits — so it is rejected.
Source
Thrown at ChatTTS/model/velocity/sampling_params.py:198
def _verify_args(self) -> None:
if self.n < 1:
raise ValueError(f"n must be at least 1, got {self.n}.")
if self.best_of < self.n:
raise ValueError(
f"best_of must be greater than or equal to n, "
f"got n={self.n} and best_of={self.best_of}."
)
if not -2.0 <= self.presence_penalty <= 2.0:
raise ValueError(
"presence_penalty must be in [-2, 2], got " f"{self.presence_penalty}."
)
if not -2.0 <= self.frequency_penalty <= 2.0:
raise ValueError(
"frequency_penalty must be in [-2, 2], got "
f"{self.frequency_penalty}."
)
if not 0.0 < self.repetition_penalty <= 2.0:
raise ValueError(
"repetition_penalty must be in (0, 2], got "
f"{self.repetition_penalty}."
)
# if self.temperature < 0.0:
# raise ValueError(
# f"temperature must be non-negative, got {self.temperature}.")
if not 0.0 < self.top_p <= 1.0:
raise ValueError(f"top_p must be in (0, 1], got {self.top_p}.")
if self.top_k < -1 or self.top_k == 0:
raise ValueError(
f"top_k must be -1 (disable), or at least 1, " f"got {self.top_k}."
)
if not 0.0 <= self.min_p <= 1.0:
raise ValueError("min_p must be in [0, 1], got " f"{self.min_p}.")
if self.max_tokens < 1:
raise ValueError(f"max_tokens must be at least 1, got {self.max_tokens}.")
if self.logprobs is not None and self.logprobs < 0:
raise ValueError(f"logprobs must be non-negative, got {self.logprobs}.")View on GitHub (pinned to 77b89ee281)
Solutions
- Use repetition_penalty=1.0 to disable the penalty (not 0)
- Keep the value within (0, 2]
- Clamp/validate user-supplied values at your boundary
Example fix
# before params = SamplingParams(repetition_penalty=0) # trying to disable # after params = SamplingParams(repetition_penalty=1.0) # no penalty
Defensive patterns
Strategy: validation
Validate before calling
def normalize_repetition(v) -> float:
v = float(v)
if v == 0.0:
return 1.0 # caller meant "disabled"
return min(max(v, 0.000001), 2.0) Type guard
def is_valid_repetition_penalty(v) -> bool:
return isinstance(v, (int, float)) and 0.0 < v <= 2.0 Prevention
- Use 1.0 to disable repetition penalty, never 0
- Cap HuggingFace-generation-config penalties above 2 before passing them in
When it happens
Trigger: Constructing SamplingParams with repetition_penalty=0, a negative value, or anything above 2.0 (e.g. the common-looking 2.5).
Common situations: Disabling repetition penalty by setting it to 0 instead of 1.0 (1.0 = no effect); copying a penalty of 2.5 or 3.0 from a HuggingFace generation_config; passing values through from users unvalidated.
Related errors
- n must be at least 1, got {self.n}.
- best_of must be greater than or equal to n, got n={self.n} a
- presence_penalty must be in [-2, 2], got {self.presence_pena
- frequency_penalty must be in [-2, 2], got {self.frequency_pe
- top_k must be -1 (disable), or at least 1, got {self.top_k}.
AI-assisted analysis of 2noise/ChatTTS@77b89ee281 (2026-08-26).
Data as JSON: /api/errors/396b798c5e16c141.
Report an issue: GitHub.