Base of RoPE Bounds Context Length

Position embedding is a core component of current Large Language Models (LLMs). Rotary position embedding (RoPE), a technique that encodes the position information with a rotation matrix, has been the de facto choice for position embedding in many LLMs, such as the Llama series. RoPE has been further utilized to extend long context capability, which is roughly based on adjusting the \textit{base} parameter of RoPE to mitigate out-of-distribution (OOD) problems in position embedding. However, in this paper, we find that LLMs may obtain a superficial long-context ability based on the OOD theory. We revisit the role of RoPE in LLMs and propose a novel property of long-term decay, we derive that the \textit{base of RoPE bounds context length}: there is an absolute lower bound for the base value to obtain certain context length capability. Our work reveals the relationship between context length and RoPE base both theoretically and empirically, which may shed light on future long context training.

Paper

Similar papers

Peer review

Reviewer aPSb7/10 · confidence 5/52024-07-07

Summary

The paper investigates the role of RoPE in long-context LLMs. It highlights that the base of RoPE crucially affects the model's ability to handle long contexts. This paper derives a theoretical (and empirical) lower bound for the base value required to maintain long-context capabilities and validates this through empirical experiments with models like Llama2-7B and Baichuan2-7B, and a 2B model trained from scratch. This work offers insights into the base of RoPE for long-context processing in LLMs, which is inspiring for the development and design of long-context LLMs.

Strengths

1. The lack of long-context ability is still an under-explored question and a very important one. Thus, the research topic of this paper is both theoretically important and practical. 2. The relationship between the RoPE base and long-context ability is important, and the proposed lower bound is interesting and inspiring. 3. The experiments in this paper are comprehensive and well support the claims made in the paper. 4. The presentation of this paper is overall very good and easy to understand and follow. 5. The claims of this paper are inspiring for the development of long-context LLM. 6. I am also very interested in RoPE-based selection in LLM and like this paper.

Weaknesses

1. The Desiderata 2. The similar token gets more attention in Section 4 seems intuitively correct but may not be empirically correct. As this desideratum is the fundamental motivation of Theorem 1, a thorough empirical verification is a must-have. 2. The motivation section is not well-written or organized. It confuses me while I read this part. These are just some previous empirical observations and are not deeply discussed. As the motivation part is very important, I would like to see a clear and well-organized motivation. 3. For the Caption of Figure 6, it would be better to show how to derive the value of the dotted line. I would also like to see a detailed derivation here. 4. Will the author plan to release the models (including the fine-tuned Llama2, Baichun2 with varying lengths, and the 2b model series)? This would benefit future work. 5. I wonder about the negativeness and positiveness of the $q^{T}R_{m,\theta}k$ in equations (8) and (9). If the values are negative, say -2 and -1, which one indicates more attention? 6. For section 5.3, I would like to regard this as a conjecture rather than an explanation. 7. Moinries - The upper case and lower case of the title are not consistent, such as the title of Section 4.1 and Section 2.2 - Line 225 “method2” -> “Method 2”

Questions

See **Weaknesses**

Rating

7

Confidence

5

Soundness

4

Presentation

3

Contribution

3

Limitations

See **Weaknesses**

Reviewer XTUy8/10 · confidence 4/52024-07-09

Summary

ROPE is wildily employed in popular LLMs which encodes positional information with a rotation matrix. Although RoPE is used to enhance long-context capabilities by adjusting its base parameter to address OOD issues, this paper finds that this may result in only superficial long-context abilities. Authors re-evaluate RoPE's role and introduce a novel property of long-term decay, showing that the base of RoPE limits context length, with an absolute lower bound required for certain capabilities. This work clarifies the theoretical and empirical relationship between context length and the RoPE base, offering insights for future long-context training.

Strengths

- The two provided desideratas are highly logical and well-aligned with language modeling. The assumption made in this paper is quite reasonable and closely aligned with practical scenarios. - Insightful analysis. The theoretical results presented in this paper are easy to understand. To the best of my knowledge, the final bound for the ROPE base is novel and first introduced in this paper

Weaknesses

There is no obvious weaknesses in my opinion. I just have a few questions: - Regarding the "Desiderata 2 The similar token gets more attention", recently StreamLLM [1] shows that there exists "attention sink" in popular LLMs. Namely most of tokens attend to the first few tokens. This somehow contradicts with the principle that "the similar token gets more attention". Could you provide your thoughts on this statement? - Anthropic's blogs reveal that different heads may have different functionality in in-context learning. How may this interplay with the Rope base? Do you think different heads may have different optimal rope base? [1] Efficient Streaming Language Models with Attention Sinks [2] In-context Learning and Induction Heads

Questions

See Weaknesses

Rating

8

Confidence

4

Soundness

4

Presentation

4

Contribution

4

Limitations

See Weaknesses

Reviewer 3a2j6/10 · confidence 3/52024-07-13

Summary

This paper investigates the role of Rotary Position Embedding (RoPE) in Large Language Models (LLMs), with a focus on the relationship between RoPE's base and the model's long context ability. The study looks into the long-context abilities and limitations of current methods that rely on smaller RoPE bases. With a lower base, LLM models may exhibit superficial long-context abilities, achieving low perplexity but failing to retrieve relevant information in extended contexts. Theoretically, The paper establishes two desiderata for the attention mechanism in language modeling: 1.Closer tokens receive more attention. 2.Similar tokens receive more attention. It examines these when applying RoPE to LLMs, revealing a long-term decay in attention score and the ability to differentiate similar from random tokens. This leads to a theorem indicating that RoPE’s base sets an absolute lower bound for achieving specific context lengths.

Strengths

1. Clarity and Technical Correctness: The paper is clear and technically sound, with theoretical and empirical analyses. 2. Experimental Rigor and Reproducibility: It includes extensive experiments to back up the theoretical findings, along with detailed setup and results. 3. Novel Findings: This paper presents a critical study of whether we should use smaller bases for continuous training, as suggested by previous work. Furthermore, this paper presents a novel perspective on long-term decay, as well as an absolute lower bound on the RoPE base parameter required for specific context lengths. This adds new knowledge to the field and improves our understanding of position embedding in LLMs.

Weaknesses

Overall, I like this paper. I would like to suggest that the authors strengthen their work by considering the following points: 1. Extensively test the model using benchmarks such as RULER [1]. 2. Provide more empirical observations on the relationship between the base of RoPE and model performance on those challenging benchmarks. -- [1] https://github.com/hsiehjackson/RULER

Questions

For the suggestions, please refer to the weaknesses section.

Rating

6

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

N/A

Reviewer mP486/10 · confidence 1/52024-07-15

Summary

Hi Area Chair, I am not qualified for the review of this paper, this is out of my knowledge scope.

Strengths

n/a

Weaknesses

n/a

Questions

n/a

Rating

6

Confidence

1

Soundness

3

Presentation

3

Contribution

3

Limitations

n/a

Reviewer XTUy2024-08-09

Thank you for your clarification. I am satisfied with the response. Good Luck!

Reviewer 3a2j2024-08-11

Thank you for your response. Could you please clarify the setup used for fine-tuning Llama2-7b to a sequence length of 32k? Specifically, I’m interested in understanding which data was used and the detailed training configuration. The number you reported appears to be *higher* than what I observed in my previous experiments.

Authorsrebuttal2024-08-12

Thank you for your feedback. We appreciate the opportunity to clarify and address your concerns. 1. **Data**: As mentioned in Section 5.1 and Appendix B, our training data is a subset of RedPajama. We upsampled long data during fine-tuning, with ~50% of tokens from documents ≥4k in length. This approach ensures a balance of shorter and longer data, differing from Longlora[1] which used only 8k to 32k data when fine-tuning LLaMA-2-7B to 32k. While data proportion isn't our paper's primary focus, we believe using a sampling method similar to Longlora would yield comparable conclusions. 2. **Training Configuration**: - As stated in Section 5.1 and Appendix B, we used a fixed learning rate of 2e-5, global batch size of 128, and fine-tuned for 1000 steps. We've reviewed our configuration and can provide additional details: | Parameter | Value | |-----------|-------| |Global Batch Size| 128 | | Steps | 1000 | | Tensor Parallelism (Tp) | 4 | | Pipeline Parallelism (Pp) | 2 | | Precision | bf16 | | Learning Rate (Lr) | 2e-5 | | Weight Decay (Wd) | 0 | | Adam Beta1 | 0.9 | | Adam Beta2 | 0.98 | | Gradient Clip | 1.0 | Perhaps you can tell us the training configuration you have conducted before and the number you observed, and we can check together what caused the difference from your previous observations. Furthermore, as mentioned in our response to Reviewer XWTB, we plan to open-source our trained models. You can download them and compare them with your own trained models at that time. We look forward to your response and the opportunity for further discussion. [1] LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models

Reviewer 3a2j2024-08-13

Thank you for the detailed explanation regarding the data and configuration. I would encourage you to incorporate our discussion into the final version of your paper. Solid work overall! I have updated my score accordingly. Good luck!

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC