transformers 4.34 caused NotImplementedError when calling CTransformersTokenizer(PreTrainedTokenizer) #154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
transformers version:
pip install transformers==4.34.0ctransformersversion:
pip install ctransformers==0.2.27I encounter the following error
transformers has PreTrainedTokenizer in
tokenization_utils.pycode change (2da8853) where _add_tokens on line 454current_vocab = self.get_vocab().copy().PreTrainedTokenizer itself has
added_tokens_decoderand__len__implemented, so onlyget_vocabwould cause NotImplementedError()Issue can be created with this code from the readme
or in https://colab.research.google.com/drive/1GMhYMUAv_TyZkpfvUI1NirM8-9mCXQyL.
Hope this issue is address because finding the correct tokenizer from a different source may not be possible for most model.
PR submitted and it works for me now, this is my setup.
transformers 4.34.0 now support Mistral, so I really want to use it. 😁
I spent all day trying to get Mistral working with ctranformers, but it is returning garbage text on my end. I believe it may be the tokenizer because
tokenizer = AutoTokenizer.from_pretrained(model)will not work for any model.Yes, they refactored PreTrainedTokenizer which cTransformers tokernizer extended from. I ran open orca Mistral it runs fine with 4.34 but all quantized failed unless I go back to 4.33, so my PR fixed that.
I will try to run quantized Mistral tomorrow to see if it works.
I just ran TheBloke/Mistral-7B-OpenOrca-GGUF, it works fine for me.
Are you able to use the
model.generate(...)I have got everything to run until I start generating text, it will just run indefinitely.ok, I quickly write this up and it works fine (you will need transformers==4.34.0 then build ctransformers from #155 and install)
Still having issues with
tokenizer = cAutoTokenizer.from_pretrained(model)but usingOpen-Orca/Mistral-7B-OpenOrcafor the tokenizer appears to resolved it. I am not too happy about the speed though. When usinglllm =cAutoModelForCausalLM.from_pretrained(...)and thenllm('Tell me a story about a knight')it will generate a full story in 10-24 seconds (200-800 tokens). But when using the generate function it takes about 15 minutes to generate 200 tokens. I am using a 3070ti, for referenceSo i get x15 faster token output by having no gpu layers.... I think something is wrong
yes, something is wrong, for me, gpu_layer has no effect.😅
I found if I build it myself, gpu_layer does not work, no idea why.
I think my lib was a bit messy yesterday. I copy get_vocab from transformers and pushed to the PR #155 . I test with open ocra mistral code from above (type mistral) and exact same code but switch the model to vicuna 1.5 gguf (type llama) and also works.
@CHesketh76 can you rebuild and give it a try?
@victorlee0505 how to rebuilt #155 ?
straight from my fork
(even tho i put [cuda], it does not work 😕)
local
under the folder dist, you will have your new package, get the full path and install
make sure to run
export CT_CUBLAS=ONbeforepython setup.py sdistotherwise it won't build the cuda support.you might also need to setup these two in your bashrc and confirm the
nvccversion matchesnvidia-smiHi @victorlee0505 . I've rebuilt with PR https://github.com/marella/ctransformers/pull/155 and can confirm, the
NotImplementedErroris gone. Thanks!I won't move forward with this PR, I don't think it is a good fix, but ok to use as is.
I only copy one of the def get_vocab(self): implementation from transformers related to transformers.models.llama.tokenization_llama.LlamaTokenizer.get_vocab. There are different get_vocab implementation for different type. search
def get_vocab(self):in transformers you will see what i mean.Therefore I can not guarantee nor have time to figure out the perfect solution😥
ok, no I do not get the error on this:
tokenizer = AutoTokenizer.from_pretrained(model)but now on:
model_inputs = tokenizer([text], return_tensors="pt")whit this error: