Deconstructing In-Context Learning: Understanding Prompts via Corruption

Namrata Shivagunde, Vladislav Lialin, Sherin Muckatira, Anna Rumshisky

Abstract

The ability of large language models (LLMs) to ‘‘learn in context" based on the provided prompt has led to an explosive growth in their use, culminating in the proliferation of AI assistants such as ChatGPT, Claude, and Bard. These AI assistants are known to be robust to minor prompt modifications, mostly due to alignment techniques that use human feedback. In contrast, the underlying pre-trained LLMs they use as a backbone are known to be brittle in this respect. Building high-quality backbone models remains a core challenge, and a common approach to assessing their quality is to conduct few-shot evaluation. Such evaluation is notorious for being highly sensitive to minor prompt modifications, as well as the choice of specific in-context examples. Prior work has examined how modifying different elements of the prompt can affect model performance. However, these earlier studies tended to concentrate on a limited number of specific prompt attributes and often produced contradictory results. Additionally, previous research either focused on models with fewer than 15 billion parameters or exclusively examined black-box models like GPT-3 or PaLM, making replication challenging. In the present study, we decompose the entire prompt into four components: task description, demonstration inputs, labels, and inline instructions provided for each demonstration. We investigate the effects of structural and semantic corruptions of these elements on model performance. We study models ranging from 1.5B to 70B in size, using ten datasets covering classification and generation tasks. We find that repeating text within the prompt boosts model performance, and bigger models (≥30B) are more sensitive to the semantics of the prompt. Finally, we observe that adding task and inline instructions to the demonstrations enhances model performance even when the instructions are semantically corrupted.

Introduction

Large Language Models (LLMs) exhibit a remarkable capacity for in-context learning (ICL), where performance on a specific task is enhanced by providing a few examples within the prompt. Despite this, pre-trained "backbone" models are notoriously brittle; minor modifications in phrasing or example selection can lead to significant performance fluctuations. While prior research has attempted to identify the most critical prompt elements, results have often been contradictory and limited to smaller models or closed-source APIs. This study systematically decomposes prompts to understand the underlying mechanics of ICL across a wide range of model sizes.

Methodology: Decomposing the Prompt

The researchers broke down standard few-shot prompts into four primary components to test their individual impact:

  1. Task Instruction: A high-level description of the objective.
  2. Demonstration Input: The specific examples provided to the model.
  3. Labels: The ground-truth answers associated with those examples.
  4. Inline Instructions: Brief, repetitive instructions accompanying each demonstration (e.g., "Which emotion is expressed in this tweet?").
Decomposition of a standard few-shot prompt into task instructions, demonstrations, and inline instructions.

To evaluate the necessity of these components, two types of "corruption" were applied:

  • Structural Corruption: Systematically adding or removing components to measure their baseline contribution.
  • Semantic Corruption: Replacing meaningful text with random words or out-of-distribution (OOD) sentences to determine if the model relies on linguistic meaning or merely the structural pattern.

The study evaluated 10 models, ranging from 1.5B (GPT2-xl) to 70B (Llama-2) parameters, across 10 diverse datasets covering classification and generation tasks.

Key Insights

The Power of Repetition

A significant finding is that repeating text—specifically inline instructions—substantially boosts performance. Interestingly, even when these instructions are replaced with random words, their presence helps the model "anchor" the task's structural pattern, suggesting that the repetitive format itself is a strong signal for ICL.

Scaling Sensitivity: Structuralists vs. Semanticists

The research identifies a clear scaling effect regarding prompt meaning. Smaller models (<15B) act as "structuralists," benefiting from the presence of instructions regardless of their semantic coherence. In contrast, larger models (≥30B) are "semanticists"; they derive significantly higher gains from meaningful instructions and experience sharper performance drops when those instructions are corrupted.

Label Space and Resilience

Models are highly sensitive to the "label space." Replacing labels with random words often results in near-zero performance. However, models show surprising resilience to incorrect labels (e.g., mislabeling a "sad" tweet as "joyful"), provided the labels remain within the expected set of words for that task.

Results

The addition of just four demonstrations to a test instance yielded a massive 25-35% accuracy gain across all tested models. Furthermore, incorporating meaningful task and inline instructions provided an additional 5-18% improvement.

Performance impact of adding various prompt components across different model architectures and sizes.

The removal of inline instructions from demonstrations led to a performance decline of 20-35% for most models, underscoring the importance of the repetitive prompt pattern. Attention analysis further revealed that models prioritize separators (like newlines) and labels, with larger models allocating more attention to semantically relevant components.

Conclusion and Limitations

This study provides a granular look at what drives in-context learning. While repetition and structure are foundational, semantic meaning becomes increasingly critical as model size grows. However, the authors note limitations, including the use of a fixed 4-shot setting and a uniform prompt template that may not be optimized for specific instruction-tuned models. Future research should investigate these dynamics in even larger models and the impact of alignment techniques like RLHF on prompt sensitivity.

Summary updated

BibTeX
@inproceedings{shivagunde2024deconstructing,
  author = {Namrata Shivagunde and Vladislav Lialin and Sherin Muckatira and Anna Rumshisky},
  title = {{Deconstructing In-Context Learning: Understanding Prompts via Corruption}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=O6WuOPACzp},
}
Figure