<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Tradeoffs on Tarragon</title><link>https://tarrragon.github.io/blog/tags/tradeoffs/</link><description>Recent content in Tradeoffs on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Thu, 14 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/tradeoffs/index.xml" rel="self" type="application/rss+xml"/><item><title>4.0 Prompt 技術光譜：手法分類、取捨、組合模式</title><link>https://tarrragon.github.io/blog/llm/04-applications/prompt-techniques-landscape/</link><pubDate>Thu, 14 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/llm/04-applications/prompt-techniques-landscape/</guid><description>&lt;p>Prompt 技術不缺教學文章——但多數教學是「教你怎麼寫」、半年後模型換代、寫法跟著過時。本章不教「怎麼寫」、寫的是&lt;strong>這個技術 landscape 的結構&lt;/strong>：有哪些手法、每個解什麼問題、它們的 trade-off 在哪、什麼時候該組合、什麼時候不該。這些結構性問題跨模型世代不變。&lt;/p>
&lt;p>讀完本章後、看到任何新 prompt 技術都能放回正確座標、判斷「這是哪一軸的優化、跟我現在的問題對上嗎、能不能跟既有技術疊」——而不是每出一個新技術都從零學一次。&lt;/p>
&lt;h2 id="本章目標">本章目標&lt;/h2>
&lt;p>讀完本章後你能：&lt;/p>
&lt;ol>
&lt;li>把任何 prompt 技術放進三軸座標（context 提供 / 推理引導 / 角色與格式）。&lt;/li>
&lt;li>對單一技術評估四維 trade-off（accuracy、latency、cost、debuggability）。&lt;/li>
&lt;li>判斷何時 stack 技術、何時 stack 會互相抵消。&lt;/li>
&lt;li>區分 prompt 層解法 vs fine-tune / RAG / chaining 解法的邊界。&lt;/li>
&lt;li>看到「prompt 改了沒效」時、診斷是 systematic error 還是 random error。&lt;/li>
&lt;/ol>
&lt;h2 id="本章鎖定的是結構層不是寫法層">本章鎖定的是結構層、不是寫法層&lt;/h2>
&lt;p>Prompt 知識可以分兩層：&lt;strong>易變層&lt;/strong>是具體寫法（特定模型偏好哪種句型、特定任務最佳 step 切法）、&lt;strong>不變層&lt;/strong>是「有哪些技術可選、各解什麼問題、能不能組合」的結構。本章只寫不變層。&lt;/p>
&lt;p>易變層為什麼留給 case-by-case：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>跨模型差異&lt;/strong>：對 GPT-4 有效的寫法、對 Claude 可能反效果。模型 SFT 分佈不同、對 prompt 結構的偏好不同。&lt;/li>
&lt;li>&lt;strong>跨任務差異&lt;/strong>：對 summarization 有效的格式、對 classification 沒幫助。每個任務的最佳 prompt 形狀要實驗。&lt;/li>
&lt;/ul>
&lt;p>不變層的價值是：看到任何新 prompt 技術都能放回正確座標、判斷它解什麼問題、跟既有技術疊能不能。具體寫法（act as XYZ 怎麼設計、step 怎麼分）屬於客製工作、不在本章。&lt;/p>
&lt;h2 id="三軸分類">三軸分類&lt;/h2>
&lt;p>把 prompt 技術放到三軸座標、看到任何新手法都能定位：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>軸&lt;/th>
 &lt;th>解決什麼問題&lt;/th>
 &lt;th>代表技術&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Context 提供&lt;/td>
 &lt;td>模型「缺資料 / 缺對齊範例」&lt;/td>
 &lt;td>zero-shot、few-shot、retrieval-augmented&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>推理引導&lt;/td>
 &lt;td>模型「直接答錯、需要 think」&lt;/td>
 &lt;td>chain-of-thought、decomposition、reflection&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>角色與格式&lt;/td>
 &lt;td>模型「不知該以什麼姿態回應」&lt;/td>
 &lt;td>role prompting、persona、output template&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>每個技術可能跨軸（如 few-shot CoT 同時 context + 推理）、但歸到主軸有助判讀「這技術在解哪一類問題」。看到新技術時、先問「它放哪一軸」、再看它跟既有技術的關係。&lt;/p>
