Prompt Engineering
Prompt
LLM
AI
Prompt Engineering: CoT, Structured Output, Delimiters
2025/12/17 10:00:00
0
5
大家應該都很熟悉怎麼下提示詞了,這邊分享三個有趣的提示辭技巧 :
Chain-of-Thought : CoT
1. 像是我們先幫他們做好planning 步驟,減少模型的揣測
2. 因為範圍限縮了,會有更優質的產出
Let's think step-by-step.
I have a Playwright test that sometimes fails at the login stage.
1. Analyze the failure logs.
2. Identify what causes the intermittent failure.
3. Suggest how to stabilize the test.
Logs:
[Error: Timeout while waiting for selector #submit]
Structured Output
如同Copilot 的Agent Mode作業流程中,會利用產出持續迭代。對待LLM就像對待API一樣,能讓流程更加可控
Analyze this Playwright test log and summarize in structured JSON.
Return only valid JSON:
{
"test_name": "<string>",
"confident": "<number>",
"result": "<string>,<string>",
"failure_reason": "<string>,<string>",
"recommendation": "<string>,<string>"
}
Log:
[Test] checkout.spec.ts - FAIL - Element not visible
Delimiters / XML
提示辭中有多種不同資料的場合,人工先整理好,減少LLM的誤判
尤其適用Claude / GPT 這種對話類型的AI工具,產出的質量會明顯上升
<analysis>
<context>We are testing the insurance claim system's hospitalization payout module.</context>
<query>SELECT * FROM claims WHERE surgery = TRUE AND payout_status = 'pending';</query>
<steps>
1. Verify data correctness.
2. Suggest test coverage.
</steps>
</analysis>
綜合以上,實際參考如下 :
You are a senior QA test engineer.
Let's think step-by-step to design test cases for the new /payout API.
<task>
<requirements>
The API must verify patient_id, hospitalization_days, and surgery_flag.
</requirements>
<constraints>
Auth required. Return JSON only.
</constraints>
</task>
Return only JSON. No explanations or text outside the JSON.
{
"endpoint": "/payout",
"test_cases": [
{"id": "<number>", "title": "<string>", "expected_result": "<string>", "risk_level": "<number>"}
],
"notes": "<string>,<string>,<string>"
}
This task is important to my career; please be thorough.
我還藏了上面沒有提到的小技巧,你有發現嗎 ?
總結
優化 LLM 互動的關鍵在於 : 將複雜任務分解、運用範例建立模式,並適時利用結構化指令來控制輸出格式。
或許讀者會認為 :「 啊我就是懶的處理這些,才通通丟給AI嘛 」
不過想想那些來回確認產出的日子,你只是把檢查提前先做起來,而且品質還比以前更好,大家可以多嘗試看看喔 !
