02 · Few-shot

Show a few examples

02Few-shot

Group 02 · 7 techniques

Few-shot

Show a few examples. Show 2-3 examples, then ask. Example: review -> Positive / Negative.

Each slide shows one technique: the plain prompt, the same prompt with the technique applied, and what changed. Use the arrows, the keys ← →, or pick a technique on the left.

Few-Shot Prompting

Few-Shot Prompting: Zero-, one- and few-shot prompts, side by sideZero-, one- and few-shot prompts, side by side
Pictures: The Prompt Report (Schulhoff et al., 2024), after Brown et al., 2020 (arxiv.org)
Before

Classify this review as Positive, Negative or Neutral: 'Battery life is okay, but the ear pads feel cheap.'

After · new words marked

'I absolutely love these headphones - sound quality is amazing!' -> Positive. 'Battery life is okay, but the ear pads feel cheap.' -> Neutral. 'Terrible customer service, I'll never buy from them again.' -> Negative. Now classify: [new review]. Only output one word.

What happened

GPT-3 (175B), no fine-tuning: 71.2% on TriviaQA few-shot (closed-book SOTA) and 85.0 F1 on CoQA.

Exemplar Ordering

Exemplar Ordering: Six choices about examples that change the answerSix choices about examples that change the answer
Pictures: The Prompt Report (Schulhoff et al., 2024) (arxiv.org)
Before

Examples in random order.

After · new words marked

Same examples, reordered so the most similar / most representative example is last.

What happened

On some tasks accuracy varies from sub-50% to 90%+ depending on exemplar order (Lu et al. 2021).

Exemplar Quantity

More exemplars generally help, especially for larger models; benefits may diminish beyond ~20 exemplars.

Before

1 example.

After · new words marked

10-20 diverse examples in the same format.

What happened

More exemplars generally help; long-context models keep gaining (Liu et al. 2021).

K-Nearest Neighbor (KNN) Exemplar Selection

Select the exemplars most similar to the test input to boost performance.

Before

Random examples from the pool.

After · new words marked

The 5 examples most similar to this test input: [retrieved examples]. Now answer.

What happened

Effective; costly at prompt-generation time (Liu et al. 2021).

Vote-K Exemplar Selection

Two-stage: the model proposes useful unlabelled candidates for an annotator to label; the labelled pool is used for few-shot, kept diverse and representative.

Before

Label these random examples.

After · new words marked

Label these model-proposed, diverse examples, then use them as few-shot exemplars.

What happened

Improves performance and diversity (Su et al. 2022).

Self-Generated In-Context Learning (SG-ICL)

The model automatically generates its own exemplars.

Before

Answer with no examples.

After · new words marked

First generate your own examples of this task, then use them to answer the question.

What happened

Better than zero-shot when training data is unavailable, but generated samples are not as effective as real data (Kim et al. 2022).

Prompt Mining

Discover optimal prompt templates by large-corpus analysis; corpus-frequent formats perform better.

Before

Q: [input] A: [label]

After · new words marked

Use the corpus-frequent format for this task instead of 'Q: / A:'.

What happened

Corpus-frequent formats likely improve performance (Jiang et al. 2020).