Mitigating Position Bias in Transformers via Layer-Specific Positional Embedding Scaling
About
Large Language Models (LLMs) still struggle with the ``lost-in-the-middle'' problem, where critical information located in the middle of long-context inputs is often underrepresented or lost. While existing methods attempt to address this by combining multi-scale rotary position embeddings (RoPE), they typically suffer from high latency or rely on suboptimal hand-crafted scaling strategies. To overcome these limitations, we introduce a layer-specific positional embedding scaling~(LPES) method that assigns distinct scaling factors to each layer. LPES achieves a more balanced attention distribution without fine-tuning model parameters or increasing inference delay. A specially designed genetic algorithm is employed to efficiently select the optimal scaling factors for each layer by incorporating B\'{e}zier curves to significantly reduce the search space. Extensive experiments demonstrate that LPES effectively mitigates positional attention bias and delivers consistent improvements across multiple long-context benchmarks, yielding up to an $11.2$\% accuracy gain on the key-value retrieval dataset.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Multi-document Question Answering | MDQA | Accuracy @ 0% Threshold71.4 | 18 | |
| Key-Value Retrieval | Key-Value Retrieval | Accuracy (0%)99.8 | 18 | |
| Long-context Understanding | ZeroSCROLLS (val) | Qasper F124.63 | 9 | |
| Closed-ended Long-Text Understanding | L-Eval Closed-ended | Coursera Score48.51 | 6 | |
| Long-context Understanding | L-Eval | Coursera Accuracy70.6 | 6 | |
| Open-ended Long-Text Understanding | ZeroSCROLLS and L-Eval Open-ended | GovRpt27.56 | 6 |