Reputation: 2106
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?
Upvotes: 3
Views: 1680
Reputation: 81
For me did not resolve restart the Kernel and I think that's related to keras_nlp and Gemma (maybe some versioning issue) I needed to update my keras_nlp to 0.8.1
pip install -U keras-nlp
Upvotes: 0
Reputation: 73414
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.
Upvotes: 3