Luigi commited on
Commit
20af279
Β·
verified Β·
1 Parent(s): f0f7133

Add score-vs-latency chart; fix pipeline_tag to token-classification

Browse files
Files changed (3) hide show
  1. README.md +20 -1
  2. make_plot.py +81 -0
  3. score_vs_latency.svg +48 -0
README.md CHANGED
@@ -11,7 +11,7 @@ tags:
11
  - bitnet
12
  - gguf
13
  library_name: gguf
14
- pipeline_tag: text2text-generation
15
  ---
16
 
17
  # SlothE-T 25M β€” Ternary Zhuyin β†’ Traditional Chinese IME model
@@ -64,6 +64,25 @@ window, filtered to be **absent from the training corpus**), then g2pW-labeled.
64
  > 25M ternary model **beats the previously-shipped 12M int8 on 免選字 and
65
  > homophone-hard** while being smaller and faster.
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  ## Training recipe (teacher-free)
68
 
69
  - **Direct cross-entropy** on a g2pW-labeled zh-TW corpus, with **label smoothing 0.1**.
 
11
  - bitnet
12
  - gguf
13
  library_name: gguf
14
+ pipeline_tag: token-classification
15
  ---
16
 
17
  # SlothE-T 25M β€” Ternary Zhuyin β†’ Traditional Chinese IME model
 
64
  > 25M ternary model **beats the previously-shipped 12M int8 on 免選字 and
65
  > homophone-hard** while being smaller and faster.
66
 
