This paper, recently presented at EMNLP 2025, uncovers a significant but overlooked factor in Large Language Model (LLM) performance: the physical location of few-shot examples within a prompt.
TL;DR
Moving a static block of few-shot demonstrations from the beginning of a prompt to the end can swing accuracy by 20% and flip nearly half of a model's predictions. This "DPP bias" (Demos' Position in Prompt) suggests that for most models and tasks, placing demonstrations at the very start of the prompt—ideally within the system message—yields the most stable and accurate results.
What Problem Does This Paper Address?
In-context learning (ICL) is the backbone of modern LLM interaction, where we provide a few examples (demos) to "teach" the model a task on the fly. While researchers knew that the selection and internal order of these examples mattered, they largely ignored the structural layout of the prompt itself.
Most developers follow a "default" layout: System Prompt -> User Message (Demos + Query). This paper asks: Does it matter if the demos come before or after the system instructions? What if they come after the user's actual question? The authors discover that LLMs are incredibly sensitive to these spatial arrangements, a phenomenon they term DPP bias. This brittleness challenges the assumption that LLMs are robustly "reasoning" from context rather than just exploiting superficial structural patterns.
Methods
The researchers designed a systematic pipeline to test four canonical positions for a fixed block of five demonstrations:
- ssp (Start of System Prompt): Demos appear at the very beginning of the input.
- esp (End of System Prompt): Demos appear after system instructions but before the user message.
- sum (Start of User Message): The "default" where demos precede the query.
- eum (End of User Message): Demos are appended at the very end, after the query.
To quantify the impact, they introduced two task-agnostic metrics:
- ACCURACY-CHANGE ($\Delta_{metric}$): The net gain or loss in performance compared to a zero-shot (no examples) baseline.
- PREDICTION-CHANGE ($\Delta_{pred}$): The "volatility" or percentage of answers that flip when moving demos from the default
sumposition to another.
They tested these across 10 open-source models (Qwen, Llama3, Mistral, Cohere) ranging from 1.5B to 72B parameters.
Datasets
The study evaluated performance across eight diverse benchmarks:
- Classification: MNLI (inference), AG News (topic).
- Question Answering/Reasoning: ARC (science), MMLU (general knowledge), SQuAD (reading comprehension).
- Arithmetic: GSM8K (math word problems).
- Summarization: XSUM, CNN/DailyMail.
- Long-Context: Booksum (chapters ~5k tokens).
Key Insights and Ideas
- The Primacy Effect: There is a consistent "front-loading" advantage. Placing demos at the start (
ssporesp) generally outperforms placing them later. For example, MMLU saw an 18% accuracy boost under thesspconfiguration. - The "End of Message" Disaster: Placing demos after the query (
eum) is highly unstable. In QA tasks, this position flipped over 30% of predictions without improving correctness. - Architectural Roots: The authors hypothesize this bias stems from the nature of causal decoders. Because these models are trained with autoregressive masking, earlier tokens exert a disproportionate influence on the hidden state that conditions all subsequent predictions.
- The Scaling Law of Robustness: Larger models (like Llama3-70B or Qwen-72B) are significantly more robust to positional changes than smaller models (1.5B–8B). However, even the giants remain sensitive when tackling complex reasoning tasks like GSM8K.
- Proximity vs. Primacy: While smaller models crave the very beginning of the prompt, some very large models actually showed a slight preference for having demos closer to the query (
sum), likely due to their superior ability to retain context over long sequences.
Key Results
- Accuracy Swings: Simply moving the demo block can change task accuracy by up to 20 percentage points.
- Output Volatility: On the AG News dataset, Qwen-1.5B saw 45.5% of its predictions change just by moving the demos.
- Optimal Strategy: For most users, ssp (Start of System Prompt) is the "goldilocks" zone—it provides the highest accuracy gains and the lowest prediction volatility.
- Task Sensitivity: Generative tasks (summarization) are far more volatile than classification tasks. In XSUM, the prediction change rate was nearly 100% for the
eumposition across almost all models.
Limitations and Future Work
The authors acknowledge several areas for further exploration:
- Language Scope: The study focused exclusively on English data; positional biases might manifest differently in non-Western scripts or low-resource languages.
- Model Diversity: While they tested four major families, they did not include proprietary models like GPT-4 or Claude, nor did they explore encoder-decoder architectures.
- Mitigation Strategies: The paper suggests two promising paths for future work: Test-time calibration (using a small retriever to find the best demo slot for a specific query) and unbiased training (randomly permuting demo positions during instruction tuning to force the model to become position-invariant).
Summary updated