Abstract
In-context learning (ICL) relies on demonstrations to guide Large Language Models (LLMs). While demo selection and order are well-studied, this paper identifies a significant "positional bias" where the spatial placement of a demo block—relative to system instructions and user queries—can swing accuracy by up to 20% and flip nearly half of a model's predictions. We find that placing demonstrations at the start of a prompt (the "primacy effect") generally improves stability and performance, though optimal placement remains model-dependent.
Introduction: The Problem of Spatial Placement
In-context learning (ICL) has become the standard paradigm for interacting with Large Language Models (LLMs). Users typically provide a few "demonstrations" (demos) to steer the model toward a desired output format or reasoning path. While previous research has focused on which demos to select or their internal order, this study investigates a neglected dimension: spatial placement.
The authors define the "DPP bias" (Demos' Position in Prompt bias), questioning whether it matters if examples precede system instructions, follow them, or appear after the user's query. LLMs exhibit extreme sensitivity to these structural choices, leading to a brittleness that threatens the reliability of production systems.
Methodology
To isolate the effects of position, the researchers defined four canonical demonstration placements:
- ssp (Start of System Prompt): Demos precede all instructions.
- esp (End of System Prompt): Demos follow system instructions but precede the user query.
- sum (Start of User Message): The standard default, where demos lead the user message.
- eum (End of User Message): Demos are appended after the user's query.
The study introduced two metrics: Accuracy-Change ($\Delta_{metric}$), measuring performance shifts relative to zero-shot baselines, and Prediction-Change ($\Delta_{pred}$), quantifying "output volatility" by counting flipped predictions when moving demos from the default sum position.
Experimental Setup
The hypothesis was tested across ten open-source LLMs (Qwen, Llama3, Mistral, Cohere) ranging from 1.5B to 72B parameters. Evaluation spanned eight diverse tasks, including classification (AG News, MNLI), reasoning (ARC, MMLU), arithmetic (GSM8K), and summarization (XSUM).
Key Results and Insights
The Primacy Effect and Volatility
A consistent "primacy bias" emerged: placing demos early (ssp or esp) generally outperforms late placement (eum). For example, MMLU accuracy improved significantly under the ssp configuration compared to zero-shot. Conversely, the eum position proved highly disruptive; in QA tasks, it flipped over 30% of predictions without improving correctness, and in summarization, the flip rate reached nearly 100%.
Model Sensitivity and Scale
Smaller models (1.5B–8B) are the most fragile, benefiting significantly from "positional tuning." While larger models (70B+) are more robust, they still exhibit non-trivial instability. Interestingly, there is no universal "best" position; while smaller Qwen models preferred ssp, Llama3-70B favored the sum position, suggesting that larger models might benefit from demos being closer to the query.
Underlying Causes
The authors hypothesize two primary drivers:
- Architectural: Autoregressive masking in causal-decoder LLMs means early tokens exert a disproportionate influence on the hidden states conditioning all subsequent tokens.
- Data-Driven: Instruction-tuning datasets often use fixed slots for demos, imprinting structural preferences during training.
Conclusion and Future Work
The study demonstrates that moving an identical block of demos can swing task accuracy by up to 20 percentage points. To mitigate this, future work should focus on test-time calibration to dynamically select optimal demo slots and robust training techniques, such as using randomly permuted contexts to encourage position-invariant representations.
Summary updated