wikillm

Paper · 2023-03-07 · cs.CL

Larger language models do in-context learning differently

Tests whether in-context learning relies on semantic priors or on input-label mappings in the prompt. With flipped labels, large models override priors (emergent with scale); with semantically unrelated labels (foo/bar), large models still learn the mapping. Instruction tuning strengthens both. Largest Codex model beats chance on 16-dimensional linear classification by 19 points (author-reported).

In-context learningEmergent abilitiesInstruction tuningin-context-learningscalingevaluation

arXivPDFMarkdown8 min read

AI-compiled by claude-haiku-5-5 on 2026-11-01, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

When you show a language model a few examples in its prompt, it can seem to learn the task on the spot. Two things could explain this: it might recognise the task from what it already knows about language, or it might work out the rule that links inputs to answers from the examples themselves. This paper separates the two by changing the example labels. It flips them so they contradict common sense, or replaces them with meaningless words such as "foo" and "bar".

The main finding is that small models keep following what they already know, while large models follow the examples. A large model will obey a prompt where positive reviews are labelled "negative", and it can still learn a task when the labels carry no meaning at all. Both abilities appear only as models grow. Tuning a model on instructions makes it better at learning from the examples, but it also makes it hold more firmly to its prior knowledge.

TL;DR

  • Measures how in-context learning uses prior knowledge (semantic priors) against the input-label pairs shown in the prompt §1.
  • With flipped labels, only large models override their priors; this is reported as emerging with scale §3.
  • With meaningless target words, large models keep most of their accuracy, and small models drop sharply §4.
  • Instruction tuning improves learning from the examples, but strengthens priors more §5. Results are author-reported on 100 evaluation examples per dataset §2.3.

Problem

Few-shot prompting is often explained by semantic priors: the model already knows the task, and the examples only show the format. Earlier work found that random ground-truth labels in the prompt barely hurt performance, which supports that view §7.1. Other work shows that simple transformers trained from scratch can learn linear-regression-like rules in context §7.2. The paper asks what happens with pretrained language models when the examples contradict priors, or when labels carry no semantic content §1, §3, §4.

Without a control like flipped or unrelated labels, a high score cannot distinguish "knew the task" from "learned the mapping". The paper's experiments are built to separate these cases. Its chance-level reference of 50% holds only for binary tasks §3.

Method

This is an empirical study, not a training method. The paper defines three prompt settings and measures accuracy across model families and sizes.

Regular ICL. Prompts contain k exemplars per class with natural-language targets, followed by one evaluation input §2.3 app. D.

Flipped-label ICL §3. For a binary task, a chosen fraction of the exemplar labels is replaced by the opposite label. The evaluation labels are not changed. Accuracy below 50% means the model follows the flipped exemplars rather than its priors. At 50% flipped, the labels are no better than random §3.

Semantically-unrelated label ICL (SUL-ICL) §4. Natural-language targets are replaced by unrelated words, by default "Foo" and "Bar" (for example, negative becomes "foo" and positive becomes "bar" for SST-2). Learning is possible only through the input-label mapping in the exemplars §4.

Instruction tuning comparison §5. PaLM is compared with its instruction-tuned version Flan-PaLM, in the same ICL and flipped-label experiments. InstructGPT is not compared with GPT-3, because the base models are not known to match §5.

Linear classification §6. Points in N dimensions are labelled by a hidden linear threshold. Exemplars are drawn on both sides of the threshold, and the model must classify a new point. The generation procedure is given below alg. 1, app. C.4.

Exemplars are sampled separately for each evaluation example, from the training split, and evaluation examples come from the validation split §2.3 app. A.

Pseudocode
# Flipped-label ICL  [§3]
# Input:  exemplars as (text, label) pairs for a binary task; flip_fraction
# Output: exemplars with a fraction of labels replaced by the other label

def flip_labels(exemplars, flip_fraction):
    # Choose the exemplars whose labels are flipped, at random  [§3]
    flip_count = round(flip_fraction * len(exemplars))
    flipped = random_sample(range(len(exemplars)), flip_count)
    result = []
    for index, (text, label) in enumerate(exemplars):
        if index in flipped:
            # Swap to the other class; evaluation labels stay unchanged  [§3]
            label = other_class(label)
        result.append((text, label))
    return result
Pseudocode
# SUL-ICL prompt  [§4] [app. D]
# Input:  exemplars (text, label) with natural labels; evaluation text
# Output: prompt string

def build_sul_prompt(exemplars, eval_text, natural_to_foo_bar):
    # Map each natural-language label to a meaningless target  [§4]
    lines = []
    for text, label in exemplars:
        target = natural_to_foo_bar[label]
        lines.append("Input: " + text)
        lines.append("Output: " + target)
    # The evaluation input ends the prompt; the model writes the target
    # [app. D]
    lines.append("Input: " + eval_text)
    lines.append("Output:")
    return "\n\n".join(lines)
Pseudocode
# Linear classification data generation  [alg. 1, app. C.4]
# Input:  n (dimension), k (exemplars per class)
# Output: training exemplars, evaluation point and its label

def generate_eval(n, k):
    # Ground-truth coefficients and a pivot point  [alg. 1]
    coefficients = random_vector(n)
    pivot = random_vector(n)
    # Threshold separating positive and negative examples  [alg. 1]
    threshold = dot(coefficients, pivot)
    train_x = []
    train_y = []
    for _ in range(k):
        # Positive point: score above the threshold  [alg. 1]
        positive = random_vector_above(coefficients, threshold)
        # Negative point: score at or below the threshold  [alg. 1]
        negative = random_vector_below(coefficients, threshold)
        train_x += [positive, negative]
        train_y += [1, -1]
    eval_x = random_vector(n)
    if dot(eval_x, coefficients) > threshold:
        eval_y = 1
    else:
        eval_y = -1
    return train_x, train_y, eval_x, eval_y

Coordinates are random integers from 1 to 1000 §6 app. C.4. The prompt uses SUL-ICL targets: negative examples are "Foo" and positive examples are "Bar" app. D.

Hyperparameters

NameValueWhereNotes
Exemplars per class (default)k = 16§2.3sampled per inference example
Exemplar sweepvaried; k = 8 for the per-dataset emergence plot§4 fig. 4 fig. 5k up to 32 in the sweep; lines stop at context-length limits app. C.2
Evaluation examples100 per dataset§2.3sampled from the validation split
Train/validation splitrandom 80/20 when no split existsapp. Atrain for exemplars, validation for evaluation
Flipped-label proportionsincreasing; exact grid not stated§350% flipped equals random for binary tasks
Default SUL targets"Foo" / "Bar"§4other target types in app. B.3
Prompt templateInput/Output§2.3 app. Dother templates in app. B.4 and app. B.5
Input-remapping proportion0% to 100% of wordsapp. B.2per-prompt word remapping
Linear classification dimensionsN = 1 to 64 (exponential steps)§6 app. C.4exact step values not stated
Linear classification coordinatesrandom integers 1 to 1000§6
Linear classification exemplarsk per class, 2k totalalg. 1
Model sizes, GPT-3ada 350M, babbage 1.3B, curie 6.7B, davinci 175B§2.2sizes from an eval-harness reference; InstructGPT and Codex sizes not stated
Model sizes, PaLM8B, 62B, 540B§2.2
Model familiesGPT-3, InstructGPT, Codex, PaLM, Flan-PaLMtab. 1 §2.2
Decoding (temperature, top-p, max tokens)not stated
Random seeds, repeats, confidence intervalsnot stated
Training by the authorsnone; models are evaluated as released§2

Results

Author-reported. Evaluation uses 100 examples per dataset, across seven binary or multi-class tasks §2.1 §2.3. Headline numbers are from the text and appendix.

