Zubnet AI學習Wiki › Few-Shot 學習ing
Using AI

Few-Shot 學習ing

Few-Shot Prompting, One-Shot, In-Context 學習ing
在你的 prompt 裡提供幾對 input-output 範例,教模型一個模式、格式或行為。「Zero-shot」意思是沒有範例(只有指令)。「One-shot」是一個範例。「Few-shot」通常是 2–10 個範例。模型從你的範例裡學到模式,套用到實際輸入上,不需要任何訓練或 fine-tuning。

為什麼重要

Few-shot prompting 是客製化模型行為最快、最便宜的辦法。要一致的 JSON 輸出?給三個範例。要特定寫作風格?包含兩個樣本。它有效是因為 LLM 是超凡的模式匹配器 — 它們從範例裡推斷規則並泛化。這常被叫做「in-context learning」,是規模化帶來的最令人驚訝的能力之一。

Deep Dive

The original GPT-3 paper (Brown et al., 2020) demonstrated that large language models could perform tasks they were never explicitly trained on, simply by being shown a few examples in the prompt. A model trained only to predict text could suddenly do translation, arithmetic, and classification with just 3–5 examples. This was the finding that launched the modern era of prompt engineering.

How Many Examples?

The optimal number of examples depends on the task complexity and the model. For simple formatting tasks (convert name to "Last, First"), 2–3 examples usually suffice. For nuanced classification with edge cases, 5–10 examples may be needed. Beyond ~10 examples, you're often better off fine-tuning. More examples also consume context window, so there's a practical trade-off between example quality and available space for the actual input.

Example Selection Matters

The examples you choose affect performance dramatically. Diverse examples that cover edge cases outperform repetitive ones. Examples that are similar to the target input outperform generic ones. The order of examples can matter too — models sometimes show recency bias, paying more attention to the last example. When building few-shot systems in production, dynamically selecting the most relevant examples for each input (using embedding similarity) outperforms static example sets.

相關概念

← 所有術語
← Feedforward Network Fine-tuning →