Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/transformers/models/auto/tokenization_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,10 @@ def from_pretrained(

model_type = config_class_to_model_type(type(config).__name__)
if model_type is not None:
if model_type == "voxtral" and not is_mistral_common_available():
raise ImportError(
"The Voxtral tokenizer requires the 'mistral-common' package. Use `pip install mistral-common` to install the package."
)
tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]

if tokenizer_class_fast and (use_fast or tokenizer_class_py is None):
Expand Down
11 changes: 11 additions & 0 deletions tests/models/voxtral/test_tokenization_voxtral.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

from transformers import AutoTokenizer
from transformers.models.auto import tokenization_auto
from transformers.models.voxtral import VoxtralConfig

def test_voxtral_tokenizer_requires_mistral_common(monkeypatch):
monkeypatch.setattr(tokenization_auto, "is_mistral_common_available", lambda: False)
monkeypatch.setattr(tokenization_auto, "get_tokenizer_config", lambda *args, **kwargs: {})
with pytest.raises(ImportError, match="mistral-common"):
AutoTokenizer.from_pretrained("dummy", config=VoxtralConfig())