{"record":{"id":"770bf8496f4aa44a","repo":"2noise/ChatTTS","slug":"best-of-must-be-greater-than-or-equal-to-n-got-n","errorCode":null,"errorMessage":"best_of must be greater than or equal to n, got n={self.n} and best_of={self.best_of}.","messagePattern":"best_of must be greater than or equal to n, got n=(.+?) and best_of=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ChatTTS/model/velocity/sampling_params.py","lineNumber":184,"sourceCode":"        self.logits_processors = logits_processors\n        self.include_stop_str_in_output = include_stop_str_in_output\n        self._verify_args()\n        if self.use_beam_search:\n            self._verify_beam_search()\n        else:\n            self._verify_non_beam_search()\n            # if self.temperature < _SAMPLING_EPS:\n            #     # Zero temperature means greedy sampling.\n            #     self.top_p = 1.0\n            #     self.top_k = -1\n            #     self.min_p = 0.0\n            #     self._verify_greedy_sampling()\n\n    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:","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/2noise/ChatTTS/blob/77b89ee281cd479f5b1a787ada330dc975ca1f2a/ChatTTS/model/velocity/sampling_params.py#L166-L202","documentation":"SamplingParams._verify_args requires best_of >= n. best_of is the total number of sequences to generate (the top n of which are returned), so it cannot be smaller than the number of returned sequences.","triggerScenarios":"Constructing SamplingParams with best_of less than n, e.g. SamplingParams(n=4, best_of=2). Note best_of defaults to n, so this only fires when best_of is set explicitly below n.","commonSituations":"Copying OpenAI-style params where best_of/n semantics differ; tuning configs and shrinking best_of while forgetting n; swapping the two arguments.","solutions":["Set best_of equal to or greater than n (or omit best_of — it defaults to n)","If you only want n sequences returned, drop best_of entirely"],"exampleFix":"# before\nparams = SamplingParams(n=4, best_of=2)\n\n# after\nparams = SamplingParams(n=4)  # best_of defaults to n","handlingStrategy":"validation","validationCode":"def normalize(best_of, n):\n    return max(best_of, n) if best_of is not None else n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit best_of unless you specifically need extra candidates","Assert best_of >= n before constructing params"],"tags":["sampling-params","validation","llm-generation","constructor"],"backgroundTag":"invalid-sampling-parameter","analyzedSha":"77b89ee281cd479f5b1a787ada330dc975ca1f2a","analyzedAt":"2026-08-26T17:48:24.233Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}