oobabooga/textgen · error · ValueError
`temperature` (={temperature}) has to be a strictly positive
Error message
`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token scores will be invalid. What it means
Error "`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token scores will be invalid." thrown in oobabooga/textgen.
Source
Thrown at modules/sampler_hijack.py:38
global_scores = None
class TemperatureLogitsWarperCustom(LogitsProcessor):
'''
A copy of the original Transformers temperature logits warper.
'''
def __init__(self, temperature: float):
if not isinstance(temperature, float) or not (temperature > 0):
except_msg = (
f"`temperature` (={temperature}) has to be a strictly positive float, otherwise your next token "
"scores will be invalid."
)
if isinstance(temperature, float) and temperature == 0.0:
except_msg += " If you're looking for greedy decoding strategies, set `do_sample=False`."
raise ValueError(except_msg)
self.temperature = temperature
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
scores = scores / self.temperature
return scores
class DynamicTemperatureLogitsWarper(LogitsProcessor):
'''
Dynamic temperature.
'''
def __init__(self, dynatemp_low: float, dynatemp_high: float, dynatemp_exponent: float):
self.dynatemp_low = dynatemp_low
self.dynatemp_high = dynatemp_high
self.dynatemp_exponent = dynatemp_exponent
View on GitHub (pinned to ed888c71f2)
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.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15).
Data as JSON: /api/errors/ce3039f8d80a4537.
Report an issue: GitHub.