An Evaluation of Context Length Extrapolation in Long Code via Positional Embeddings and Efficient Attention
Organizations: Indian Association for the Cultivation of Science, Kolkata, India · Bosch Research and Technology Centre, Bangalore, India
Abstract
The rapid advancement of large language models (LLMs) has led to a significant increase in automated tools in the software engineering, capable of performing various code-related tasks such as code generation, completion, and translation. Despite these advancements, its effectiveness is constrained by fixed context lengths, limiting its ability to generalize across long, domain-specific code sequences. To address this challenge, we investigate zero-shot, inference-only methods aimed at improving position encodings and optimizing attention mechanisms. Our goal is to provide a thorough analysis of current approaches that facilitate context length extrapolation in code, particularly in the context of long code completion tasks.
Figures & tables
| LLaMA-2 | ShearedLLaMA | TinyLLaMA | Vicuna | |
| Para. | 7B | 1.3B | 1.1B | 7B |
| 4096 | 4096 | 2048 | 2048 | |
| Vocab Size | 32000 | 32000 | 32000 | 32000 |
| Hidden Size | 4096 | 2048 | 2048 | 4096 |
| Model | Python | Csharp | Java | ||||
| EM | Edit Sim | EM | Edit Sim | EM | Edit Sim | ||
| TinyLlama | RoPE | 0.000 | 8.886 | 0.025 | 10.533 | 0.000 | 11.141 |
| ReRoPE | 0.000 | 19.271 | 0.000 | 20.241 | 0.012 | 18.821 | |
| StreamingLLM | 0.000 | 12.656 | 0.000 | 11.769 | 0.000 | 11.693 | |
| Paged Attn | 0.034 | 2.278 | 0.087 | 4.194 | 0.024 | 3.019 | |
| Flash Attn | 0.000 | 11.031 | 0.000 | 11.629 | 0.000 | 11.672 | |
Long-Context Modeling
Long-context modeling studies how AI systems process, retrieve, and reason over sequences that exceed ordinary context windows.
See all 133 papers