&lt;h2 id="context-軸模型缺什麼資料">Context 軸：模型缺什麼資料&lt;/h2>
&lt;h3 id="zero-shot">Zero-shot&lt;/h3>
&lt;p>直接給任務、不給範例。&lt;/p>
&lt;ul>
&lt;li>&lt;strong>適用&lt;/strong>：模型對任務分佈熟、輸出格式可預測。例：「將下列文字翻譯成英文」。&lt;/li>
&lt;li>&lt;strong>失效&lt;/strong>：任務邊界模糊、模型沒「對齊到你的標準」。例：「分類這個 review 是正向 / 中性 / 負向」——「中性」的邊界在不同產業差很多。&lt;/li>
&lt;/ul>
&lt;h3 id="few-shot">Few-shot&lt;/h3>
&lt;p>&lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/few-shot-prompting/" data-link-title="Few-shot prompting" data-link-desc="在 prompt 內塞 input-output 範例對齊任務、不動模型權重的 in-context learning 技術">Few-shot prompting&lt;/a> 在 prompt 內塞幾個 input-output 範例、模型透過範例對齊任務。&lt;/p>
&lt;ul>
&lt;li>&lt;strong>適用&lt;/strong>：任務有「我的標準跟模型預設不同」、但能舉幾個代表性例子。常見場景：分類、抽取、格式轉換、tone alignment。&lt;/li>
&lt;li>&lt;strong>核心收益&lt;/strong>：把「對齊任務」這件事從 fine-tune 移到 prompt——iteration 從幾天縮到幾分鐘、不動模型權重。&lt;/li>
&lt;li>&lt;strong>失效&lt;/strong>：範例選不好（cherry-picked、cover 不到 edge case）、範例太多撐爆 context、任務本質需要外部知識（這時該用 RAG 不是 few-shot）。&lt;/li>
&lt;/ul>
&lt;p>Few-shot 跟 fine-tune 是「對齊」這件事的兩個 endpoint。Trade-off：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>維度&lt;/th>
 &lt;th>Few-shot in prompt&lt;/th>
 &lt;th>Fine-tune&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Iteration&lt;/td>
 &lt;td>分鐘級、改 prompt 即可&lt;/td>
 &lt;td>天級、要 retrain&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>範例容量&lt;/td>
 &lt;td>受 context window 限制（10–50）&lt;/td>
 &lt;td>可以幾千幾萬、整個 dataset 都行&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Cost&lt;/td>
 &lt;td>每次 inference 多付 token&lt;/td>
 &lt;td>一次性訓練 cost、之後 inference 不變&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>模型遷移&lt;/td>
 &lt;td>跨模型即時換、prompt 直接搬&lt;/td>
 &lt;td>綁特定 base model、換模型要 retrain&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>知識更新&lt;/td>
 &lt;td>改 prompt 即可&lt;/td>
 &lt;td>要 retrain&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>實務啟示：先 few-shot、等到範例真的多到撐爆 context 又每天都用、再考慮 fine-tune。本指南對 fine-tune 的整體看法見 &lt;a href="https://tarrragon.github.io/blog/llm/03-theoretical-foundations/training-pipeline/" data-link-title="3.4 訓練流程：pre-train → SFT → RLHF" data-link-desc="LLM 的三階段訓練：預訓練、指令微調、人類反饋強化學習；各階段目標與最新替代方案">3.4 訓練流程&lt;/a>。&lt;/p></description><content:encoded><![CDATA[<p>Prompt 技術不缺教學文章——但多數教學是「教你怎麼寫」、半年後模型換代、寫法跟著過時。本章不教「怎麼寫」、寫的是<strong>這個技術 landscape 的結構</strong>：有哪些手法、每個解什麼問題、它們的 trade-off 在哪、什麼時候該組合、什麼時候不該。這些結構性問題跨模型世代不變。</p>
<p>讀完本章後、看到任何新 prompt 技術都能放回正確座標、判斷「這是哪一軸的優化、跟我現在的問題對上嗎、能不能跟既有技術疊」——而不是每出一個新技術都從零學一次。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本章後你能：</p>
<ol>
<li>把任何 prompt 技術放進三軸座標（context 提供 / 推理引導 / 角色與格式）。</li>
<li>對單一技術評估四維 trade-off（accuracy、latency、cost、debuggability）。</li>
<li>判斷何時 stack 技術、何時 stack 會互相抵消。</li>
<li>區分 prompt 層解法 vs fine-tune / RAG / chaining 解法的邊界。</li>
<li>看到「prompt 改了沒效」時、診斷是 systematic error 還是 random error。</li>
</ol>
<h2 id="本章鎖定的是結構層不是寫法層">本章鎖定的是結構層、不是寫法層</h2>
<p>Prompt 知識可以分兩層：<strong>易變層</strong>是具體寫法（特定模型偏好哪種句型、特定任務最佳 step 切法）、<strong>不變層</strong>是「有哪些技術可選、各解什麼問題、能不能組合」的結構。本章只寫不變層。</p>
<p>易變層為什麼留給 case-by-case：</p>
<ul>
<li><strong>跨模型差異</strong>：對 GPT-4 有效的寫法、對 Claude 可能反效果。模型 SFT 分佈不同、對 prompt 結構的偏好不同。</li>
<li><strong>跨任務差異</strong>：對 summarization 有效的格式、對 classification 沒幫助。每個任務的最佳 prompt 形狀要實驗。</li>
</ul>
<p>不變層的價值是：看到任何新 prompt 技術都能放回正確座標、判斷它解什麼問題、跟既有技術疊能不能。具體寫法（act as XYZ 怎麼設計、step 怎麼分）屬於客製工作、不在本章。</p>
<h2 id="三軸分類">三軸分類</h2>
<p>把 prompt 技術放到三軸座標、看到任何新手法都能定位：</p>
<table>
  <thead>
      <tr>
          <th>軸</th>
          <th>解決什麼問題</th>
          <th>代表技術</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Context 提供</td>
          <td>模型「缺資料 / 缺對齊範例」</td>
          <td>zero-shot、few-shot、retrieval-augmented</td>
      </tr>
      <tr>
          <td>推理引導</td>
          <td>模型「直接答錯、需要 think」</td>
          <td>chain-of-thought、decomposition、reflection</td>
      </tr>
      <tr>
          <td>角色與格式</td>
          <td>模型「不知該以什麼姿態回應」</td>
          <td>role prompting、persona、output template</td>
      </tr>
  </tbody>
</table>
<p>每個技術可能跨軸（如 few-shot CoT 同時 context + 推理）、但歸到主軸有助判讀「這技術在解哪一類問題」。看到新技術時、先問「它放哪一軸」、再看它跟既有技術的關係。</p>
<h2 id="context-軸模型缺什麼資料">Context 軸：模型缺什麼資料</h2>
<h3 id="zero-shot">Zero-shot</h3>
<p>直接給任務、不給範例。</p>
<ul>
<li><strong>適用</strong>：模型對任務分佈熟、輸出格式可預測。例：「將下列文字翻譯成英文」。</li>
<li><strong>失效</strong>：任務邊界模糊、模型沒「對齊到你的標準」。例：「分類這個 review 是正向 / 中性 / 負向」——「中性」的邊界在不同產業差很多。</li>
</ul>
<h3 id="few-shot">Few-shot</h3>
<p><a href="/blog/llm/knowledge-cards/few-shot-prompting/" data-link-title="Few-shot prompting" data-link-desc="在 prompt 內塞 input-output 範例對齊任務、不動模型權重的 in-context learning 技術">Few-shot prompting</a> 在 prompt 內塞幾個 input-output 範例、模型透過範例對齊任務。</p>
<ul>
<li><strong>適用</strong>：任務有「我的標準跟模型預設不同」、但能舉幾個代表性例子。常見場景：分類、抽取、格式轉換、tone alignment。</li>
<li><strong>核心收益</strong>：把「對齊任務」這件事從 fine-tune 移到 prompt——iteration 從幾天縮到幾分鐘、不動模型權重。</li>
<li><strong>失效</strong>：範例選不好（cherry-picked、cover 不到 edge case）、範例太多撐爆 context、任務本質需要外部知識（這時該用 RAG 不是 few-shot）。</li>
</ul>
<p>Few-shot 跟 fine-tune 是「對齊」這件事的兩個 endpoint。Trade-off：</p>
<table>
  <thead>
      <tr>
          <th>維度</th>
          <th>Few-shot in prompt</th>
          <th>Fine-tune</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Iteration</td>
          <td>分鐘級、改 prompt 即可</td>
          <td>天級、要 retrain</td>
      </tr>
      <tr>
          <td>範例容量</td>
          <td>受 context window 限制（10–50）</td>
          <td>可以幾千幾萬、整個 dataset 都行</td>
      </tr>
      <tr>
          <td>Cost</td>
          <td>每次 inference 多付 token</td>
          <td>一次性訓練 cost、之後 inference 不變</td>
      </tr>
      <tr>
          <td>模型遷移</td>
          <td>跨模型即時換、prompt 直接搬</td>
          <td>綁特定 base model、換模型要 retrain</td>
      </tr>
      <tr>
          <td>知識更新</td>
          <td>改 prompt 即可</td>
          <td>要 retrain</td>
      </tr>
  </tbody>
</table>
<p>實務啟示：先 few-shot、等到範例真的多到撐爆 context 又每天都用、再考慮 fine-tune。本指南對 fine-tune 的整體看法見 <a href="/blog/llm/03-theoretical-foundations/training-pipeline/" data-link-title="3.4 訓練流程：pre-train → SFT → RLHF" data-link-desc="LLM 的三階段訓練：預訓練、指令微調、人類反饋強化學習；各階段目標與最新替代方案">3.4 訓練流程</a>。</p>
<h3 id="retrieval-augmented-prompting">Retrieval-augmented prompting</h3>
<p>跟 few-shot 像、但範例不是寫死、是<strong>從一個範例庫即時 retrieve</strong>。技術上落在 <a href="/blog/llm/04-applications/rag-principles/" data-link-title="4.1 RAG 原理：retrieval &#43; augmentation 模式" data-link-desc="為什麼模型需要外掛知識、語意相似 vs 字面相似、chunking 的本質取捨、retrieval 失敗的根本原因">4.1 RAG 原理</a>、但概念上是 few-shot 的延伸——把固定範例變成動態範例。</p>
<ul>
<li><strong>適用</strong>：範例庫大、每次任務最相關的範例不同。</li>
<li><strong>跟 RAG 知識檢索的差異</strong>：RAG 取「事實 / 文件」、retrieval-augmented prompting 取「相似任務的解答範例」。兩個目的不同、但 infra 共用。</li>
</ul>
<h2 id="推理軸模型該不該think">推理軸：模型該不該「think」</h2>
<h3 id="chain-of-thoughtcot">Chain-of-Thought（CoT）</h3>
<p><a href="/blog/llm/knowledge-cards/chain-of-thought/" data-link-title="Chain-of-Thought（CoT）" data-link-desc="讓 LLM 先輸出推理步驟再給最終答案的 prompting / 訓練方式、reasoning model 的基礎機制">Chain-of-Thought</a> 要求模型「show your work」、把推理步驟寫出來、再給最終答案。</p>
<ul>
<li><strong>適用</strong>：multi-step reasoning（數學、邏輯、複雜判斷）、模型直接答錯但 step-by-step 後對。</li>
<li><strong>失效在 reasoning model 出現後</strong>：<a href="/blog/llm/03-theoretical-foundations/reasoning-models/" data-link-title="3.8 Reasoning models：test-time compute paradigm" data-link-desc="Chain-of-thought 從 prompting 技巧演化成訓練 paradigm、reasoning model 的內部運作、本地可跑的選項與適用任務">reasoning model</a> 本身就在生成內部推理 trace、再外加 explicit CoT prompt 邊際收益遞減、部分模型可能反而干擾內部推理路徑。判讀訊號：模型卡片寫「reasoning model」、就不要再加 &ldquo;think step by step&rdquo;。</li>
<li><strong>失效在低能力模型</strong>：模型本身推理能力不足、CoT 變成「把錯誤推理寫得更詳細」、不會把答案變對。CoT 是「把潛在能力擠出來」、不是「給模型新能力」。</li>
</ul>
<h3 id="task-decomposition">Task decomposition</h3>
<p>把大任務拆成幾個明確子任務、prompt 內 enumerate 出來。</p>
<ul>
<li><strong>跟 CoT 的差異</strong>：CoT 是「過程要 explicit」、decomposition 是「子任務要 explicit」。CoT 在 single call 內展開、decomposition 可以單 call 也可以多 call。</li>
<li><strong>適用</strong>：任務有明顯的 phase（如「先抽要點、再寫 outline、再展開段落」）、不分階段就會走錯。</li>
<li><strong>跟 chaining 的邊界</strong>：decomposition 寫在 single prompt 裡是 prompt 技術；拆成多 call 是 <a href="/blog/llm/04-applications/workflow-patterns/" data-link-title="4.7 Workflow 編排模式" data-link-desc="Pipeline / router / parallel / reflection：多 LLM call 組合的四種基本模式與退化條件">4.7 workflow patterns</a> 的 pipeline 模式。判讀：每階段 output 要不要被審查 / 被 inject 不同 context → 要 → 走 chaining；不需要 → 留在 single prompt 內 decomposition。</li>
</ul>
<h3 id="reflection--self-critique">Reflection / self-critique</h3>
<p><a href="/blog/llm/knowledge-cards/reflection/" data-link-title="Reflection / Self-critique" data-link-desc="要求模型先輸出一版、再 critique 自己、再修改的 prompting / workflow 模式、有自身失敗模式">Reflection</a> 要求模型先輸出一版、再 critique 自己、再修改。</p>
<ul>
<li><strong>適用</strong>：模型有能力辨識「自己寫的不夠好」、critique 跟 generator 不會共用同樣 blind spot。</li>
<li><strong>失效</strong>：critique 跟 generator 是同個模型、訓練分佈中的盲點不會因為「再想一次」消失。判讀訊號：critique 每次都給很像的建議、或修完還是同一類錯——這是 systematic error、加 reflection 沒收益。</li>
<li><strong>完整失敗模式分析見</strong> <a href="/blog/llm/04-applications/workflow-patterns/" data-link-title="4.7 Workflow 編排模式" data-link-desc="Pipeline / router / parallel / reflection：多 LLM call 組合的四種基本模式與退化條件">4.7 workflow patterns</a> reflection 段。</li>
</ul>
<h2 id="角色與格式軸模型該以什麼姿態回應">角色與格式軸：模型該以什麼姿態回應</h2>
<h3 id="role-prompting">Role prompting</h3>
<p>&ldquo;Act as X&rdquo; 系列——指定模型扮演的角色或專業領域。</p>
<ul>
<li><strong>適用</strong>：通用模型在多種風格之間漂、加 role 把它鎖到特定分佈。例：「act as a senior backend engineer reviewing this PR」鎖技術深度。</li>
<li><strong>失效</strong>：role 跟任務無關（&ldquo;act as a wizard&rdquo; 做財務分析）、或 role 設定跟使用者實際需求衝突。Role 是調 tone / 深度 / 視角的工具、不會給模型新能力。</li>
<li><strong>常見過度迷信</strong>：&ldquo;you are the best in the world at this&rdquo; 這類自誇式 prompt 跨模型效果不穩定、難以可靠重現。不值得當核心策略。</li>
</ul>
<h3 id="output-template">Output template</h3>
<p>指定 output 格式（JSON schema、Markdown 結構、特定欄位）。</p>
<ul>
<li><strong>適用</strong>：output 要餵下游 deterministic 系統（API、DB、UI）、格式錯就整個流程斷。</li>
<li><strong>執行層次</strong>：純 prompt 指定（弱）→ few-shot 範例（中）→ structured output / constrained decoding（強、見 <a href="/blog/llm/03-theoretical-foundations/constrained-decoding-internals/" data-link-title="3.10 Constrained decoding 內部：grammar mask 跟性能取捨" data-link-desc="Constrained decoding 的內部運作：token mask 計算、JSON schema / regex / CFG 三種 grammar、XGrammar pre-compile 機制、性能反而加速">3.10 constrained decoding 內部</a>）。三者疊用最穩。</li>
<li><strong>失效</strong>：模板太緊、模型為了符合格式犧牲內容品質。Trade-off：嚴格 schema 換來下游穩定、但 prompt 的 expression 空間變小。</li>
</ul>
<h3 id="persona--system-prompt">Persona / system prompt</h3>
<p>跨 turn 持續性的角色與行為設定、放在 <a href="/blog/llm/knowledge-cards/system-prompt/" data-link-title="System Prompt" data-link-desc="LLM application 中由開發者預設、不直接顯示給使用者的指令層、定義模型的角色、行為規範、輸出格式">system prompt</a>。</p>
<ul>
<li><strong>跟 role prompting 的差異</strong>：role prompting 是 single call 的暫時角色、persona 是跨 turn 的長期人設。多數 chatbot 應用都在後台塞 persona。</li>
<li><strong>失效</strong>：persona 跟 user request 衝突時、模型在「跟 persona 一致」跟「滿足 user」之間擺盪、行為不穩。</li>
</ul>
<h2 id="四維-trade-off">四維 Trade-off</h2>
<p>每個 prompt 技術都可以用這四維評估：</p>
<table>
  <thead>
      <tr>
          <th>維度</th>
          <th>意義</th>
          <th>典型代價</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Accuracy</td>
          <td>任務完成品質</td>
          <td>—</td>
      </tr>
      <tr>
          <td>Latency</td>
          <td>從 request 到 final response 的時間</td>
          <td>Token 累積拉長生成時間</td>
      </tr>
      <tr>
          <td>Cost</td>
          <td>每次 inference 的 token 成本</td>
          <td>Token 累積放大成本</td>
      </tr>
      <tr>
          <td>Debuggability</td>
          <td>失敗時能不能定位是哪一步出問題</td>
          <td>Single 大 prompt 失敗難排查</td>
      </tr>
  </tbody>
</table>
<p>四維是 trade-off、不是「都拉到最高」。Few-shot 提高 accuracy 但加 cost 跟 latency；CoT 提高 accuracy 但顯著拉長 latency；reflection 進一步提高 accuracy 但 cost / latency 翻倍以上。</p>
<p>Latency 的展開：標準 LLM 生成的 latency 由 TTFT（首 token 時間）+ output token 數 × per-token latency 決定。Few-shot 加 input token、影響 TTFT 但不影響 per-token；CoT / reflection 加 output token、顯著拉長總生成時間。Reasoning model 例外——它的 thinking token 也算 output、顯著拉長 TTFT 跟總時間、加 explicit CoT 在 reasoning model 上是重複收費。</p>
<p>Debuggability 的展開：single 大 prompt 跑出錯時、要排查是 task 拆解錯、role 不對、few-shot 範例誤導、還是格式描述不清——所有問題混在一個 call 裡。Chaining / decomposition 把流程拆成多個獨立 step、每 step 有自己的 input / output trace、可以 isolate 故障點。Trade-off：chaining 加 latency / cost、但 debug 時間遠少。</p>
<p>設計時先問「我的 binding constraint 是哪個」：</p>
<ul>
<li>即時 chatbot → latency / cost 優先、accuracy 次要、避開 reflection</li>
<li>後台 batch（每晚跑、明早看）→ accuracy 優先、latency 不重要、reflection 可用</li>
<li>高代價任務（醫療、法律、財務）→ accuracy + debuggability 優先、cost 不在乎</li>
</ul>
<h2 id="組合stack-的兩個條件">組合：Stack 的兩個條件</h2>
<p>Stack 有效的必要條件是<strong>兩技術解不同軸的問題、且底層假設一致</strong>。兩條件都滿足才有疊加收益、任一失效就會抵消甚至反效果。</p>
<h3 id="有效的-stack-組合">有效的 stack 組合</h3>
<ul>
<li><strong>Few-shot + role</strong>：few-shot 解「任務對齊」、role 解「回應姿態」、兩軸不衝突。</li>
<li><strong>Few-shot + output template</strong>：few-shot 教任務、template 鎖格式、互補。</li>
<li><strong>CoT + decomposition</strong>：decomposition 拆 phase、CoT 展開每 phase 的推理、層級互補。</li>
</ul>
<h3 id="失效的-stack-組合同軸或假設衝突">失效的 stack 組合（同軸或假設衝突）</h3>
<ul>
<li><strong>CoT + reasoning model</strong>：reasoning model 內部已在做 chain-of-thought、外加 explicit CoT 邊際收益遞減、部分模型可能反而干擾內部推理路徑。判讀：模型卡片寫 reasoning、就不要再加 &ldquo;think step by step&rdquo;。</li>
<li><strong>Reflection + 低能力模型</strong>：reflection 需要 critique 能力、低能力模型 critique 不出有用建議、徒增 cost。</li>
<li><strong>多重 role 衝突</strong>：&ldquo;act as a creative writer AND a strict editor&rdquo;——指令互相牴觸、模型隨機選一邊。</li>
<li><strong>Few-shot 太多 + long context 任務</strong>：few-shot 撐爆 context、留給實際任務的空間不足、accuracy 反降。</li>
</ul>
<p>判讀 stack 是否有效的反射動作：問「兩個技術解的是不同問題嗎、它們有沒有共用底層假設」。</p>
<h2 id="跟相鄰技術的邊界">跟相鄰技術的邊界</h2>
<p>Prompt 技術不是萬能、有些問題該換層解：</p>
<table>
  <thead>
      <tr>
          <th>問題</th>
          <th>Prompt 層能解到哪</th>
          <th>該換的層</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>模型不知道某個事實</td>
          <td>few-shot 塞少量、不夠</td>
          <td>RAG（<a href="/blog/llm/04-applications/rag-principles/" data-link-title="4.1 RAG 原理：retrieval &#43; augmentation 模式" data-link-desc="為什麼模型需要外掛知識、語意相似 vs 字面相似、chunking 的本質取捨、retrieval 失敗的根本原因">4.1</a>）</td>
      </tr>
      <tr>
          <td>模型完全不會某個任務</td>
          <td>few-shot 撐不住、頻繁失敗</td>
          <td>Fine-tune（<a href="/blog/llm/03-theoretical-foundations/training-pipeline/" data-link-title="3.4 訓練流程：pre-train → SFT → RLHF" data-link-desc="LLM 的三階段訓練：預訓練、指令微調、人類反饋強化學習；各階段目標與最新替代方案">3.4</a>）</td>
      </tr>
      <tr>
          <td>任務要多步、每步要不同 context</td>
          <td>single prompt 塞不下、邏輯混</td>
          <td>Chaining / workflow（<a href="/blog/llm/04-applications/workflow-patterns/" data-link-title="4.7 Workflow 編排模式" data-link-desc="Pipeline / router / parallel / reflection：多 LLM call 組合的四種基本模式與退化條件">4.7</a>）</td>
      </tr>
      <tr>
          <td>任務要外部資料 / API</td>
          <td>prompt 描述不出、需要實際呼叫</td>
          <td>Tool use（<a href="/blog/llm/04-applications/tool-use-principles/" data-link-title="4.3 Tool use 原理：LLM 跟外部世界互動" data-link-desc="Structured output 是 LLM 跨入工程系統的橋、function calling 取捨、為什麼本地小模型 tool use 表現崩潰">4.3</a>）</td>
      </tr>
      <tr>
          <td>任務要 LLM 自主推進</td>
          <td>prompt 無法表達「持續決定下一步」</td>
          <td>Agent（<a href="/blog/llm/04-applications/agent-architecture/" data-link-title="4.4 Agent 架構原理" data-link-desc="Agent loop 結構、失敗模式、什麼任務適合 vs 不適合、跟人類審查的協作模型">4.4</a>）</td>
      </tr>
  </tbody>
</table>
<p>判讀訊號：prompt 改了五版、accuracy 還是不到 baseline、就該往這個表的右欄移、不是再改 prompt 第六版。</p>
<h2 id="失敗診斷prompt-改了沒效時">失敗診斷：Prompt 改了沒效時</h2>
<p>Prompt 修改沒效、定位是 systematic 還是 random error：</p>
<ul>
<li><strong>Random error</strong>：同 prompt 跑 N 次、output 不穩定、有時對有時錯。可以靠 reflection / 多採樣 / temperature 降低收斂——這條路 prompt 層有解。</li>
<li><strong>Systematic error</strong>：同 prompt 跑 N 次、output 一致地錯（或一致地朝某個方向偏）。reflection 沒用、prompt 改寫也救不回——這是模型能力 / 訓練分佈問題、要往 RAG / fine-tune / 換模型走、不是再改 prompt。</li>
</ul>
<p>判讀步驟：</p>
<ol>
<li>同 prompt 跑 5–10 次、看 output 分佈</li>
<li>若分佈寬：random error、prompt 層可解</li>
<li>若分佈窄但錯：systematic error、不要再 iterate prompt、換層</li>
</ol>
<p>這個判讀直接呼應 <a href="/blog/llm/00-foundations/deterministic-vs-fuzzy-engineering/" data-link-title="0.8 Deterministic vs Fuzzy Engineering：軟體設計典範的位移" data-link-desc="傳統 deterministic 軟體跟 fuzzy LLM 軟體在資料、邏輯、分解、實驗成本四個維度的根本差異、以及哪段該 deterministic、哪段該 fuzzy 的決策框架">模組零 fuzzy engineering</a> 的「同 input → 分佈」假設——不看分佈、debug 就是瞎猜。</p>
<h2 id="何時過時--何時不過時">何時過時 / 何時不過時</h2>
<p><strong>不會過時的部分</strong>：</p>
<ul>
<li>三軸分類（context / 推理 / 格式）。</li>
<li>四維 trade-off（accuracy / latency / cost / debuggability）。</li>
<li>Stack 有效 vs 抵消的判讀原則（不同軸 vs 同軸 / 底層假設）。</li>
<li>Prompt 層 vs 換層的邊界判讀。</li>
<li>Systematic vs random error 的診斷流程。</li>
</ul>
<p><strong>會變的部分</strong>：</p>
<ul>
<li>對特定模型有效的具體寫法（每個模型偏好的 prompt structure）。</li>
<li>角色 prompting 的有效程度（隨 model alignment 訓練成熟、role hack 的效果逐年降低）。</li>
<li>CoT 的必要性（reasoning model 普及後、explicit CoT 的場景縮小）。</li>
<li>Output format 強制手段（從 prompt-only 走向 structured output API、再走向 constrained decoding）。</li>
</ul>
<h2 id="下一章">下一章</h2>
<p>下一章：<a href="/blog/llm/04-applications/rag-principles/" data-link-title="4.1 RAG 原理：retrieval &#43; augmentation 模式" data-link-desc="為什麼模型需要外掛知識、語意相似 vs 字面相似、chunking 的本質取捨、retrieval 失敗的根本原因">4.1 RAG 原理</a>、把「prompt 層塞不下知識」這個邊界往外推、進入 LLM 跟外部資料互動的領域。Prompt 跟 fine-tune 的對齊取捨見 <a href="/blog/llm/03-theoretical-foundations/training-pipeline/" data-link-title="3.4 訓練流程：pre-train → SFT → RLHF" data-link-desc="LLM 的三階段訓練：預訓練、指令微調、人類反饋強化學習；各階段目標與最新替代方案">3.4</a>、跟 chaining 的邊界完整討論見 <a href="/blog/llm/04-applications/workflow-patterns/" data-link-title="4.7 Workflow 編排模式" data-link-desc="Pipeline / router / parallel / reflection：多 LLM call 組合的四種基本模式與退化條件">4.7</a>、跟 fuzzy engineering 典範的關係見 <a href="/blog/llm/00-foundations/deterministic-vs-fuzzy-engineering/" data-link-title="0.8 Deterministic vs Fuzzy Engineering：軟體設計典範的位移" data-link-desc="傳統 deterministic 軟體跟 fuzzy LLM 軟體在資料、邏輯、分解、實驗成本四個維度的根本差異、以及哪段該 deterministic、哪段該 fuzzy 的決策框架">0.8</a>。</p>
]]></content:encoded></item></channel></rss>