{"record":{"id":"27ad59e5128833b9","repo":"2noise/ChatTTS","slug":"top-p-must-be-in-0-1-got-self-top-p","errorCode":null,"errorMessage":"top_p must be in (0, 1], got {self.top_p}.","messagePattern":"top_p must be in \\(0, 1\\], got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ChatTTS/model/velocity/sampling_params.py","lineNumber":206,"sourceCode":"        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}.\")\n        if self.prompt_logprobs is not None and self.prompt_logprobs < 0:\n            raise ValueError(\n                f\"prompt_logprobs must be non-negative, got \" f\"{self.prompt_logprobs}.\"\n            )\n\n    def _verify_beam_search(self) -> None:\n        if self.best_of == 1:\n            raise ValueError(","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/2noise/ChatTTS/blob/77b89ee281cd479f5b1a787ada330dc975ca1f2a/ChatTTS/model/velocity/sampling_params.py#L188-L224","documentation":"SamplingParams._verify_args enforces top_p in the range (0, 1] (open at zero). top_p is nucleus-sampling probability mass; 0 would keep no candidates and values above 1 are meaningless.","triggerScenarios":"Constructing SamplingParams with top_p=0, a negative value, or top_p > 1.0 (e.g. 1.5 passed through from user input).","commonSituations":"Trying to make sampling deterministic by setting top_p=0 (use temperature=0 / greedy instead); a typo like top_p=10; unvalidated API payloads.","solutions":["For greedy/deterministic output use temperature=0 or top_k=1 rather than top_p=0","Keep top_p in (0, 1]; 1.0 disables nucleus filtering","Validate/clamp user input"],"exampleFix":"# before\nparams = SamplingParams(top_p=0)\n\n# after\nparams = SamplingParams(temperature=0)  # greedy","handlingStrategy":"validation","validationCode":"def normalize_top_p(v: float) -> float:\n    return min(max(float(v), 0.000001), 1.0)","typeGuard":"def is_valid_top_p(v) -> bool:\n    return isinstance(v, (int, float)) and 0.0 < v <= 1.0","tryCatchPattern":null,"preventionTips":["Map top_p<=0 from users to greedy (temperature=0) instead of forwarding it","Clamp top_p to (0, 1] at the boundary"],"tags":["sampling-params","validation","top-p","nucleus-sampling"],"backgroundTag":"invalid-sampling-parameter","analyzedSha":"77b89ee281cd479f5b1a787ada330dc975ca1f2a","analyzedAt":"2026-08-26T17:48:24.233Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}