mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 21:05:01 +08:00
[Bugfix] fix logit processor excceed vocab size issue (#6927)
This commit is contained in:
parent
533d1932d2
commit
c0644cf9ce
@ -58,6 +58,12 @@ def get_logits_processors(
|
|||||||
"Found token_id in logit_bias that is not "
|
"Found token_id in logit_bias that is not "
|
||||||
"an integer or string representing an integer") from exc
|
"an integer or string representing an integer") from exc
|
||||||
|
|
||||||
|
# Check if token_id is within the vocab size
|
||||||
|
for token_id, bias in clamped_logit_bias.items():
|
||||||
|
if token_id < 0 or token_id >= tokenizer.vocab_size:
|
||||||
|
raise ValueError("token_id in logit_bias contains "
|
||||||
|
"out-of-vocab token id")
|
||||||
|
|
||||||
def logit_bias_logits_processor(token_ids: List[int],
|
def logit_bias_logits_processor(token_ids: List[int],
|
||||||
logits: torch.Tensor) -> torch.Tensor:
|
logits: torch.Tensor) -> torch.Tensor:
|
||||||
for token_id, bias in clamped_logit_bias.items():
|
for token_id, bias in clamped_logit_bias.items():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user