Skip to content

Commit

Permalink
chore: raise import error when using mistral tokenizer
Browse files Browse the repository at this point in the history
Signed-off-by: elijah <[email protected]>
  • Loading branch information
e1ijah1 committed Jan 13, 2025
1 parent 7707f2c commit 971102d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions benchmarks/backend_request_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
from transformers import (AutoTokenizer, PreTrainedTokenizer,
PreTrainedTokenizerFast)

vllm_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(vllm_dir)
from vllm.transformers_utils.tokenizers import MistralTokenizer

AIOHTTP_TIMEOUT = aiohttp.ClientTimeout(total=6 * 60 * 60)


Expand Down Expand Up @@ -436,6 +432,13 @@ def get_tokenizer(
"Cannot use the fast tokenizer in slow tokenizer mode.")
kwargs["use_fast"] = False
if tokenizer_mode == "mistral":
try:
from vllm.transformers_utils.tokenizer import (
MistralTokenizer)
except ImportError:
raise ImportError(
"MistralTokenizer requires vllm package.\n"
"Please install it with `pip install vllm` to use mistral tokenizer mode.")

Check failure on line 441 in benchmarks/backend_request_func.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (B904)

benchmarks/backend_request_func.py:439:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling

Check failure on line 441 in benchmarks/backend_request_func.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (E501)

benchmarks/backend_request_func.py:441:81: E501 Line too long (91 > 80)
return MistralTokenizer.from_pretrained(
str(pretrained_model_name_or_path))
else:
Expand Down

0 comments on commit 971102d

Please sign in to comment.