SettingMetricBaselineThis paperSource
Flipped labels, text-davinci-002accuracy at 0% vs 100% flipped90.3% at 0% flipped22.5% at 100% flipped§3
Flipped labels, small vs large modelsaccuracy as flip fraction rises to 100%small models stay near their prior accuracylarge models drop well below chance§3 fig. 2
Flipped labels, PaLM vs Flan-PaLMaccuracy at 100% flippedPaLM as low as 31%Flan-PaLM does not go below chance§5 fig. 7
SUL-ICL, Flan-PaLM-8B vs PaLM-8BaccuracyPaLM-8B+9.6 points§5 fig. 6
Linear classification, N=16, Codexaccuracy above chancesmaller Codex models at most +9 pointslargest Codex model +19 points§6 fig. 8
Linear classification, Codexhighest N that workssmaller Codex models reach chance at about N=16code-davinci-002 works up to N=64app. C.4
Linear classification, PaLMhighest N that worksall PaLM models work at N=8no scale effect on this rangeapp. C.4
OOD, SST-2 in context, RT evalaccuracy (ada, babbage, curie, davinci)80, 91, 94, 9354, 63, 90, 93tab. 2 app. B.6
OOD, RT in context, SST-2 evalaccuracy (ada, babbage, curie, davinci)80, 91, 94, 9344, 61, 90, 92tab. 2 app. B.6
Input formats, code-davinci-002mean accuracy across formatsmean 84.2%range 77.9% to 87.7%app. B.4
Medium models, flipped vs SULlargest gaptext-curie-001 on SST-2up to 74 pointsapp. B.1

Overall, the paper's central claim is that flipped-label override and SUL-ICL both appear only above a certain scale in the tested families §3 §4 §6. The exact threshold depends on the model family and task app. C.1. For example, all GPT-3 models are classed as small, and davinci behaves like a small model in the SUL setting §3 app. C.2.

Paper vs code

No official code. The paper does not link a code repository in the abstract or the TeX source, and no official repository was found on GitHub. Only the paper's own LaTeX source was used to write this card.

Pitfalls

  • Unknown model sizes. The authors use OpenAI API models and Google PaLM. The sizes of InstructGPT and Codex are not public, and the authors only assume they increase in size §2.2. Scale claims for those families rest on that assumption.
  • Binary chance level. 50% flipped labels equal random for binary tasks. TREC has six classes and is excluded from the flipped-label experiments §3.
  • Context-length exclusions. RTE is excluded for PaLM because prompts at k=16 per class exceed the context window app. C.1. Some sweep lines stop early app. C.2. Results on those datasets are therefore not comparable across models.
  • Small evaluation sets. 100 evaluation examples per dataset, with no reported confidence intervals or repeated runs. Several claims rest on gaps of a few points, such as the 9.6 points in SUL-ICL §5. Some datasets (FP, ETHOS, WSC) have fewer than 250 examples and use all available ones app. B.3.
  • Output outside the label set. Small models sometimes answer with text that is not a label, so accuracy under flipped labels is not always 100% minus the reported accuracy app. B.1.
  • Flan-PaLM one-shot. Flan-PaLM scores near 0% with one exemplar per class on many datasets, and the authors note that this does not happen with two or more. The cause is not known app. C.3.
  • Dataset choices. FP uses the sentences_allagree subset, ETHOS uses the binary subset, and TREC uses the six coarse labels app. A. QNLI and WSC were dropped from the main experiments app. B.3.
  • Semantic label words. "0" and "1" are not fully neutral, because they correlate with sentiment. The authors judge the effect small app. B.3.
  • Remapping. Remapping input words hurts all but the largest models, and even the largest fail at 100% remapping, except TREC, which the authors could not explain app. B.2.
  • Semantic templates. Semantically relevant templates reduce accuracy for the smallest Codex model. Only SST-2, TREC and RTE were tested, on Codex only app. B.5.
  • Linear classification. Neither PaLM nor Codex beat an SVM baseline app. C.4. The scaling factor behind Codex's behaviour is not identified.
  • Decoding and prompting details. Temperature, decoding method, maximum output length and random seeds are not stated, so exact reproduction with the same API models may not be possible.

Lineage

  • Builds on: in-context learning as cited to GPT-3 §1 and the semantic-prior view from earlier label-randomisation work §7.1.
  • Compared against: the random-label findings of min2022rethinking §1 §7.1 and the implicit linear-learning results of Garg et al. and follow-up transformer work §7.2.
  • Related: instruction tuning studies §5, emergent-ability work on scaling §7.3.
  • Superseded by: not stated in this card.

Source and license

Adapted from “Larger language models do in-context learning differently” by Jerry Wei, Jason Wei, Yi Tay, Dustin Tran, Albert Webson, Yifeng Lu, Xinyun Chen, Hanxiao Liu, Da Huang, Denny Zhou, Tengyu Ma (arXiv:2303.03846), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.