← back to Exo
fix Mistral-Large special case when we pass in a path
01cc6a4c9d1cf4390ae58d9e101b443cf6bdb5ae · 2024-09-04 17:25:57 +0100 · Alex Cheema
Files touched
M exo/inference/tokenizers.py
Diff
commit 01cc6a4c9d1cf4390ae58d9e101b443cf6bdb5ae
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Wed Sep 4 17:25:57 2024 +0100
fix Mistral-Large special case when we pass in a path
---
exo/inference/tokenizers.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/exo/inference/tokenizers.py b/exo/inference/tokenizers.py
index e0bc332d..7e9a5c8e 100644
--- a/exo/inference/tokenizers.py
+++ b/exo/inference/tokenizers.py
@@ -1,5 +1,8 @@
import traceback
from aiofiles import os as aios
+from os import PathLike
+from pathlib import Path
+from typing import Union
from transformers import AutoTokenizer, AutoProcessor
from exo.download.hf.hf_helpers import get_local_snapshot_dir
from exo.helpers import DEBUG
@@ -16,10 +19,10 @@ async def resolve_tokenizer(model_id: str):
if DEBUG >= 5: traceback.print_exc()
return await _resolve_tokenizer(model_id)
-async def _resolve_tokenizer(model_id_or_local_path: str):
+async def _resolve_tokenizer(model_id_or_local_path: Union[str, PathLike]):
try:
if DEBUG >= 4: print(f"Trying AutoProcessor for {model_id_or_local_path}")
- processor = AutoProcessor.from_pretrained(model_id_or_local_path, use_fast=True if "Mistral-Large" in model_id_or_local_path else False)
+ processor = AutoProcessor.from_pretrained(model_id_or_local_path, use_fast=True if "Mistral-Large" in f"{model_id_or_local_path}" else False)
if not hasattr(processor, 'eos_token_id'):
processor.eos_token_id = getattr(processor, 'tokenizer', getattr(processor, '_tokenizer', processor)).eos_token_id
if not hasattr(processor, 'encode'):
← 41dd700f less aggressive logs for opaque status / download progress.
·
back to Exo
·
DEBUG>=8 for SendOpaqueStatus logs 41f0a22e →