A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 05:30 UTC
[Bugfix] Replace custom Encoding class with BatchEncoding in MistralTokenizer (#22786)
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Jiangyun Zhu committed
Aug 14, 2025 at 23:09 UTC
625ccd1c4d1996a144b0167caefd150cf2956437
1 file changed
+2
-7
vllm/transformers_utils/tokenizers/mistral.py
+2
-7
@@ -2,13 +2,13 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
import os
5
-from dataclasses import dataclass
5
from pathlib import Path
6
from typing import TYPE_CHECKING, Any, Optional, Union, cast
7
8
import huggingface_hub
9
import regex as re
10
from huggingface_hub import HfApi, hf_hub_download
11
+from transformers.tokenization_utils_base import BatchEncoding
12
13
from vllm.logger import init_logger
14
from vllm.transformers_utils.tokenizer_base import TokenizerBase
@@ -27,11 +27,6 @@ if TYPE_CHECKING:
27
logger = init_logger(__name__)
28
29
30
-@dataclass
31
-class Encoding:
32
- input_ids: Union[list[int], list[list[int]]]
33
-
34
-
30
def maybe_serialize_tool_calls(request: "ChatCompletionRequest"):
31
# SEE: https://github.com/vllm-project/vllm/pull/9951
32
# Credits go to: @gcalmettes
@@ -359,7 +354,7 @@ class MistralTokenizer(TokenizerBase):
354
# For str, single prompt text
355
else:
356
input_ids = self.encode_one(text, truncation, max_length)
362
- return Encoding(input_ids=input_ids)
357
+ return BatchEncoding({"input_ids": input_ids})
358
359
def get_vocab(self) -> dict[str, int]:
360
# NB: the dictionary form of the vocabulary collapses token ids that map