FDEAI 工程實戰課AI Engineering for FDEs
入門篇 · 第 3 章Basics · Chapter 3

把話說清楚:寫 promptSaying it clearly: prompts

prompt 就是你給 AI 的指示。很多人以為寫 prompt 需要什麼神秘咒語,其實不用。最大的秘訣只有一個:把它當成一位很聰明、但完全不了解你狀況的新同事。

A prompt is the instruction you give the AI. Many people assume prompts need some secret incantation. They don't. The biggest secret is this: treat the AI as a very smart new colleague who knows nothing about your situation.

⏱ 15 分鐘min

讀完這章你會知道After this chapter you'll know

  • 為什麼同樣的 AI,有人用起來很好,有人覺得很笨。
  • 一個好 prompt 通常包含的六個部分。
  • 幾個常見的誤解,以及怎麼一步步改進 prompt。
  • Why the same AI seems brilliant to some people and dumb to others.
  • The six parts a good prompt usually contains.
  • A few common misconceptions, and how to improve a prompt step by step.

新同事原則The new-colleague rule

一句話重點Key point

你沒說的事,AI 只能用猜的。猜錯了,不是它笨,是你沒給它需要的資訊。

Whatever you don't say, the AI has to guess. When it guesses wrong, it isn't stupid; you didn't give it what it needed.

如果你跟一位剛到職的同事說「幫我寫一封請假信」,他一定會問:寫給誰?請哪幾天?為什麼?要多正式?AI 也有一樣的疑問,只是它通常不會問,而是自己挑一個答案繼續寫。結果就是一封很通順、但不是你要的信。

Tell a new colleague "write a leave request for me" and they'll ask: to whom? Which days? Why? How formal? The AI has the same questions, but it usually doesn't ask; it picks an answer and carries on. The result is a fluent letter that isn't what you wanted.

動手試:一步步把 prompt 補完整Try it: complete the prompt step by step

demo

請假信 promptLeave-request prompt

勾選要加進 prompt 的部分。右邊會列出 AI 還得自己猜的事。

Tick the parts to add to the prompt. The list shows what the AI still has to guess.

Prompt

好 prompt 的六個部分Six parts of a good prompt

不是每次都要六個全寫,但寫完一個 prompt 後,用這張表檢查一下有沒有漏掉重要的。

You won't need all six every time, but after writing a prompt, check this list for anything important you left out.

部分Part問自己Ask yourself例子Example
背景Context我是誰?給誰看?用在哪裡?Who am I? Who is it for? Where will it be used?「這是要貼在公司內部 wiki 的說明,讀者是新進工程師。」"This goes on our internal wiki; readers are new engineers."
任務Task我到底要它做什麼?What exactly should it do?「把下面的會議紀錄整理成待辦事項。」"Turn these meeting notes into action items."
細節與素材Details and material它需要哪些事實才做得到?What facts does it need?貼上會議紀錄全文、日期、參與者名單。Paste the full notes, the date, the attendee list.
格式Format結果要長什麼樣子?多長?What should the result look like? How long?「條列式,每項包含負責人與期限,最多 10 項。」"Bullets, each with owner and deadline, at most 10."
範例Example有沒有一個「我要的就是這樣」的例子?Is there an example of exactly what you want?「格式像這樣:- [王小明] 更新報價單(11/20 前)」"Like this: - [Wang] update the quote (by 11/20)"
不知道時When unsure資訊不夠時,要它怎麼做?What should it do when information is missing?「如果某項沒有負責人,標示『待確認』,不要自己指派。」"If an item has no owner, mark it 'TBC'; don't assign one yourself."
最常被忽略的是最後一項The most overlooked is the last one

還記得第 1 章說的嗎?AI 不知道答案時,傾向於編一個聽起來對的。明確告訴它「不知道就說不知道」或「先問我」,是減少胡說八道最簡單的方法。

Remember chapter B1? When the AI doesn't know, it tends to invent something plausible. Telling it explicitly "say so if you don't know" or "ask me first" is the simplest way to reduce made-up answers.

改寫前後對照Before and after

改寫前Before

「幫我解釋這段程式碼。」

"Explain this code."

改寫後After

「我剛學 Python 兩個月,看得懂 for 迴圈和函式,但沒學過 class。請逐行解釋下面這段程式在做什麼,遇到我沒學過的語法時多解釋一點。最後用一句話總結它的用途。」+ 貼上程式碼

"I've been learning Python for two months; I understand for loops and functions but not classes. Explain line by line what the code below does, spending more time on syntax I haven't learned. End with a one-sentence summary of its purpose." + the code

改寫前Before

「這個錯誤怎麼修?」+ 錯誤訊息

"How do I fix this error?" + the error message

改寫後After

「我在 Windows 上用 Python 3.12 執行下面的程式,出現這個錯誤。我已經試過重新安裝套件,沒有用。請先說明錯誤的原因,再給我修改方式。」+ 程式碼 + 完整錯誤訊息

"I'm running the code below with Python 3.12 on Windows and get this error. Reinstalling the package didn't help. First explain the cause, then show me the fix." + the code + the full error message

常見誤解Common misconceptions

  • 「要先說『你是世界頂尖的專家』才會變聰明。」角色設定能幫它決定語氣與觀點,但影響有限。給它具體的資訊比給它頭銜有用得多。
  • 「prompt 越長越好。」重點是完整,不是長。和任務無關的內容反而會讓它分心。
  • 「寫一次就要完美。」寫 prompt 和寫程式一樣:寫、試、看結果、改。結果不對時,先問自己「它缺了什麼資訊?」
  • 「AI 回答錯了,就是 AI 不行。」先檢查是不是 prompt 沒說清楚;如果說清楚了還是錯,才是模型的限制(這時就需要後面幾章的方法)。
  • "Start with 'You are a world-class expert' to make it smarter." A role helps with tone and perspective, but its effect is limited. Concrete information beats a title by far.
  • "Longer prompts are better." Complete, not long. Irrelevant content can distract it.
  • "It must be perfect on the first try." Prompts are like code: write, test, look at the result, revise. When the result is wrong, first ask "what information was it missing?"
  • "A wrong answer means the AI is bad." First check whether the prompt was clear. If it was and the answer is still wrong, that's a model limitation, and later chapters cover what to do about it.

小測驗Quiz

1. 你請 AI 摘要一份報告,結果它寫了 800 字,你只想要三句話。最好的改法是?1. You asked for a summary and got 800 words when you wanted three sentences. Best fix?
長度與讀者是它猜不到的資訊。直接說出來最有效。
Length and audience are things it can't guess. Saying them directly works best.
2. 要減少 AI 編造答案,prompt 裡最直接有用的一句是?2. To reduce made-up answers, the most directly useful line in a prompt is:
給它一個明確的「出口」。要求「正確」不會讓它知道它不知道的事;要求「詳細」反而可能讓它編更多。
Give it an explicit way out. Asking for correctness doesn't tell it what it doesn't know, and asking for detail may make it invent more.