GemmaTokenizer does not exist or is not currently imported
ValueError: Tokenizer class GemmaTokenizer does not exist or is not currently imported.
from transformers import AutoTokenizer, AutoModelForCausalLM
from huggingface_hub import login
#from huggingface_hub import snapshot_download
#snapshot_download(repo_id="google/gemma-2b")
login("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")
model_path = "/Users/macbook/.cache/huggingface/hub/models--google--gemma-2b/snapshots/9d067f00def958594aaa16b39a65b07d69ca655b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path)
input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))
same error for me as well
ValueError Traceback (most recent call last)
in <cell line: 4>()
2 from transformers import AutoTokenizer, AutoModelForCausalLM
3
----> 4 tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
5 model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", device_map="auto")
6
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
809 tokenizer_class.register_for_auto_class()
810 return tokenizer_class.from_pretrained(
--> 811 pretrained_model_name_or_path, *inputs, trust_remote_code=trust_remote_code, **kwargs
812 )
813 elif config_tokenizer_class is not None:
ValueError: Tokenizer class GemmaTokenizer does not exist or is not currently imported.
reinstall transformers
pip uninstall transformers
pip install transformers
pip install -U transformers
should solve the issue. If not, make sure to create a fresh new env
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b", use_auth_token=True)
model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", device_map="auto")
''''''''
tokenizer not imported in this and below error
already updated tokenizer but got same error
ValueError: Tokenizer class GemmaTokenizer does not exist or is not currently imported.
Hi there! Did you upgrade transformers
by doing pip install -U transformer
?
did but got the same error as below:
ValueError Traceback (most recent call last)
in <cell line: 5>()
3
4 # tokenizer = GemmaTokenizer.from_preset("google/gemma-2b", use_auth_token=True)
----> 5 tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b", use_auth_token=True)
6 model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", device_map="auto")
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
697 Will be passed to the Tokenizer __init__()
method. Can be used to set special tokens like
698 bos_token
, eos_token
, unk_token
, sep_token
, pad_token
, cls_token
, mask_token
,
--> 699 additional_special_tokens
. See parameters in the __init__()
for more details.
700
701 Examples:
ValueError: Tokenizer class GemmaTokenizer does not exist or is not currently imported.
I am running in google colab, which has python 3.10
issue resolved, after updating python from 3.10 to 3.11
Hi, just restart the session again but before that,
remove any pip install transformers command and replace it with below line.
!pip -q install git+https://github.com/huggingface/transformers.git
Install other packages like trl or peft seperately using !pip install trl peft
It started working for me..
it worked for me too! thanks
it worked for me too! thanks
Hey! Can you please share your colab code? I'm getting multiple errors, it will be helpful thanks
reinstall transformers
pip uninstall transformers pip install transformers
After reinstallation, the versation of transformers still keep same
transformers-4.30.2
# python
Python 3.7.3
@WQW You need to upgrade it
pip install --upgrade transformers
A simple install will used the cached version of your already installed package
Colab comes with an older transformers version pre-installed. If you install/upgrade the last version, you will need to restart the runtime so it picks the newly installed version
pip install transformers==4.38.2 and it works