Resonance RoPE: Improving Context Length Generalization of Large Language Models

Suyuchen Wang, Ivan Kobyzev, Peng Lu, Mehdi Rezagholizadeh, Bang Liu
2/29/2024
cs.CLcs.AI

No official code found. Best implementation: sheryc/resonance_rope (24 stars, Apache-2.0, last commit 2024-03-05).

Abstract

This paper addresses the challenge of train-short-test-long (TSTL) scenarios in Large Language Models (LLMs) equipped with Rotary Position Embedding (RoPE), where models pre-trained on shorter sequences face difficulty with out-of-distribution (OOD) token positions in longer sequences. We introduce Resonance RoPE, a novel approach designed to narrow the generalization gap in TSTL scenarios by refining the interpolation of RoPE features for OOD positions, significantly improving the model performance without additional online computational costs. Furthermore, we present PosGen, a new synthetic benchmark specifically designed for fine-grained behavior analysis in TSTL scenarios, aiming to isolate the constantly increasing difficulty of token generation on long contexts from the challenges of recognizing new token positions. Our experiments on synthetic tasks show that after applying Resonance RoPE, Transformers recognize OOD position better and more robustly. Our extensive LLM experiments also show superior performance after applying Resonance RoPE to the current state-of-the-art RoPE scaling method, YaRN, on both upstream language modeling tasks and a variety of downstream long-text applications.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[ACL 24 Findings] Implementation of Resonance RoPE and the PosGen synthetic dataset.

240Shell, PythonFeb 28, 20242 years agoApache-2.0

Similar Papers

Cite this paper

@article{wang2024resonance,
  title  = {Resonance RoPE: Improving Context Length Generalization of Large Language Models},
  author = {Suyuchen Wang and Ivan Kobyzev and Peng Lu and Mehdi Rezagholizadeh and Bang Liu},
  year   = {2024},
  eprint = {2403.00071},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2403.00071v2}
}

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/2403.00071.svg)](https://codeofpaper.com/paper/2403.00071)

Discussion