# SWE-bench: Can Language Models Resolve Real-World GitHub Issues?

Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press and 1 more · arXiv · 2023-10-10

- **Problem** Existing coding benchmarks mostly test self-contained snippets, while real issues often need coordinated edits across a repository.
- **Method** The authors build SWE-bench from merged GitHub pull requests that include test changes, score patches by running the repository's tests, and fine-tune CodeLlama-Python models with LoRA on gold patches.
- **Results** Claude 2 with BM25 retrieval resolves 1.96% of task instances at a 13k context limit.

![Figure 1: SWE-bench sources task instances from real-world Python repositories by connecting GitHub issues to merged pull request solutions that resolve relate…](https://refivu.com/papers/1cf41e87-39dc-4e23-9d0c-22ab7bc2a24b/figures/figure-9edbba63f2377b78ce88264eca856776.png?thumb=512)

**Figure 1** : SWE-bench sources task instances from real-world Python repositories by connecting GitHub issues to merged pull request solutions that resolve related tests. Provided with the issue text and a codebase snapshot, models generate a patch that is evaluated against real tests.

[Original paper](https://arxiv.org/abs/2310.06770v3) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, Karthik Narasimhan · SWE-bench: Can Language Models Resolve Real-World GitHub Issues? · Original paper figure · Extracted the figure area from page 1 of the original PDF.

## Why repository-scale issues test more than snippets

HumanEval and similar coding benchmarks mostly ask for self-contained functions that fit in a few lines of code. Real maintenance work looks different: a developer has to locate the right spot in a large repository, trace how functions in different files interact, and spot a small mistake inside tangled code. SWE-bench turns that setting into a test.

A model receives an issue and a codebase, edits the codebase, and the change counts only if the repository's tests pass.

Current systems do poorly under this setup. Claude 2 with BM25 retrieval resolves 1.96% of the issues, and the authors find that models solve only the simplest ones.

## How task instances are mined and filtered

The attribute filter keeps merged pull requests that resolve a GitHub issue and also change test files, which suggests the contributor wrote tests for the fix. The execution filter applies each candidate's test changes before and after the rest of the pull request. It keeps instances that contain at least one fail-to-pass test and drops those that fail during installation or runtime.

After all filters, 2,294 task instances remain from the original 90,000 pull requests.

Because the collection steps need little manual work, the same procedure can be applied to new issues as they appear. This lets the benchmark test a model on issues created after its training data was gathered, which makes it less likely that the reference solution was already in the training corpus.

## Scoring a patch by running tests

The model returns a patch file that names the lines to change in the codebase. The benchmark is designed so that this edit, rather than a free-form answer, is what gets judged. The evaluator applies the patch with the unix patch program and then runs the unit and system tests linked to the instance. An instance counts as resolved only when the patch applies and every linked test passes.

The headline metric is % Resolved, the percentage of task instances that end up resolved.

Reference edits are not small. On average they touch 1.7 files, 3.0 functions and 32.8 lines, spread over the codebase rather than one function.

## Adapting CodeLlama with LoRA

CodeLlama models are among the few open models able to take the very long contexts that repository editing requires. Off-the-shelf CodeLlama variants, however, often answer with placeholder text or with code unrelated to the issue when asked for repository-wide edits.

To train on this task, the authors collected 19,000 issue-PR pairs from 37 further Python repositories. Unlike the benchmark pipeline, these pairs did not require pull requests to contribute test changes. The training repositories are disjoint from the evaluation repositories, which guards against contamination of the benchmark.

Each training prompt holds the instructions, the issue text and the relevant code files, and the target is the gold patch that resolved the issue. Only the attention sublayer weights are updated, through LoRA, and training sequences longer than 30,000 tokens are dropped, which leaves about 10,000 instances.

## Choosing which files the model sees

Codebases average 438K lines, far more than any context window, so each model receives only part of the repository. Under BM25, files are ranked against the issue text and added until a maximum context limit is reached.

Dense retrieval is set aside because the queries and keys become very long, and natural language queries over code are an unusual setting for it. BM25 is applied at three context limits, and each model is reported at the limit where it performs best. Models perform best at the shortest context window tested.

The oracle setting gives the model the files that the reference patch edits. It is an analysis tool, not a realistic option, because an engineer may not know beforehand which files need to change. Even the edited files may leave out context needed to see how the changed code interacts with the rest of the program.

At a 27,000-token limit, BM25 retrieves a superset of the oracle files in about 40% of instances. In almost half of the instances at that limit, it retrieves none of the oracle files. Average BM25 recall against the oracle files rises from 29.58 at 13k to 44.41 at 27k and 51.06 at 50k.

## Resolve rates across models

Across the full benchmark, Claude 3 Opus reaches a % Resolved of 3.79 and Claude 2 reaches 1.97. GPT-4-turbo reaches 1.31 and ChatGPT-3.5 reaches 0.17. SWE-Llama 7b and 13b each reach 0.70. On the 300-instance SWE-bench Lite subset, Claude 3 Opus reaches 4.33 and Claude 2 reaches 3.00, while SWE-Llama 7b reaches 1.33.

The authors describe SWE-Llama 13b as competitive with Claude 2 in some settings, and its Table 4 window covers at least 100,000 tokens for 94.8% of instances.

## Limits of the current evidence

Oracle retrieval uses information a developer would not have in advance, so its scores describe an upper reference rather than a deployable system. The retrieval comparison covers only BM25 at three context limits, and the training data excludes sequences longer than 30,000 tokens. The full benchmark spans 12 repositories and the Lite subset spans 11, so results cover only those Python projects.

## Paper info

- **Authors**: Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, Karthik Narasimhan
- **Venue**: arXiv · Preprint
- **First published**: 2023-10-10
- **Added**: 2026-10-20
- **Updated**: 2024-11-11
- **Version**: v3
- **arXiv**: 2310.06770
- **Category**: cs.CL · cs.AI · cs.SE
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2310.06770v3) · [PDF ↗](https://arxiv.org/pdf/2310.06770v3)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Language models have outpaced our ability to evaluate them effectively, but for their future development it is essential to study the frontier of their capabilities. We find real-world software engineering to be a rich, sustainable, and challenging testbed for evaluating the next generation of language models. To this end, we introduce SWE-bench, an evaluation framework consisting of $2,294$ software engineering problems drawn from real GitHub issues and corresponding pull requests across $12$ popular Python repositories. Given a codebase along with a description of an issue to be resolved, a language model is tasked with editing the codebase to address the issue. Resolving issues in SWE-bench frequently requires understanding and coordinating changes across multiple functions, classes, and even files simultaneously, calling for models to interact with execution environments, process extremely long contexts and perform complex reasoning that goes far beyond traditional code generation tasks. Our evaluations show that both state-of-the-art proprietary models and our fine-tuned model SWE-Llama can resolve only the simplest issues. The best-performing model, Claude 2, is able to solve a mere $1.96$% of the issues. Advances on SWE-bench represent steps towards LMs that are more practical, intelligent, and autonomous.

## Quote from the paper

Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, Karthik Narasimhan (2023). SWE-bench: Can Language Models Resolve Real-World GitHub Issues?. arXiv:2310.06770v3. https://arxiv.org/abs/2310.06770v3

**BibTeX**

```
@misc{jimenez2023bench,
  title = {{SWE-bench: Can Language Models Resolve Real-World GitHub Issues?}},
  author = {Carlos E. Jimenez and John Yang and Alexander Wettig and Shunyu Yao and Kexin Pei and Ofir Press and Karthik Narasimhan},
  year = {2023},
  eprint = {2310.06770},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.06770v3}
}
```

## Other paper commentary

- [Voyager: An Open-Ended Embodied Agent with Large Language Models](https://refivu.com/en/papers/39fe0a31-1bf8-4ca2-bc7b-151ae7a6faa4-voyager-an-open-ended-embodied-agent-with-large.md)
- [Finetuned Language Models Are Zero-Shot Learners](https://refivu.com/en/papers/3dedf278-64d7-4653-93ff-bf4504ae70ac-finetuned-language-models-are-zero-shot-learners.md)
- [Scaling Instruction-Finetuned Language Models](https://refivu.com/en/papers/6f9b141d-190c-4397-9e41-4f796f4ef56e-scaling-instruction-finetuned-language-models.md)
- [LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale](https://refivu.com/en/papers/263598fd-8186-4bb8-858a-0eba8ecdb369-llm-int8-8-bit-matrix-multiplication-for-transformers.md)
- [Efficient Memory Management for Large Language Model Serving with PagedAttention](https://refivu.com/en/papers/a69a26aa-a470-4bff-9c73-2a7fe8ffd528-efficient-memory-management-for-large-language-model-serving.md)
- [Retentive Network: A Successor to Transformer for Large Language Models](https://refivu.com/en/papers/ca4ee5c6-87cf-427b-ae91-b593c10e0b48-retentive-network-a-successor-to-transformer-for-large.md)
- [STaR: Bootstrapping Reasoning With Reasoning](https://refivu.com/en/papers/2942117a-1b64-4434-bef7-4f70b61ab603-star-bootstrapping-reasoning-with-reasoning.md)
- [Scalable Diffusion Models with Transformers](https://refivu.com/en/papers/20637697-d13d-4af8-bc4d-7f97df178df2-scalable-diffusion-models-with-transformers.md)
- [Image-to-Image Translation with Conditional Adversarial Networks](https://refivu.com/en/papers/92d09be2-7a1b-4f53-9d24-569d7cc94149-image-to-image-translation-with-conditional-adversarial.md)
- [HexaShell: A Thin Harness for Exploring the Limits of VLM Agents as Robot Coding Agents](https://refivu.com/en/papers/987b0722-81e4-41f3-8104-a1d8a65def66-hexashell-a-thin-harness-for-exploring-the-limits.md)
- [Prefix-Tuning: Optimizing Continuous Prompts for Generation](https://refivu.com/en/papers/01cf041e-b71c-444b-8b44-e94ac976a9db-prefix-tuning-optimizing-continuous-prompts-for-generation.md)
- [WebGPT: Browser-assisted question-answering with human feedback](https://refivu.com/en/papers/b41258c0-ce1e-478c-ad2b-6bccd936ae34-webgpt-browser-assisted-question-answering-with-human.md)

## Terms in this paper

- [LoRA](https://refivu.com/en/terms/bee764895c36-lora)
- [supervised fine-tuning](https://refivu.com/en/terms/1a2c1f079517-supervised-fine-tuning)
- [SWE-bench Lite](https://refivu.com/en/terms/edd3c9b8fc40-swe-bench-lite)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/1cf41e87-39dc-4e23-9d0c-22ab7bc2a24b-swe-bench-can-language-models-resolve-real-world)
