-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SWE-Benchmarks (from Huggingface) (#544)
- Loading branch information
1 parent
480063a
commit 3976617
Showing
11 changed files
with
202 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ build | |
benchmark_repos | ||
docs/build | ||
.DS_Store | ||
benchmarks/benchmarks/swe_bench_samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pathlib import Path | ||
|
||
from datasets import load_dataset, DatasetDict # type: ignore | ||
|
||
from mentat.sampler.sample import Sample | ||
|
||
|
||
SWE_BENCH_SAMPLES_DIR = Path(__file__).parent / "benchmarks" / "swe_bench_samples" | ||
|
||
|
||
def download_swe_benchmarks(split: str = "dev") -> list[dict[str, str]]: | ||
"""3 splits are available: dev (225), test (2.29k), and train (19k).""" | ||
dataset: DatasetDict = load_dataset("princeton-nlp/SWE-bench", split=split) # type: ignore | ||
dataset: list[dict[str, str]] = [dict(benchmark) for benchmark in dataset] | ||
return dataset | ||
|
||
|
||
def get_swe_samples(split: str = "dev", max_benchmarks: int | None = None) -> list[Sample]: | ||
"""Return a list of SWE-Bench samples. | ||
If missing, download, convert to Samples and save locally. | ||
""" | ||
split_dir = SWE_BENCH_SAMPLES_DIR / split | ||
saved_benchmarks = list(split_dir.glob("*.json")) | ||
if not split_dir.exists() or max_benchmarks and len(saved_benchmarks) < max_benchmarks: | ||
print(f"Downloading {split} split from SWE-Bench...") | ||
split_dir.mkdir(parents=True, exist_ok=True) | ||
dataset = download_swe_benchmarks(split) | ||
samples = [Sample.from_swe_bench(benchmark) for benchmark in dataset] | ||
for sample in samples: | ||
sample.save(split_dir / f"{sample.id}.json") | ||
else: | ||
samples = [Sample.load(fname) for fname in saved_benchmarks] | ||
|
||
if max_benchmarks: | ||
samples = samples[:max_benchmarks] | ||
print(f"Selected {len(samples)} benchmarks from '{split}'") | ||
return samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
aiomultiprocess==0.9.0 | ||
black==23.9.1 | ||
datasets==2.18.0 | ||
gitpython==3.1.41 | ||
isort==5.12.0 | ||
pip-licenses==4.3.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [2024-03-22]: Add fields to cover content of SWE-Bench | ||
Fields in common are left with their current name. Missing fields (*) are added. | ||
|
||
Sampler SWE-Bench | ||
- title | ||
- description | ||
- id instance_id | ||
- parent_id | ||
- repo repo | ||
- environment_setup_commit * | ||
- merge_base base_commit | ||
- diff_merge_base | ||
- diff_active | ||
- message_history | ||
- message_prompt problem_statement | ||
hint_text * | ||
- message_edit | ||
- context | ||
- diff_edit patch | ||
test_patch * | ||
- test_command FAIL_TO_PASS | ||
PASS_TO_PASS * | ||
- version | ||
- version | ||
- created_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.2.0" | ||
__version__ = "0.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters