Skip to content

Commit b3579fe

Browse files
committed
fix: add clear error message when mistral-common is missing for AutoTokenizer loading Voxtral
1 parent 4d0b675 commit b3579fe

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/transformers/models/auto/tokenization_auto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,10 @@ def from_pretrained(
11311131

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

11361140
if tokenizer_class_fast and (use_fast or tokenizer_class_py is None):
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pytest
2+
import transformers.models.auto.tokenization_auto as ta
3+
from transformers import AutoTokenizer
4+
from transformers.models.voxtral import VoxtralConfig
5+
6+
def test_voxtral_tokenizer_requires_mistral_common(monkeypatch):
7+
monkeypatch.setattr(ta, "is_mistral_common_available", lambda: False)
8+
monkeypatch.setattr(ta, "get_tokenizer_config", lambda *args, **kwargs: {})
9+
with pytest.raises(ImportError, match="mistral-common"):
10+
AutoTokenizer.from_pretrained("dummy", config=VoxtralConfig())

0 commit comments

Comments
 (0)