Can't get local huggingface model to work #315
Unanswered
EdwardSJ151
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to use LMQL with a local Huggingface model, which I have in my Drive. I downloaded all of the files for the model in the tinyllama folder, and I have tried leaving the path to the folder itself, as well as all of its files, including tokenizer_config.json and model.safetensors.
I am on Google Colab. I have the following code:
!pip install -q lmql
from google.colab import drive
drive.mount('/content/drive')
from transformers import AutoTokenizer
import transformers
import torch
import lmql
path = "/content/drive/MyDrive/TinyLlamav1.0"
lmql.model(path)
@lmql.query(model="path")
async def _genBotMessage(topic) -> str:
'''lmql
"""
{:system}
You are an helpful chatbot guiding John Doe in elaborating his idea.
You two are chatting via instant messages.
"""
"""
{:user}
Make a question to John Doe about '{topic}' that prompts the user to advance in the idea.
{:assistant}
Advisor message: [MESSAGE]
"""
return MESSAGE
'''
result = await _genBotMessage("buying stocks")
The error is the following:
TokenizerNotAvailableError Traceback (most recent call last)
in <cell line: 22>()
20 '''
21
---> 22 result = await _genBotMessage("buying stocks")
14 frames
/usr/local/lib/python3.10/dist-packages/lmql/runtime/lmql_runtime.py in acall(self, *args, **kwargs)
228 PromptInterpreter.main = interpreter
229 # execute main prompt
--> 230 results = await interpreter.run(self.fct, **query_kwargs)
231 finally:
232 if PromptInterpreter.main == interpreter:
/usr/local/lib/python3.10/dist-packages/lmql/runtime/tracing/tracer.py in wrapper(*args, **kwargs)
238
239 with ContextTracer(tracer):
--> 240 return await fct(*args, **kwargs)
241 else:
242 def wrapper(*args, **kwargs):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/interpreter.py in run(self, fct, *args, **kwargs)
953 stopping_phrases=None, where=None,
954 tail=None)
--> 955 self.root_state = await self.advance(self.root_state)
956
957 async def debug_out(decoder_step):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/interpreter.py in advance(self, state)
383 while variable is None and query_head.result is None:
384 if len(stmt_buffer) == 0 and variable is None:
--> 385 await continue_for_more_prompt_stmts()
386 if distribution_reached:
387 assert len(stmt_buffer) == 0, "error: distribution variable must be the last statement in a prompt, but found {}".format(format_buffer())
/usr/local/lib/python3.10/dist-packages/lmql/runtime/interpreter.py in continue_for_more_prompt_stmts()
363 assert query_head.fresh_copy, "query head must be fresh copy to avoid state sharing side effects"
364 query_head.context = LMQLContext(self, state, prompt)
--> 365 await query_head.continue_()
366
367 qstring = query_head.current_args[0]
/usr/local/lib/python3.10/dist-packages/lmql/runtime/multi_head_interpretation.py in continue_(self)
138 while self.current_args is None and self.result is None:
139 self.current_args = await self.iterator_fct().anext()
--> 140 await self.handle_current_arg()
141
142 def iterator_fct(self):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/multi_head_interpretation.py in handle_current_arg(self)
110 else:
111 res = await fct(*self.current_args[1], **self.current_args[2])
--> 112 await self.advance(res)
113 return
114 elif type(self.current_args) is tuple and len(self.current_args) >= 2 and self.current_args[0].startswith("interrupt:"):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/multi_head_interpretation.py in advance(self, result)
87 self.trace.append(result)
88 self.current_args = await self.iterator_fct().asend(result)
---> 89 await self.handle_current_arg()
90
91 async def materialize_copy_if_necessary(self):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/multi_head_interpretation.py in handle_current_arg(self)
109 return
110 else:
--> 111 res = await fct(*self.current_args[1], **self.current_args[2])
112 await self.advance(res)
113 return
/usr/local/lib/python3.10/dist-packages/lmql/runtime/interpreter.py in set_model(self, model_name)
164
165 async def set_model(self, model_name):
--> 166 self.interpreter.set_model(model_name)
167
168 async def set_decoder(self, method, **kwargs):
/usr/local/lib/python3.10/dist-packages/lmql/runtime/interpreter.py in set_model(self, model_handle)
321
322 # setup the VocabularyMatcher to use the concrete vocabulary of the model
--> 323 VocabularyMatcher.init(model_handle.get_tokenizer())
324
325 # for OpenAI models we optimize for compact logit masks
/usr/local/lib/python3.10/dist-packages/lmql/ops/token_set.py in init(tokenizer)
40 @staticmethod
41 def init(tokenizer):
---> 42 if tokenizer.name in VocabularyMatcher._instances:
43 return
44
/usr/local/lib/python3.10/dist-packages/lmql/runtime/tokenizer.py in name(self)
86 @Property
87 def name(self):
---> 88 return self.tokenizer_impl.name
89
90 @Property
/usr/local/lib/python3.10/dist-packages/lmql/runtime/tokenizer.py in tokenizer_impl(self)
81 self.loader_thread.join()
82 if self._tokenizer_impl is None:
---> 83 tokenizer_not_found_error(self.model_identifier)
84 return self._tokenizer_impl
85
/usr/local/lib/python3.10/dist-packages/lmql/runtime/tokenizer.py in tokenizer_not_found_error(model_identifier)
364
365 def tokenizer_not_found_error(model_identifier):
--> 366 raise TokenizerNotAvailableError("Failed to locate a suitable tokenizer implementation for '{}' (Make sure your current environment provides a tokenizer backend like 'transformers', 'tiktoken' or 'llama.cpp' for this model)".format(model_identifier))
367
368 def get_vocab(tokenizer):
TokenizerNotAvailableError: Failed to locate a suitable tokenizer implementation for 'path' (Make sure your current environment provides a tokenizer backend like 'transformers', 'tiktoken' or 'llama.cpp' for this model)
Can anyone help me?
Beta Was this translation helpful? Give feedback.
All reactions