67
+ ### Quality vs. latency
68
+
69
+ ![Held-out 免選字 vs. on-device latency](score_vs_latency.svg)
70
+
71
+ Latency is per-6-syllable decode on a **BOOX (Snapdragon 662, no-dotprod ARM)**.
72
+ 4M and 12M are measured (ORT int8); the **25M ternary** point is *projected* from
73
+ measured-shape TQ2_0 / I2_S kernel benchmarks (the ternary win is diluted by the
74
+ int8 8342-way head, which ternary can't accelerate). The takeaway: the 25M ternary
75
+ is **Pareto-dominant** β€” roughly the 4M's latency (~9 ms) but **+6 免選字**, and
76
+ both faster *and* more accurate than the 12M.
77
+
78
+ | model | params | 免選字 | homophone | toneless | latency (BOOX) |
79
+ |---|---|---|---|---|---|
80
+ | 4M int8 | 4M | 70 % | 83 % | 74 % | 9.1 ms |
81
+ | 12M int8 | 12M | 72 % | 82 % | 79 % | 13.3 ms |
82
+ | **25M ternary** | **25M** | **76 %** | **86 %** | **77 %** | **~9 ms\*** |
83
+
84
+ <sub>\* projected, not full end-to-end measured. See the [experiment notes](REPRODUCE.md).</sub>
85
+
86
  ## Training recipe (teacher-free)
87
 
88
  - **Direct cross-entropy** on a g2pW-labeled zh-TW corpus, with **label smoothing 0.1**.
make_plot.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Score-vs-latency scatter for the model card. Self-contained SVG, no deps."""
3
+
4
+ # honest held-out (500 fresh zh-TW sentences) + BOOX (SD662) per-6-syllable decode ms
5
+ # latency: 4M/12M measured (ORT int8); 25M ternary projected from measured-shape
6
+ # bitnet TQ2_0/I2_S kernel benchmarks (marked with *).
7
+ MODELS = [
8
+ # name, params, latency_ms, proj, mianxuan, homophone, toneless, color
9
+ ("4M int8", "4M", 9.06, False, 70, 83, 74, "#6b7280"),
10
+ ("12M int8", "12M", 13.3, False, 72, 82, 79, "#2563eb"),
11
+ ("25M ternary", "25M", 9.0, True, 76, 86, 77, "#dc2626"),
12
+ ]
13
+
14
+ W, H = 680, 440
15
+ L, R, T, B = 74, 28, 46, 66 # margins
16
+ PX0, PX1 = L, W - R
17
+ PY0, PY1 = T, H - B
18
+ XMIN, XMAX = 8.0, 14.5
19
+ YMIN, YMAX = 66.0, 80.0
20
+
21
+ def x(v): return PX0 + (v - XMIN) / (XMAX - XMIN) * (PX1 - PX0)
22
+ def y(v): return PY1 - (v - YMIN) / (YMAX - YMIN) * (PY1 - PY0)
23
+
24
+ s = []
25
+ s.append(f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}" height="{H}" '
26
+ f'viewBox="0 0 {W} {H}" font-family="-apple-system,Segoe UI,Roboto,sans-serif">')
27
+ # always-light background card so it reads on both HF themes
28
+ s.append(f'<rect x="0" y="0" width="{W}" height="{H}" rx="10" fill="#ffffff"/>')
29
+ s.append(f'<text x="{L}" y="26" font-size="16" font-weight="700" fill="#111827">'
30
+ f'Held-out quality vs. on-device latency (BOOX SD662)</text>')
31
+
32
+ # gridlines + y ticks (免選字 %)
33
+ for yv in range(66, 81, 2):
34
+ yy = y(yv)
35
+ s.append(f'<line x1="{PX0}" y1="{yy:.1f}" x2="{PX1}" y2="{yy:.1f}" stroke="#e5e7eb"/>')
36
+ s.append(f'<text x="{PX0-10}" y="{yy+4:.1f}" font-size="12" fill="#6b7280" '
37
+ f'text-anchor="end">{yv}</text>')
38
+ # x ticks (ms)
39
+ for xv in range(8, 15, 1):
40
+ xx = x(xv)
41
+ s.append(f'<line x1="{xx:.1f}" y1="{PY0}" x2="{xx:.1f}" y2="{PY1}" stroke="#f3f4f6"/>')
42
+ s.append(f'<text x="{xx:.1f}" y="{PY1+20}" font-size="12" fill="#6b7280" '
43
+ f'text-anchor="middle">{xv}</text>')
44
+ # axis labels
45
+ s.append(f'<text x="{(PX0+PX1)/2:.0f}" y="{H-14}" font-size="13" fill="#374151" '
46
+ f'text-anchor="middle">latency β€” ms / 6-syllable decode (lower = faster)</text>')
47
+ s.append(f'<text x="18" y="{(PY0+PY1)/2:.0f}" font-size="13" fill="#374151" '
48
+ f'text-anchor="middle" transform="rotate(-90 18 {(PY0+PY1)/2:.0f})">'
49
+ f'免選字 (whole-sentence) % (higher = better)</text>')
50
+ # axis frame
51
+ s.append(f'<rect x="{PX0}" y="{PY0}" width="{PX1-PX0}" height="{PY1-PY0}" '
52
+ f'fill="none" stroke="#9ca3af"/>')
53
+
54
+ # Pareto arrow: 4M -> 25M ternary (up, same latency), the headline story
55
+ s.append(f'<line x1="{x(9.06):.1f}" y1="{y(70)-10:.1f}" x2="{x(9.0):.1f}" '
56
+ f'y2="{y(76)+12:.1f}" stroke="#dc2626" stroke-width="1.5" '
57
+ f'stroke-dasharray="4 3" opacity="0.6"/>')
58
+
59
+ # points
60
+ for name, tag, lat, proj, mx, ho, tl, col in MODELS:
61
+ cx, cy = x(lat), y(mx)
62
+ s.append(f'<circle cx="{cx:.1f}" cy="{cy:.1f}" r="8" fill="{col}" '
63
+ f'stroke="#ffffff" stroke-width="2"/>')
64
+ star = "*" if proj else ""
65
+ # two-line label fully above the point (name higher, stats just above point),
66
+ # except 4M which sits low so its label goes below the point.
67
+ if name == "4M int8":
68
+ name_y, sub_y = cy + 24, cy + 39
69
+ else:
70
+ name_y, sub_y = cy - 30, cy - 14
71
+ s.append(f'<text x="{cx:.1f}" y="{name_y:.1f}" font-size="13" font-weight="700" '
72
+ f'fill="{col}" text-anchor="middle">{name}{star}</text>')
73
+ s.append(f'<text x="{cx:.1f}" y="{sub_y:.1f}" font-size="11" fill="#6b7280" '
74
+ f'text-anchor="middle">免{mx} Β· 同{ho} Β· η„‘{tl}</text>')
75
+
76
+ # projection note under the title (avoids the crowded bottom axis area)
77
+ s.append(f'<text x="{L}" y="42" font-size="11" fill="#9ca3af">'
78
+ f'* 25M ternary latency projected from measured-shape TQ2_0 / I2_S kernels</text>')
79
+ s.append('</svg>')
80
+ open("score_vs_latency.svg", "w").write("\n".join(s))
81
+ print("wrote score_vs_latency.svg")
score_vs_latency.svg ADDED