单轮对话
现在来试试您的 Conversation 类吧!您将用这个类创建一个旅行推荐聊天机器人。它接收您想要的描述或条件规格,模型会返回一个推荐地点。
您在上一个练习中创建的 Conversation 类仍然可用,并包含以下方法:
__init__(self, llm: Llama, system_prompt='', history=[])create_completion(self, user_prompt='')
本练习是课程的一部分
使用 Llama 3
练习说明
- 使用给定的
instruction和预加载的llm实例化一个Conversation类。 - 向模型发送一个提示以获取旅行推荐(您也可以使用自己的提示)。
交互式实操练习
通过完成这段示例代码来试试这个练习。
instruction = "You are a travel expert that recommends a travel destination based on a specification. Return the location name only in City, Country form."
# Define a chatbot using the Conversation class
chatbot = ____(llm, system_prompt=____)
# Send a prompt to the model
result = chatbot.____("I'd like to learn about the Aztecs.")
print(result)