Learning inside a prompt #
Suppose a cataloger supplies several pairs of item descriptions and shelf labels, followed by a new description. A language model may produce a label in the expected format even though the cataloger has supplied no training code. The examples form part of the current input. Remove them from a later request and the model may behave differently. This makes the effect inexpensive to try and sensitive to how the context is arranged.
What the examples convey #
A demonstration can communicate the intended task, the set of permitted labels, the subject matter and the output format at once. Correctly labeling the next item does not reveal which clue the model used. In a 2022 study, Sewon Min and colleagues replaced correct demonstration labels with random ones in several classification and multiple-choice settings. Performance often changed surprisingly little within those settings. The surrounding examples still revealed information about the inputs and possible answers.
Testing a genuinely new mapping #
One way to distinguish familiarity from learning is to make up labels and change their mapping between trials. A researcher might assign a triangle the label “dax” in one trial and “wug” in the next, while balancing how often each label occurs. Varying the shapes and order of demonstrations can then show which parts of the example the model transfers. A task designed this way asks a narrower and more interpretable question.
Mechanisms and limits #
Brown and colleagues documented varied few-shot performance in GPT-3. Later, researchers studying induction heads investigated circuits that help transformers continue repeated patterns in their context. Evidence for a circuit in simplified models offers one mechanism for some forms of contextual adaptation. Real prompts can combine pattern completion, prior knowledge and reasoning about instructions. A successful demonstration alone cannot identify their respective contributions.
An experiment with unseen linear rules #
Garg and colleagues designed a controlled setting where the training distribution was known. They trained transformers on prompts containing examples from a family of functions. At evaluation, a prompt could present examples of a fresh linear function and ask for its value at a new input. In their linear setting the transformer achieved errors comparable to a least-squares estimator. The new function could be chosen by the experimenter, which made simple recall of one fixed solution an implausible account of the result.
For a small analogy, give the model several observations of an unknown rule relating distance to fare, then ask about a longer journey. Within a linear family, familiar fitting procedures supply quantitative baselines. Taxicab fares with minimum charges and discontinuous surcharges would be a different test. The experiment shows what a transformer trained for a specified family can learn within a prompt, leaving the breadth of a general-purpose language model as a separate empirical question.
The same examples in a different order #
Four distinct demonstrations give a prompt designer 24 possible orders before a single word is changed. Lu and colleagues found that rearranging identical examples could move classification performance from strong results to near guessing. An order that worked well for one model could work poorly for another. Reporting the best order after trying many on labeled test questions quietly gives the designer information that a reader with only four demonstrations would lack.
One diagnostic keeps the demonstrations fixed and replaces the final question with an uninformative placeholder. If the model strongly favors one label even then, the prompt is contributing a preference before any evidence from the question arrives. Zhao and colleagues used this observation to calibrate predictions against the label preferences elicited by content-free inputs. A reader comparing two few-shot results can ask how examples were chosen, how many permutations were tried and what data guided the choice. Those details help explain why the same model and the same demonstration count can produce different scores.
Sources
- Tom Brown and colleagues, Language Models are Few-Shot Learners (2020) arxiv.org
- Sewon Min and colleagues, Rethinking the Role of Demonstrations (2022) arxiv.org
- Catherine Olsson and colleagues, In-context Learning and Induction Heads (2022) transformer-circuits.pubCited in
- Shivam Garg and colleagues, What Can Transformers Learn In-Context? A Case Study of Simple Function Classes (2022) arxiv.org
- Yao Lu and colleagues, Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity (2022) aclanthology.org
- Zihao Zhao and colleagues, Calibrate Before Use: Improving Few-shot Performance of Language Models (2021) proceedings.mlr.press
Step 4 of 5