v1 · 9 พ.ค. 2569 · 2 tracks · ~25-90 นาที
THมี English ด้วย
ศาสตร์ของการสื่อสารกับ LLM เพื่อบังคับพฤติกรรม โดยไม่ต้องแก้ weights ของโมเดล
"Methods for how to communicate with LLM to steer its behavior for desired outcomes without updating the model weights." — Lilian Weng
ตามเอกสาร Anthropic — ก่อน PE จะช่วย ต้องมี:
ไม่มีครบ 3 = ปรับในที่มืด แก้ตรงนั้นก่อน
| ปัญหา | เครื่องมือที่ถูก |
|---|---|
| Output format ผิด | Prompt engineering |
| คุณภาพ output ต่ำ | Prompt engineering |
| Latency สูงเกิน | เปลี่ยนโมเดลให้เล็ก/เร็วกว่า |
| Cost สูงเกิน | เปลี่ยนโมเดล / architecture |
| Knowledge cutoff | RAG (retrieval) |
| พฤติกรรมเสถียรที่ scale | Fine-tuning |
| องค์ประกอบ | ตอบคำถาม |
|---|---|
| Instruction | ทำอะไร |
| Context | พื้นหลังที่บอก |
| Input data | ทำกับอะไร |
| Output indicator | format / structure |
"Show your prompt to a colleague with minimal context. If they'd be confused, Claude will be too."
❌ "Summarise this."
✅ "Summarise the following customer review for our weekly report.
Focus on actionable feedback. Output 3 bullets, ≤15 words each.
<review>{{text}}</review>"
Full version: instruction + context + input + output indicator
| Setting | ทำอะไร |
|---|---|
temperature | ความสุ่ม — 0 = deterministic, สูง = สร้างสรรค์ |
top_p | Nucleus sampling (ใช้แทน temperature, อย่าใช้พร้อมกัน) |
max_length | จำกัด output tokens |
stop | String ที่หยุด generation |
frequency_penalty | ลดการพูด token ซ้ำ |
presence_penalty | ลดการพูดเรื่องซ้ำ |
Temperature คุม ความหลากหลาย, ไม่ใช่ คุณภาพ
effort| Level | เมื่อไหร่ |
|---|---|
max | Reasoning หนักสุด อาจ over-think |
xhigh | Coding / agentic work |
high | Default สำหรับ task ที่ต้องการ intelligence |
medium | Cost-sensitive แลกกับ intelligence |
low | Latency-sensitive, scoped tasks |
CLAUDE 4.x ไม่มีตัวเทียบโดยตรงข้าม vendor
ส่ง task ไปโดย ไม่มี example โมเดล instruction-tuned ปัจจุบันจัดการได้:
ถ้าใช้ได้ → จบ ไม่ต้องเพิ่ม examples เพื่อความสบายใจ
Classify as: BILLING, BUG, FEATURE, OTHER
Example: "Charges me twice every month." → BILLING
Example: "Click 'Save', page reloads." → BUG
Example: "Could you add dark mode?" → FEATURE
Now: "I love the new logo!"
→
Sweet spot: 2-5 examples. >10 → diminishing returns; พิจารณา RAG
3 bias ที่งานวิจัยพบ (Zhao et al., 2021):
ขอให้โมเดล คิดออกเสียง ก่อนตอบ
Let's think step by step.
Show your reasoning before answering.
ดีมากกับ math + multi-step logic ไม่ช่วย translation หรือ recall
ปัญหา "วิธี" ที่โมเดลตอบ?
→ prompt engineering
ปัญหา "ความรู้" ที่โมเดลขาด?
→ RAG
ปัญหาพฤติกรรมเสถียรที่ scale?
→ fine-tuning
ปัญหา latency / cost?
→ เปลี่ยนโมเดล
— จบ Track A —
สำหรับวิศวกรที่สร้าง LLM applications
| เป้าหมาย | ที่ไหน |
|---|---|
| Persona / expertise | system |
| Constraints | system |
| Output format defaults | system |
| Per-task instructions | user |
| คำถาม / ข้อมูลจริง | user |
กฎพฤติกรรมที่เป็นรูปธรรม >> การอ้าง expertise นามธรรม
{Reliability สูงสุด: schema + prefill ร่วมกัน ("the double belt")
Plan → Validate → Execute
ถ้า validate fail → ย้อน Plan พร้อม error
แต่ละ step ง่ายขึ้น debug ง่าย evaluate ง่าย
1. Define tools (name, description, parameter schema)
2. Send request + tools to model
3. Model responds with text OR tool call
4. Your code executes the tool
5. Send result back; loop until done
Description trigger การ call. ปฏิบัติเป็น prompt-engineering task: บุรุษที่สาม, ทำอะไร + เมื่อไหร่
INDEX (ครั้งเดียว): documents → chunks → embeddings → vector store
QUERY (ทุก request):
user query → embed → top-k similar chunks
↓
prompt: "Answer using only <context>. Q: {{query}}"
↓
output (พร้อม citations to chunks)
Garbage in, garbage out — ลงทุน retrieval quality ก่อน
เลือก iteration ที่ validation pass rate ดีที่สุด — ไม่ใช่ตัวล่าสุด
trigger_rate = (runs ที่ trigger) / (total runs)
Test ผ่านเมื่อ trigger_rate ตรง expectation:
should_trigger=true: trigger_rate > 0.5
should_trigger=false: trigger_rate < 0.5
รันแต่ละ query อย่างน้อย 3 ครั้ง
Train (60%) drives revisions. Validation (40%) วัด generalisation
"The line between aligned and adversarial behavior is thinner than most people think." — Lakera
LLMs อ่านและทำตาม ทุก text ใน prompt — input ของ user ถูก execute โดยโมเดลในแบบเดียวกับ system prompt ของคุณ
ไม่มี trust boundary ที่ชัดเจนใน text. Defences เป็น layered ไม่ absolute
ไม่มี layer เดียวที่พอ. ใช้ทั้งหมดร่วมกันถึงได้ผล
| Layer | กลไก |
|---|---|
| Input filter | Block known-malicious ก่อนถึงโมเดล |
| Output filter | Scan secrets, PII, policy violations |
| Tool restrictions | Allowlist ว่าโมเดลทำอะไรได้ |
| Audit logging | เก็บทุก prompt + response |
| Human-in-loop | Action high-stakes ต้องคนยืนยัน |
เมื่อ single prompt + chain ไม่พอ — ต้องการ loop
Cap iterations เสมอ. รักษา state. Anchor role ตลอด
ข้อมูลทั้งหมดในสไลด์นี้มี citation ใน /wiki/
Prompt Engineering 101 · 9 พ.ค. 2569