Abstract Standard Large Language Models (LLMs) rely on rigid, linear positional indices (e.g., 0, 1, 2...) to process text. This imposes a heavy "extraneous cognitive load" on attention mechanisms, forcing them to spend their computational budget deciphering input structure rather than reasoning over content. RePo (Context Re-Positioning) introduces a differentiable module that learns to assign token positions based on semantic relevance rather than strict sequential order. By enabling tokens to exist in a continuous, non-linear positional space, RePo significantly enhances performance on long-context tasks, noisy data, and structured information with negligible computational overhead.
1. The Problem: The Cognitive Load of Rigid Context
Modern LLMs typically treat input sequences as a flat, strictly ordered line. Whether utilizing absolute embeddings or relative schemes like Rotary Position Embedding (RoPE), every token is assigned a fixed integer index based solely on its string position.
This rigid structure creates a high extraneous cognitive load for the model. In Cognitive Load Theory, extraneous load refers to the effort required to process how information is organized, rather than the information itself. Because standard architectures impose a strict linear structure, the attention mechanism must expend its limited capacity figuring out the underlying structure of the text—such as identifying which parts of a long prompt are relevant to a specific query. This structural bottleneck directly contributes to the well-known "lost in the middle" phenomenon and degrades performance on tasks featuring highly diluted or structured information.
2. Methodology: The RePo Architecture
The core innovation of this work is the RePo module ($f_\phi$), a lightweight neural network inserted prior to the position encoding step. Instead of relying on a pre-defined sequential order, RePo assigns a real-valued position $z_i$ to each token $x_i$ based on its hidden state.
The mechanism operates in two primary steps:
- Position Representation: A lightweight SwiGLU sub-layer extracts a lower-dimensional "positional feature" from the token's hidden state.
- Position Assignment: A linear transformation maps this feature to a specific position value $z_i$ for each attention head.
Crucially, because this module is differentiable, the model can be trained end-to-end to "move" relevant tokens closer together in positional space, even if they are far apart in the original text. To maintain efficiency and training stability, RePo is applied only to the upper two-thirds of the model's layers. Lower layers tend to focus on surface-level features (like syntax) that benefit less from structural reorganization.
3. Key Mechanisms and Insights
By shifting from rigid integers to learned, continuous positions, RePo unlocks several emergent behaviors:
- Breaking the Locality Bias: Standard LLMs exhibit a strong locality bias, naturally attending more to nearby tokens. RePo breaks this constraint by allowing the model to assign distant but critical "needle" tokens a position value that makes them appear "closer" to the query token during attention calculation.
- Dense, Non-linear Space: RePo allows for a much denser representation of information. The model frequently assigns positions within a range much smaller than the actual sequence length, indicating that relative semantic distance is more important than absolute sequential distance.
- Emergent Semantic Mapping: RePo naturally learns to group related tokens. In few-shot learning scenarios, for instance, the model learns to positionally "segment" different examples, effectively creating a structured internal map of the prompt without explicit supervision.
- Hybrid Strategies: RePo does not rely on a single positional pattern. It utilizes a hybrid approach—sometimes keeping positions constant, sometimes monotonic (like RoPE), and often deploying a complex mixture of both depending on the context.
4. Experimental Results
To evaluate RePo, the authors continually pre-trained the open-source OLMo-2 models (1B and 7B variants) on 50 billion tokens of general text data. The resulting models were tested across several specialized benchmarks, demonstrating consistent gains as task complexity increased:
- Noisy Context (RULER): On the "Needle-in-a-Haystack" tasks, which test retrieval in noisy contexts, RePo outperformed standard RoPE by 5.4 points on the 1B model.
- Structured Data (HybridQA): RePo achieved a 2.27 point (1B) and 4.09 point (7B) improvement on HybridQA, indicating it better handles the structural loss that occurs when tables are flattened into text.
- Long Context (LongBench): Across a suite of long-context tasks (up to 16K tokens), RePo improved the average score by 6.93 points (1B) and 6.38 points (7B) over the baseline.
- General Benchmarks: RePo maintained competitive performance on short-context suites (ARC, BoolQ, Hellaswag), ensuring no regression on standard tasks.
- Efficiency: The module is highly efficient, introducing only a 0.9% increase in parameters and a negligible 3.4% increase in inference latency per token.
5. Limitations and Future Work
While RePo offers substantial improvements, the authors note a few current limitations:
- KV Cache Constraints: Currently, RePo only affects the attention score calculation. To avoid massive overhead during auto-regressive generation, the model does not physically re-sort the Key-Value (KV) cache based on the new positions. A truly "re-ordered" cache could unlock further gains but remains a technical challenge.
- Training Stability: Applying RePo to the very first layers of the model caused training instability, likely because those layers are still learning foundational token relationships.
Future research directions include exploring more complex architectures for the $f_\phi$ module and investigating how RePo might assist in multi-modal models, where spatial relationships (such as those in images) are even more critical to structural understanding.
Summary updated