我的环境
我尝试按照此简介运行以下命令来安装 keras_nlp 和 keras。
pip install -U keras-nlp
pip install -U keras
命令运行成功。 但是我安装的kerasNLP似乎内容不正确,这里应该有很多模型。
这是我要测试的演示。
import keras_nlp
import os
os.environ["KERAS_BACKEND"] = "tensorflow"
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_instruct_7b_en")
gotA = gemma_lm.generate("Keras is a", max_length=30)
print(gotA)
# Generate with batched prompts.
gotB = gemma_lm.generate(["Keras is a", "I want to say"], max_length=30)
print(gotB)
程序总是关闭并显示以下日志:
2024-02-25 23:23:39.045761: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-02-25 23:23:39.504814: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
Traceback (most recent call last):
File "d:\llm_demo\gemma.py", line 5, in <module>
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_instruct_7b_en")
^^^^^^^^^^^^^^^^
AttributeError: module 'keras_nlp' has no attribute 'models'
我可以做些什么来让这个演示工作吗?
对我来说同样的错误。请建议该怎么做?