Saved in:
Bibliographic Details
Main Authors: Ma, Xin, Liu, Yang, Liu, Jingjing, Ma, Xiaoxu
Format: Preprint
Published: 2024
Subjects:
Online Access:https://arxiv.org/abs/2410.15859
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916451457171456
author Ma, Xin
Liu, Yang
Liu, Jingjing
Ma, Xiaoxu
author_facet Ma, Xin
Liu, Yang
Liu, Jingjing
Ma, Xiaoxu
contents 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. 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}.
format Preprint
id arxiv_https___arxiv_org_abs_2410_15859
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs
Ma, Xin
Liu, Yang
Liu, Jingjing
Ma, Xiaoxu
Machine Learning
Artificial Intelligence
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. 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}.
title Mesa-Extrapolation: A Weave Position Encoding Method for Enhanced Extrapolation in LLMs
topic Machine Learning
Artificial Intelligence
url https://arxiv.org/abs/2410.15859