TL;DR
This paper introduces LongCodeBench (LCB), a new benchmark designed to evaluate Large Language Models (LLMs) on their ability to understand and fix code within extremely long contexts, up to 1 million tokens. LCB reveals that despite advancements, current LLMs still struggle significantly with these long-context coding tasks, showing substantial performance degradation as context length increases.
What Problem Does This Paper Address?
The rapid growth of LLM context windows, now reaching millions of tokens, presents a significant challenge for evaluation. Existing benchmarks often fall short in providing realistic, large-scale tasks that truly test the capabilities of these "long-context LLMs" (LCLMs). Specifically, evaluating LCLMs on complex, real-world coding scenarios like understanding entire codebases or fixing bugs within them has been underexplored. The authors aim to bridge this gap by creating a benchmark that reflects practical software engineering challenges and allows for fine-grained analysis of LCLM performance across various context lengths.
Methods
The core contribution is the creation of LongCodeBench (LCB), a benchmark comprising two main tasks:
- LongCodeQA: This task evaluates code comprehension. It presents LLMs with a full GitHub repository and a multiple-choice question derived from real GitHub issue discussions. The goal is to test the model's ability to extract relevant information and reason about the codebase.
- LongSWE-Bench: This task focuses on code repair, specifically bug fixing. LLMs are given a subset of repository files and a GitHub issue describing a bug. They must then generate a code patch to fix the issue, which is evaluated using unit tests.
LCB emphasizes realism by drawing data from actual GitHub repositories and issues, and scalability by offering evaluations across a range of context lengths (32K to 1M tokens). The benchmark is designed to provide granular insights into how performance degrades with increasing context.
Datasets
The paper introduces LongCodeBench (LCB) as a new benchmark. LCB is constructed from real-world GitHub issues and repositories. It includes:
- LongCodeQA: 443 question-answer instances from 98 repositories.
- LongSWE-Bench: 600 bug-fixing instances from 61 repositories.
These tasks are designed to be more challenging and realistic than synthetic benchmarks, pushing the boundaries of current LLM evaluation.
Key Insights and Ideas
- Long-context coding is still a major weakness: Even state-of-the-art LLMs show significant performance drops when dealing with contexts up to 1 million tokens, especially for code repair tasks.
- Performance degradation is not uniform: Models don't just linearly degrade; some peak at mid-range contexts and then drop sharply, while others show more gradual declines. This highlights the need for granular evaluation across many context lengths.
- Realism matters: Using actual GitHub issues and codebases provides a more accurate picture of LLM capabilities than synthetic tasks.
- Code repair is harder than comprehension: LongSWE-Bench results are generally much lower than LongCodeQA, indicating that generating correct code patches in long contexts is a more difficult challenge.
- RAG can be a double-edged sword: While Retrieval Augmented Generation (RAG) can sometimes help, it can also negatively impact performance on certain tasks, as seen with Claude 3.5 Sonnet on LongSWE-Bench.
Key Results
- Significant performance drops: For example, Claude 3.5 Sonnet's accuracy on LongSWE-Bench drops from 29% at 32K tokens to 3% at 256K tokens. Qwen2.5's accuracy on LongCodeQA drops from 70.2% at 512K tokens to 40% at 1M tokens.
- Model variability: Different models exhibit distinct patterns of performance degradation. Some models like Gemini 1.5 Pro and Gemini 2.5 Pro show more stable performance across longer contexts compared to others.
- Open-source vs. Closed-source: Open-source models generally underperform closed-source models on these challenging long-context coding tasks.
- File length correlation: Interestingly, for Gemini 2 Flash on LongCodeQA, longer files were sometimes associated with higher accuracy, contrary to expectations.
Limitations and Future Work
- Computational Cost: Evaluating LCLMs on long contexts is computationally expensive, both in terms of time and cost, as detailed in the paper's Appendix C.
- Model Development Trends: The paper suggests a potential shift in model development towards specialized competence rather than general adaptability, which could impact future long-context reasoning capabilities.
- Future Work: The authors aim for LCB to serve as a foundation for advancing long-context modeling in realistic software engineering settings, implying continued development and use of the benchmark. They also highlight the need for more granular evaluations to understand context scaling effects and model capabilities.
Summary updated