การควบคุมการตอบสนองแบบไม่มีโครงสร้าง

การทำงานกับ Llama 3

Imtihan Ahmed

Machine Learning Engineer

การควบคุมผลลัพธ์ของโมเดล

  • ✅ พารามิเตอร์
  • ✅ บทบาท

วิธีปรับแต่งโมเดล

การทำงานกับ Llama 3

การควบคุมผลลัพธ์ของโมเดล

  • ✅ พารามิเตอร์
  • ✅ บทบาท

วิธีปรับแต่งโมเดล - ปรับแต่ง prompt

การทำงานกับ Llama 3

การควบคุมผลลัพธ์ของโมเดล

  • ✅ พารามิเตอร์
  • ✅ บทบาท

วิธีปรับแต่งโมเดล - zero-shot/few-shot prompting

การทำงานกับ Llama 3

การควบคุมผลลัพธ์ของโมเดล

  • ✅ พารามิเตอร์
  • ✅ บทบาท

วิธีปรับแต่งโมเดล - ใช้ stop words

การทำงานกับ Llama 3

การปรับแต่ง prompt

  • ตัวอย่าง: การสรุปข้อมูล
text_choice1 = "Summarize key trends in the aviation industry from the last year, 
                focusing on fuel efficiency innovations."

text_choice2 = "Tell me about the aviation industry."
output = llm(text_choice1) # More specific prompt is more effective print(output['choices'][0]['text'])
The aviation industry has made significant strides in fuel efficiency innovations 
over the last year, driven by the need to reduce greenhouse gas emissions and 
operating costs. Sustainable Aviation Fuels (SAFs) have emerged as a key trend...
การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ - ความแม่นยำ

การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ - ความกำกวม

การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ - คีย์เวิร์ด

การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ - คำกริยาแสดงการกระทำ

การทำงานกับ Llama 3

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ

องค์ประกอบของการเขียน prompt ที่มีประสิทธิภาพ - ตัวอย่าง

การทำงานกับ Llama 3

Zero-shot prompting

  • Zero-shot prompting: คำสั่งเดี่ยวไม่มีตัวอย่าง
text = "Summarize recent mergers in the airline industry."

output = llm(text) print(output['choices'][0]['text'])
Recent mergers in the airline industry include Alaska Air Group's acquisition of 
Hawaiian Airlines in 2024, with both airlines continuing to operate as separate 
brands. In 2022, Delta Air Lines purchased 20% of LATAM Airlines Group...
การทำงานกับ Llama 3

การปรับแต่ง zero-shot prompt

  • ระบุงาน ผลลัพธ์ที่ต้องการ และบริบทเพิ่มเติมให้ชัดเจน
  • Zero-shot prompting แบบมี label
text = """
       INSTRUCTION: Write concisely and in 2-3 sentences that cover only key points.
       QUESTION: Summarize recent mergers in the airline industry.
       ANSWER:
       """
การทำงานกับ Llama 3

Few-shot prompting

  • Few-shot prompting: ใช้ตัวอย่างหลายรายการ

Prompt

การทำงานกับ Llama 3

Few-shot prompting

  • Few-shot prompting: ใช้ตัวอย่างหลายรายการ

Prompt ที่ไฮไลต์ "aircraft model"

การทำงานกับ Llama 3

Few-shot prompting

  • Few-shot prompting: ใช้ตัวอย่างหลายรายการ

Prompt ที่ไฮไลต์ "passenger capacity"

การทำงานกับ Llama 3

Few-shot prompting

  • Few-shot prompting: ใช้ตัวอย่างหลายรายการ

Prompt ที่ไฮไลต์ "fuel consumption"

การทำงานกับ Llama 3

Few-shot prompting

$$

output = llm(f"Continue the entries: {text}") 

print(output['choices'][0]['text'])
Aircraft Model: Airbus A350-900
Passenger Capacity: 350
Fuel Consumption: 2.39 liters per seat per 100 km
การทำงานกับ Llama 3

การใช้ stop words

  • ต้องการข้อมูลเชิงลึกที่กระชับ
  • ใช้ stop words เพื่อหยุดการตอบสนองที่จุดที่กำหนด
  • ตัวอย่าง: แอปพลิเคชันถาม-ตอบ
text = "Which airlines operate direct flights from London to Singapore?"


output = llm(text, stop=["Q:"]) # Stop responses at "Q:"
print(output['choices'][0]['text'])
You can fly direct from London to Singapore with Singapore Airlines and 
British Airways.
การทำงานกับ Llama 3

มาฝึกกันเถอะ!

การทำงานกับ Llama 3

Preparing Video For Download...