単発の会話
Conversation クラスを試してみましょう!このクラスを使って旅行先をおすすめするチャットボットを作ります。探している内容の説明や条件を入力すると、モデルが行き先を提案します。
前の演習で作成した Conversation クラスは、次のメソッドとともに引き続き利用できます。
__init__(self, llm: Llama, system_prompt='', history=[])create_completion(self, user_prompt='')
この演習はコースの一部です
Llama 3 を使いこなす
演習の手順
- 事前に読み込まれている
llmと定義済みのinstructionを使って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)