Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs

Xin Ma, Yang Liu, Jingjing Liu, Xiaoxu Ma
10/1/2024
3 citations

Official code: soacker/Mesa-Extrapolation (3 stars, Python, last commit 2024-10-29).

Abstract

Large language models (LLMs), although having revolutionized many fields, still suffer from the challenging extrapolation problem, where the inference ability of LLMs sharply declines beyond their max training lengths. In this work, we conduct a theoretical analysis to better understand why No Position Encoding (NoPE) fails outside its effective range, as well as examining the power of Position Encoding (PE) in this context.

Show full abstract

Our findings reveal that with meticulous weave position, PE can indeed be extended beyond effective range. Our theorems establish that LLMs equipped with weave PE can achieve improved extrapolation performance without additional cost. Furthermore, we introduce a novel weave PE method, Mesa-Extrapolation, which utilizes a chunk-based triangular attention matrix and applies Stair PE to manage the final chunk. This method not only retains competitive performance but also offers substantial benefits such as significantly reduced memory demand and faster inference speed. Extensive experiments validate the effectiveness of Mesa-Extrapolation, demonstrating its potential as a scalable solution to enhancing LLMs applicative reach. Our code is available at \url{https://github.com/soacker/Mesa-Extrapolation}.

View on arXivView PDF

Code Implementations(1)

[NeurIPS 2024] Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs

30PythonOct 14, 20242 years ago
extrapolationlarge-language-modelstrain-free

Similar Papers

Cite this paper

@article{ma2024mesaextrapolation,
  title  = {Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs},
  author = {Xin Ma and Yang Liu and Jingjing Liu and Xiaoxu Ma},
  year   = {2024},
  eprint = {2410.15859},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2410.15859},
  url    = {https://arxiv.org/abs/2410.15859},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.15859.svg)](https://codeofpaper.com/paper/2410.15859)

Discussion