Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

HiRoPE: Length Extrapolation for Code Models Using Hierarchical Position

About

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.

Kechi Zhang, Ge Li, Huangzhao Zhang, Zhi Jin• 2024

Related benchmarks

TaskDatasetResultRank
Code Symbol UnderstandingCode Symbol Understanding 1.0 (test)
Recall14.15
12
Long Code CompletionLCC 0-4k
Edit Similarity66.61
12
Long Code CompletionLCC (4k-8k)
Edit Similarity69.93
12
Long Code CompletionLCC >8k
Edit Sim65.38
12
Long Code CompletionRepoBench 4k-8k
Edit Similarity53.3
12
Long Code CompletionRepoBench >8k
Edit Sim51.24
12
Long Code CompletionRepoBench 0-4k
Edit Similarity52.2
12
Language ModelingReRoPE (eval)
Overall Loss1.7622
10
Showing 8 of 8 rows

Other info

Follow for update