forked from Aider-AI/aider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswe_bench.py
131 lines (111 loc) · 3.54 KB
/
swe_bench.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import sys
from pathlib import Path
import matplotlib.pyplot as plt
from imgcat import imgcat
from matplotlib import rc
from aider.dump import dump # noqa: F401
def plot_swe_bench(data_file, is_lite):
with open(data_file, "r") as file:
lines = file.readlines()
models = []
pass_rates = []
instances = []
for line in lines:
if line.strip():
pass_rate, model = line.split("%")
model = model.strip()
if "(" in model:
pieces = model.split("(")
model = pieces[0]
ins = pieces[1].strip(")")
else:
ins = None
instances.insert(0, ins)
model = model.replace("|", "\n")
models.insert(0, model.strip())
pass_rates.insert(0, float(pass_rate.strip()))
dump(instances)
plt.rcParams["hatch.linewidth"] = 0.5
plt.rcParams["hatch.color"] = "#444444"
font_color = "#555"
font_params = {
"family": "sans-serif",
"sans-serif": ["Helvetica"],
"size": 10,
"weight": "bold",
}
rc("font", **font_params)
plt.rcParams["text.color"] = font_color
fig, ax = plt.subplots(figsize=(10, 5.5))
ax.grid(axis="y", zorder=0, lw=0.2)
for spine in ax.spines.values():
spine.set_edgecolor("#DDDDDD")
spine.set_linewidth(0.5)
if is_lite:
colors = ["#17965A" if "Aider" in model else "#b3d1e6" for model in models]
else:
colors = ["#1A75C2" if "Aider" in model else "#b3d1e6" for model in models]
bars = []
for model, pass_rate, color in zip(models, pass_rates, colors):
alpha = 0.9 if "Aider" in model else 0.3
hatch = ""
# if is_lite:
# hatch = "///" if "(570)" in model else ""
bar = ax.bar(model, pass_rate, color=color, alpha=alpha, zorder=3, hatch=hatch)
bars.append(bar[0])
for label in ax.get_xticklabels():
if "Aider" in str(label):
label.set_fontfamily("Helvetica Bold")
for model, bar in zip(models, bars):
yval = bar.get_height()
y = yval - 1
va = "top"
color = "#eee" if "Aider" in model else "#555"
fontfamily = "Helvetica Bold" if "Aider" in model else "Helvetica"
ax.text(
bar.get_x() + bar.get_width() / 2,
y,
f"{yval}%",
ha="center",
va=va,
fontsize=16,
color=color,
fontfamily=fontfamily,
)
for model, ins, bar in zip(models, instances, bars):
if not ins:
continue
yval = bar.get_height()
y = yval - 2.5
va = "top"
color = "#eee" if "Aider" in model else "#555"
ax.text(
bar.get_x() + bar.get_width() / 2,
y,
f"of {ins}",
ha="center",
va=va,
fontsize=12,
color=color,
)
# ax.set_xlabel("Models", fontsize=18)
ax.set_ylabel("Pass@1 (%)", fontsize=18, color=font_color)
if is_lite:
title = "SWE Bench Lite"
else:
title = "SWE Bench"
ax.set_title(title, fontsize=20)
# ax.set_ylim(0, 29.9)
plt.xticks(
fontsize=16,
color=font_color,
)
plt.tight_layout(pad=3.0)
out_fname = Path(data_file.replace("-", "_"))
plt.savefig(out_fname.with_suffix(".jpg").name)
plt.savefig(out_fname.with_suffix(".svg").name)
imgcat(fig)
ax.xaxis.label.set_color(font_color)
fname = sys.argv[1]
is_lite = "lite" in fname
plot_swe_bench(fname, is_lite)