กลยุทธ์การออกแบบที่กระตุ้นผลลัพธ์

การออกแบบพรอมต์คือกระบวนการสร้างพรอมต์หรือคำขอที่ใช้ภาษาธรรมชาติ ซึ่งจะกระตุ้นให้โมเดลภาษาให้คำตอบที่ถูกต้องและมีคุณภาพสูง

หน้านี้จะแนะนำแนวคิดพื้นฐาน กลยุทธ์ และแนวทางปฏิบัติแนะนำเพื่อช่วยให้คุณเริ่มต้นออกแบบพรอมต์เพื่อใช้ประโยชน์สูงสุดจากโมเดล AI ของ Gemini

คู่มือการใช้พรอมต์เฉพาะหัวข้อ

หากกำลังมองหากลยุทธ์พรอมต์ที่เฉพาะเจาะจงมากขึ้น ดูคู่มือการเขียนพรอมต์อื่นๆ ของเราในหัวข้อต่อไปนี้

คุณดูพรอมต์ตัวอย่างอื่นๆ ได้ในแกลเลอรีพรอมต์ ซึ่งออกแบบมาเพื่อแสดงแนวคิดต่างๆ ที่แชร์ในคู่มือนี้แบบอินเทอร์แอกทีฟ

วิธีการที่ชัดเจนและเจาะจง

วิธีที่มีประสิทธิภาพและประสิทธิผลในการปรับแต่งลักษณะการทำงานของโมเดลคือการให้วิธีการที่ชัดเจนและเจาะจง คำสั่งอาจอยู่ในรูปแบบคำถาม งานแบบทีละขั้นตอน หรือซับซ้อนถึงขั้นการทำแผนที่ประสบการณ์และความคิดของผู้ใช้

อินพุต

อินพุตคือข้อความที่จำเป็นในพรอมต์ที่คุณต้องการให้โมเดลตอบกลับ อินพุตอาจเป็นคำถามที่โมเดลตอบ (อินพุตคำถาม) งานที่โมเดลดำเนินการ (อินพุตงาน) เอนทิตีที่โมเดลดำเนินการ (อินพุตเอนทิตี) หรืออินพุตบางส่วนที่โมเดลทำให้เสร็จสมบูรณ์หรือดำเนินการต่อ (อินพุตการเติมข้อความอัตโนมัติ)

ประเภทอินพุต พรอมต์ เอาต์พุตที่สร้างขึ้น
คำถาม

    What's a good name for a flower shop that specializes in selling bouquets of
    dried flowers? Create a list of 5 options with just the names.

    Here are 5 names for a flower shop specializing in dried flowers:

    1. Everlasting Blooms
    2. Dried & Delightful
    3. The Petal Preserve
    4. Whispers of Wildflowers
    5. Forever Blooms
    
งาน
    Give me a simple list of just the things that I must bring on a camping trip. The list should have 5 items.
    1. **Tent:** Your shelter from the elements.
    2. **Sleeping Bag:** Stay warm and comfortable.
    3. **Sleeping Pad:** Insulation and cushioning for a good night's sleep.
    4. **Headlamp or Flashlight:** Light for nighttime activities.
    5. **First Aid Kit:** Be prepared for minor injuries.
เอนทิตี

    Classify the following items as [large, small]:
Elephant
Mouse
Snail

Here's the classification:

* **Elephant:** Large
* **Mouse:** Small
* **Snail:** Small
    

การป้อนข้อมูลบางส่วน

โมเดลภาษาแบบ Generative ทำงานเหมือนเครื่องมือเติมข้อความอัตโนมัติขั้นสูง เมื่อคุณ ระบุเนื้อหาบางส่วน โมเดลจะสามารถระบุเนื้อหาที่เหลือหรือเนื้อหาที่ โมเดลคิดว่าเป็นการต่อจากเนื้อหานั้นเป็นคำตอบได้ เมื่อทำเช่นนั้น หากคุณ ใส่ตัวอย่างหรือบริบท โมเดลจะพิจารณาตัวอย่างหรือบริบทเหล่านั้น

ตัวอย่างต่อไปนี้แสดงพรอมต์ที่มีคำสั่งและอินพุตเอนทิตี

For the given order, return a JSON object that has the fields cheeseburger, hamburger, fries, or
drink, with the value being the quantity.

Order: A burger and a drink.
  
{
  "cheeseburger": 0,
  "hamburger": 1,
  "fries": 0,
  "drink": 1
}
  

แม้ว่าโมเดลจะทำตามพรอมต์ แต่การเขียนวิธีการด้วยภาษาธรรมชาติบางครั้งอาจเป็นเรื่องท้าทายและทำให้โมเดลต้องตีความเองเป็นจำนวนมาก เช่น เมนูของร้านอาหารอาจมีหลายรายการ หากต้องการลดขนาดของการตอบกลับ JSON คุณอาจต้องละเว้นรายการที่ไม่ได้สั่งซื้อ ใน กรณีนี้ คุณสามารถระบุตัวอย่างและคำนำหน้าคำตอบ แล้วปล่อยให้โมเดล เติมข้อความให้สมบูรณ์ได้

Valid fields are cheeseburger, hamburger, fries, and drink.
Order: Give me a cheeseburger and fries
Output:
```
{
  "cheeseburger": 1,
  "fries": 1
}
```
Order: I want two burgers, a drink, and fries.
Output:
  
```
{
  "hamburger": 2,
  "drink": 1,
  "fries": 1
}
```
  

สังเกตว่า "ชีสเบอร์เกอร์" ถูกยกเว้นจากเอาต์พุตเนื่องจากไม่ได้เป็นส่วนหนึ่งของคำสั่งซื้อ

แม้ว่าคุณจะระบุรูปแบบของออบเจ็กต์การตอบกลับ JSON แบบง่ายได้โดยใช้พรอมต์ แต่เราขอแนะนำให้ใช้ฟีเจอร์เอาต์พุตที่มีโครงสร้างของ Gemini API เมื่อระบุสคีมา JSON ที่ซับซ้อนมากขึ้นสำหรับการตอบกลับ

ข้อจำกัด

ระบุข้อจำกัดในการอ่านพรอมต์หรือการสร้างคำตอบ คุณสามารถบอกโมเดลว่าควรทำอะไรและไม่ควรทำอะไร เช่น คุณสามารถระบุข้อจำกัดในพรอมต์เกี่ยวกับความยาวของสรุปที่ต้องการได้ ดังนี้

Summarize this text in one sentence:
Text: A quantum computer exploits quantum mechanical phenomena to perform calculations exponentially
faster than any modern traditional computer. At very tiny scales, physical matter acts as both
particles and as waves, and quantum computing uses specialized hardware to leverage this behavior.
The operating principles of quantum devices is beyond the scope of classical physics. When deployed
at scale, quantum computers could be used in a wide variety of applications such as: in
cybersecurity to break existing encryption methods while helping researchers create new ones, in
meteorology to develop better weather forecasting etc. However, the current state of the art quantum
computers are still largely experimental and impractical.
    

      Exploiting quantum mechanical phenomena, quantum computers can perform calculations exponentially faster than traditional computers for potential applications like cybersecurity and meteorology, although they are currently largely experimental and impractical.
    

รูปแบบคำตอบ

คุณสามารถให้คำสั่งที่ระบุรูปแบบของคำตอบได้ ตัวอย่างเช่น คุณสามารถขอให้จัดรูปแบบคำตอบเป็นตาราง รายการสัญลักษณ์หัวข้อย่อย การเสนอขายโดยใช้เวลาสั้นๆ คีย์เวิร์ด ประโยค หรือย่อหน้า คำสั่งของระบบต่อไปนี้จะบอกให้โมเดล ตอบกลับในลักษณะที่เป็นการสนทนามากขึ้น

    All questions should be answered comprehensively with details, unless the user requests a concise response specifically.
  
    What is a smart way to make a business that sells DVD's in 2026?
  
Starting a business selling DVDs in 2026 presents significant challenges due to the overwhelming dominance of digital streaming and on-demand services; a "smart" approach would therefore require a highly specialized niche, a strong value proposition beyond just the disc, and likely a focus on community or collector markets rather than mainstream consumption.

Here's a breakdown of what a smart DVD business in 2026 would likely entail:

1. Extreme Niche Specialization: You cannot compete with streaming libraries. Your business must focus on what digital doesn't offer easily or at all. This could include:

    * Out-of-Print & Rare Titles: Sourcing films or TV shows that have never been released digitally or are currently unavailable on major streaming platforms.
    ....
  

จัดรูปแบบคำตอบด้วยกลยุทธ์การเติมข้อความ

กลยุทธ์การเติมข้อความยังช่วยจัดรูปแบบคำตอบได้ด้วย ตัวอย่างต่อไปนี้จะแจ้งให้โมเดลสร้างโครงร่างเรียงความ

Create an outline for an essay about hummingbirds.
  
Here is a possible outline for an essay about hummingbirds:

I. Introduction
A. Hook: Start with a captivating fact or description about hummingbirds (e.g., their speed, iridescent colors, or tiny size).
B. Background: Briefly introduce hummingbirds – where they are found (Americas), their reputation as unique birds.
C. Thesis Statement: State the main point of the essay, which could be about the remarkable adaptations, behaviors, and ecological importance of hummingbirds.

II. Appearance and Identification
.....
  

พรอมต์ไม่ได้ระบุรูปแบบสำหรับเค้าโครง และโมเดลเลือกรูปแบบให้คุณ หากต้องการให้โมเดลแสดงผลโครงร่างในรูปแบบที่เฉพาะเจาะจง คุณสามารถเพิ่มข้อความที่แสดงถึงจุดเริ่มต้นของโครงร่างและให้โมเดลเติมข้อความให้สมบูรณ์ตามรูปแบบที่คุณเริ่มไว้

Create an outline for an essay about hummingbirds.
I. Introduction
   *
  
Okay, here is an outline for an essay about hummingbirds, starting from the introduction you provided:

I. Introduction
* Hook: Start with a captivating fact or description about hummingbirds (e.g., their speed, iridescent colors, or tiny size).
* Background: Briefly introduce hummingbirds – where they are found (Americas), their reputation as unique birds, and their general characteristics.
* Thesis Statement: State the main point of the essay, focusing on the remarkable adaptations, behaviors, and ecological significance that make hummingbirds extraordinary.
.....
  

พรอมต์แบบ Zero-Shot กับ Few-Shot

คุณสามารถใส่ตัวอย่างในพรอมต์เพื่อแสดงให้โมเดลเห็นว่าการตอบที่ถูกต้อง มีลักษณะอย่างไร โมเดลจะพยายามระบุรูปแบบและความสัมพันธ์จาก ตัวอย่างและนำไปใช้เมื่อสร้างคำตอบ พรอมต์ที่มีตัวอย่าง 2-3 รายการเรียกว่าพรอมต์แบบ Few-Shot ส่วนพรอมต์ที่ไม่มีตัวอย่างเรียกว่าพรอมต์แบบ Zero-Shot Few-Shot Prompt มักใช้เพื่อควบคุมการจัดรูปแบบ การใช้ถ้อยคำ การกำหนดขอบเขต หรือรูปแบบทั่วไปของการตอบสนองของโมเดล ใช้ตัวอย่างที่เฉพาะเจาะจงและหลากหลายเพื่อช่วยให้โมเดลจำกัดขอบเขตการโฟกัสและสร้างผลลัพธ์ที่แม่นยำยิ่งขึ้น

เราขอแนะนำให้ใส่ตัวอย่างแบบ Few-Shot ในพรอมต์เสมอ พรอมต์ที่ไม่มีตัวอย่างแบบ Few-Shot มีแนวโน้มที่จะมีประสิทธิภาพน้อยกว่า ในความเป็นจริง คุณสามารถนำ คำสั่งออกจากพรอมต์ได้หากตัวอย่างของคุณแสดงให้เห็นถึง งานที่กำลังทำอยู่ได้อย่างชัดเจน

ข้อความแจ้งแบบ Zero-Shot ต่อไปนี้ขอให้โมเดลเลือกคำอธิบายที่ดีที่สุด

Please choose the best explanation to the question:

Question: How is snow formed?
Explanation1: Snow is formed when water vapor in the air freezes into ice
crystals in the atmosphere, which can combine and grow into snowflakes as they
fall through the atmosphere and accumulate on the ground.
Explanation2: Water vapor freezes into ice crystals forming snow.
Answer:
  
Explanation1 is the better explanation because it provides more detail on the
process, including how ice crystals combine and grow into snowflakes as they
fall through the atmosphere.
  

หาก Use Case ของคุณกำหนดให้โมเดลสร้างคำตอบที่กระชับ คุณสามารถใส่ตัวอย่างในพรอมต์ที่ให้ความสำคัญกับคำตอบที่กระชับได้

พรอมต์ต่อไปนี้แสดงตัวอย่าง 2 รายการที่แสดงความต้องการคำอธิบายที่สั้นกว่า ในคำตอบ คุณจะเห็นว่าตัวอย่างได้แนะนำโมเดลให้เลือกคำอธิบายที่สั้นกว่า (Explanation2) แทนที่จะเป็นคำอธิบายที่ยาวกว่า (Explanation1) เหมือนที่เคยทำก่อนหน้านี้

Below are some examples showing a question, explanation, and answer format:

Question: Why is the sky blue?
Explanation1: The sky appears blue because of Rayleigh scattering, which causes
shorter blue wavelengths of light to be scattered more easily than longer red
wavelengths, making the sky look blue.
Explanation2: Due to Rayleigh scattering effect.
Answer: Explanation2

Question: What is the cause of earthquakes?
Explanation1: Sudden release of energy in the Earth's crust.
Explanation2: Earthquakes happen when tectonic plates suddenly slip or break
apart, causing a release of energy that creates seismic waves that can shake the
ground and cause damage.
Answer: Explanation1

Now, Answer the following question given the example formats above:

Question: How is snow formed?
Explanation1: Snow is formed when water vapor in the air freezes into ice
crystals in the atmosphere, which can combine and grow into snowflakes as they
fall through the atmosphere and accumulate on the ground.
Explanation2: Water vapor freezes into ice crystals forming snow.
Answer:
  
Answer: Explanation2
  

จำนวนตัวอย่างที่เหมาะสม

โมเดลอย่าง Gemini มักจะตรวจจับรูปแบบได้โดยใช้ตัวอย่างเพียงไม่กี่รายการ แต่คุณอาจต้องทดลองจำนวนตัวอย่างที่จะระบุในพรอมต์เพื่อให้ได้ผลลัพธ์ที่ดีที่สุด ในขณะเดียวกัน หากคุณใส่ตัวอย่างมากเกินไป โมเดลอาจเริ่มโอเวอร์ฟิต คำตอบให้ตรงกับตัวอย่าง

ใช้รูปแบบที่สม่ำเสมอ

ตรวจสอบว่าโครงสร้างและการจัดรูปแบบของตัวอย่างแบบ Few-Shot เหมือนกันเพื่อ หลีกเลี่ยงการตอบกลับที่มีรูปแบบไม่พึงประสงค์ วัตถุประสงค์หลักอย่างหนึ่งของการเพิ่มตัวอย่าง Few-Shot ในพรอมต์คือการแสดงรูปแบบการตอบกลับให้โมเดลเห็น ดังนั้น คุณจึงต้องตรวจสอบว่าตัวอย่างทั้งหมดมีรูปแบบที่สอดคล้องกัน โดยเฉพาะอย่างยิ่งการให้ความสำคัญกับแท็ก XML, ช่องว่าง, บรรทัดใหม่ และตัวแยกตัวอย่าง

เพิ่มบริบท

คุณสามารถใส่คำสั่งและข้อมูลในพรอมต์ที่โมเดลต้องใช้เพื่อแก้ปัญหา แทนที่จะคิดว่าโมเดลมีข้อมูลที่จำเป็นทั้งหมด ข้อมูลบริบทนี้จะช่วยให้โมเดลเข้าใจข้อจำกัดและรายละเอียดของสิ่งที่คุณขอให้ทำ

ตัวอย่างต่อไปนี้ขอให้โมเดลให้คำแนะนำในการแก้ปัญหาสำหรับเราเตอร์

What should I do to fix my disconnected wifi? The light on my Google
Wifi router is yellow and blinking slowly.
  
  A yellow blinking light on your Google Wifi router usually indicates a problem
  with the internet connection. Here are some steps to troubleshoot and fix the
  issue:
  1. Restart your router and modem:
    - Unplug your modem from the power outlet and wait for 30 seconds.
    - Plug your modem back in and wait for it to fully boot up.
    - Unplug your Google Wifi router and wait for 30 seconds.
    - Plug your Google Wifi router back in and wait for it to fully boot up.
.....
  

คำตอบดูเหมือนข้อมูลการแก้ปัญหาทั่วไปที่ไม่ได้เจาะจง เราเตอร์หรือสถานะของไฟแสดงสถานะ LED

หากต้องการปรับแต่งคำตอบสำหรับเราเตอร์ที่เฉพาะเจาะจง คุณสามารถเพิ่มคู่มือการแก้ปัญหาของ เราเตอร์ลงในพรอมต์เป็นบริบทเพื่อให้ AI อ้างอิงเมื่อให้คำตอบ

Answer the question using the text below. Respond with only the text provided.
Question: What should I do to fix my disconnected wifi? The light on my Google Wifi router is yellow and blinking slowly.

Text:
Color: Slowly pulsing yellow
What it means: There is a network error.
What to do:
Check that the Ethernet cable is connected to both your router and your modem and both devices are turned on. You might need to unplug and plug in each device again.

Color: Fast blinking yellow
What it means: You are holding down the reset button and are factory resetting this device.
What to do:
If you keep holding down the reset button, after about 12 seconds, the light will turn solid yellow. Once it is solid yellow, let go of the factory reset button.

Color: Solid yellow
What it means: Router is factory resetting.
What to do:
This can take up to 10 minutes. When it's done, the device will reset itself and start pulsing white, letting you know it's ready for setup.

Color: Solid red
What it means: Something is wrong.
What to do:
Critical failure. Factory reset the router. If the light stays red, contact Wifi customer support.
  
Check that the Ethernet cable is connected to both your router and your modem and both devices are turned on. You might need to unplug and plug in each device again.
  

แบ่งพรอมต์ออกเป็นคอมโพเนนต์

สำหรับกรณีการใช้งานที่ต้องใช้พรอมต์ที่ซับซ้อน คุณสามารถช่วยให้โมเดลจัดการความซับซ้อนนี้ได้โดยการแบ่งออกเป็นองค์ประกอบที่ง่ายขึ้น

  1. แบ่งย่อยคำสั่ง: แทนที่จะใส่คำสั่งหลายรายการในพรอมต์เดียว ให้สร้างพรอมต์ 1 รายการต่อคำสั่ง 1 รายการ คุณเลือกได้ว่าจะประมวลผลพรอมต์ใดตามข้อมูลที่ผู้ใช้ป้อน

  2. เชื่อมโยงพรอมต์: สำหรับงานที่ซับซ้อนซึ่งเกี่ยวข้องกับขั้นตอนตามลำดับหลายขั้นตอน ให้กำหนดแต่ละขั้นตอนเป็นพรอมต์และเชื่อมโยงพรอมต์เข้าด้วยกันตามลำดับ ในเชนพรอมต์แบบต่อเนื่องนี้ เอาต์พุตของพรอมต์หนึ่งในลำดับจะกลายเป็นอินพุตของพรอมต์ถัดไป เอาต์พุตของพรอมต์สุดท้ายในลำดับ คือเอาต์พุตสุดท้าย

  3. รวมคำตอบ: การรวมคือเมื่อคุณต้องการทำงานแบบขนานที่แตกต่างกันในส่วนต่างๆ ของข้อมูลและรวมผลลัพธ์เพื่อสร้างเอาต์พุตสุดท้าย ตัวอย่างเช่น คุณสามารถบอกให้โมเดลดำเนินการอย่างหนึ่งกับข้อมูลส่วนแรก ดำเนินการอีกอย่างหนึ่งกับข้อมูลที่เหลือ และรวบรวมผลลัพธ์

ทดลองใช้พารามิเตอร์โมเดล

การเรียกแต่ละครั้งที่คุณส่งไปยังโมเดลจะมีค่าพารามิเตอร์ที่ควบคุมวิธีที่โมเดลสร้างคำตอบ โมเดลสามารถสร้างผลลัพธ์ที่แตกต่างกันสำหรับค่าพารามิเตอร์ที่แตกต่างกัน ทดลองใช้ค่าพารามิเตอร์ต่างๆ เพื่อให้ได้ค่าที่ดีที่สุดสำหรับงาน พารามิเตอร์ที่ใช้ได้สำหรับโมเดลต่างๆ อาจแตกต่างกัน พารามิเตอร์ที่พบบ่อยที่สุดมีดังนี้

  1. โทเค็นเอาต์พุตสูงสุด: ระบุจำนวนโทเค็นสูงสุดที่สร้างได้ในการตอบกลับ โทเค็นมีประมาณ 4 อักขระ 100 โทเค็นจะเท่ากับประมาณ 60-80 คำ

  2. อุณหภูมิ: อุณหภูมิจะควบคุมระดับความสุ่มในการเลือกโทเค็น ระบบจะใช้ค่าพารามิเตอร์ Temperature สำหรับการสุ่มตัวอย่างระหว่างการสร้างคำตอบ ซึ่งจะเกิดขึ้นเมื่อใช้ topP และ topK อุณหภูมิต่ำเหมาะสำหรับพรอมต์ที่ต้องการคำตอบเชิงกำหนดมากขึ้นหรือปลายเปิดน้อยลง ส่วนอุณหภูมิสูงอาจให้ผลลัพธ์ที่หลากหลายหรือสร้างสรรค์มากขึ้น อุณหภูมิ 0 เป็นแบบเชิงกำหนด ซึ่งหมายความว่าระบบจะเลือกคำตอบที่มีความน่าจะเป็นสูงสุดเสมอ

  3. topK: พารามิเตอร์ topK จะเปลี่ยนวิธีที่โมเดลเลือกโทเค็นสำหรับเอาต์พุต topK ที่มีค่า 1 หมายความว่าโทเค็นที่เลือกมีความน่าจะเป็นมากที่สุดในบรรดาโทเค็นทั้งหมดในคำศัพท์ของโมเดล (เรียกอีกอย่างว่าการถอดรหัสแบบตะกละ) ขณะที่ topK ที่มีค่า 3 หมายความว่าระบบจะเลือกโทเค็นถัดไปจากโทเค็นที่มีความน่าจะเป็นมากที่สุด 3 รายการโดยใช้ค่าอุณหภูมิ สำหรับแต่ละขั้นตอนการเลือกโทเค็น ระบบจะสุ่มตัวอย่างโทเค็นที่มีความน่าจะเป็นสูงสุด topK จากนั้นระบบจะกรองโทเค็นเพิ่มเติมตามtopP โดยเลือกโทเค็นสุดท้ายโดยใช้การสุ่มตัวอย่างอุณหภูมิ

  4. topP: พารามิเตอร์ topP จะเปลี่ยนวิธีที่โมเดลเลือกโทเค็นสำหรับเอาต์พุต ระบบจะเลือกโทเค็นจากโทเค็นที่มีความเป็นไปได้มากที่สุดไปจนถึงน้อยที่สุดจนกว่าผลรวมของ ความน่าจะเป็นจะเท่ากับค่า topP ตัวอย่างเช่น หากโทเค็น A, B และ C มีความน่าจะเป็น 0.3, 0.2 และ 0.1 และค่า topP เป็น 0.5 โมเดลจะเลือก A หรือ B เป็นโทเค็นถัดไปโดยใช้อุณหภูมิและไม่รวม C เป็นตัวเลือก ค่า topP เริ่มต้นคือ 0.95

  5. stop_sequences: ตั้งค่าลำดับการหยุดเพื่อ บอกให้โมเดลหยุดสร้างเนื้อหา ลำดับการหยุดอาจเป็นลำดับอักขระใดก็ได้ พยายามหลีกเลี่ยงการใช้ลำดับอักขระที่อาจปรากฏในเนื้อหาที่สร้างขึ้น

กลยุทธ์การปรับพรอมต์เพื่อถามซ้ำ

บางครั้งการออกแบบพรอมต์อาจต้องมีการทำซ้ำ 2-3 ครั้งก่อน จึงจะได้คำตอบที่ต้องการอย่างสม่ำเสมอ ส่วนนี้จะให้คำแนะนำเกี่ยวกับสิ่งที่คุณลองทำได้เมื่อปรับแต่งพรอมต์ซ้ำๆ

  1. ใช้ถ้อยคำที่แตกต่างกัน: การใช้คำหรือถ้อยคำที่แตกต่างกันในพรอมต์มักจะให้คำตอบที่แตกต่างกันจากโมเดล แม้ว่าทั้งหมดจะมีความหมายเหมือนกันก็ตาม หากไม่ได้รับผลลัพธ์ที่คาดไว้จากพรอมต์ ให้ลอง เรียบเรียงใหม่

    Version 1:
    How do I bake a pie?
    
    Version 2:
    Suggest a recipe for a pie.
    
    Version 3:
    What's a good pie recipe?
      

  2. เปลี่ยนไปใช้คำสั่งที่คล้ายกัน: หากคุณไม่สามารถทำให้โมเดลทำตามคำสั่งสำหรับงานหนึ่งๆ ได้ ให้ลองให้คำสั่งสำหรับงานที่คล้ายกันซึ่งให้ผลลัพธ์เดียวกัน

    พรอมต์นี้จะบอกให้โมเดลจัดหมวดหมู่หนังสือโดยใช้หมวดหมู่ที่กำหนดไว้ล่วงหน้า

    Which category does The Odyssey belong to:
    thriller
    sci-fi
    mythology
    biography
      
        The Odyssey belongs to the category of **mythology**. 
    
        Here's why:
    
        * **Mythology:** The Odyssey tells the story of Odysseus, a hero from Greek mythology, and his
        journey home after the Trojan War. It features gods, monsters, and supernatural events common to
        Greek mythology.
    .....
      

    คำตอบถูกต้อง แต่โมเดลไม่ได้อยู่ภายในขอบเขตของตัวเลือก นอกจากนี้ คุณยังต้องการให้โมเดลตอบกลับด้วยตัวเลือกใดตัวเลือกหนึ่งแทนที่จะเป็นประโยคเต็ม ในกรณีนี้ คุณสามารถเปลี่ยนคำสั่งเป็นคำถามแบบหลายตัวเลือกและขอให้โมเดลเลือกตัวเลือกได้

    Multiple choice problem: Which of the following options describes the book The Odyssey?
    Options:

    • thriller
    • sci-fi
    • mythology
    • biography
    The correct answer is mythology. 
    

  3. เปลี่ยนลำดับเนื้อหาของพรอมต์: บางครั้งลำดับของเนื้อหาในพรอมต์อาจส่งผลต่อคำตอบ ลองเปลี่ยนลำดับเนื้อหาและดู ว่าการดำเนินการดังกล่าวส่งผลต่อคำตอบอย่างไร

    Version 1:
    [examples]
    [context]
    [input]
    
    Version 2:
    [input]
    [examples]
    [context]
    
    Version 3:
    [examples]
    [input]
    [context]
    

คำตอบสำรอง

คำตอบสำรองคือคำตอบที่โมเดลแสดงเมื่อพรอมต์หรือคำตอบทริกเกอร์ตัวกรองความปลอดภัย ตัวอย่างคำตอบสำรองคือ "ฉันช่วยคุณเรื่องนี้ไม่ได้เพราะเป็นเพียงโมเดลภาษา"

หากโมเดลตอบกลับด้วยคำตอบสำรอง ให้ลองเพิ่มอุณหภูมิ

การอ้างอิงข้อมูลและการเรียกใช้โค้ด

Gemini สามารถใช้เครื่องมือเพื่อหลีกเลี่ยงการหลอนในสถานการณ์ที่อาจทำให้ได้คำตอบที่ไม่ถูกต้อง

การเชื่อมต่อแหล่งข้อมูลกับ Google Search จะเชื่อมต่อโมเดล Gemini กับเนื้อหาเว็บแบบเรียลไทม์ และควรเปิดใช้ทุกครั้งที่โมเดลอาจต้องทราบข้อเท็จจริงที่คลุมเครือหรือล่าสุด

เครื่องมือเรียกใช้โค้ดของ Gemini ช่วยให้โมเดลสร้างและเรียกใช้โค้ด Python ได้ และควรเปิดใช้เมื่อใดก็ตามที่โมเดลจำเป็นต้องดำเนินการทางคณิตศาสตร์ การนับ หรือการคำนวณใดๆ

Gemini 3

โมเดล Gemini 3 ออกแบบมาเพื่อการให้เหตุผลขั้นสูงและการทำตามคำสั่ง โมเดลจะตอบสนองต่อพรอมต์ที่ตรงไปตรงมา มีโครงสร้างที่ดี และกำหนดงานและข้อจำกัดอย่างชัดเจนได้ดีที่สุด เราขอแนะนำให้ทำตามแนวทางปฏิบัติต่อไปนี้เพื่อให้ได้ผลลัพธ์ที่ดีที่สุดจาก Gemini 3

หลักการสำคัญในการเขียนพรอมต์

  • แม่นยำและตรงประเด็น: ระบุเป้าหมายอย่างชัดเจนและกระชับ หลีกเลี่ยงการใช้ภาษาที่ไม่จำเป็นหรือโน้มน้าวใจมากเกินไป
  • ใช้โครงสร้างที่สอดคล้องกัน: ใช้ตัวคั่นที่ชัดเจนเพื่อแยกส่วนต่างๆ ของพรอมต์ แท็กรูปแบบ XML (เช่น <context>, <task>) หรือ ส่วนหัว Markdown จะมีประสิทธิภาพ เลือกรูปแบบใดรูปแบบหนึ่งและใช้รูปแบบนั้นอย่างสม่ำเสมอภายในพรอมต์เดียว
  • กำหนดพารามิเตอร์: อธิบายคำหรือพารามิเตอร์ที่กำกวมอย่างชัดเจน
  • ควบคุมความละเอียดของเอาต์พุต: โดยค่าเริ่มต้น โมเดล Gemini 3 จะให้คำตอบที่ตรงไปตรงมาและมีประสิทธิภาพ หากต้องการคำตอบที่เป็นการสนทนาหรือละเอียดมากขึ้น คุณต้องระบุไว้อย่างชัดเจนในคำสั่ง
  • จัดการอินพุตหลายรูปแบบอย่างสอดคล้องกัน: เมื่อใช้ข้อความ รูปภาพ เสียง หรือวิดีโอ ให้ถือว่าอินพุตเหล่านี้เป็นอินพุตที่มีความสำคัญเท่ากัน ตรวจสอบว่าคำสั่งของคุณอ้างอิงถึงแต่ละโมดัลลิตีอย่างชัดเจนตามความจำเป็น
  • จัดลำดับความสำคัญของคำสั่งที่สำคัญ: ใส่ข้อจำกัดด้านพฤติกรรมที่สำคัญ คำจำกัดความของบทบาท (Persona) และข้อกำหนดรูปแบบเอาต์พุตในคำสั่งของระบบหรือที่จุดเริ่มต้นของพรอมต์ของผู้ใช้
  • โครงสร้างสำหรับบริบทที่ยาว: เมื่อให้บริบทจำนวนมาก (เช่น เอกสาร โค้ด) ให้ระบุบริบททั้งหมดก่อน วางคำสั่งหรือคำถามที่เฉพาะเจาะจงไว้ที่ท้ายพรอมต์
  • บริบทของ Anchor: หลังจากบล็อกข้อมูลขนาดใหญ่ ให้ใช้วลีเปลี่ยนผ่านที่ชัดเจนเพื่อเชื่อมโยงบริบทกับคำถาม เช่น "จากข้อมูลข้างต้น..."

กลยุทธ์ Gemini 3 Flash

  • ความแม่นยำของวันปัจจุบัน: เพิ่มข้อความต่อไปนี้ลงในคำสั่งของระบบ เพื่อช่วยให้โมเดลพิจารณาวันปัจจุบันในปี 2026

    For time-sensitive user queries that require up-to-date information, you
    MUST follow the provided current time (date and year) when formulating
    search queries in tool calls. Remember it is 2026 this year.
    
  • ความแม่นยำของการตัดข้อมูล: เพิ่มเงื่อนไขต่อไปนี้ลงในคำสั่งของระบบ เพื่อให้โมเดลทราบการตัดข้อมูลของตน

    Your knowledge cutoff date is January 2025.
    
  • ประสิทธิภาพการอ้างอิง: เพิ่มส่วนต่อไปนี้ลงในคำสั่งของระบบ (พร้อมแก้ไขตามความเหมาะสม) เพื่อปรับปรุงความสามารถของโมเดลในการอ้างอิงคำตอบในบริบทที่ระบุ

    You are a strictly grounded assistant limited to the information provided in
    the User Context. In your answers, rely **only** on the facts that are
    directly mentioned in that context. You must **not** access or utilize your
    own knowledge or common sense to answer. Do not assume or infer from the
    provided facts; simply report them exactly as they appear. Your answer must
    be factual and fully truthful to the provided text, leaving absolutely no
    room for speculation or interpretation. Treat the provided context as the
    absolute limit of truth; any facts or details that are not directly
    mentioned in the context must be considered **completely untruthful** and
    **completely unsupported**. If the exact answer is not explicitly written in
    the context, you must state that the information is not available.
    

การปรับปรุงการให้เหตุผลและการวางแผน

โมเดล Gemini 2.5 และ 3 Series จะสร้างข้อความ "การคิด" ภายในโดยอัตโนมัติเพื่อปรับปรุงประสิทธิภาพการให้เหตุผล ด้วยเหตุนี้ โดยทั่วไปแล้วจึงไม่จำเป็นต้องมีโครงร่าง แผน หรือขั้นตอนการให้เหตุผลโดยละเอียดของโมเดลในการตอบกลับที่แสดงผล สำหรับปัญหาที่ต้องใช้การให้เหตุผลอย่างมาก คำของ่ายๆ เช่น "คิดให้ดีก่อนตอบ" สามารถปรับปรุงประสิทธิภาพได้ แม้ว่าจะต้องใช้โทเค็นการคิดเพิ่มเติมก็ตาม

ดูรายละเอียดเพิ่มเติมได้ในเอกสารประกอบเกี่ยวกับการคิดของ Gemini

ตัวอย่างพรอมต์ที่มีโครงสร้าง

การใช้แท็กหรือ Markdown จะช่วยให้โมเดลแยกความแตกต่างระหว่างคำสั่ง บริบท และงานได้

ตัวอย่าง XML

<role>
You are a helpful assistant.
</role>

<constraints>
1. Be objective.
2. Cite sources.
</constraints>

<context>
[Insert User Input Here - The model knows this is data, not instructions]
</context>

<task>
[Insert the specific user request here]
</task>

ตัวอย่างมาร์กดาวน์

# Identity
You are a senior solution architect.

# Constraints
- No external libraries allowed.
- Python 3.11+ syntax only.

# Output format
Return a single code block.

ตัวอย่างเทมเพลตที่รวมแนวทางปฏิบัติแนะนำ

เทมเพลตนี้รวบรวมหลักการสำคัญสำหรับการเขียนพรอมต์ด้วย Gemini 3 อย่าลืมปรับปรุงและแก้ไขให้เหมาะกับ Use Case ที่เฉพาะเจาะจงของคุณเสมอ

คำสั่งของระบบ:

<role>
You are Gemini 3, a specialized assistant for [Insert Domain, e.g., Data Science].
You are precise, analytical, and persistent.
</role>

<instructions>
1. **Plan**: Analyze the task and create a step-by-step plan.
2. **Execute**: Carry out the plan.
3. **Validate**: Review your output against the user's task.
4. **Format**: Present the final answer in the requested structure.
</instructions>

<constraints>
- Verbosity: [Specify Low/Medium/High]
- Tone: [Specify Formal/Casual/Technical]
</constraints>

<output_format>
Structure your response as follows:
1. **Executive Summary**: [Short overview]
2. **Detailed Response**: [The main content]
</output_format>

พรอมต์ของผู้ใช้:

<context>
[Insert relevant documents, code snippets, or background info here]
</context>

<task>
[Insert specific user request here]
</task>

<final_instruction>
Remember to think step-by-step before answering.
</final_instruction>

เวิร์กโฟลว์แบบ Agentic

สำหรับเวิร์กโฟลว์ Agentic เชิงลึก มักจะต้องใช้คำสั่งเฉพาะเพื่อควบคุมวิธีที่โมเดลให้เหตุผล วางแผน และดำเนินงาน แม้ว่า Gemini จะมีประสิทธิภาพทั่วไปที่ยอดเยี่ยม แต่เอเจนต์ที่ซับซ้อนมักกำหนดให้คุณกำหนดค่าการแลกเปลี่ยนระหว่างต้นทุนการคำนวณ (เวลาในการตอบสนองและโทเค็น) กับความแม่นยำของงาน

เมื่อออกแบบพรอมต์สำหรับเอเจนต์ ให้พิจารณามิติข้อมูลพฤติกรรมต่อไปนี้ที่คุณสามารถควบคุมในเอเจนต์ได้

การให้เหตุผลและกลยุทธ์

การกำหนดค่าวิธีที่โมเดลคิดและวางแผนก่อนดำเนินการ

  • การแยกย่อยเชิงตรรกะ: กำหนดความละเอียดที่โมเดลต้องใช้ในการวิเคราะห์ข้อจำกัด ข้อกำหนดเบื้องต้น และลำดับการดำเนินการ
  • การวินิจฉัยปัญหา: ควบคุมความลึกของการวิเคราะห์เมื่อระบุสาเหตุและการใช้การให้เหตุผลแบบอนุมานของโมเดล กำหนดว่าโมเดลควรยอมรับคำตอบที่ชัดเจนที่สุดหรือสำรวจคำอธิบายที่ซับซ้อนและมีความเป็นไปได้น้อยกว่า
  • ความครอบคลุมของข้อมูล: การแลกเปลี่ยนระหว่างการวิเคราะห์นโยบายและเอกสารที่มีอยู่ทั้งหมดกับการจัดลําดับความสําคัญของประสิทธิภาพและความเร็ว

การดำเนินการและความน่าเชื่อถือ

การกำหนดค่าวิธีการทำงานของ Agent โดยอัตโนมัติและจัดการอุปสรรค

  • ความสามารถในการปรับตัว: วิธีที่โมเดลตอบสนองต่อข้อมูลใหม่ พิจารณาว่าควรยึดตามแผนเริ่มต้นอย่างเคร่งครัดหรือเปลี่ยนแผนทันทีเมื่อการสังเกตขัดแย้งกับสมมติฐาน
  • ความพยายามและการกู้คืน: ระดับที่โมเดลพยายามแก้ไขข้อผิดพลาดด้วยตนเอง ความต่อเนื่องสูงจะเพิ่มอัตราความสำเร็จ แต่มีความเสี่ยงที่จะมีค่าใช้จ่ายโทเค็นสูงขึ้นหรือเกิดลูป
  • การประเมินความเสี่ยง: ตรรกะในการประเมินผลลัพธ์ แยกความแตกต่างอย่างชัดเจนระหว่างการดำเนินการสำรวจที่มีความเสี่ยงต่ำ (การอ่าน) และการเปลี่ยนแปลงสถานะที่มีความเสี่ยงสูง (การเขียน)

การโต้ตอบและเอาต์พุต

