Unverified Commit 0a365c3e authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

Generate: nudge towards `do_sample=False` when `temperature=0.0` (#25722)

parent 584eeb53
......@@ -266,7 +266,13 @@ class TemperatureLogitsWarper(LogitsWarper):
def __init__(self, temperature: float):
if not isinstance(temperature, float) or not (temperature > 0):
raise ValueError(f"`temperature` has to be a strictly positive float, but is {temperature}")
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment