DAPE: Data-Adaptive Positional Encoding for Length Extrapolation

Abstract

Positional encoding plays a crucial role in transformers, significantly impact- ing model performance and length generalization. Prior research has introduced absolute positional encoding (APE) and relative positional encoding (RPE) to distinguish token positions in given sequences. However, both APE and RPE remain fixed after model training regardless of input data, limiting their adaptability and flexibility. Hence, we expect that the desired positional encoding should be data-adaptive and can be dynamically adjusted with the given attention. In this paper, we propose a Data-Adaptive Positional Encoding (DAPE) method, which dynamically and semantically adjusts based on input context and learned fixed priors. Experimental validation on real-world datasets (Arxiv, Books3, and CHE) demonstrates that DAPE enhances model performances in terms of trained length and length generalization, where the improvements are statistically significant. The model visualization suggests that our model can keep both local and anti-local information. Finally, we successfully train the model on sequence length 128 and achieve better performance at evaluation sequence length 8192, compared with other static positional encoding methods, revealing the benefit of the adaptive positional encoding method.

Cite

Text

Zheng et al. "DAPE: Data-Adaptive Positional Encoding for Length Extrapolation." Neural Information Processing Systems, 2024. doi:10.52202/079017-0838

Markdown

[Zheng et al. "DAPE: Data-Adaptive Positional Encoding for Length Extrapolation." Neural Information Processing Systems, 2024.](https://mlanthology.org/neurips/2024/zheng2024neurips-dape/) doi:10.52202/079017-0838

BibTeX

@inproceedings{zheng2024neurips-dape,
  title     = {{DAPE: Data-Adaptive Positional Encoding for Length Extrapolation}},
  author    = {Zheng, Chuanyang and Gao, Yihang and Shi, Han and Huang, Minbin and Li, Jingyao and Xiong, Jing and Ren, Xiaozhe and Ng, Michael and Jiang, Xin and Li, Zhenguo and Li, Yu},
  booktitle = {Neural Information Processing Systems},
  year      = {2024},
  doi       = {10.52202/079017-0838},
  url       = {https://mlanthology.org/neurips/2024/zheng2024neurips-dape/}
}