LaMPE: Length-aware Multi-grained Positional Encoding for Adaptive Long-context Scaling Without Training
2508.02308v2
cs.CL
2025-08-09
Авторы:
Sikui Zhang, Guangze Gao, Ziyun Gan, Chunfeng Yuan, Zefeng Lin, Houwen Peng, Bing Li, Weiming Hu
Резюме на русском
**Резюме**
Проблема: Большинство больших языковых моделей (LLMs) сталкиваются с существенной потерей эффективности при обработке входных данных, превышающих предобученную окновость контекста. Это происходит в основном из-за неточного представления позиционных сигналов в Rotary Position Embedding (RoPE), которое приводит к выходу данных за диапазон индифицированных позиций.
Предложенное решение: Мы предлагаем **Length-aware Multi-grained Positional Encoding (LaMPE)** — новую методику, которая адаптивно распределяет позиционные эмбеддинги в зависимости от длины входного сообщения, используя параметрическую функцию сигмоида. LaMPE также включает многоуровневую механику внимания, которая разделяет позиционные сигналы между локальными и длинными зависимостями на последовательности. Особенность LaMPE в том, что она не требует дополнительной тренировки и может быть легко интегрирована с любыми LLM-моделями, основанными на RoPE.
Основные выводы: Мы провели эксперименты на трех моделях LLMs в пяти различных задачах длинного контекста. Результаты показали, что LaMPE превосходит другие методы увеличения длины контекста, обеспечивая значительные повышения точности без дополнительного обучения. Наше решение представляет новый подход к эффективной обработке длинных входных последовательностей в LLMs.
Abstract
Large language models (LLMs) experience significant performance degradation
when the input exceeds the pretraining context window, primarily due to the
out-of-distribution (OOD) behavior of Rotary Position Embedding (RoPE). Recent
studies mitigate this problem by remapping OOD positions into the
in-distribution range with fixed mapping strategies, ignoring the dynamic
relationship between input length and the model's effective context window. To
this end, we propose Length-aware Multi-grained Positional Encoding (LaMPE), a
training-free method that fully utilizes the model's effective context window
for adaptive long-context scaling in LLMs. Motivated by the left-skewed
frequency distribution of relative positions, LaMPE establishes a dynamic
relationship between mapping length and input length through a parametric
scaled sigmoid function to adaptively allocate positional capacity across
varying input lengths. Meanwhile, LaMPE devises a novel multi-grained attention
mechanism that strategically allocates positional resolution across different
sequence regions to capture both fine-grained locality and long-range
dependencies. Our method can be seamlessly applied to a wide range of
RoPE-based LLMs without training. Extensive experiments on three representative
LLMs across five mainstream long-context benchmarks demonstrate that LaMPE
achieves significant performance improvements compared to existing length
extrapolation methods. The code will be released at
https://github.com/scar-on/LaMPE.
Ссылки и действия
Дополнительные ресурсы: