Skip to content

Commit 986940a

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

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from transformers import AutoTokenizer
4+
from transformers.models.auto import tokenization_auto
5+
from transformers.models.voxtral import VoxtralConfig
6+
7+
def test_voxtral_tokenizer_requires_mistral_common(monkeypatch):
8+
monkeypatch.setattr(tokenization_auto, "is_mistral_common_available", lambda: False)
9+
monkeypatch.setattr(tokenization_auto, "get_tokenizer_config", lambda *args, **kwargs: {})
10+
with pytest.raises(ImportError, match="mistral-common"):
11+
AutoTokenizer.from_pretrained("dummy", config=VoxtralConfig())

0 commit comments

Comments
 (0)