{"record":{"id":"ce3039f8d80a4537","repo":"oobabooga/textgen","slug":"temperature-temperature-has-to-be-a-strictl","errorCode":null,"errorMessage":"`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token scores will be invalid.","messagePattern":"`temperature` \\(=(.+?)\\) has to be a strictly positive float, otherwise your next token scores will be invalid\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"modules/sampler_hijack.py","lineNumber":38,"sourceCode":"\nglobal_scores = None\n\n\nclass TemperatureLogitsWarperCustom(LogitsProcessor):\n    '''\n    A copy of the original Transformers temperature logits warper.\n    '''\n\n    def __init__(self, temperature: float):\n        if not isinstance(temperature, float) or not (temperature > 0):\n            except_msg = (\n                f\"`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token \"\n                \"scores will be invalid.\"\n            )\n            if isinstance(temperature, float) and temperature == 0.0:\n                except_msg += \" If you're looking for greedy decoding strategies, set `do_sample=False`.\"\n\n            raise ValueError(except_msg)\n\n        self.temperature = temperature\n\n    def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:\n        scores = scores / self.temperature\n        return scores\n\n\nclass DynamicTemperatureLogitsWarper(LogitsProcessor):\n    '''\n    Dynamic temperature.\n    '''\n\n    def __init__(self, dynatemp_low: float, dynatemp_high: float, dynatemp_exponent: float):\n        self.dynatemp_low = dynatemp_low\n        self.dynatemp_high = dynatemp_high\n        self.dynatemp_exponent = dynatemp_exponent\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/sampler_hijack.py#L20-L56","documentation":"Error \"`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token scores will be invalid.\" thrown in oobabooga/textgen.","triggerScenarios":"Raised during sampler parameter validation when `temperature` is not a strictly positive float (e.g. 0 or a negative value). Triggers from API or UI settings that pass temperature <= 0; use a small positive value such as 0.01 for near-greedy sampling.","commonSituations":"See trigger scenarios.","solutions":["Set temperature to a strictly positive float (e.g. 0.7).","If you want greedy decoding, use the dedicated greedy/deterministic option instead of temperature=0."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}