mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-17 21:47:58 +08:00
[Misc] Improve validation errors around best_of and n (#9167)
Signed-off-by: Travis Johnson <tsjohnso@us.ibm.com>
This commit is contained in:
parent
acce7630c1
commit
480b7f40cf
@ -330,8 +330,8 @@ class SamplingParams(
|
|||||||
if self.n < 1:
|
if self.n < 1:
|
||||||
raise ValueError(f"n must be at least 1, got {self.n}.")
|
raise ValueError(f"n must be at least 1, got {self.n}.")
|
||||||
if not isinstance(self.best_of, int):
|
if not isinstance(self.best_of, int):
|
||||||
raise ValueError(f'best_of must be an int, but is of '
|
raise ValueError(f"best_of must be an int, but is of "
|
||||||
f'type {type(self.best_of)}')
|
f"type {type(self.best_of)}")
|
||||||
if self.best_of < self.n:
|
if self.best_of < self.n:
|
||||||
raise ValueError(f"best_of must be greater than or equal to n, "
|
raise ValueError(f"best_of must be greater than or equal to n, "
|
||||||
f"got n={self.n} and best_of={self.best_of}.")
|
f"got n={self.n} and best_of={self.best_of}.")
|
||||||
@ -390,10 +390,13 @@ class SamplingParams(
|
|||||||
raise ValueError("best_of must equal n to use output_kind=DELTA")
|
raise ValueError("best_of must equal n to use output_kind=DELTA")
|
||||||
|
|
||||||
def _verify_greedy_sampling(self) -> None:
|
def _verify_greedy_sampling(self) -> None:
|
||||||
|
if self.n > 1:
|
||||||
|
raise ValueError("n must be 1 when using greedy sampling, "
|
||||||
|
f"got {self.n}.")
|
||||||
assert isinstance(self.best_of, int)
|
assert isinstance(self.best_of, int)
|
||||||
if self.best_of > 1:
|
if self.best_of > 1:
|
||||||
raise ValueError("best_of must be 1 when using greedy sampling."
|
raise ValueError("best_of must be 1 when using greedy sampling, "
|
||||||
f"Got {self.best_of}.")
|
f"got {self.best_of}.")
|
||||||
|
|
||||||
def update_from_generation_config(
|
def update_from_generation_config(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user