GemmaTokenizer
I am runngin the exact same code here (copied from the higgingface)
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
model = AutoModelForCausalLM.from_pretrained("google/gemma-2b")
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]))
the below error popped up when I ran the script.
ImportError: cannot import name 'GemmaTokenizer' from 'transformers'
I don't know what is the reason behind this error, can some one help me here.
Hi there! Please make sure to upgrade to the last transformers versions
pip install -U transformers
base) mac-2:~ mac$ /Users/mac/anaconda3/bin/python /Users/mac/Downloads/ai_gemma_2_data.py
Traceback (most recent call last):
File "/Users/mac/Downloads/ai_gemma_2_data.py", line 48, in
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
File "/Users/mac/anaconda3/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 616, in from_pretrained
raise ValueError(
ValueError: Tokenizer class GemmaTokenizer does not exist or is not currently imported.
my error ,who can help me?thaks!!!!!!
transform version is 4.24.0
mac os 10.15.7
anconda
transform version is 4.24.0
mac os 10.15.7
anconda
I think you cannot run it because it is a gated model.
Go to your settings, create a token and then add the token to your code.
from transformers import AutoTokenizer, AutoModelForCausalLM
hf_token = "(ADD YOUR TOKEN HERE)" <- This is where you add your token and then try doing it?
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b", use_auth_token=hf_token)
model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", use_auth_token=hf_token)
input_text = "Check the grammar of this Japanese sentence: 私はりんごは好きです。"
input_ids = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))