เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

ควบคุมความสร้างสรรค์ด้วย temperature

คุณคือหัวหน้าทีมผลิตภัณฑ์ของ Luna Gear ที่กำลังเปิดตัวกระเป๋าเป้รักษ์โลก TerraPack ทีมต้องการแคปชันสำหรับทดสอบแบบ A/B สองเวอร์ชัน ได้แก่ เวอร์ชันที่เรียบร้อยและให้ข้อมูล กับเวอร์ชันที่สนุกและดึงดูดความสนใจ

ไลบรารี anthropic, client และสตริง product_info ถูกโหลดไว้ให้แล้ว

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Claude Models เบื้องต้น

ดูคอร์ส

คำแนะนำการฝึกหัด

  • กำหนดค่า temperature ต่ำสำหรับผลลัพธ์ที่สม่ำเสมอและเป็นมืออาชีพ (0.1-0.3)
  • กำหนดค่า temperature สูงสำหรับผลลัพธ์ที่สร้างสรรค์และหลากหลาย (0.7-0.9)
  • แสดงผลเนื้อหาจาก conservative response และ creative response

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

conservative_response = client.messages.create(
  # Conservative caption with low temperature
    model="claude-sonnet-4-6", temperature=____, max_tokens=150,
    messages=[{"role": "user", 
        "content": f"Write a professional caption for this product: {product_info}"}])

creative_response = client.messages.create(
  # Creative caption with high temperature  
    model="claude-sonnet-4-6", temperature=____, max_tokens=150,
    messages=[{"role": "user",
        "content": f"Write a fun, engaging caption for this product: {product_info}"}])

# Print the Conservative and Creative Responses
print("Conservative caption:", ____)
print("\nCreative caption:", ____)
แก้ไขและรันโค้ด