mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-03 03:31:05 +06:00
Generate: nudge towards do_sample=False
when temperature=0.0
(#25722)
This commit is contained in:
parent
584eeb5387
commit
0a365c3e6a
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user