Zubnet AIAprenderWiki › Few-Shot Aprendering
Using AI

Few-Shot Aprendering

Few-Shot Prompting, One-Shot, In-Context Aprendering
Fornecer um punhado de pares exemplo entrada-saída no seu prompt para ensinar ao modelo um padrão, formato ou comportamento. “Zero-shot” significa sem exemplos (só uma instrução). “One-shot” é um exemplo. “Few-shot” é tipicamente 2–10 exemplos. O modelo aprende o padrão dos seus exemplos e o aplica à entrada real, sem treinamento ou fine-tuning.

Por que importa

Prompting few-shot é o jeito mais rápido e barato de customizar o comportamento do modelo. Precisa de saída JSON consistente? Mostre três exemplos. Precisa de um estilo de escrita específico? Inclua duas amostras. Funciona porque LLMs são pattern matchers extraordinários — inferem a regra dos exemplos e a generalizam. Isso é chamado “in-context learning” e é uma das capacidades mais surpreendentes que emergiu da escala.

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.

Conceitos relacionados

← Todos os termos
← Feedforward Network Fine-tuning →