Zubnet AIAprenderWiki › Few-Shot Aprendering
Using AI

Few-Shot Aprendering

Few-Shot Prompting, One-Shot, In-Context Aprendering
Proporcionar un puñado de pares ejemplo entrada-salida en tu prompt para enseñar al modelo un patrón, formato o comportamiento. «Zero-shot» significa sin ejemplos (solo una instrucción). «One-shot» es un ejemplo. «Few-shot» es típicamente 2–10 ejemplos. El modelo aprende el patrón de tus ejemplos y lo aplica a la entrada real, sin entrenamiento ni fine-tuning.

Por qué importa

El prompting few-shot es la forma más rápida y barata de customizar el comportamiento del modelo. ¿Necesitas salida JSON consistente? Muestra tres ejemplos. ¿Necesitas un estilo de escritura específico? Incluye dos muestras. Funciona porque los LLMs son pattern matchers extraordinarios — infieren la regla de los ejemplos y la generalizan. A esto se le llama «in-context learning» y es una de las capacidades más sorprendentes que emergieron con la 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.

Conceptos relacionados

← Todos los términos
← Feedforward Network Fine-tuning →