Long Code Bench
Long Code Bench
Stefano Rando∗ & Yuta Kyuragi Luca Romani∗ & Fabio Galasso
Panasonic AI Research Sapienza University of Rome
{[Link], [Link]}@[Link] [Link]@[Link]
galasso@[Link]
Alessio Sampieri∗ & Luca Franco John Yang & Tatsunori Hashimoto
ItalAI Stanford University
{[Link], [Link]}@[Link] {johnby, thashim}@[Link]
arXiv:2505.07897v1 [[Link]] 12 May 2025
Abstract
Context lengths for models have grown rapidly, from thousands to millions
of tokens in just a few years. The extreme context sizes of modern long-
context models have made it difficult to construct realistic long-context
benchmarks – not only due to the cost of collecting million-context tasks
but also in identifying realistic scenarios that require significant contexts.
We identify code comprehension and repair as a natural testbed and chal-
lenge task for long-context models and introduce LongCodeBench (LCB),
a benchmark to test LLM coding abilities in long-context scenarios. Our
benchmark tests both the comprehension and repair capabilities of LCLMs
in realistic and important settings by drawing from real-world GitHub
issues and constructing QA (LongCodeQA) and bug fixing (LongSWE-
Bench) tasks. We carefully stratify the complexity of our benchmark, en-
abling us to evaluate models across different scales – ranging from Qwen2.5
14B Instruct to Google’s flagship Gemini model. We find that long-context
remains a weakness for all models, with performance drops such as from
29% to 3% for Claude 3.5 Sonnet, or from 70.2% to 40% for Qwen2.5.
1 Introduction
Long-context modeling has arisen as an active
research area, motivated by the potential of mod-
els capable of processing extended inputs in real-
world applications, such as entire code reposito-
ries or large document collections. This trend is
reflected in the emergence of Large Context Lan-
guage Models (LCLMs) (Anthropic, 2024; Ope-
nAI, 2024; GeminiTeamGoogle, 2024; JambaT-
eam, 2024), with industry-driven models now
supporting context windows up to millions of to-
kens. In parallel, experimental architectures con-
tinue to explore novel approaches for long-range
modeling (Gu et al., 2022; Gu & Dao, 2024). As il-
lustrated in Figure 1, model context lengths have
grown superexponentially in recent years, mak- Figure 1: Increasing trend of LCLM con-
ing it important for us to understand whether text lengths over time. Models tested on
and how such context sizes are effective. LCB are highlighted in orange.
1
Preprint. Under review.
Tasks Principles
Comprehension Repair Coding Synthetic Max. Context Granular Eval.
LRA ✓ × × Yes 16K ×
NIAH ✓ × × Partial 200K ×
RULER ✓ × × Yes 200K ×
HELMET ✓ ✓ × Partial 128K ✓
∞BENCH ✓ × ✓ Yes 256K ×
SWE-Bench × ✓ ✓ No 50K ×
LongCodeBench ✓ ✓ ✓ No 1M ✓
Table 1: Comparison of long-context benchmarks across task coverage (left) and core
principles (right). Repair tasks support Scalability. Generation tasks, coding, and non-synthetic
data reflect Realism. Maximum context length and granular evaluation assess Long-context.
See the discussions in Sections 1 and 3 for details.
and a few long-context reading comprehension style tasks (Wu et al., 2025; Wang et al., 2024;
Hsieh et al., 2024). However, these tasks do not fully capture the transformative potential of
LCLMs envisioned by their creators, where LCLMs are imagined to learn a foreign language
from a single book or find and fix bugs after ingesting an entire codebase (GeminiTeam-
Google, 2024).
In this work, we focus on the last of these scenarios, aiming to build a benchmark that
allows us to track progress in LMs that understand and fix codebases in challenging real-
world scenarios. This benchmark setting is underexplored, with most current coding
benchmarks (Jimenez et al., 2024; Bogomolov et al., 2024) evaluating shorter context lengths
(up to 64K–200K tokens) or focus on isolated tasks such as commit message generation. Our
work expands upon these existing benchmarks by testing the largest existing contexts and
grounding the tasks and scenarios in real-world, economically valuable software engineering
tasks.
We propose LongCodeBench (LCB), a benchmark that evaluates coding LCLMs on both
code comprehension and repair across a range of context sizes, ranging from tens of thou-
sands of tokens up to one million. To test code comprehension, we construct LongCodeQA,
which tests comprehension by posing questions derived from real GitHub issue discussions.
We complement this task with LongSWE-Bench, which assesses repair through debugging
tasks that require models to generate patches for bugs of actual software. As illustrated in
Table 1 (left), our benchmark is grounded on real-world tasks, while providing coverage
over tasks and context lengths. The dataset comprises 1043 instances that have been col-
lected from 108 repositories, and have been curated with human supervision to achieve
high-quality standards.
As illustrated in Table 1 (right), we argue for three principles that guide the creation of LCB:
2
Preprint. Under review.
2 Related work
3
Preprint. Under review.
Figure 2: Input prompt structure and output format for the two LCB tasks. LongCodeQA
(left) answer a multiple-choice question considering the full repository and the question de-
rived from GitHub issues. LongSWE-Bench (right) generate a bug-fixing patch considering
a subset of the codebase files and the GitHub issue.
the sample size and diversity. Similarly, RepoBench (Liu et al., 2024) draws data from
public GitHub repositories and departs from execution-based metrics, a significant shift that
underlines the need for alternative evaluation criteria.
SWE-Bench (Jimenez et al., 2024) proposes a range of debugging tasks by testing models on
real-world problems extracted from public GitHub issues with minimal processing overhead,
thereby closely approximating actual debugging scenarios. Inspired by SWE-Bench realism,
LongCodeBench proposes similar debugging tasks while also introducing a novel challenge
for code comprehension, which is missing in the mentioned benchmarks. Moreover, LCB
pushes the context length well beyond the 50K token limit of SWE-Bench, providing samples
of up to a million tokens. This enables a more challenging and comprehensive evaluation
framework for coding applications.
3 LongCodeBench
In this section, we introduce an overview of the proposed benchmark. Section 3.1 outlines
the general design principles, while Sections 3.2 and 3.3 detail the structure of the LongCod-
eQA and LongSWE-Bench tasks, respectively. For each task, we report its definition and
evaluation, prompt format, data collection process, and data statistics.
• Task-context interaction. Both tasks in LCB operate under the same long-context
regime, but they place fundamentally different demands on how models interact
with the context. In the comprehension task (LongCodeQA), models must identify
relevant information to answer a specific question, evaluating both their implicit
comprehension of the repository-level context and their explicit reasoning skills for
4
Preprint. Under review.
Table 2: Dataset statistics for the two LCB tasks across different context-length brackets. For
each bracket (32K to 1M), we report: the number of instances and repositories considered,
the average number of files per repository and the average number of tokens per file.
For long-context benchmarks, dataset size must be carefully balanced against the tradeoff
between inference cost and statistical reliability. As the input scales up to a million tokens,
resource requirements scale up quickly, risking inaccessibility if the dataset includes too
many instances, while a sufficient and representative number of samples is needed for
robust evaluation. In LCB, we collect a sufficient number of samples to ensure robust
estimation while containing the evaluation costs within practical limits. We report the total
cost and time of inference for the models tested on LCB in Table 6.
3.2 LongCodeQA
Here we detail LongCodeQA, including the task formulation, the prompt structure, and
data information (i.e., collection, validation, and statistics).
Task formulation To test the models’ code comprehension ability in a long-context sce-
nario, we propose LongCodeQA, which is a multiple-choice question task. Each question is
derived from public GitHub Python repositories, grounding the benchmarking in real-world
software engineering scenarios.
The evaluation metric considered is accuracy, which is measured as the percentage of correct
responses over the total number of questions.
Prompt structure Figure 2 (left) shows an example of the input prompt structure and the
response format. The prompt contains:
To ensure fairness and avoid positional biases in model evaluation, the correct answer
is randomly assigned to one of the four multiple-choice options, with uniform shuffling
5
Preprint. Under review.
applied during generation. Moreover, the task is presented in a zero-shot format, with no
additional instructions or in-context examples provided to the prompt. Complete prompt
examples are reported in appendix B.
Data collection Collecting data for LongCodeQA involves different steps: selecting the
relevant repositories, filtering the issues, and converting issues to multiple-choice questions.
As a first step, to ground the LongCodeQA task in real-world scenarios, we collect questions
derived from closed GitHub issues via GitHub REST APIs. Repositories are selected based
on their total token length to ensure a consistent distribution of samples across different
context-length brackets. To have a significant number of samples, we prioritize repositories
with a high number of publicly available issues.
After selecting repositories based on the mentioned criteria, the second step involves filtering
for relevant issues. To achieve this, we leverage an LLM (i.e., GPT-4) prompting it to filter out
cases involving bug fixing, new feature addition, installation problems, project roadmaps,
or development practices. For the selected issues, the prompt instructs the LLM to convert
them into a multiple-choice question, with the use of structured outputs (Willard & Louf,
2023) for robust formatting. However, we notice that 64% of the questions generated can
be answered using general coding knowledge alone, without referencing the repository
content. As a final safeguard against data contamination (Balloccu et al., 2024), we prompt
GPT-4 to answer each question in the dataset without access to context, and we filter out
the questions on which the model succeeded using internal knowledge alone. After all
iterations, the percentage of initial issues that are converted into appropriate questions is
3.99%. This small percentage reinforces our first point about prioritization of repositories
with a sufficient number of issues.
As a final step, we generate the specific question from the issue, the correct answer, and the
other three wrong answers. The LLM performs an additional step in extracting questions
and answers.
Data validation We design the data generation pipeline for LongCodeQA to satisfy two
key criteria: reliability and fairness. To assess reliability, we perform manual verification
on a stratified random subset of 9 questions for each context length bracket. We verify
that for 52 of the 54 selected questions—96.3%—in-depth research about the repository
and its internal codebase is required to answer successfully. Regarding fairness, a central
design decision in our pipeline is to generate all questions using only the issue “Discussion”,
without referencing the full codebase. This ensures that the benchmark is unbiased and does
not benefit from any implicit access to repository content during construction, preserving
its role as a fair evaluation tool for data construction.
Dataset statistics Table 2 (top) reports additional statistics to characterize the structure and
variability of the LongCodeQA dataset. The task comprises 443 question-answer instances
drawn from 98 public GitHub repositories. Shorter repositories are more common on
GitHub, while larger ones are comparatively rare. To ensure balanced evaluation across
context lengths, we sample a representative number of QA instances for each bracket. The
first and second rows of Table 2 report, respectively, the final number of instances and
repositories contributing to each bracket.
To better understand what drives context size, we analyze the repository structure. The
overall context length of each repository depends on both the average number of files per
repository and the average number of tokens per file, reported in the third and fourth rows
of Table 2, respectively. These two factors reflect complementary sources of complexity:
a higher number of files increases inter-file dependencies, while longer individual files
introduce more intricate intra-file dependencies. We perform an analysis on this aspect in
Section 4, as illustrated in Figure 3.
3.3 LongSWE-Bench
As for LongCodeQA, this section describes the LongSWE-Bench task, describing the task
formulation, the prompt structure, and data information (i.e., collection, validation, and
statistics).
6
Preprint. Under review.
We regulate the prompt length by selecting a subset of files (ground-truth and random)
aligning with the desired target context length. No additional instructions or in-context
examples are included, making the task zero-shot. We report additional prompt details in
Appendix B.
Data collection We assemble LongSWE-Bench through three iterative data refining steps.
In the first step, we select public Python GitHub repositories, that meet quality and size
criteria. For quality, we prioritize repositories with a large number of reported issues and
an active development cycle, as these offer a richer set of real-world debugging cases. For
size, we select repositories of sufficient length, ensuring that designated issues come from
projects with considerable codebase.
In the second step, we filter for issues that have been resolved through a pull request.
However, not all such issues are suitable: many lack explicit test cases or involve refactoring
rather than a clear bug fix. Then we restrict the selection to issues for which unit tests are
available, guaranteeing a more reliable performance metric.
As a third step, we manually discard ill-posed samples. Issues have to include a clear
description of the problem and a well-defined solution within the provided information,
excluding feature requests or ambiguous bug reports.
Data validation We design the data collection pipeline to ensure two criteria: reliability
and reproducibility. To ensure the benchmark reliability, we evaluate all the instances in the
benchmark manually, ensuring that they are well-posed and unambiguous. We do not
include issues involving the addition of new features or design choices, as those correspond
to more open-ended problems that are challenging to evaluate. To further verify data
reliability, we provide a detailed analysis in Appendix A, which guides the design of the
issue filtering pipeline used during data collection. To ensure reproducibility, we create
a dedicated execution environment to replicate each issue, guaranteeing that tests run
on the same version of the codebase in which the issue was originally raised. This is
accomplished by creating a dedicated Docker image per instance, where we install the
correct dependencies and verify the bug’s presence before applying the patch. This approach
ensures a reproducible and reliable execution of the unit tests.
Dataset statistics Table 2 (bottom) provides statistics that characterize the structure and
variability of the LongSWE-Bench dataset. The task comprises 600 bug-fixing instances
evenly distributed across six context-length brackets (32K to 1M), with 100 instances per
bracket. These instances are sampled from 61 public Python repositories. Moreover, we
analyze the repository composition, reporting both the number of files and the average
token length per file.
7
Preprint. Under review.
LongCodeQA LongSWE-Bench
32K 64K 128K 256K 512K 1M 32K 64K 128K 256K 512K 1M
Qwen2.5 - 14B Instruct 61.9 65.8 68.5 63.1 70.2 40.0 0 0 0 0 0 0
Jamba 1.5 - 400B Large 69.0 69.7 72.8 54.2 - - 3 1 1 0 - -
Llama 3.1 - 405B Instruct 69.9 72.4 67.4 - - - 0 1 0 - - -
Llama 4 Scout 66.4 73.7 70.7 63.1 78.7 76.0 0 0 0 0 0 0
GPT-4o 65.5 76.3 74.3 - - - 11 6 5 - - -
GPT-4.1 72.6 73.7 78.3 72.3 78.7 80.0 1 1 1 1 1 2
Gemini 2 Flash 66.4 68.4 65.2 63.1 70.2 65.5 10 6 7 3 2 2
Gemini 1.5 Pro 67.3 63.2 72.8 64.6 72.3 66.0 1 6 2 3 4 5
Gemini 2.5 Pro 75.2 71.1 71.7 67.7 68.1 69.8 23 25 22 24 12 7
Claude 3.5 Sonnet 65.5 69.7 71.7 66.6 - - 29 19 15 3 - -
4 Analysis
This section presents the evaluation results for a range of open- and closed-source models
detailed in Section 4.1. The results for LongSWE-Bench and LongCodeQA tasks are dis-
cussed relatively in Sections 4.2 and 4.3. Section 4.4 reports additional observations and
insights based on the results.
8
Preprint. Under review.
We report LongSWE-Bench results across context brackets in Table 3 (right section), measuring
the number of successfully resolved issues per model per bracket. As expected from the
difficulty of the task—real-world bug fixing requires precise code patch—the results are
significantly lower compared to LongCodeQA. Despite the overall difficulty, some trends
emerge. Claude 3.5 Sonnet shows the strongest performance at shorter context lengths,
solving 29% of issues at 32K. It maintains relatively high success at 64K and 128K but drops
at 3% sharply at 256K. Both Gemini 2 Flash and GPT-4o peak at 32K with 11% and 10%
relatively and show a gradual drop across longer contexts. On the other hand, Gemini
1.5 Pro demonstrates a consistently low performance, solving between 1% and 6% across
the full range; Gemini 2.5 Pro approaches Claude 3.5 at the 32K window with 23% and
maintaining a consistent rate of success until 256K, decreasing to 7% at 1M. Open-source
models perform significantly worse. Jamba solves up to 3% issues at 32K but drops to 0%
by 256K. Qwen2.5, Llama 3.1, Llama 4, and GPT-4.1 fail to solve any issue across all tested
brackets. These results reflect both the increased challenge of generative code tasks and the
current gap between open- and closed-source models in long-context code repair.
LongSWE-Bench exposes the limitations of current LCLMs in long-context settings. While
some models perform reasonably well at shorter context lengths, their effectiveness declines
significantly as the context increases — an effect amplified by the binary nature of the task,
where even small errors lead to complete failure.
4.4 Discussion
9
Preprint. Under review.
5 Conclusion
10
Preprint. Under review.
Ethics statement
This research uses only publicly available data from open-source GitHub repositories. No
personal or sensitive information is included. All experiments comply with the terms of
service of the used platforms and APIs. We will release our dataset and code to support
transparency and reproducibility.
References
Anthropic. Claude 3 haiku: Our fastest model yet. [Link]
claude-3-haiku, 2024.
Simone Balloccu, Patrı́cia Schmidtová, Mateusz Lango, and Ondrej Dusek. Leak, cheat,
repeat: Data contamination and evaluation malpractices in closed-source LLMs. In Yvette
Graham and Matthew Purver (eds.), Proceedings of the 18th Conference of the European
Chapter of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 67–
93, St. Julian’s, Malta, March 2024. Association for Computational Linguistics. URL
[Link]
Egor Bogomolov, Aleksandra Eliseeva, Timur Galimzyanov, Evgeniy Glukhov, Anton
Shapkin, Maria Tigina, Yaroslav Golubev, Alexander Kovrigin, Arie van Deursen, Maliheh
Izadi, and Timofey Bryksin. Long code arena: a set of benchmarks for long-context code
models, 2024. URL [Link]
Federico Cassano, John Gouwar, Daniel Nguyen, Sydney Nguyen, Luna Phipps-Costin,
Donald Pinckney, Ming-Ho Yee, Yangtian Zi, Carolyn Jane Anderson, Molly Q Feldman,
Arjun Guha, Michael Greenberg, and Abhinav Jangda. Multipl-e: A scalable and poly-
glot approach to benchmarking neural code generation. IEEE Transactions on Software
Engineering, 49(7):3675–3691, 2023. doi: 10.1109/TSE.2023.3267446.
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde De Oliveira Pinto,
Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evalu-
ating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
GeminiTeamGoogle. Gemini: A family of highly capable multimodal models, 2024. URL
[Link]
Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces.
In First Conference on Language Modeling, 2024.
Albert Gu, Karan Goel, and Christopher Re. Efficiently modeling long sequences with
structured state spaces. In International Conference on Learning Representations, 2022.
Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia,
and Boris Ginsburg. RULER: What’s the real context size of your long-context language
models? In First Conference on Language Modeling, 2024.
JambaTeam. Jamba-1.5: Hybrid transformer-mamba models at scale, 2024. URL https:
//[Link]/abs/2408.12570.
Carlos E Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and
Karthik R Narasimhan. SWE-bench: Can language models resolve real-world github
issues? In The Twelfth International Conference on Learning Representations, 2024.
Gregory Kamradt. Needle in a haystack - pressure testing llms. Github, 2023. URL
[Link] NeedleInAHaystack/tree/main.
Tianyang Liu, Canwen Xu, and Julian McAuley. Repobench: Benchmarking repository-
level code auto-completion systems. In The Twelfth International Conference on Learning
Representations, 2024.
LlamaTeam. The llama 3 herd of models, 2024. URL [Link]
11
Preprint. Under review.
12
Preprint. Under review.
Here, we report additional experiments that guide the design of LCB’s data collection.
A.1 Performance on the small-scale dataset before and after the first filter
In this section, we analyze the impact of the initial filtering step on a small-scale dataset
of around 60 samples. Initially, this dataset is generated by converting GitHub issues into
multiple-choice questions using the prompt in Appendix B.1. Then, we assess model accu-
racy both before and after applying the prompt in Appendix B.2, which filters out questions
that do not require detailed, repository-specific knowledge. Results in Table 4 indicate a
substantial accuracy drop after filtering, confirming the importance and effectiveness of this
step in refining the dataset quality.
Table 4: Model accuracy comparison on a small dataset to test the effectiveness of the first
filter described in Appendix B. After testing the two models on the initial dataset, we filter
out questions that do not require repo-specific knowledge.
This section presents the results obtained on the complete LongCodeQA dataset following
the application of the prompts described in Appendix B.1 and B.2. Before the second
filter, the dataset includes questions explicitly identified as requiring repository-specific
comprehension, but it still includes questions that might be correctly answered without
repository context. Table 5 presents the accuracy of LCLMs on the LongCodeQA task,
evaluated at different context lengths ranging from 32K to 1M tokens after filtering. The
comparison includes both closed-source models (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5
Pro, and Gemini 2 Flash) and open-source models (Qwen2.5, Jamba 1.5, and Llama 3.1).
The results indicate that while most models maintain strong performance at shorter and
moderate context lengths, accuracy reduces significantly at extreme lengths, such as the
1M token bracket (e.g., Qwen2.5 dropping to 54.5%). Models like Llama 3.1, Jamba 1.5,
and the Gemini series demonstrate stable performance across mid-to-high context lengths,
highlighting their robustness.
The last filtering step described in section 3.2 provides the final version presented in the main
paper. It exclusively contains challenging questions that only require detailed repository
analysis, which we show in Table 3.
Table 5: Model performance for LongCodeQA task on the complete dataset after applying
prompts in Appendix B.1 and B.2.
13
Preprint. Under review.
B Prompts
Here are reported the prompts used for generating the LongCodeQA dataset and for
prompting the LLMs.
Comments: {issue["comments"]}
This prompt filters the initially generated questions, including only those that require
detailed repository-specific knowledge to be accurately answered.
You are provided with a question about the repository {repo}. Your task is not to
answer the question directly but to evaluate whether an accurate answer requires a
detailed, up-to-date understanding of the repository, or if it can be answered
accurately using only your pre-existing knowledge (which may include exposure to the
repository during training) and general programming knowledge.
Please explain your reasoning in detail. At the end of your response, on a new line,
output only 'Yes' if you believe the question requires repository-specific knowledge
to answer accurately, or 'No' if you believe it can be answered correctly without
directly consulting the repository.
14
Preprint. Under review.
This prompt is used to answer multiple choice questions based on repository analysis.
You are a coding expert. Your task is to analyze a GitHub repository and then answer
one question about it.
Repository:
{repo_text}
Question:
{question}
Please analyze the repository text, reason through the question, and then choose
among A, B, C, D answers the correct one.
This prompt generates a patch file to address a coding issue described in a given repository.
You will be provided with a partial code base and an issue statement explaining a
problem to resolve.
<issue>
{issue_body}
</issue>
<code>
{repo_body}
</code>
Here is an example of a patch file. It consists of changes to the code base. It
specifies the file names, the line numbers of each change, and the removed and added
lines. A single patch file can contain changes to multiple files.
<patch>
--- a/[Link]
+++ b/[Link]
@@ -1,27 +1,35 @@
def euclidean(a, b):
- while b:
- a, b = b, a % b
- return a
+ if b == 0:
+ return a
+ return euclidean(b, a % b)
I need you to solve the provided issue by generating a single patch file that I can
apply directly to this repository using git apply. Please respond with a single patch
file in the format shown above.
Respond below:
15
Preprint. Under review.
Table 6 details the inference cost and resource requirements for the models evaluated on
LongCodeBench. For self-hosted models, we report both the GPU configuration and the
total runtime. For example, Qwen2.5 was run on 8×A100 80GB GPUs for LongSWE-Bench,
completing inference in 12 hours, and on 4×A100 64GB GPUs for LongCodeQA, taking 35
hours. In contrast, API-based models show varied costs depending on the provider and
context length. Claude 3.5 Sonnet incurs the highest cost, totaling 100 USD for LongCodeQA
and 140 USD for LongSWE-Bench. GPT-4o shows lower costs at 50 USD per task. Overall,
these figures underscore the high computational and financial burden of evaluating LCLMs
on long-context tasks, especially as context windows approach one million tokens.
Table 6: Inference cost and time on LCB for the models used in the experiments. For self-
hosted models, GPU configuration and total inference time are reported; hosted (API-based)
models include provider and total inference cost in USD.
The LongSWE-Bench task is inspired by Jimenez et al. (2024) but extends it to a significantly
longer context scenario. Specifically, we increase the maximum context length to one million
tokens and introduce a scalable, granular evaluation across multiple length brackets.
Another key difference with SWE-Bench is in the repository file selection for the context.
SWE-Bench uses the BM25 (Robertson & Zaragoza, 2009) retrieval algorithm, we always
include the ground-truth files and then add random files as a distraction. As observed
by the original SWE-Bench authors, the inclusion or omission of ground-truth files in the
prompt creates a sizable gap in performance. This implies that the benchmark results are a
combined measure of the models’ performance and the accuracy of the retrieval algorithm.
Our decision to always provide ground-truth files as context is for the objective of ensuring
the benchmark is an unbiased estimator of exclusively models’ performance.
For files provided as additional context, we rely on random retrieval for statistical reasons.
The creation of samples through relevance-based retrieval of documents introduces bias
in the data, as large codebases or other forms of long documents are rarely provided after
filtering for non-relevant documents. Random selection, instead, is a form of uniform
sampling. This way, we reduce bias at the cost of a higher variance. However, variance can
be controlled by providing a sufficiently large number of instances. In this context, random
retrieval provides the additional benefit of allowing us to retrieve more samples per issue, as
a different selection of the majority of files in a prompt changes the problem in meaningful
ways. Figures 5 and 6 show the difference in variance by selecting files randomly or with
the BM25 retrieval algorithm. The plots are supported by an analysis of relation between
context length and resolution rate through logistic regression. The random retrieval case
exhibits a p-value of 0.005, which is statistically significant. On the contrary, the p-value for
BM25 is larger than 0.01.
16
Preprint. Under review.
17