Skip to content

Commit

Permalink
[BugFix] Apply get_cached_tokenizer to the tokenizer setter of LLM (v…
Browse files Browse the repository at this point in the history
…llm-project#5207)

Co-authored-by: qiujiawei9 <qiujiawei9@jd.com>
  • Loading branch information
2 people authored and jimpang committed Jun 27, 2024
1 parent 2f9d561 commit 13744f9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vllm/entrypoints/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from vllm.outputs import EmbeddingRequestOutput, RequestOutput
from vllm.pooling_params import PoolingParams
from vllm.sampling_params import SamplingParams
from vllm.transformers_utils.tokenizer import get_cached_tokenizer
from vllm.usage.usage_lib import UsageContext
from vllm.utils import Counter, deprecate_kwargs

Expand Down Expand Up @@ -152,7 +153,14 @@ def set_tokenizer(
self,
tokenizer: Union[PreTrainedTokenizer, PreTrainedTokenizerFast],
) -> None:
self.llm_engine.tokenizer.tokenizer = tokenizer
# While CachedTokenizer is dynamic, have no choice but
# compare class name. Misjudgment will arise from
# user-defined tokenizer started with 'Cached'
if tokenizer.__class__.__name__.startswith("Cached"):
self.llm_engine.tokenizer.tokenizer = tokenizer
else:
self.llm_engine.tokenizer.tokenizer = get_cached_tokenizer(
tokenizer)

@overload # LEGACY: single (prompt + optional token ids)
def generate(
Expand Down

0 comments on commit 13744f9

Please sign in to comment.