HiRoPE: Length Extrapolation for Code Models Using Hierarchical Position
Not on the map. Why?
Abstract (arXiv)
Addressing the limitation of context length in large language models for code-related tasks is the primary focus of this paper. Existing LLMs are constrained by their pre-trained context lengths, leading to performance issues in handling long complex code sequences. Inspired by how human programmers navigate code, we introduce Hierarchical Rotary Position Embedding (HiRoPE), a novel approach that enhances the traditional rotary position embedding into a hierarchical format based on the hierarchical structure of source code. HiRoPE offers easy integration into existing LLMs without extra training costs. Our method is extensively evaluated with various LLMs, demonstrating stable performance in tasks such as language modeling and long code completion. We also introduce a new long code understanding task with real-world code projects, in hopes of promoting further development in this code-related field. Theoretically and experimentally, we find that HiRoPE also addresses the out-of-distribution issue in position encoding. Our HiRoPE significantly expands the context length capabilities of LLMs, enabling inference at lengths exponentially greater than the training length.
Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). First posted on arXiv 28 Mar 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2025: 7; 2026: 1.
8 papers.
- 2025LongCodeZip: Compress Long Context for Code Language Modelscited by 38
- 2025Sample Complexity and Representation Ability of Test-time Scaling Paradigmscited by 12
- 2025UltraFlux: Data-Model Co-Design for High-quality Native 4K Text-to-Image Generation across Diverse Aspect Ratioscited by 6
- 2025CodeSSM: Towards State Space Models for Code Understandingcited by 3
- 2025Large Language Models for Predictive Analysis: How Far Are They?cited by 3
- 2025On Pretraining for Project-Level Code Completioncited by 1
- 2025Effective Length Extrapolation via Dimension-Wise Positional Embeddings Manipulationcited by 0
- 2026Labeled Incidence Structures for Native Transformer Modeling of Text, Knowledge Graphs, and Hypergraphscited by 0
- 2026Labeled Incidence Structures for Native Transformer Modeling of Text, Knowledge Graphs, and Hypergraphs29 Jul 2026
- 2025UltraFlux: Data-Model Co-Design for High-quality Native 4K Text-to-Image Generation across Diverse Aspect Ratios22 Nov 2025
- 2025On Pretraining for Project-Level Code Completion15 Oct 2025
- 2025LongCodeZip: Compress Long Context for Code Language Models1 Oct 2025
- 2025Sample Complexity and Representation Ability of Test-time Scaling Paradigms5 Jun 2025
- 2025Large Language Models for Predictive Analysis: How Far Are They?22 May 2025
- 2025CodeSSM: Towards State Space Models for Code Understanding2 May 2025
- 2025Effective Length Extrapolation via Dimension-Wise Positional Embeddings Manipulation26 Apr 2025