Prompting 104: ตัวอย่างชนะคำอธิบายPrompting 104: examples beat explanation
ใช้ตัวอย่าง before-after, tone sample และ output example เพื่อสอน AI ให้จับ pattern ที่คุณต้องการUse before-and-after examples, tone samples, and output examples to teach AI the pattern you want.
If you cannot describe the style, show it.
AI is good at pattern matching. One useful example can replace a long explanation.
This is called few-shot prompting when you give the model a few examples of input and output.
Why examples help
Instructions explain rules.
Examples show taste.
Compare these two prompts:
Write in a friendly professional tone.
and:
Use this tone:
"Thanks for flagging this. I checked the file and found one issue we should fix before sending it out."
The second prompt is clearer because the model can imitate the pattern.
Use before and after
For rewriting tasks, before-and-after examples are powerful.
Rewrite the next message using the same kind of improvement shown below.
Before:
Please be informed that the meeting has been postponed due to scheduling conflicts.
After:
The meeting has been moved because several people are unavailable at the original time.
Now rewrite:
[paste text]
The example teaches what "better" means.
Use format examples
If you need a table, checklist, or structured answer, show the exact shape.
Output format:
| Issue | Why it matters | Suggested fix |
|---|---|---|
| [short issue] | [impact] | [specific fix] |
This is often better than saying "make a table" because the model knows the columns.
Use positive and negative examples
Sometimes the model needs to know what not to do.
Good:
"Could you send the updated file by Friday?"
Too harsh:
"You need to send this immediately."
Too vague:
"Please handle this soon."
Positive and negative examples teach the boundary.
Keep examples diverse
If all examples are too similar, the model may copy superficial details.
Weak examples:
- all three are about email
- all three use the same length
- all three have the same sentiment
Better examples:
- one short email
- one announcement
- one customer reply
- different lengths
- same style principle
The model should learn the rule, not the accident.
Practice: style sample
Pick one writing style you use often.
Create a prompt with:
Task:
Style examples:
Good:
Too formal:
Too casual:
Text to rewrite:
Then test it with two different texts. If it only works for one, improve your examples.
References
- OpenAI Prompt Engineering describes few-shot learning as steering a model with input/output examples rather than fine-tuning.
- Google Gemini Prompt Design Strategies recommends examples and prefixes to make output easier to guide and parse.
- Sahoo et al., 2024: Systematic Survey of Prompt Engineering covers example-based prompting as a core prompt engineering family.
ถ้าอธิบาย style ไม่ออก ให้โชว์ตัวอย่าง
AI เก่งเรื่องการจับ pattern ตัวอย่างที่ดีหนึ่งอันอาจแทนคำอธิบายยาวๆ ได้
ถ้าให้ model ดู input/output สักสองสามตัวอย่าง วิธีนี้มักเรียกว่า few-shot prompting
ทำไมตัวอย่างช่วย
instruction อธิบายกฎ
example โชว์รสนิยม
ลองเทียบ prompt สองอันนี้:
Write in a friendly professional tone.
กับ:
Use this tone:
"Thanks for flagging this. I checked the file and found one issue we should fix before sending it out."
อันที่สองชัดกว่า เพราะ model เห็น pattern ให้เลียนแบบ
ใช้ before และ after
สำหรับงาน rewrite ตัวอย่าง before-after มีพลังมาก
Rewrite the next message using the same kind of improvement shown below.
Before:
Please be informed that the meeting has been postponed due to scheduling conflicts.
After:
The meeting has been moved because several people are unavailable at the original time.
Now rewrite:
[paste text]
ตัวอย่างช่วยสอนว่า "ดีขึ้น" แปลว่าอะไร
ใช้ตัวอย่าง format
ถ้าต้องการ table, checklist หรือคำตอบที่มีโครง ให้โชว์รูปทรงที่ต้องการไปเลย
Output format:
| Issue | Why it matters | Suggested fix |
|---|---|---|
| [short issue] | [impact] | [specific fix] |
วิธีนี้มักดีกว่าการบอกว่า "make a table" เพราะ model รู้ว่าต้องมี column อะไรบ้าง
ใช้ตัวอย่างที่ดีและไม่ดี
บางครั้ง model ต้องรู้ด้วยว่าอะไรไม่ควรทำ
Good:
"Could you send the updated file by Friday?"
Too harsh:
"You need to send this immediately."
Too vague:
"Please handle this soon."
ตัวอย่างบวกและลบช่วยสอน boundary
ทำตัวอย่างให้หลากหลาย
ถ้าตัวอย่างคล้ายกันเกินไป model อาจ copy รายละเอียดผิวเผิน
ตัวอย่างที่อ่อน:
- ทั้งหมดเป็น email
- ทั้งหมดความยาวเท่ากัน
- ทั้งหมดอารมณ์เดียวกัน
ตัวอย่างที่ดีกว่า:
- email สั้นหนึ่งอัน
- announcement หนึ่งอัน
- customer reply หนึ่งอัน
- ความยาวต่างกัน
- ใช้หลัก style เดียวกัน
model ควรเรียนรู้กฎ ไม่ใช่รายละเอียดบังเอิญ
แบบฝึก: style sample
เลือก style งานเขียนที่คุณใช้บ่อยหนึ่งแบบ
สร้าง prompt ที่มี:
Task:
Style examples:
Good:
Too formal:
Too casual:
Text to rewrite:
จากนั้นลองกับข้อความสองแบบ ถ้าใช้ได้แค่ข้อความเดียว ให้ปรับตัวอย่างให้ดีขึ้น
แหล่งอ้างอิง
- OpenAI Prompt Engineering อธิบาย few-shot learning ว่าเป็นการ steer model ด้วย input/output examples แทนการ fine-tune
- Google Gemini Prompt Design Strategies แนะนำการใช้ examples และ prefixes เพื่อกำกับ output
- Sahoo et al., 2024: Systematic Survey of Prompt Engineering จัด example-based prompting เป็นเทคนิคหลักกลุ่มหนึ่ง
เข้าสู่ระบบเพื่อบันทึกความคืบหน้าSign in to track your progress
เข้าสู่ระบบSign in→