File size: 5,710 Bytes
21efdcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
"""Generate the BananaMind 2 Micro Base Bench efficiency chart."""

from dataclasses import dataclass
from pathlib import Path

import matplotlib

matplotlib.use("Agg")

import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator


RANDOM_BASELINE = 25.0
OUTPUT_PATH = Path(__file__).with_name("parameter_efficiency.png")


@dataclass(frozen=True)
class ModelResult:
    name: str
    parameters: int
    accuracy: float
    highlighted: bool = False

    @property
    def excess_accuracy(self) -> float:
        return self.accuracy - RANDOM_BASELINE

    @property
    def efficiency(self) -> float:
        return self.excess_accuracy / (self.parameters / 100_000)

    @property
    def parameter_label(self) -> str:
        return f"{self.parameters / 1_000_000:.2f}M"


# Accuracy values are raw public BananaMind Base Bench 1.1 accuracy.
# Exact parameter counts and scores are preserved so the chart can be rebuilt.
MODELS = (
    ModelResult("BananaMind 2 Micro", 2_933_193, 34.57, highlighted=True),
    ModelResult("GPT-S-5M", 5_158_464, 37.14),
    ModelResult("GPT-S2-5M", 5_384_258, 35.71),
    ModelResult("Syn-2.6M", 2_604_210, 32.57),
    ModelResult("Ant-5M", 4_713_344, 25.43),
    ModelResult("Supra-Mini-v5-8M", 7_867_584, 36.29),
    ModelResult("cma-8M", 7_849_161, 40.86),
)


def build_chart(output_path: Path = OUTPUT_PATH) -> Path:
    ranked = sorted(MODELS, key=lambda model: model.efficiency, reverse=True)

    background = "#f4f7fb"
    ink = "#172033"
    muted = "#667085"
    grid = "#d8dee9"
    peer = "#5d7898"
    banana = "#f3b61f"
    banana_edge = "#d99a00"

    fig = plt.figure(figsize=(16, 9), dpi=120, facecolor=background)
    ax = fig.add_axes([0.255, 0.18, 0.49, 0.61], facecolor=background)

    positions = list(range(len(ranked)))
    colors = [banana if model.highlighted else peer for model in ranked]
    edges = [banana_edge if model.highlighted else peer for model in ranked]
    bars = ax.barh(
        positions,
        [model.efficiency for model in ranked],
        height=0.56,
        color=colors,
        edgecolor=edges,
        linewidth=1.2,
        zorder=3,
    )

    ax.invert_yaxis()
    ax.set_yticks(positions, [model.name for model in ranked])
    ax.tick_params(axis="y", length=0, pad=14, labelsize=14, colors=ink)
    ax.tick_params(axis="x", length=0, pad=8, labelsize=11, colors=muted)

    max_efficiency = max(model.efficiency for model in ranked)
    ax.set_xlim(0, max_efficiency * 1.18)
    ax.xaxis.set_major_locator(MultipleLocator(0.05))
    ax.grid(axis="x", color=grid, linewidth=1, zorder=0)
    ax.set_axisbelow(True)
    for spine in ax.spines.values():
        spine.set_visible(False)

    ax.set_xlabel(
        "Accuracy points above random per 100K parameters",
        fontsize=12,
        color=muted,
        labelpad=16,
    )

    for tick, model in zip(ax.get_yticklabels(), ranked):
        tick.set_fontweight("bold" if model.highlighted else "normal")
        tick.set_color("#9a6800" if model.highlighted else ink)

    for bar, model in zip(bars, ranked):
        ax.text(
            bar.get_width() + 0.006,
            bar.get_y() + bar.get_height() / 2,
            f"{model.efficiency:.3f}",
            va="center",
            ha="left",
            fontsize=12,
            fontweight="bold",
            color=ink,
        )

    column_transform = ax.get_yaxis_transform()
    ax.text(
        1.12,
        -0.82,
        "BASE BENCH\nACCURACY",
        transform=column_transform,
        ha="center",
        va="bottom",
        fontsize=9,
        fontweight="bold",
        color=muted,
        clip_on=False,
    )
    ax.text(
        1.34,
        -0.82,
        "PARAMETERS",
        transform=column_transform,
        ha="center",
        va="bottom",
        fontsize=9,
        fontweight="bold",
        color=muted,
        clip_on=False,
    )
    for position, model in zip(positions, ranked):
        text_color = "#9a6800" if model.highlighted else ink
        fontweight = "bold" if model.highlighted else "normal"
        ax.text(
            1.12,
            position,
            f"{model.accuracy:.2f}%",
            transform=column_transform,
            ha="center",
            va="center",
            fontsize=12,
            fontweight=fontweight,
            color=text_color,
            clip_on=False,
        )
        ax.text(
            1.34,
            position,
            model.parameter_label,
            transform=column_transform,
            ha="center",
            va="center",
            fontsize=12,
            fontweight=fontweight,
            color=text_color,
            clip_on=False,
        )

    fig.text(
        0.06,
        0.925,
        "BananaMind 2 Micro",
        fontsize=34,
        fontweight="bold",
        color=ink,
    )
    fig.text(
        0.06,
        0.872,
        "Base Bench parameter efficiency",
        fontsize=21,
        fontweight="bold",
        color=ink,
    )
    fig.text(
        0.06,
        0.835,
        "Seven sub-10M models ranked by useful accuracy per parameter",
        fontsize=13,
        color=muted,
    )

    fig.text(
        0.06,
        0.075,
        "Formula: (raw accuracy - 25% random baseline) / (parameters / 100,000)",
        fontsize=11,
        color=muted,
    )
    fig.text(
        0.94,
        0.075,
        "BananaMind Base Bench 1.1 | 350 questions",
        fontsize=11,
        color=muted,
        ha="right",
    )

    output_path.parent.mkdir(parents=True, exist_ok=True)
    fig.savefig(output_path, facecolor=background)
    plt.close(fig)
    return output_path


if __name__ == "__main__":
    print(build_chart())