Prompt engineering ขั้นสูงสำหรับการเขียนโค้ด

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Francesca Donadoni

AI Curriculum Manager, DataCamp

Chain-of-thought

65.png

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Chain-of-thought

66.png

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Chain-of-thought

$$

แนวทาง Chain-of-Thought แบบที่ 1

$$

<Regular Prompt>

  +

  "Let's think step by step"

บทความต้นฉบับ

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Chain-of-thought

  • CoT บังคับให้โมเดลคำนวณขั้นตอนกลางอย่างชัดเจน
    • ได้คำตอบที่แม่นยำมากขึ้น

$$

คำตอบแบบทีละขั้นตอน

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Chain-of-thought

☺ Prompt ปกติ

"Write a Python function that checks if a string is a palindrome"

🤓 CoT Prompt

"Check if a string is a palindrome.

  • Step 1: Normalize the string (lowercase, remove non-alphanumeric characters).
  • Step 2: Reverse the cleaned string.
  • Step 3: Compare the original and reversed versions.

Write a function that implements this logic"

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Reasoning models

  • ใช้การอนุมานแบบ Chain-of-Thought โดยอัตโนมัติ
  • ตรวจสอบขั้นตอนกลางด้วยตนเอง
  • ทบทวนและปรับปรุงการอนุมานซ้ำได้

โลโก้ reasoning models

deepseek_prompt.gif

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

System roles

  • การกำหนด role ช่วยเพิ่มคุณภาพและความแม่นยำของผลลัพธ์ได้อย่างสม่ำเสมอ

system_roles.png

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

System roles

🎓 ติวเตอร์ด้านการเขียนโค้ด

$$

"You are a friendly programming tutor. Explain each concept in simple terms, using analogies when helpful. Highlight common mistakes to avoid"

🖥 วิศวกรซอฟต์แวร์อาวุโส

$$

"You are a senior software engineer helping to debug code. First, identify what the code is trying to do. Then, analyze where and why it might be failing"

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

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

การเขียนโค้ดด้วยความช่วยเหลือของ AI สำหรับนักพัฒนา

Preparing Video For Download...