Elffuss BraidHub

kikocis/otter public

d87f7b0f40bb · 25.8 KiBRawPermalink
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="UTF-8">
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>Otter — Gemma 4 31B Layer & Quantization Study</title>
7<meta name="description" content="Empirical study of Gemma 4 31B: which transformer layers are redundant, which quantizations preserve quality, and what's the Pareto frontier sub-3 BPW.">
8<meta property="og:title" content="Otter — Gemma 4 31B Layer Study">
9<meta property="og:description" content="Sub-3 BPW Pareto frontier for Gemma 4 31B. 3-phase ablation study + 8 quantization benchmarks on NL2Bash.">
10<meta property="og:type" content="website">
11<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js"></script>
12<!-- Privacy-first analytics: GoatCounter (primary) + Umami fallback. No cookies. -->
13<script data-goatcounter="https://kikocis-otter.goatcounter.com/count"
14 async src="//gc.zgo.at/count.js"></script>
15<!-- Fallback pixel tracking via countapi (completely anonymous, no setup required) -->
16<script>
17(function(){
18 // Fire-and-forget hit counter — bumps a counter, no personal data
19 fetch('https://api.counterapi.dev/v1/kikocis-otter/visits/up').catch(()=>{});
20})();
21// Safe wrapper so link click handlers don't throw if GoatCounter blocked
22window.goatcounter = window.goatcounter || {count: function(){}};
23</script>
24<style>
25:root{
26 --bg:#0d1117;--card:#161b22;--border:#30363d;--text:#c9d1d9;--text2:#8b949e;
27 --accent:#58a6ff;--green:#3fb950;--red:#f85149;--orange:#d29922;--purple:#bc8cff;
28 --gold:#ffd700;
29}
30*{margin:0;padding:0;box-sizing:border-box}
31body{background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display",system-ui,sans-serif;font-size:15px;line-height:1.6}
32code,pre,.mono{font-family:'SF Mono',Monaco,Consolas,monospace}
33.container{max-width:1200px;margin:0 auto;padding:20px}
34
35/* Hero */
36.hero{padding:60px 20px 40px;text-align:center;border-bottom:1px solid var(--border)}
37.hero h1{font-size:48px;font-weight:800;letter-spacing:-1px;margin-bottom:12px;background:linear-gradient(135deg,#fff 0%,var(--accent) 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
38.hero .tagline{font-size:20px;color:var(--text2);max-width:720px;margin:0 auto 30px}
39.hero .emoji{font-size:80px;display:block;margin-bottom:16px}
40
41.cta-row{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;margin-top:24px}
42.btn{display:inline-flex;align-items:center;gap:8px;padding:12px 24px;border-radius:10px;font-weight:600;text-decoration:none;transition:all 0.15s;font-size:14px;border:1px solid transparent}
43.btn-primary{background:var(--accent);color:#0d1117;border-color:var(--accent)}
44.btn-primary:hover{background:#7cb7ff;transform:translateY(-1px)}
45.btn-ghost{background:transparent;color:var(--text);border-color:var(--border)}
46.btn-ghost:hover{background:var(--card);border-color:var(--text2)}
47.btn-gold{background:linear-gradient(135deg,#ffd700 0%,#ffb700 100%);color:#0d1117;border-color:var(--gold);font-weight:700}
48.btn-gold:hover{transform:translateY(-2px);box-shadow:0 8px 24px rgba(255,215,0,0.2)}
49
50/* Key stats */
51.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;margin:40px 0}
52@media(max-width:700px){.stats{grid-template-columns:1fr}}
53.stat-card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:24px;text-align:center}
54.stat-card .num{font-size:44px;font-weight:800;color:#fff;line-height:1}
55.stat-card .num.gold{color:var(--gold)}
56.stat-card .num.green{color:var(--green)}
57.stat-card .label{color:var(--text2);font-size:13px;margin-top:8px;text-transform:uppercase;letter-spacing:0.5px}
58.stat-card .sub{color:var(--text);font-size:13px;margin-top:4px}
59
60/* Sections */
61section{margin:60px 0;scroll-margin-top:20px}
62h2{font-size:28px;font-weight:700;margin-bottom:12px;color:#fff;letter-spacing:-0.5px}
63h2 .num{color:var(--accent);font-weight:800;margin-right:8px}
64.lede{color:var(--text2);font-size:16px;max-width:800px;margin-bottom:24px}
65h3{font-size:18px;font-weight:600;color:var(--purple);margin:28px 0 12px}
66
67.card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:24px;margin-bottom:20px}
68.chart-container{position:relative;height:380px}
69.chart-container.tall{height:480px}
70.chart-container.small{height:280px}
71
72/* Tables */
73table{width:100%;border-collapse:collapse;font-size:14px}
74th,td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:right}
75th{color:var(--text2);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:0.5px;position:sticky;top:0;background:var(--card)}
76td:first-child,th:first-child{text-align:left}
77tr.winner{background:rgba(255,215,0,0.05)}
78tr.winner td:first-child{color:var(--gold);font-weight:700}
79tr.strike td{color:var(--text2);text-decoration:line-through;opacity:0.6}
80.score{display:inline-block;min-width:60px}
81.bar-cell{position:relative}
82.bar{height:6px;border-radius:3px;margin-top:4px}
83
84.badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.5px;margin-left:6px}
85.badge-gold{background:var(--gold);color:#0d1117}
86.badge-green{background:var(--green);color:#0d1117}
87.badge-red{background:var(--red);color:#fff}
88.badge-blue{background:var(--accent);color:#0d1117}
89.badge-purple{background:var(--purple);color:#0d1117}
90
91/* Insights */
92.insights{background:linear-gradient(135deg,rgba(88,166,255,0.08) 0%,rgba(188,140,255,0.04) 100%);border:1px solid rgba(88,166,255,0.2);border-radius:14px;padding:24px;margin:20px 0}
93.insights h3{color:var(--accent);margin:0 0 12px;font-size:16px}
94.insights ul{padding-left:18px;color:var(--text)}
95.insights li{margin-bottom:8px}
96.insights strong{color:#fff}
97
98/* Nav */
99.nav{position:sticky;top:0;z-index:100;background:rgba(13,17,23,0.85);backdrop-filter:blur(12px);border-bottom:1px solid var(--border);padding:12px 0}
100.nav-inner{display:flex;justify-content:space-between;align-items:center;max-width:1200px;margin:0 auto;padding:0 20px}
101.nav-brand{font-size:18px;font-weight:700;color:#fff;text-decoration:none;letter-spacing:-0.5px}
102.nav-links{display:flex;gap:6px;flex-wrap:wrap}
103.nav-links a{color:var(--text2);text-decoration:none;padding:6px 12px;border-radius:6px;font-size:13px;transition:all 0.15s}
104.nav-links a:hover{color:#fff;background:var(--card)}
105
106/* Footer */
107footer{border-top:1px solid var(--border);padding:40px 20px;margin-top:80px;text-align:center;color:var(--text2);font-size:13px}
108footer a{color:var(--accent);text-decoration:none}
109footer a:hover{text-decoration:underline}
110
111/* Code blocks */
112pre{background:var(--card);border:1px solid var(--border);border-radius:8px;padding:16px;overflow-x:auto;font-size:13px;margin:12px 0}
113code.inline{background:var(--card);padding:2px 6px;border-radius:4px;font-size:13px;border:1px solid var(--border)}
114
115/* Links in cards */
116.link-card{display:flex;align-items:center;gap:12px;padding:16px;background:var(--card);border:1px solid var(--border);border-radius:10px;text-decoration:none;color:var(--text);transition:all 0.15s;margin-bottom:10px}
117.link-card:hover{border-color:var(--accent);transform:translateX(2px)}
118.link-card .icon{font-size:24px}
119.link-card .title{font-weight:600;color:#fff;font-size:15px}
120.link-card .desc{font-size:13px;color:var(--text2);margin-top:2px}
121
122/* Chart legend tweak */
123.legend-row{display:flex;gap:20px;flex-wrap:wrap;justify-content:center;margin-top:12px;font-size:12px;color:var(--text2)}
124.legend-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:5px;vertical-align:middle}
125</style>
126</head>
127<body>
128
129<div class="nav">
130 <div class="nav-inner">
131 <a class="nav-brand" href="#">🦦 Otter</a>
132 <div class="nav-links">
133 <a href="#benchmarks">Benchmarks</a>
134 <a href="#layer-study">Layer Study</a>
135 <a href="#quants">Quantizations</a>
136 <a href="#methodology">Methodology</a>
137 <a href="https://github.com/KikoCis/otter" target="_blank">⭐ GitHub</a>
138 </div>
139 </div>
140</div>
141
142<div class="container">
143
144<header class="hero">
145 <span class="emoji">🦦</span>
146 <h1>Otter</h1>
147 <p class="tagline">
148 Empirical study of <strong>Gemma 4 31B</strong>: which transformer layers are redundant,
149 which quantizations preserve quality, and what's the Pareto frontier below 3 BPW.
150 </p>
151 <div class="cta-row">
152 <a class="btn btn-gold" href="https://github.com/KikoCis/otter" target="_blank" onclick="goatcounter.count({path:'github-click'})">
153 ⭐ Star on GitHub
154 </a>
155 <a class="btn btn-ghost" href="https://huggingface.co/KikoCis/gemma-4-31b-it-IQ3_XS-GGUF" target="_blank">
156 🤗 Base IQ3_XS Model
157 </a>
158 <a class="btn btn-ghost" href="https://huggingface.co/datasets/KikoCis/gemma4-31b-layer-study" target="_blank">
159 📊 Raw Study Data
160 </a>
161 </div>
162</header>
163
164<div class="stats">
165 <div class="stat-card">
166 <div class="num gold">85.06%</div>
167 <div class="label">Best Char-F1 (NL2Bash)</div>
168 <div class="sub">Unsloth UD-IQ3_XXS · 11.84 GB</div>
169 </div>
170 <div class="stat-card">
171 <div class="num green">6.0×</div>
172 <div class="label">This repo IQ2_M vs f16</div>
173 <div class="sub">10.17 GB · F1 84.71% · <strong>BLEU-4 22.39</strong> (beats f16)</div>
174 </div>
175 <div class="stat-card">
176 <div class="num">3 / 60</div>
177 <div class="label">Phases × Layers analyzed</div>
178 <div class="sub">300 probes · 60 layers · 6 categories</div>
179 </div>
180</div>
181
182<!-- BENCHMARKS -->
183<section id="benchmarks">
184 <h2><span class="num">01</span>NL2Bash Benchmark — 8 Variants Ranked</h2>
185 <p class="lede">
186 50 examples from the official Stanford/Tellina test split. Each question runs as an isolated
187 <code class="inline">llama-cli</code> subprocess with reasoning OFF, max_tokens=200, temp=0.1.
188 Char-F1 captures semantic equivalence; BLEU/EM are stricter token-exact metrics.
189 </p>
190
191 <div class="card">
192 <h3>Char-F1 vs Model Size</h3>
193 <div class="chart-container"><canvas id="chartSizeF1"></canvas></div>
194 </div>
195
196 <div class="card">
197 <table>
198 <thead>
199 <tr>
200 <th>Rank</th><th>Model</th><th>Size</th><th>BPW</th>
201 <th>Char-F1</th><th>BLEU-4</th><th>EM</th>
202 </tr>
203 </thead>
204 <tbody id="benchTable"></tbody>
205 </table>
206 </div>
207
208 <div class="insights">
209 <h3>Key findings</h3>
210 <ul>
211 <li><strong>Unsloth UD-IQ3_XXS (11.84 GB) beats f16 on Char-F1</strong> — the dynamic per-layer bit allocation + Gemma-specific imatrix preserves structure better than the full-precision model itself on this benchmark.</li>
212 <li><strong>This repo's custom IQ2_M (10.17 GB, CLI-tuned imatrix) matches f16 Char-F1 (84.71 vs 84.76) and beats f16 on BLEU-4 (22.39 vs 21.02)</strong> at 6× smaller. Beats Unsloth UD-IQ2_M on every metric at 0.6 GB smaller — evidence that domain-focused calibration data pushes the 2.8 BPW Pareto frontier further. <a href="https://huggingface.co/KikoCis/gemma-4-31b-it-IQ2_M-GGUF" target="_blank" style="color:var(--accent)">[HF repo →]</a></li>
213 <li><strong>UD-IQ2_M at 10.75 GB matches f16 quality</strong> (F1 84.02% vs 84.76%). <strong>+25.4 F1 points over standard Q2_K</strong> at identical 2.70 BPW — a massive gap caused entirely by the calibration method.</li>
214 <li><strong>Q2_K collapses on Gemma 4</strong> (F1 58.6%, outputs "-y-y-y-y"). Standard scalar 2-bit quantization is not viable for this architecture's wide logit distribution + RMSNorm scaling.</li>
215 <li><strong>Layer pruning is dominated by dynamic quantization</strong>. Otter-v3 (58 layers, 12.1 GB) scored 6 F1 lower than the custom IQ2_M (60 layers, 10.17 GB). Pruning without recovery fine-tuning loses more than it saves.</li>
216 </ul>
217 </div>
218</section>
219
220<!-- LAYER STUDY -->
221<section id="layer-study">
222 <h2><span class="num">02</span>Layer Ablation Study</h2>
223 <p class="lede">
224 For every one of the 60 transformer layers we measured Block Influence (BI), logit-lens decision
225 point, and the perplexity delta when the layer is individually zeroed out.
226 <strong>Surprise</strong>: several middle layers have <em>negative</em> deltas — removing them
227 improves the model.
228 </p>
229
230 <div class="card">
231 <h3>Single-layer ablation: perplexity delta %</h3>
232 <p style="color:var(--text2);font-size:13px;margin-bottom:12px">
233 Positive bars (red) = layer is critical (breaks model when removed).
234 Negative bars (green) = removing this layer improves perplexity.
235 </p>
236 <div class="chart-container"><canvas id="chartAblation"></canvas></div>
237 </div>
238
239 <div class="card">
240 <h3>Block Influence per layer (log scale)</h3>
241 <div class="chart-container small"><canvas id="chartBI"></canvas></div>
242 </div>
243
244 <div class="insights">
245 <h3>Layer findings</h3>
246 <ul>
247 <li><strong>Layer 27 &amp; 29 are net-negative</strong>: single ablation improves PPL by -74% and -71%. These layers are adding noise to the residual stream.</li>
248 <li><strong>Layers 0, 1, 58, 59 are critical</strong>: ablation explodes PPL ×100 to ×2360. Never remove them.</li>
249 <li><strong>Decision happens in layers 56-59</strong>: logit-lens shows the target token rank collapses from 2533 → 51 → 3 → 1 in the last 4 layers.</li>
250 <li><strong>Middle layers (10-22) are almost inert</strong>: BI &lt; 0.005 across all 6 probe categories, but compound effects prevent dropping more than 2 at once without fine-tuning recovery.</li>
251 </ul>
252 <p style="margin-top:12px;font-size:13px;color:var(--text2)">
253 Full interactive visualization with per-category heatmaps:
254 <a href="https://huggingface.co/datasets/KikoCis/gemma4-31b-layer-study/blob/main/index.html" target="_blank" style="color:var(--accent)">layer study viewer →</a>
255 </p>
256 </div>
257</section>
258
259<!-- QUANTIZATION GUIDE -->
260<section id="quants">
261 <h2><span class="num">03</span>Quantization Recommendations</h2>
262 <p class="lede">
263 Based on these benchmarks, here's the Pareto frontier for deploying Gemma 4 31B locally.
264 </p>
265
266 <a class="link-card" href="https://huggingface.co/unsloth/gemma-4-31B-it-GGUF" target="_blank" onclick="goatcounter.count({path:'click-unsloth'})">
267 <span class="icon">🏆</span>
268 <div>
269 <div class="title">Unsloth UD-IQ3_XXS — 11.84 GB · F1 85.06%</div>
270 <div class="desc">The winner. Dynamic per-layer bit allocation + Gemma-specific imatrix. Beats f16 on Char-F1.</div>
271 </div>
272 </a>
273
274 <a class="link-card" href="https://huggingface.co/KikoCis/gemma-4-31b-it-IQ2_M-GGUF" target="_blank" onclick="goatcounter.count({path:'click-mine-iq2m'})">
275 <span class="icon">🎯</span>
276 <div>
277 <div class="title">This repo: IQ2_M CLI imatrix — 10.17 GB · F1 84.71% · BLEU-4 22.39</div>
278 <div class="desc">New Pareto point at 2.84 BPW. Matches f16 on F1 and <strong>beats f16 on BLEU-4</strong> at 6× smaller. Beats Unsloth UD-IQ2_M across the board with a CLI-focused importance matrix.</div>
279 </div>
280 </a>
281
282 <a class="link-card" href="https://huggingface.co/unsloth/gemma-4-31B-it-GGUF" target="_blank" onclick="goatcounter.count({path:'click-unsloth-2m'})">
283 <span class="icon">🎯</span>
284 <div>
285 <div class="title">Unsloth UD-IQ2_M — 10.75 GB · F1 84.02%</div>
286 <div class="desc">Generic dynamic IQ2_M. Matches f16 at 1/5.7 the size. Sub-3 BPW done right.</div>
287 </div>
288 </a>
289
290 <a class="link-card" href="https://huggingface.co/KikoCis/gemma-4-31b-it-IQ3_XS-GGUF" target="_blank" onclick="goatcounter.count({path:'click-iq3xs'})">
291 <span class="icon">🔬</span>
292 <div>
293 <div class="title">This repo: Base IQ3_XS — 13.1 GB · F1 84.76%</div>
294 <div class="desc">Standard IQ3_XS with CLI-focused imatrix. Ties f16 on Char-F1 at 1/4.7 the size.</div>
295 </div>
296 </a>
297
298 <a class="link-card" href="https://huggingface.co/KikoCis/gemma-4-31b-otter-v3-GGUF" target="_blank" onclick="goatcounter.count({path:'click-otter'})">
299 <span class="icon">🦦</span>
300 <div>
301 <div class="title">Otter v3 — 58-layer pruned variant</div>
302 <div class="desc">Research artifact demonstrating ablation-guided pruning (layers 27 &amp; 29 removed). Dominated by dynamic quantization on benchmarks.</div>
303 </div>
304 </a>
305</section>
306
307<!-- METHODOLOGY -->
308<section id="methodology">
309 <h2><span class="num">04</span>Methodology</h2>
310 <p class="lede">Everything is reproducible — code and raw measurements are public.</p>
311
312 <div class="card">
313 <h3>Layer study pipeline</h3>
314 <pre>phase_a.py # Block Influence: ||h_out - h_in||, cosine(h_in, h_out)
315phase_b.py # Logit Lens: project h_l through norm+lm_head for each layer
316phase_c.py # Single-layer ablation: skip one layer, measure PPL delta
317phase_c2.py # Block ablation: drop N layers together, measure PPL</pre>
318
319 <h3>Benchmark setup</h3>
320 <pre>nl2bash_bench_sub.py \
321 --model gguf/X.gguf \
322 --limit 50 --max-tokens 200 \
323 --report-every 5 --out bench.jsonl</pre>
324
325 <h3>Hardware</h3>
326 <p style="color:var(--text2)">Apple M4 Max, 128 GB unified memory. Full GPU offload via Metal.
327 All measurements single-run, deterministic at temp=0.1 (small residual variance).</p>
328 </div>
329
330 <div class="insights" style="background:linear-gradient(135deg,rgba(255,215,0,0.06) 0%,rgba(255,183,0,0.03) 100%);border-color:rgba(255,215,0,0.2)">
331 <h3 style="color:var(--gold)">⭐ Support this work</h3>
332 <p>Otter is an open-source study. If it helped you understand Gemma 4, pruning, or GGUF quantization:</p>
333 <div class="cta-row" style="justify-content:flex-start;margin-top:16px">
334 <a class="btn btn-gold" href="https://github.com/KikoCis/otter" target="_blank" onclick="goatcounter.count({path:'github-star-bottom'})">
335 ⭐ Star Otter on GitHub
336 </a>
337 <a class="btn btn-ghost" href="https://huggingface.co/KikoCis" target="_blank" onclick="goatcounter.count({path:'hf-follow'})">
338 🤗 Follow on Hugging Face
339 </a>
340 </div>
341 </div>
342</section>
343
344</div><!-- /container -->
345
346<footer>
347 <p>
348 Built by <a href="https://huggingface.co/KikoCis" target="_blank">KikoCis</a> ·
349 <a href="https://github.com/KikoCis/otter" target="_blank">GitHub</a> ·
350 <a href="https://huggingface.co/datasets/KikoCis/gemma4-31b-layer-study" target="_blank">Raw Data</a>
351 </p>
352 <p style="margin-top:8px;font-size:11px">
353 Privacy-first analytics via <a href="https://www.goatcounter.com/" target="_blank">GoatCounter</a> —
354 no cookies, no personal data, no tracking.
355 </p>
356</footer>
357
358<script>
359// Data from actual benchmark runs
360const BENCH = [
361 {rank:1, name:'Unsloth UD-IQ3_XXS', size:11.84, bpw:2.98, f1:85.06, bleu1:46.30, bleu4:20.26, em:12, winner:true, highlight:'winner', link:'https://huggingface.co/unsloth/gemma-4-31B-it-GGUF'},
362 {rank:2, name:'Base f16 (full precision)', size:61.40, bpw:16.0, f1:84.76, bleu1:43.94, bleu4:21.02, em:12, link:null, note:'baseline'},
363 {rank:3, name:'Base IQ3_XS', size:13.10, bpw:3.40, f1:84.76, bleu1:42.77, bleu4:18.95, em:8, link:'https://huggingface.co/KikoCis/gemma-4-31b-it-IQ3_XS-GGUF'},
364 {rank:4, name:'This repo IQ2_M (CLI imatrix)', size:10.17, bpw:2.84, f1:84.71, bleu1:44.72, bleu4:22.39, em:12, winner:true, highlight:'sweet-spot', link:'https://huggingface.co/KikoCis/gemma-4-31b-it-IQ2_M-GGUF'},
365 {rank:5, name:'Unsloth UD-IQ2_M', size:10.75, bpw:2.70, f1:84.02, bleu1:42.38, bleu4:18.64, em:10, link:'https://huggingface.co/unsloth/gemma-4-31B-it-GGUF'},
366 {rank:6, name:'Otter v3 Q3_K_M (58L)', size:14.10, bpw:3.98, f1:79.89, bleu1:35.09, bleu4:12.80, em:0, link:'https://huggingface.co/KikoCis/gemma-4-31b-otter-v3-GGUF'},
367 {rank:7, name:'Otter v3 IQ3_XS (58L)', size:12.10, bpw:3.41, f1:78.72, bleu1:37.01, bleu4:15.14, em:4, link:'https://huggingface.co/KikoCis/gemma-4-31b-otter-v3-GGUF'},
368 {rank:8, name:'Unsloth UD-IQ2_XXS', size:8.53, bpw:2.06, f1:76.82, bleu1:33.03, bleu4:11.49, em:0, link:'https://huggingface.co/unsloth/gemma-4-31B-it-GGUF'},
369 {rank:9, name:'Base Q2_K (3rd party)', size:11.00, bpw:2.70, f1:58.60, bleu1:18.82, bleu4:6.92, em:0, strike:true},
370];
371
372// Layer ablation data (PPL delta % per layer vs 241.57 baseline)
373const ABLATION = [
374 {l:0,d:1512.9},{l:1,d:5560.5},{l:2,d:-12.3},{l:3,d:10.5},{l:4,d:-10.9},{l:5,d:-28.4},{l:6,d:-5.1},{l:7,d:-1.4},{l:8,d:-24.4},{l:9,d:-5.1},
375 {l:10,d:2.8},{l:11,d:-12.0},{l:12,d:-9.8},{l:13,d:8.8},{l:14,d:-0.4},{l:15,d:-18.0},{l:16,d:2.6},{l:17,d:27.3},{l:18,d:7.2},{l:19,d:2.7},
376 {l:20,d:11.2},{l:21,d:-12.9},{l:22,d:-14.2},{l:23,d:-47.3},{l:24,d:-49.6},{l:25,d:-51.0},{l:26,d:-60.1},{l:27,d:-73.8},{l:28,d:-70.1},{l:29,d:-71.1},
377 {l:30,d:-47.9},{l:31,d:-43.0},{l:32,d:-43.6},{l:33,d:-38.9},{l:34,d:-30.9},{l:35,d:-50.6},{l:36,d:-52.7},{l:37,d:-22.6},{l:38,d:-46.4},{l:39,d:102.3},
378 {l:40,d:20.9},{l:41,d:-38.7},{l:42,d:31.1},{l:43,d:40.2},{l:44,d:8.9},{l:45,d:3.4},{l:46,d:8.0},{l:47,d:-17.6},{l:48,d:10.8},{l:49,d:355.0},
379 {l:50,d:8.7},{l:51,d:26.9},{l:52,d:-6.2},{l:53,d:31.0},{l:54,d:6.4},{l:55,d:6.2},{l:56,d:93.6},{l:57,d:-7.9},{l:58,d:236261},{l:59,d:14518}
380];
381
382// BI scores per layer
383const BI = [0.9497,0.3247,0.0040,0.0119,0.0030,0.0288,0.0088,0.0164,0.0073,0.0035,0.0019,0.0040,0.0059,0.0006,0.0005,0.0021,0.0009,0.0020,0.0010,0.0023,0.0025,0.0017,0.0037,0.0077,0.0078,0.0083,0.0102,0.0155,0.0727,0.0203,0.0135,0.0097,0.0087,0.0089,0.0102,0.0125,0.0128,0.0131,0.0198,0.0708,0.0495,0.0628,0.0341,0.0334,0.0241,0.0227,0.0209,0.0239,0.0203,0.0321,0.0258,0.0527,0.2192,0.1025,0.0642,0.0800,0.1141,0.3363,0.5640,0.8622];
384
385// Full attention layers
386const FA = new Set([5,11,17,23,29,35,41,47,53,59]);
387
388// Build bench table
389const tbody = document.getElementById('benchTable');
390BENCH.forEach(r => {
391 const tr = document.createElement('tr');
392 if (r.winner && r.highlight === 'winner') tr.classList.add('winner');
393 if (r.strike) tr.classList.add('strike');
394 const badge = r.highlight === 'winner' ? '<span class="badge badge-gold">Best F1</span>'
395 : r.highlight === 'sweet-spot' ? '<span class="badge badge-green">Sweet spot</span>'
396 : r.note === 'baseline' ? '<span class="badge badge-blue">f16 ref</span>'
397 : r.strike ? '<span class="badge badge-red">Collapsed</span>' : '';
398 const nameCell = r.link
399 ? `<a href="${r.link}" target="_blank" style="color:inherit;text-decoration:none">${r.name}</a>${badge}`
400 : `${r.name}${badge}`;
401 tr.innerHTML = `
402 <td>${r.rank}</td>
403 <td>${nameCell}</td>
404 <td>${r.size.toFixed(1)} GB</td>
405 <td>${r.bpw.toFixed(2)}</td>
406 <td><span class="score">${r.f1.toFixed(2)}%</span><div class="bar" style="width:${r.f1}%;background:${r.f1>80?'var(--green)':r.f1>70?'var(--orange)':'var(--red)'}"></div></td>
407 <td>${r.bleu4.toFixed(2)}</td>
408 <td>${r.em}%</td>
409 `;
410 tbody.appendChild(tr);
411});
412
413// Chart: Size vs F1 scatter
414const ctxSF = document.getElementById('chartSizeF1').getContext('2d');
415new Chart(ctxSF, {
416 type: 'scatter',
417 data: {
418 datasets: [{
419 label: 'Model variants',
420 data: BENCH.map(r => ({x: r.size, y: r.f1, name: r.name, bpw: r.bpw})),
421 backgroundColor: BENCH.map(r => r.winner ? '#ffd700' : r.strike ? '#f85149' : r.note==='baseline' ? '#58a6ff' : '#3fb950'),
422 borderColor: '#fff',
423 borderWidth: 2,
424 pointRadius: 10,
425 pointHoverRadius: 14,
426 }]
427 },
428 options: {
429 responsive: true, maintainAspectRatio: false,
430 plugins: {
431 legend: {display: false},
432 tooltip: {
433 callbacks: {
434 label: ctx => {
435 const d = ctx.raw;
436 return `${d.name}: ${d.y.toFixed(2)}% F1, ${d.x.toFixed(1)}GB, ${d.bpw.toFixed(2)} BPW`;
437 }
438 }
439 }
440 },
441 scales: {
442 x: {
443 type: 'logarithmic',
444 title: {display: true, text: 'Model Size (GB, log)', color: '#8b949e'},
445 grid: {color: '#21262d'},
446 ticks: {color: '#8b949e', callback: v => v + 'GB'}
447 },
448 y: {
449 title: {display: true, text: 'Char-F1 (%)', color: '#8b949e'},
450 grid: {color: '#21262d'},
451 ticks: {color: '#8b949e'},
452 min: 55, max: 90
453 }
454 }
455 }
456});
457
458// Chart: Ablation
459const layers = ABLATION.map(a => a.l);
460const deltas = ABLATION.map(a => Math.max(-80, Math.min(a.d, 200)));
461const colors = ABLATION.map(a => a.d > 100 ? '#f85149' : a.d > 10 ? '#d29922' : a.d > 0 ? '#d2992288' : '#3fb950');
462
463new Chart(document.getElementById('chartAblation'), {
464 type: 'bar',
465 data: {
466 labels: layers,
467 datasets: [{
468 label: 'PPL Δ %',
469 data: deltas,
470 backgroundColor: colors,
471 borderColor: colors,
472 borderWidth: 1
473 }]
474 },
475 options: {
476 responsive: true, maintainAspectRatio: false,
477 plugins: {
478 legend: {display: false},
479 tooltip: {
480 callbacks: {
481 label: ctx => {
482 const a = ABLATION[ctx.dataIndex];
483 return `Layer ${a.l}: ${a.d > 0 ? '+' : ''}${a.d.toFixed(1)}% PPL`;
484 }
485 }
486 }
487 },
488 scales: {
489 x: {grid: {color: '#21262d'}, ticks: {color: '#8b949e', font: {size: 10}}},
490 y: {
491 title: {display: true, text: 'PPL Δ % (clamped -80 to +200)', color: '#8b949e'},
492 grid: {color: '#21262d'},
493 ticks: {color: '#8b949e'}
494 }
495 }
496 }
497});
498
499// BI chart
500new Chart(document.getElementById('chartBI'), {
501 type: 'bar',
502 data: {
503 labels: BI.map((_,i)=>i),
504 datasets: [{
505 label: 'BI Score',
506 data: BI,
507 backgroundColor: BI.map((_,i)=>FA.has(i)?'rgba(188,140,255,0.7)':'rgba(63,185,80,0.5)'),
508 borderColor: BI.map((_,i)=>FA.has(i)?'#bc8cff':'#3fb950'),
509 borderWidth: 1
510 }]
511 },
512 options: {
513 responsive: true, maintainAspectRatio: false,
514 plugins: {legend: {display: false},
515 tooltip: {callbacks: {label: ctx => `Layer ${ctx.dataIndex}: BI=${ctx.raw.toFixed(4)} (${FA.has(ctx.dataIndex)?'full_attention':'sliding'})`}}
516 },
517 scales: {
518 x: {grid: {color: '#21262d'}, ticks: {color: '#8b949e', font: {size: 9}}},
519 y: {type: 'logarithmic', grid: {color: '#21262d'}, ticks: {color: '#8b949e'},
520 title: {display: true, text: 'BI Score (log)', color: '#8b949e'}}
521 }
522 }
523});
524
525// Smooth scroll for nav
526document.querySelectorAll('.nav-links a, .btn[href^="#"]').forEach(a => {
527 const href = a.getAttribute('href');
528 if (href && href.startsWith('#')) {
529 a.addEventListener('click', e => {
530 e.preventDefault();
531 document.querySelector(href)?.scrollIntoView({behavior: 'smooth'});
532 });
533 }
534});
535</script>
536
537</body>
538</html>