File size: 1,396 Bytes
8507a20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""The evaluation subset: 100 instances of SWE-bench Verified, drawn once with a fixed seed.

    python eval/make_subset.py            # writes eval/subset.json

The file also lists every repository of SWE-bench Verified: training data must share none of them.
"""
import json
import random
import sys
from pathlib import Path

from datasets import load_dataset

DATASET, SPLIT, SEED, N = "princeton-nlp/SWE-bench_Verified", "test", 20261201, 100


def main():
    out = Path(sys.argv[1] if len(sys.argv) > 1 else Path(__file__).parent / "subset.json")
    ds = load_dataset(DATASET, split=SPLIT)
    repo_of = dict(zip(ds["instance_id"], ds["repo"]))
    ids = sorted(repo_of)
    pick = sorted(random.Random(SEED).sample(ids, N))
    per_repo = {}
    for i in pick:
        per_repo[repo_of[i]] = per_repo.get(repo_of[i], 0) + 1
    out.write_text(json.dumps({
        "dataset": DATASET, "split": SPLIT, "dataset_fingerprint": ds._fingerprint, "total_instances": len(ids),
        "seed": SEED, "n": N, "method": "random.Random(seed).sample(sorted(instance_ids), n)",
        "instance_ids": pick, "instances_per_repo": dict(sorted(per_repo.items())),
        "all_repos_of_the_benchmark": sorted(set(repo_of.values())),
    }, indent=1) + "\n", encoding="utf-8")
    print(f"{out}: {len(pick)} of {len(ids)} instances, {len(per_repo)} repositories")


if __name__ == "__main__":
    main()