Bläddra i källkod

Merge pull request #225 from exo-explore/remote_code

Fix tokenizers delay
Alex Cheema 7 månader sedan
förälder
incheckning
3d98cc13b9
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      exo/inference/tokenizers.py

+ 2 - 2
exo/inference/tokenizers.py

@@ -22,7 +22,7 @@ async def resolve_tokenizer(model_id: 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 f"{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, trust_remote_code=True)
     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'):
@@ -36,7 +36,7 @@ async def _resolve_tokenizer(model_id_or_local_path: Union[str, PathLike]):
 
   try:
     if DEBUG >= 4: print(f"Trying AutoTokenizer for {model_id_or_local_path}")
-    return AutoTokenizer.from_pretrained(model_id_or_local_path)
+    return AutoTokenizer.from_pretrained(model_id_or_local_path, trust_remote_code=True)
   except Exception as e:
     if DEBUG >= 4: print(f"Failed to load tokenizer for {model_id_or_local_path}. Falling back to tinygrad tokenizer. Error: {e}")
     if DEBUG >= 4: print(traceback.format_exc())