{"record":{"id":"396b798c5e16c141","repo":"2noise/ChatTTS","slug":"repetition-penalty-must-be-in-0-2-got-self-re","errorCode":null,"errorMessage":"repetition_penalty must be in (0, 2], got {self.repetition_penalty}.","messagePattern":"repetition_penalty must be in \\(0, 2\\], got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ChatTTS/model/velocity/sampling_params.py","lineNumber":198,"sourceCode":"    def _verify_args(self) -> None:\n        if self.n < 1:\n            raise ValueError(f\"n must be at least 1, got {self.n}.\")\n        if self.best_of < self.n:\n            raise ValueError(\n                f\"best_of must be greater than or equal to n, \"\n                f\"got n={self.n} and best_of={self.best_of}.\"\n            )\n        if not -2.0 <= self.presence_penalty <= 2.0:\n            raise ValueError(\n                \"presence_penalty must be in [-2, 2], got \" f\"{self.presence_penalty}.\"\n            )\n        if not -2.0 <= self.frequency_penalty <= 2.0:\n            raise ValueError(\n                \"frequency_penalty must be in [-2, 2], got \"\n                f\"{self.frequency_penalty}.\"\n            )\n        if not 0.0 < self.repetition_penalty <= 2.0:\n            raise ValueError(\n                \"repetition_penalty must be in (0, 2], got \"\n                f\"{self.repetition_penalty}.\"\n            )\n        # if self.temperature < 0.0:\n        #     raise ValueError(\n        #         f\"temperature must be non-negative, got {self.temperature}.\")\n        if not 0.0 < self.top_p <= 1.0:\n            raise ValueError(f\"top_p must be in (0, 1], got {self.top_p}.\")\n        if self.top_k < -1 or self.top_k == 0:\n            raise ValueError(\n                f\"top_k must be -1 (disable), or at least 1, \" f\"got {self.top_k}.\"\n            )\n        if not 0.0 <= self.min_p <= 1.0:\n            raise ValueError(\"min_p must be in [0, 1], got \" f\"{self.min_p}.\")\n        if self.max_tokens < 1:\n            raise ValueError(f\"max_tokens must be at least 1, got {self.max_tokens}.\")\n        if self.logprobs is not None and self.logprobs < 0:\n            raise ValueError(f\"logprobs must be non-negative, got {self.logprobs}.\")","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/2noise/ChatTTS/blob/77b89ee281cd479f5b1a787ada330dc975ca1f2a/ChatTTS/model/velocity/sampling_params.py#L180-L216","documentation":"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.","triggerScenarios":"Constructing SamplingParams with repetition_penalty=0, a negative value, or anything above 2.0 (e.g. the common-looking 2.5).","commonSituations":"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.","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"],"exampleFix":"# before\nparams = SamplingParams(repetition_penalty=0)  # trying to disable\n\n# after\nparams = SamplingParams(repetition_penalty=1.0)  # no penalty","handlingStrategy":"validation","validationCode":"def normalize_repetition(v) -> float:\n    v = float(v)\n    if v == 0.0:\n        return 1.0  # caller meant \"disabled\"\n    return min(max(v, 0.000001), 2.0)","typeGuard":"def is_valid_repetition_penalty(v) -> bool:\n    return isinstance(v, (int, float)) and 0.0 < v <= 2.0","tryCatchPattern":null,"preventionTips":["Use 1.0 to disable repetition penalty, never 0","Cap HuggingFace-generation-config penalties above 2 before passing them in"],"tags":["sampling-params","validation","repetition-penalty","llm-generation"],"backgroundTag":"penalty-out-of-range","analyzedSha":"77b89ee281cd479f5b1a787ada330dc975ca1f2a","analyzedAt":"2026-08-26T17:48:24.233Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}