I'm trying to run Gemma on Keras with this model https://www.kaggle.com/models/keras/gemma/frameworks/keras/variations/gemma_instruct_7b_en And I'm reproducing the Example available on "Model Card" on above page. When I run this code:
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_instruct_7b_en")
gemma_lm.generate("Keras is a", max_length=30)
# Generate with batched prompts.
gemma_lm.generate(["Keras is a", "I want to say"], max_length=30)
I get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_instruct_7b_en")
2 gemma_lm.generate("Keras is a", max_length=30)
4 # Generate with batched prompts.
AttributeError: module 'keras_nlp.models' has no attribute 'GemmaCausalLM'
How can I fix this?
Try restarting the kernel.
Note that the same behavior occurs with the 2B Gemma model, i.e. gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_2b_en")
.
I am not sure why restarting the kernel works, but it's worth noting that this doesn't happen in Google Colab.