What it is used for
SWE-bench is used to measure the frontier of language model capability on genuine software engineering work, rather than on made-up exercise problems. Its creators state that real-world software engineering is a rich, sustainable, and challenging testbed for evaluating the next generation of language models, and that advances on SWE-bench represent steps towards language models that are more practical, intelligent, and autonomous.
Its second use is fair comparison between models. Because every model faces the same 2,294 problems under the same scoring, namely running the repositories' own tests, differences in results read as differences in capability on the same work, not differences in the luck of the questions.
Its third use, recorded in the paper itself, is as training material. From its companion training set, the creators fine-tuned two models named SWE-Llama, CodeLlama-Python models of 7 billion and 13 billion parameters trained specifically to become repository editors. The benchmark was therefore designed from the start as both a measuring instrument and a source of material for improving what it measures.
How it works
SWE-bench is not an application for general users; it is an evaluation tool for researchers and model developers. Its workings divide into how the problems are constructed and how answers are scored, and both are recorded openly in the paper.
Problem construction runs in three stages from about 90,000 pull requests collected from the 12 repositories. The first stage collects pull requests together with the codebase at their starting point. The second stage keeps only merged pull requests that resolve an issue and that change test files, because a test change signals that an official check exists for the issue. The third stage runs those tests before and after the change is applied, and keeps only problems with at least one test that changes from failing to passing, while discarding problems that produce installation or runtime errors. From about 90,000 pull requests, 2,294 final problems remain.
Scoring is done by machine, not by human impression. The patch a model generates is applied to the codebase using unix's patch program, and then the unit and system tests associated with the problem are run. A problem counts as resolved if the patch applies successfully and all of these tests pass. The final score is the percentage of problems resolved.
One arrangement for feeding material to models is essential for reading SWE-bench results. A complete codebase is far too large to fit entirely into a model's context window, so in the paper's main arrangement the files handed to the model are selected by a retriever named BM25. There is also a comparison arrangement named "oracle", in which the model is handed exactly the files that the original pull request edited. The difference between these two arrangements is large, and every figure in the next section names its arrangement so the two are never confused.
Real examples
The following examples are not invented for this article. Both are recorded in the SWE-bench paper itself and are quoted from the text opened for this article.
The first example is one problem analysed in depth in the paper, from the sphinx repository. Under the oracle arrangement, the model edited the correct function, _parse_other_parameters_section in the file sphinx/ext/napoleon/docstring.py, but changed its behaviour as if the setting napoleon.use_param were always true, without checking the setting first as the original patch did. The error was caught immediately by a test named test_parameters_with_class_reference, which compares the documentation produced when the setting is set to false. The problem was counted as unresolved: the model found the right place, but failed to reproduce the right logic.
The second example is the first evaluation run itself. Under the main arrangement with BM25 retrieval, the best model of the paper's time, Claude 2, resolved 1.96% of the problems. Under the oracle arrangement, Claude 2 rose to 4.8%, SWE-Llama 13b reached 3.97%, GPT-4 reached 1.74% with the caveat that GPT-4 was evaluated only on a 25% random subset of the problems because of budget constraints, and ChatGPT-3.5 reached 0.52%. The paper also records that the problems resolved by each model do not overlap extensively: under the oracle arrangement Claude 2 resolved 110 problems and SWE-Llama 13b resolved 91 problems, yet Claude 2 solved only 42% of the problems that SWE-Llama solved. Different models turned out to solve different problems.
Practitioner level
For practitioners reading SWE-bench result boards, the paper's first lesson is that retrieval of material matters as much as the model. When the files handed over are narrowed further to only the lines actually edited by the original patch, with a buffer of 15 lines around them, in the arrangement the paper names "oracle"-collapsed, GPT-4 jumped from 1.3% to 3.4% and Claude 2 rose from 4.8% to 5.9%. The same model changed its result purely because the material handed to it changed.
The second lesson concerns the shape of model patches. The paper records that model-generated patches that apply correctly are on average far shorter than the original patches, 30.1 lines against 74.5 lines, and rarely edit more than a single file, whereas the original patches commonly edit many files at once. Models of that time tended to write primitive Python code, made little use of third-party libraries and of the rest of the codebase, and solved problems in the narrowest way without the broader structural improvements that the original patches commonly make.
The third lesson is that difficulty is uneven. Difficulty differs across repositories, and difficulty correlates with context length. The paper also notes that some issues embed images in their text, for example 32% of matplotlib problems and 10% of seaborn problems contain embedded images, against just 2% of all problems, so resolving such problems may require models that can process images or additional tool use.
Expert level
SWE-bench scoring rests on two test lists that the paper records under the literal names FAIL_TO_PASS and PASS_TO_PASS. FAIL_TO_PASS tests are those that fail before the original patch is applied and pass after it, the tests that prove the issue is resolved. PASS_TO_PASS tests are those that already passed before and must keep passing, the tests that prove the patch did not break previous behaviour. A problem counts as resolved only if both lists pass in full on the model's patch.
From that framework the paper derives failure classes that are worth knowing. If a patch changes no behaviour at all, every PASS_TO_PASS test passes but zero FAIL_TO_PASS tests pass, and the state is named a "No-Op". If zero FAIL_TO_PASS tests pass and some PASS_TO_PASS tests also fail, the codebase is left in a worse state than before, and the state is named a "Regression".
The training side is also recorded in detail. SWE-Llama was fine-tuned from CodeLlama-Python using LoRA, a fine-tuning method that changes only a small part of the model's weights, with issue text and the relevant code files as input and the original patch as the answer to imitate. Training sequences longer than 30,000 tokens were excluded, reducing the effective training corpus to 10,000 instances.
Two official standings of the project can be read on its own official repository. The paper was accepted at ICLR 2024 as an oral presentation, and the licence file in the official repository states the MIT licence in the names of its seven authors: Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik R. Narasimhan. The arXiv abstract page records its version history: the first version was submitted on 10 October 2023 and the third version, the version opened for this article, on 11 November 2024.
Limits and risks
The first limit is its coverage. SWE-bench contains only Python problems from 12 repositories; it does not measure model capability in other programming languages, in companies' closed repositories, or in engineering work that does not take the shape of issues and pull requests.
The second limit is its era. The models the paper evaluates are the models of the paper's time, and the 1.96% figure is a portrait of capability at that time, not a standing of any model today. Reading this paper's figures as a current ranking is a misreading; what endures from the paper is the design of its test, not its result numbers.
The third limit is inherent in how its score is computed. Resolved means passing the official tests that accompanied the original pull request; this scoring is strong because it runs by machine and can be repeated, but it judges a patch by the tests that exist, not by human review of its design quality. The paper itself records its own reading cautions, among them that GPT-4 was evaluated only on a 25% random subset of the problems because of budget constraints, so its figure is not fully comparable with models evaluated on all problems, and that the creators checked results before and after a certain cutoff date and found little difference, with the exception of GPT-4.
The final risk is misuse of the name. Because SWE-bench became a famous benchmark, its name can be used to claim model capability on work it never tested. This article limits itself to what the paper records: 2,294 problems, 12 Python repositories, and results under the arrangements named one by one.