{"record":{"id":"996b2743081543b6","repo":"openai/whisper","slug":"patience-requires-beam-size-to-be-given","errorCode":null,"errorMessage":"patience requires beam_size to be given","messagePattern":"patience requires beam_size to be given","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"whisper/decoding.py","lineNumber":579,"sourceCode":"            max_initial_timestamp_index = None\n            if options.max_initial_timestamp:\n                max_initial_timestamp_index = round(\n                    self.options.max_initial_timestamp / precision\n                )\n            self.logit_filters.append(\n                ApplyTimestampRules(\n                    tokenizer, self.sample_begin, max_initial_timestamp_index\n                )\n            )\n\n    def _verify_options(self, options: DecodingOptions) -> DecodingOptions:\n        if options.beam_size is not None and options.best_of is not None:\n            raise ValueError(\"beam_size and best_of can't be given together\")\n        if options.temperature == 0:\n            if options.best_of is not None:\n                raise ValueError(\"best_of with greedy sampling (T=0) is not compatible\")\n        if options.patience is not None and options.beam_size is None:\n            raise ValueError(\"patience requires beam_size to be given\")\n        if options.length_penalty is not None and not (\n            0 <= options.length_penalty <= 1\n        ):\n            raise ValueError(\"length_penalty (alpha) should be a value between 0 and 1\")\n\n        return options\n\n    def _get_initial_tokens(self) -> Tuple[int]:\n        tokens = list(self.sot_sequence)\n\n        if prefix := self.options.prefix:\n            prefix_tokens = (\n                self.tokenizer.encode(\" \" + prefix.strip())\n                if isinstance(prefix, str)\n                else prefix\n            )\n            if self.sample_len is not None:\n                max_prefix_len = self.n_ctx // 2 - self.sample_len","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/openai/whisper/blob/5f86d1d86363843179951550570367b37c5d6f78/whisper/decoding.py#L561-L597","documentation":"_verify_options() requires that patience (the beam-search patience factor that lets the search keep going when a better beam might still appear) only makes sense inside beam search. Specifying patience without beam_size is rejected because there is no beam to be patient with.","triggerScenarios":"DecodingOptions(patience=1.5) with beam_size left at its default None; passing patience through a custom DecodingTask; enabling patience via a config dict that does not also set beam_size.","commonSituations":"Copying patience from the paper/repo examples (which always pair it with beam_size) into a partially-specified options object; config files shared across pipelines where beam_size is conditionally set.","solutions":["Set beam_size together with patience: DecodingOptions(beam_size=5, patience=1.5)","Remove patience if you did not intend beam search"],"exampleFix":"# before\noptions = whisper.DecodingOptions(patience=2.0)  # ValueError\n\n# after\noptions = whisper.DecodingOptions(beam_size=5, patience=2.0)","handlingStrategy":"validation","validationCode":"def patience_ok(options) -> bool:\n    return options.patience is None or options.beam_size is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat patience as a beam-search-only knob and set it in the same config block as beam_size","Assert option invariants once at config load time, not per request"],"tags":["decoding","options-validation","beam-search"],"backgroundTag":null,"analyzedSha":"5f86d1d86363843179951550570367b37c5d6f78","analyzedAt":"2026-08-14T18:53:59.547Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}