NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Positional Encoding and Prompt-Order Sensitivity in In-Context Learning

Zhijie Wang, Bo Jiang, Shuai Li

NeurIPS page · Open on the map

Category: Interpretability & Model Adaptation › Transformer In-Context Learning · Type: theory · Keywords: in-context learning, positional encoding, prompt order sensitivity, linear attention, theoretical analysis, transformer models

Areas: LLM Reasoning › Efficient Reasoning › In-Context Learning; Long Context › Long-context mechanisms › In-context learning; Model Architectures & Sequence Modeling › Language Model Architectures › Attention Geometry

Summary

The paper provides a theoretical analysis of how positional encoding influences in-context learning in linear-attention transformers, revealing a k/N dependence on prompt order for both order-invariant and order-sensitive tasks and validating the findings experimentally.

Explained to a 5-year-old

When a computer learns from examples, it looks at the order of those examples. The paper studies how the computer remembers where each example sits using special numbers. It shows that the computer’s answer changes a little when the examples are rearranged, and this change depends on how many examples there are and how long the list is. The study checks its ideas with simple made-up tasks.

Explained to a 5-year-old, longer

Imagine you have a toy robot that can solve puzzles by looking at a few example pictures. The robot notices where each picture is in the row, using little tags. If you move the pictures around, the robot’s answer might shift a bit. The researchers looked at a simpler robot that uses straight lines instead of pictures, and they studied two kinds of tags: simple tags and rotating tags. They tested the robot on two kinds of puzzles: one where the order of pictures doesn’t matter (like adding numbers) and one where order does matter (like a story that changes if you swap sentences). They found that the robot’s change in answer grows with how many pictures you have and how long the row is, following a simple rule. They then ran some experiments to make sure their theory matches what the robot actually does. This helps us understand why the robot sometimes works differently depending on how we show it examples.

For a technical reader

We analyze how positional encodings affect in-context learning in linear-attention transformers. The theoretical derivation shows a k/N scaling of output change with prompt permutation size and context length, dependent on encoding type, weights, input dimension, and task parameters. Experiments confirm the predictions across linear regression and dynamical systems tasks. The findings provide insight into designing more robust ICL systems.

Problem

In-context learning can be affected by the order in which example prompts are presented, yet the underlying mechanisms remain poorly understood. This paper seeks to characterize how positional encodings modulate this order sensitivity in transformer models.

Method

The approach theoretically analyzes linear-attention transformer models under two positional encoding schemes (one-hot and rotary) and examines order-invariant (linear regression) and order-sensitive (dynamical systems) ICL tasks. It derives how changes in prompt order affect model output, showing a leading k/N dependence on permutation size and context length. The theoretical results are validated with experiments.

Results

The approach finds that the change in model output scales as k/N with permutation size and context length, and these theoretical predictions are confirmed by experiments.

Contributions

It provides the first theoretical characterization of how positional encodings affect prompt-order sensitivity in ICL for linear-attention transformers, covering both order-invariant and order-sensitive tasks, and validates the theory empirically.

Limitations and assumptions

The analysis focuses on linear-attention transformer models and idealized tasks; extensions to more complex architectures or real-world datasets are not covered.

Practical relevance

Understanding prompt-order sensitivity and the role of positional encodings can guide the design of more reliable in-context learning systems for language models.

Research questions this paper is counted under

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction