System messages
ข้อความในแบบฝึกหัดก่อนหน้าให้ผลลัพธ์ที่ถูกต้อง แต่ยังเปิดโอกาสให้ผู้ใช้ถามคำถามใดก็ได้ แม้ไม่เกี่ยวข้องกับการสนับสนุนด้านอินเทอร์เน็ต ในแบบฝึกหัดนี้ จะใช้ system message เพื่อกำหนดให้โมเดลตอบเฉพาะคำถามของลูกค้าเกี่ยวกับบริการอินเทอร์เน็ตเท่านั้น
โมเดล Llama ยังคงพร้อมใช้งานในชื่อตัวแปร llm
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การทำงานกับ Llama 3
คำแนะนำการฝึกหัด
- เพิ่ม role
"system"ลงใน message dictionary ที่ส่งให้ listconv - ดึง response ของโมเดล
"message"จาก objectresult
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Add a system message to the conversation list
conv = [
{
"role": "____",
"content": "You are a helpful and professional customer support assistant for an internet service provider. If the question or instruction doesn't relate to internet service, quote the response: 'Sorry, I can't answer that.'"},
{
"role": "user",
"content": "Help me decide which stocks to invest in."
}
]
result = llm.create_chat_completion(messages=conv, max_tokens=15)
# Extract the model response from the result object
assistant_content = result["choices"][0]["____"]["content"]
print(assistant_content)