File size: 6,167 Bytes
8ce2c21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Render public benchmark assets for TensorMind 1.5 Preview."""

from __future__ import annotations

import json
from pathlib import Path

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.offsetbox import AnnotationBbox, OffsetImage


ROOT = Path(__file__).resolve().parent
DATA = json.loads((ROOT / "benchmark-results.json").read_text())
LOGO = ROOT / "tensorplay-ai-logo.png"

BG = "#07111F"
PANEL = "#0C1A2C"
PANEL_ALT = "#10243A"
WHITE = "#F4F8FF"
MUTED = "#8EA5C3"
GRID = "#263A52"
CYAN = "#2ED7FF"
BLUE = "#267BFF"
ORANGE = "#FF9D42"

mpl.rcParams.update(
    {
        "font.family": "DejaVu Sans",
        "axes.facecolor": BG,
        "figure.facecolor": BG,
        "savefig.facecolor": BG,
        "text.color": WHITE,
        "axes.labelcolor": MUTED,
        "xtick.color": MUTED,
        "ytick.color": MUTED,
        "axes.edgecolor": GRID,
        "svg.fonttype": "none",
    }
)


def add_logo(fig: plt.Figure) -> None:
    rgba = plt.imread(LOGO)
    alpha = rgba[..., 3].copy() if rgba.shape[-1] == 4 else 1.0 - rgba[..., :3].mean(axis=-1)
    white_logo = np.ones((*alpha.shape, 4), dtype=float)
    white_logo[..., 3] = alpha
    fig.add_artist(
        AnnotationBbox(
            OffsetImage(white_logo, zoom=0.105),
            (0.84, 0.927),
            xycoords="figure fraction",
            frameon=False,
        )
    )


def header(fig: plt.Figure, title: str, subtitle: str) -> None:
    fig.text(0.055, 0.905, "TensorMind 1.5 Preview", fontsize=13, color=CYAN, weight="bold")
    fig.text(0.055, 0.843, title, fontsize=28, weight="bold")
    fig.text(0.055, 0.792, subtitle, fontsize=11, color=MUTED)
    add_logo(fig)


def footer(fig: plt.Figure) -> None:
    fig.text(
        0.055,
        0.055,
        "Protocol  lm-eval 0.4.12 路 SGLang 0.5.14 路 0-shot 路 full datasets 路 batch 48 路 fixed seeds",
        fontsize=8.5,
        color=MUTED,
    )
    fig.text(0.955, 0.055, "Accuracy, higher is better", ha="right", fontsize=8.5, color=MUTED)


def save(fig: plt.Figure, name: str) -> None:
    fig.savefig(ROOT / f"{name}.png", dpi=200)
    fig.savefig(ROOT / f"{name}.svg")
    plt.close(fig)


def render_suite() -> None:
    results = DATA["results"]
    metrics = [
        ("CMMLU", results["cmmlu"]),
        ("AGIEval-CN", results["agieval_cn"]),
        ("A-CLUE", results["a_clue"]),
        ("C-Eval", results["c_eval"]),
        ("TMMLU+", results["tmmlu_plus"]),
    ]

    fig = plt.figure(figsize=(14, 7.875), dpi=200)
    header(fig, "Chinese benchmark suite", "Five full-dataset evaluations under one matched zero-shot protocol")
    gs = fig.add_gridspec(1, 12, left=0.095, right=0.955, top=0.72, bottom=0.13, wspace=1.2)

    ax = fig.add_subplot(gs[0, :8])
    ax.set_facecolor(PANEL)
    for spine in ax.spines.values():
        spine.set_visible(False)
    names = [name for name, _ in metrics][::-1]
    values = [value for _, value in metrics][::-1]
    y = np.arange(len(metrics))
    ax.barh(y, values, height=0.46, color=[BLUE, CYAN, BLUE, CYAN, BLUE], alpha=0.95)
    ax.set_xlim(0, 35)
    ax.set_yticks(y, names, fontsize=10.5)
    ax.set_xticks([0, 10, 20, 30])
    ax.tick_params(axis="both", length=0, pad=10)
    ax.grid(axis="x", color=GRID, linewidth=0.8, alpha=0.75)
    ax.set_axisbelow(True)
    for yi, value in enumerate(values):
        ax.text(value + 0.45, yi, f"{value:.4f}", va="center", fontsize=10, color=WHITE, weight="bold")
    ax.set_xlabel("Accuracy (%)", loc="right", fontsize=9, labelpad=10)

    ax_card = fig.add_subplot(gs[0, 9:])
    ax_card.set_facecolor(PANEL_ALT)
    ax_card.set_xticks([])
    ax_card.set_yticks([])
    for spine in ax_card.spines.values():
        spine.set_visible(False)
    ax_card.text(0.10, 0.86, "FIVE-SUITE MACRO", fontsize=8.5, color=CYAN, weight="bold", transform=ax_card.transAxes)
    ax_card.text(0.10, 0.64, f"{results['five_suite_macro']:.4f}", fontsize=36, color=WHITE, weight="bold", transform=ax_card.transAxes)
    ax_card.text(0.10, 0.53, "full-dataset accuracy", fontsize=9.5, color=MUTED, transform=ax_card.transAxes)
    ax_card.plot([0.10, 0.90], [0.43, 0.43], color=GRID, linewidth=1.0, transform=ax_card.transAxes)
    ax_card.text(0.10, 0.32, "5", fontsize=19, color=CYAN, weight="bold", transform=ax_card.transAxes)
    ax_card.text(0.21, 0.33, "benchmark suites", fontsize=9.5, color=MUTED, transform=ax_card.transAxes)
    ax_card.text(0.10, 0.18, "0-shot", fontsize=19, color=ORANGE, weight="bold", transform=ax_card.transAxes)
    ax_card.text(0.52, 0.19, "matched protocol", fontsize=9.5, color=MUTED, transform=ax_card.transAxes)

    footer(fig)
    save(fig, "benchmark-suite")


def render_scorecard() -> None:
    results = DATA["results"]
    cards = [
        ("CMMLU", results["cmmlu"], BLUE),
        ("AGIEval-CN", results["agieval_cn"], CYAN),
        ("A-CLUE", results["a_clue"], BLUE),
        ("C-Eval", results["c_eval"], ORANGE),
        ("TMMLU+", results["tmmlu_plus"], CYAN),
        ("5-suite macro", results["five_suite_macro"], WHITE),
    ]

    fig = plt.figure(figsize=(14, 7.875), dpi=200)
    header(fig, "Benchmark scorecard", "TensorMind 1.5 Preview 路 full-dataset accuracy (%)")
    gs = fig.add_gridspec(2, 3, left=0.08, right=0.92, top=0.70, bottom=0.18, wspace=0.10, hspace=0.14)
    for idx, (name, value, color) in enumerate(cards):
        ax = fig.add_subplot(gs[idx // 3, idx % 3])
        ax.set_facecolor(PANEL_ALT if idx == 5 else PANEL)
        ax.set_xticks([])
        ax.set_yticks([])
        for spine in ax.spines.values():
            spine.set_visible(False)
        ax.add_patch(plt.Rectangle((0.0, 0.0), 0.018, 1.0, color=color, transform=ax.transAxes, lw=0))
        ax.text(0.09, 0.70, name.upper(), fontsize=9, color=MUTED, weight="bold", transform=ax.transAxes)
        ax.text(0.09, 0.29, f"{value:.4f}", fontsize=27, color=color, weight="bold", transform=ax.transAxes)
        ax.text(0.09, 0.12, "accuracy", fontsize=8.5, color=MUTED, transform=ax.transAxes)

    footer(fig)
    save(fig, "benchmark-matrix")


if __name__ == "__main__":
    render_suite()
    render_scorecard()