Skip to content

Commit

Permalink
Set top_p=0 and top_k=-1 in greedy sampling (vllm-project#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
beginlner authored Nov 22, 2023
1 parent a921d8b commit 4cea74c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions vllm/sampling_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def __init__(
self._verify_non_beam_search()
if self.temperature < _SAMPLING_EPS:
# Zero temperature means greedy sampling.
self.top_p = 1.0
self.top_k = -1
self._verify_greedy_sampling()

def _verify_args(self) -> None:
Expand Down Expand Up @@ -214,10 +216,6 @@ def _verify_greedy_sampling(self) -> None:
if self.best_of > 1:
raise ValueError("best_of must be 1 when using greedy sampling."
f"Got {self.best_of}.")
if self.top_p < 1.0 - _SAMPLING_EPS:
raise ValueError("top_p must be 1 when using greedy sampling.")
if self.top_k != -1:
raise ValueError("top_k must be -1 when using greedy sampling.")

@cached_property
def sampling_type(self) -> SamplingType:
Expand Down

0 comments on commit 4cea74c

Please sign in to comment.