การกำหนดค่าวิธีที่ Agent สื่อสารกับผู้ใช้และจัดรูปแบบผลลัพธ์

  • ความกำกวมและการจัดการสิทธิ์: กำหนดว่าเมื่อใดที่โมเดลได้รับอนุญาตให้ตั้งสมมติฐาน และเมื่อใดที่โมเดลต้องหยุดการดำเนินการชั่วคราวเพื่อขอคำชี้แจงหรือสิทธิ์จากผู้ใช้
  • การกำหนดปริมาณข้อมูล: ควบคุมปริมาณข้อความที่สร้างขึ้นควบคู่ไปกับการเรียกใช้เครื่องมือ ซึ่งจะกำหนดว่าโมเดลจะอธิบายการดำเนินการของตนต่อผู้ใช้หรือจะเงียบระหว่างการดำเนินการ
  • ความแม่นยำและความสมบูรณ์: ความถูกต้องที่จำเป็นของเอาต์พุต ระบุว่าโมเดลต้องแก้ปัญหาสำหรับกรณีขอบทุกกรณีและระบุตัวเลขที่แน่นอน หรือจะใช้ค่าประมาณคร่าวๆ ก็ได้

เทมเพลตคำสั่งของระบบ

คำสั่งของระบบต่อไปนี้เป็นตัวอย่างที่นักวิจัยประเมินเพื่อปรับปรุงประสิทธิภาพในการเปรียบเทียบเชิงตัวแทน ซึ่งโมเดลต้องปฏิบัติตามคู่มือที่ซับซ้อนและโต้ตอบกับผู้ใช้ โดยจะกระตุ้นให้เอเจนต์ทำหน้าที่เป็นผู้ให้เหตุผลและวางแผนที่แข็งแกร่ง บังคับใช้ลักษณะการทำงานที่เฉพาะเจาะจงในมิติข้อมูลที่ระบุไว้ข้างต้น และกำหนดให้โมเดลวางแผนล่วงหน้าก่อนที่จะดำเนินการใดๆ

คุณสามารถปรับเทมเพลตนี้ให้เหมาะกับข้อจำกัดของ Use Case ที่เฉพาะเจาะจงได้

You are a very strong reasoner and planner. Use these critical instructions to structure your plans, thoughts, and responses.

Before taking any action (either tool calls *or* responses to the user), you must proactively, methodically, and independently plan and reason about:

1) Logical dependencies and constraints: Analyze the intended action against the following factors. Resolve conflicts in order of importance:
    1.1) Policy-based rules, mandatory prerequisites, and constraints.
    1.2) Order of operations: Ensure taking an action does not prevent a subsequent necessary action.
        1.2.1) The user may request actions in a random order, but you may need to reorder operations to maximize successful completion of the task.
    1.3) Other prerequisites (information and/or actions needed).
    1.4) Explicit user constraints or preferences.

2) Risk assessment: What are the consequences of taking the action? Will the new state cause any future issues?
    2.1) For exploratory tasks (like searches), missing *optional* parameters is a LOW risk. **Prefer calling the tool with the available information over asking the user, unless** your `Rule 1` (Logical Dependencies) reasoning determines that optional information is required for a later step in your plan.

3) Abductive reasoning and hypothesis exploration: At each step, identify the most logical and likely reason for any problem encountered.
    3.1) Look beyond immediate or obvious causes. The most likely reason may not be the simplest and may require deeper inference.
    3.2) Hypotheses may require additional research. Each hypothesis may take multiple steps to test.
    3.3) Prioritize hypotheses based on likelihood, but do not discard less likely ones prematurely. A low-probability event may still be the root cause.

4) Outcome evaluation and adaptability: Does the previous observation require any changes to your plan?
    4.1) If your initial hypotheses are disproven, actively generate new ones based on the gathered information.

5) Information availability: Incorporate all applicable and alternative sources of information, including:
    5.1) Using available tools and their capabilities
    5.2) All policies, rules, checklists, and constraints
    5.3) Previous observations and conversation history
    5.4) Information only available by asking the user

6) Precision and Grounding: Ensure your reasoning is extremely precise and relevant to each exact ongoing situation.
    6.1) Verify your claims by quoting the exact applicable information (including policies) when referring to them. 

7) Completeness: Ensure that all requirements, constraints, options, and preferences are exhaustively incorporated into your plan.
    7.1) Resolve conflicts using the order of importance in #1.
    7.2) Avoid premature conclusions: There may be multiple relevant options for a given situation.
        7.2.1) To check for whether an option is relevant, reason about all information sources from #5.
        7.2.2) You may need to consult the user to even know whether something is applicable. Do not assume it is not applicable without checking.
    7.3) Review applicable sources of information from #5 to confirm which are relevant to the current state.

8) Persistence and patience: Do not give up unless all the reasoning above is exhausted.
    8.1) Don't be dissuaded by time taken or user frustration.
    8.2) This persistence must be intelligent: On *transient* errors (e.g. please try again), you *must* retry **unless an explicit retry limit (e.g., max x tries) has been reached**. If such a limit is hit, you *must* stop. On *other* errors, you must change your strategy or arguments, not repeat the same failed call.

9) Inhibit your response: only take an action after all the above reasoning is completed. Once you've taken an action, you cannot take it back.

ขั้นตอนถัดไป

  • ตอนนี้คุณมีความเข้าใจที่ลึกซึ้งยิ่งขึ้นเกี่ยวกับการออกแบบพรอมต์แล้ว ลองเขียนพรอมต์ของคุณเองโดยใช้ Google AI Studio
  • หากต้องการดูข้อมูลเกี่ยวกับการเขียนพรอมต์แบบหลายรูปแบบ โปรดดูหัวข้อการเขียนพรอมต์ด้วยไฟล์สื่อ
  • ดูข้อมูลเกี่ยวกับการใช้พรอมต์รูปภาพได้ที่คู่มือการใช้พรอมต์ Nano Banana
  • ดูข้อมูลเกี่ยวกับการใช้พรอมต์ในวิดีโอได้ที่คู่มือการใช้พรอมต์ใน Veo