Mitigate Position Bias in Large Language Models via Scaling a Single Dimension

Yijiong Yu, Huiqiang Jiang, Xufang Luo, Qianhui Wu, Chin-Yew Lin, Dongsheng Li, Yuqing Yang, Yongfeng Huang, Lili Qiu · DOI

Abstract Large Language Models (LLMs) often suffer from "position bias," a phenomenon where information located in the middle of a long context is significantly harder to retrieve than information at the beginning or end. This research, a collaboration between Tsinghua University and Microsoft, identifies that positional information is implicitly encoded within specific "positional channels" of an LLM's hidden states, independent of explicit position embeddings. By surgically scaling just one of these channels, the researchers demonstrate a training-free method to mitigate position bias, improving middle-context retrieval accuracy by up to 15.2% across various model architectures without degrading general reasoning capabilities.

The "Lost in the Middle" Problem

As LLMs process increasingly long contexts, they exhibit a performance dip known as the "lost in the middle" phenomenon. While models excel at retrieving information from the start or end of a prompt, their accuracy plummets when the target information is buried in the center. Traditional solutions involve modifying position embeddings (like RoPE) or expensive supervised fine-tuning (SFT). This paper explores a different hypothesis: that the model's internal hidden states carry their own positional signals—generated by the causal attention mask—and that these signals are a primary driver of position bias.

Conceptual framework showing how the causal mask generates positional information in hidden states, leading to attention patterns and subsequent position bias.

Methodology: Scaling Positional Hidden States

The researchers propose a training-free method to "steer" model attention by modifying these internal positional signals. The process involves three key steps:

  1. Identification: A heuristic search algorithm identifies "positional channels"—dimensions in the hidden states where activation values change monotonically as token position increases. Even models without explicit position embeddings (e.g., TinyLlama-NoPE) develop these channels because the causal mask inherently tracks the number of preceding tokens.
  2. Calibration: From a candidate set of monotonic channels, the optimal one is selected by testing which channel's scaling minimizes loss on a small validation dataset (e.g., 100 samples of a Key-Value retrieval task).
  3. Surgical Scaling: To minimize side effects, the researchers only modify the query and key states for the last token in the sequence. By scaling this single dimension (often multiplying by 0 or -1), they shift the attention distribution away from the initial tokens and toward the middle or end of the context.

Experimental Results

The method was evaluated on benchmarks including NaturalQuestions (NQ) Multi-document QA and Key-Value (KV) Retrieval. On the KV retrieval task, the approach improved LLaMA-2-7B's performance by 15.2% and Mistral-7B's by 9.3%.

Comparison of attention weights and retrieval accuracy across different positions of ground-truth information, showing how specific interventions can rebalance attention and improve accuracy.

As shown in the figures above, the "Original" model (purple) shows a sharp drop in accuracy for middle positions. Interventions like "PE to End" (orange) or "Crop Mask" (red) successfully rebalance the attention weights, leading to significantly higher retrieval accuracy for information buried deep in the context.

Key Insights and Discussion

  • Hidden States as Clocks: The discovery that models develop positional channels regardless of explicit embeddings suggests that the causal mask acts as a fundamental clock for the transformer architecture.
  • The Single-Dimension Lever: In a model with thousands of dimensions, it is remarkable that modifying a single channel can fundamentally alter attention distribution across tens of thousands of tokens.
  • Minimal Side Effects: Testing on MMLU benchmarks confirmed that scaling these channels has virtually no negative impact on general intelligence or reasoning, as the modification is applied surgically only during the final attention calculation.

Conclusion

This research provides a highly efficient, training-free method for extending the effective context window of LLMs. By identifying and scaling a single positional dimension in the hidden states, researchers can mitigate the "lost in the middle" bias with negligible inference latency. Future work may focus on automating layer selection and refining scaling factors for the latest frontier models.

Summary updated

BibTeX
@inproceedings{yu2024mitigate,
  author = {Yijiong Yu and Huiqiang Jiang and Xufang Luo and Qianhui Wu and Chin-Yew Lin and Dongsheng Li and Yuqing Yang and Yongfeng Huang and Lili Qiu},
  title = {{Mitigate Position Bias in Large Language Models via Scaling a Single Dimension}},
  booktitle = {LCFM @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=mo7cdmBlUi},
}
Figure