Pacific-i64 commited on
Commit
c59cebc
·
verified ·
1 Parent(s): 7e0f35b

Update interactive report for final TR-HASH-0.5B

Browse files
Files changed (2) hide show
  1. README.md +8 -10
  2. index.html +81 -94
README.md CHANGED
@@ -7,27 +7,25 @@ sdk: static
7
  app_file: index.html
8
  pinned: false
9
  license: apache-2.0
10
- short_description: Interactive companion for the 306.5M routing study.
11
  ---
12
 
13
- # Token Identity Routing — Interactive Paper
14
 
15
- Interactive companion for **Token Identity as a Routing Signal for Residual MLP Experts**.
16
 
17
  The Space provides:
18
 
19
  - an architecture explorer for the shared SwiGLU and fixed top-2 residual path;
20
  - checkpoint-derived tokenizer IDs and expert assignments for selected tokens;
21
- - the reported matched-run measurements and their stated limitations;
22
- - live side-by-side SSE generation from `Pacific-i64/TR-HASH-MOE-500M-HF` and `Pacific-i64/Dense-306`.
23
 
24
- The historical measurements remain the matched 306.5M study. The live panel now
25
- compares the current 492.1M TR-Hash release with Dense-306, so its outputs are a
26
- non-iso-parameter qualitative inspection and not additional experimental evidence.
27
 
28
  ## Sources
29
 
30
- - [Paper and reproducibility artifacts](https://github.com/Complexity-ML/tmlr-paper-pool)
31
  - [TR-HASH-MOE-500M-HF](https://huggingface.co/Pacific-i64/TR-HASH-MOE-500M-HF)
32
- - [Dense-306](https://huggingface.co/Pacific-i64/Dense-306)
33
  - [vllm-i64](https://github.com/Complexity-ML/vllm-i64)
 
7
  app_file: index.html
8
  pinned: false
9
  license: apache-2.0
10
+ short_description: Interactive report for the final TR-HASH-0.5B.
11
  ---
12
 
13
+ # TR-HASH-0.5B — Interactive Architecture Report
14
 
15
+ Interactive companion for the final **TR-HASH-0.5B** research checkpoint.
16
 
17
  The Space provides:
18
 
19
  - an architecture explorer for the shared SwiGLU and fixed top-2 residual path;
20
  - checkpoint-derived tokenizer IDs and expert assignments for selected tokens;
21
+ - the recorded 20B-token pretraining and one-epoch SFT diagnostics;
22
+ - live chat generation from `Pacific-i64/TR-HASH-MOE-500M-HF`.
23
 
24
+ Its metrics describe only the final 492.1M model. They are training
25
+ diagnostics, not a dense-baseline comparison or a general-capability benchmark.
 
26
 
27
  ## Sources
28
 
 
29
  - [TR-HASH-MOE-500M-HF](https://huggingface.co/Pacific-i64/TR-HASH-MOE-500M-HF)
30
+ - [Training framework](https://github.com/Complexity-ML/complexity-framework)
31
  - [vllm-i64](https://github.com/Complexity-ML/vllm-i64)
index.html CHANGED
@@ -3,8 +3,8 @@
3
  <head>
4
  <meta charset="utf-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <meta name="description" content="Interactive companion for Token Identity as a Routing Signal for Residual MLP Experts.">
7
- <title>Token Identity Routing — Interactive Paper</title>
8
  <link rel="stylesheet" href="./visualize.css">
9
  <script defer src="https://unpkg.com/lucide@1.17.0/dist/umd/lucide.js"></script>
10
  <style>
@@ -348,25 +348,25 @@
348
  <span class="tr-mark"><i data-lucide="git-branch" aria-hidden="true"></i></span>
349
  <span class="tr-brand-copy">
350
  <strong>COMPLEXITY</strong>
351
- <span class="text-small">Research companion</span>
352
  </span>
353
  </div>
354
  <nav class="tr-actions" aria-label="Research links">
355
- <a class="btn btn-ghost" href="https://www.complexity-ai.fr/papers/token-identity-routing-residual-experts.pdf" target="_blank" rel="noopener noreferrer"><i data-lucide="file-text" aria-hidden="true"></i> Paper</a>
356
- <a class="btn btn-ghost" href="https://github.com/Complexity-ML/tmlr-paper-pool" target="_blank" rel="noopener noreferrer"><i data-lucide="package-open" aria-hidden="true"></i> Supplement</a>
357
- <a class="btn btn-ghost" href="https://github.com/Complexity-ML/tmlr-paper-pool" target="_blank" rel="noopener noreferrer"><i data-lucide="github" aria-hidden="true"></i> Code</a>
358
  </nav>
359
  </header>
360
 
361
  <section class="tr-hero">
362
  <div class="tr-hero-copy">
363
- <span class="tr-kicker text-small">Interactive architecture study</span>
364
- <h2>Token identity as a routing signal for residual MLP experts</h2>
365
- <p>Explore how a fixed lexical lookup selects a narrow residual parameter subspace while a shared dense SwiGLU path handles contextual computation.</p>
366
  <div class="tr-chip-row">
367
- <span class="viz-badge">306.5M parameters</span>
368
- <span class="viz-badge">8B training tokens</span>
369
- <span class="viz-badge">fixed top-2 routing</span>
370
  </div>
371
  </div>
372
  <div class="tr-note text-small">
@@ -378,7 +378,7 @@
378
  <button class="btn tr-tab" type="button" role="tab" aria-selected="true" data-view="overview">Architecture</button>
379
  <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="routing">Routing lab</button>
380
  <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="results">Results</button>
381
- <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="compare">Live compare</button>
382
  </nav>
383
 
384
  <section class="tr-view tr-overview is-active" data-panel="overview" role="tabpanel">
@@ -412,14 +412,14 @@
412
  </div>
413
  <div class="tr-node tr-shared">
414
  <strong>Shared SwiGLU</strong>
415
- <span class="text-small">Width 3,840 · all tokens · contextual computation</span>
416
  </div>
417
  <div class="tr-node tr-table route-active">
418
  <strong>Fixed route table <em>r<sub>l</sub>(t)</em></strong>
419
- <span class="text-small">Selects two of four experts</span>
420
  </div>
421
  <div class="tr-node tr-experts route-active">
422
- <strong style="grid-column:1/-1">Residual experts</strong>
423
  <span class="tr-expert" data-expert="0">E0</span>
424
  <span class="tr-expert route-active" data-expert="1">E1</span>
425
  <span class="tr-expert route-active" data-expert="2">E2</span>
@@ -428,7 +428,7 @@
428
  <button class="btn tr-sum" type="button" data-tooltip="Element-wise branch sum" aria-label="Add the branch outputs">+</button>
429
  <div class="tr-node tr-output">
430
  <strong>Feed-forward output</strong>
431
- <span class="text-small">Shared path + 0.5 E<span data-route-a>1</span> + 0.5 E<span data-route-b>2</span></span>
432
  </div>
433
  </div>
434
  </div>
@@ -436,13 +436,13 @@
436
  <aside class="tr-side">
437
  <div class="tr-metric-grid">
438
  <div class="card viz-stat">
439
- <span class="text-muted text-small">Matched pair</span>
440
- <span class="viz-stat-value">306.5M</span>
441
  <span class="text-small">trainable parameters</span>
442
  </div>
443
  <div class="card viz-stat">
444
- <span class="text-muted text-small">Primary run</span>
445
- <span class="viz-stat-value">8B</span>
446
  <span class="text-small">FineWeb-Edu tokens</span>
447
  </div>
448
  </div>
@@ -451,11 +451,11 @@
451
  <i data-lucide="route" aria-hidden="true"></i>
452
  <strong>Selected route</strong>
453
  </div>
454
- <p data-route-copy>“routing” selects E1 + E2 in layer 1. The primary route is checkpoint-derived; the published inference runtime derives the cyclic secondary route.</p>
455
  </div>
456
  <div class="card">
457
  <strong>Scope of evidence</strong>
458
- <p class="text-muted">One matched 306.5M run pair. The result is reported as an observation, not a claim of statistical significance.</p>
459
  </div>
460
  </aside>
461
  </section>
@@ -483,14 +483,15 @@
483
  <div class="card">
484
  <div class="tr-route-matrix" aria-label="Expert assignment matrix">
485
  <span></span><span class="text-small text-center">E0</span><span class="text-small text-center">E1</span><span class="text-small text-center">E2</span><span class="text-small text-center">E3</span>
486
- <span class="text-small">Layer 1</span><span class="tr-route-cell" data-cell="1-0"></span><span class="tr-route-cell is-on" data-cell="1-1">0.5</span><span class="tr-route-cell is-on" data-cell="1-2">0.5</span><span class="tr-route-cell" data-cell="1-3"></span>
487
- <span class="text-small">Layer 6</span><span class="tr-route-cell" data-cell="6-0"></span><span class="tr-route-cell" data-cell="6-1">—</span><span class="tr-route-cell is-on" data-cell="6-2">0.5</span><span class="tr-route-cell is-on" data-cell="6-3">0.5</span>
488
- <span class="text-small">Layer 12</span><span class="tr-route-cell is-on" data-cell="12-0">0.5</span><span class="tr-route-cell" data-cell="12-1">—</span><span class="tr-route-cell" data-cell="12-2"></span><span class="tr-route-cell is-on" data-cell="12-3">0.5</span>
489
- <span class="text-small">Layer 18</span><span class="tr-route-cell" data-cell="18-0"></span><span class="tr-route-cell" data-cell="18-1">—</span><span class="tr-route-cell is-on" data-cell="18-2">0.5</span><span class="tr-route-cell is-on" data-cell="18-3">0.5</span>
 
490
  </div>
491
  </div>
492
  </div>
493
- <div class="tr-note text-small" data-lab-detail>Token “routing” follows a reproducible, layer-specific route. A different occurrence of the same token keeps the same route, while its hidden-state input still changes with context.</div>
494
  </section>
495
 
496
  <section class="tr-view" data-panel="results" role="tabpanel">
@@ -498,41 +499,41 @@
498
  <div>
499
  <div class="tr-run-head">
500
  <div>
501
- <strong>Last common evaluation point</strong>
502
- <div class="text-small text-muted">Fixed evaluation stream from the FineWeb-Edu training split · lower is better</div>
503
  </div>
504
  </div>
505
- <div class="tr-result-chart" role="img" aria-label="Evaluation NLL: dense 2.9482, token-routed 2.9329.">
506
  <div class="tr-bar-group">
507
- <div class="tr-bar" style="height:81%"><span>2.9482</span></div>
508
- <div class="tr-bar routed" style="height:68%"><span>2.9329</span></div>
509
- <div class="tr-bar-label text-small">Evaluation NLL</div>
510
  </div>
511
  <div class="tr-bar-group">
512
- <div class="tr-bar" style="height:75%"><span>1.00×</span></div>
513
- <div class="tr-bar routed" style="height:96%"><span>0.79×</span></div>
514
- <div class="tr-bar-label text-small">Training throughput</div>
515
  </div>
516
  </div>
517
  <div class="tr-legend text-small" style="margin-top:30px">
518
- <span class="tr-swatch"></span><span>Dense</span>
519
- <span class="tr-swatch routed"></span><span>Token-routed</span>
520
  </div>
521
  </div>
522
  <div class="card">
523
  <table class="table table-sm">
524
  <thead>
525
- <tr><th>Measurement</th><th class="text-end">Dense</th><th class="text-end">Routed</th></tr>
526
  </thead>
527
  <tbody>
528
- <tr><td>Parameters</td><td class="text-end">306.5M</td><td class="text-end">306.5M</td></tr>
529
- <tr><td>Evaluation NLL</td><td class="text-end">2.9482</td><td class="text-end">2.9329</td></tr>
530
- <tr><td>NLL difference</td><td class="text-end"></td><td class="text-end">−0.0153</td></tr>
531
- <tr><td>Training tokens</td><td class="text-end">8B</td><td class="text-end">8B</td></tr>
532
- <tr><td>Seeds</td><td class="text-end">1</td><td class="text-end">1</td></tr>
533
  </tbody>
534
  </table>
535
- <p class="text-small text-muted">Single-seed matched-run observation. Evaluation is not held out; downstream multiple-choice differences are within one reported standard error.</p>
536
  </div>
537
  </div>
538
  </section>
@@ -541,29 +542,27 @@
541
  <div class="tr-prompt-row">
542
  <label class="form-label">
543
  Prompt
544
- <input class="form-control" data-prompt value="Machine learning is a branch of artificial intelligence that" />
545
  </label>
546
  <button class="btn btn-primary" type="button" data-run>
547
- <i data-lucide="play" aria-hidden="true"></i> Run comparison
548
  </button>
549
  </div>
550
  <div class="tr-compare-grid">
551
- <div class="card">
552
- <div class="tr-run-head">
553
- <strong>Dense-306</strong>
554
- <span class="viz-badge" data-dense-state>ready</span>
555
- </div>
556
- <p class="tr-generation" data-dense-output aria-live="polite">Dense output will stream here token by token.</p>
557
- </div>
558
  <div class="card">
559
  <div class="tr-run-head">
560
  <strong>TR-HASH-0.5B</strong>
561
  <span class="viz-badge" data-routed-state>ready</span>
562
  </div>
563
- <p class="tr-generation" data-routed-output aria-live="polite">Token-routed output will stream here token by token.</p>
 
 
 
 
 
564
  </div>
565
  </div>
566
- <div class="tr-status text-small" data-status>TR-Hash 492.1M vs Dense 306.5M · non-iso-parameter qualitative comparison</div>
567
  </section>
568
  </div>
569
 
@@ -573,14 +572,14 @@
573
  if (!root) return;
574
 
575
  const routes = {
576
- routing: { id: 22447, layers: [[1, 2], [2, 3], [3, 0], [2, 3]] },
577
- context: { id: 4057, layers: [[0, 1], [1, 2], [2, 3], [0, 1]] },
578
- expert: { id: 5217, layers: [[0, 1], [1, 2], [2, 3], [0, 1]] },
579
- shared: { id: 5586, layers: [[3, 0], [0, 1], [1, 2], [3, 0]] },
580
- token: { id: 23394, layers: [[3, 0], [0, 1], [1, 2], [3, 0]] },
581
- model: { id: 2181, layers: [[0, 1], [1, 2], [2, 3], [0, 1]] },
582
- dense: { id: 8581, layers: [[0, 1], [1, 2], [2, 3], [0, 1]] },
583
- learned: { id: 4273, layers: [[0, 1], [1, 2], [2, 3], [0, 1]] }
584
  };
585
 
586
  const tabs = [...root.querySelectorAll(".tr-tab")];
@@ -651,7 +650,7 @@
651
  root.querySelector("[data-route-a]").textContent = String(pair[0]);
652
  root.querySelector("[data-route-b]").textContent = String(pair[1]);
653
  root.querySelector("[data-route-copy]").textContent =
654
- `“${token}” selects E${pair[0]} + E${pair[1]} in layer 1. The primary route is checkpoint-derived; the published inference runtime derives the cyclic secondary route.`;
655
  root.querySelectorAll("[data-expert]").forEach((expert) => {
656
  expert.classList.toggle("route-active", pair.includes(Number(expert.dataset.expert)));
657
  });
@@ -667,7 +666,7 @@
667
  const updateMatrix = (token) => {
668
  const route = routes[token];
669
  if (!route) return;
670
- const layers = [1, 6, 12, 18];
671
  layers.forEach((layer, layerIndex) => {
672
  const [a, b] = route.layers[layerIndex];
673
  for (let expert = 0; expert < 4; expert += 1) {
@@ -681,14 +680,14 @@
681
  button.classList.toggle("is-selected", button.dataset.labToken === token);
682
  });
683
  root.querySelector("[data-lab-detail]").textContent =
684
- `Token “${token}” (ID ${route.id}) follows these routes in the published inference runtime. Primary routes come from the checkpoint; cyclic secondary routes are deterministic.`;
685
  };
686
 
687
  root.querySelectorAll(".tr-token-btn").forEach((button) => {
688
  button.addEventListener("click", () => updateMatrix(button.dataset.labToken));
689
  });
690
 
691
- const COMPARE_ENDPOINT = "https://pacific-i64-compare-306.hf.space/v1/compare";
692
  let activeController = null;
693
 
694
  const consumeSSE = async (response, onEvent) => {
@@ -718,9 +717,7 @@
718
 
719
  root.querySelector("[data-run]").addEventListener("click", async () => {
720
  const runButton = root.querySelector("[data-run]");
721
- const denseOutput = root.querySelector("[data-dense-output]");
722
  const routedOutput = root.querySelector("[data-routed-output]");
723
- const denseState = root.querySelector("[data-dense-state]");
724
  const routedState = root.querySelector("[data-routed-state]");
725
  const status = root.querySelector("[data-status]");
726
  const prompt = root.querySelector("[data-prompt]").value.trim();
@@ -728,34 +725,32 @@
728
  if (activeController) {
729
  activeController.abort();
730
  activeController = null;
731
- runButton.textContent = "Run comparison";
732
- denseState.textContent = "stopped";
733
  routedState.textContent = "stopped";
734
  status.textContent = "Generation stopped.";
735
  status.classList.remove("is-live");
736
  return;
737
  }
738
  if (!prompt) {
739
- status.textContent = "Enter a prompt before running the comparison.";
740
  return;
741
  }
742
 
743
  const controller = new AbortController();
744
  activeController = controller;
745
- denseOutput.textContent = "";
746
  routedOutput.textContent = "";
747
- denseState.textContent = "connecting";
748
  routedState.textContent = "connecting";
749
  runButton.textContent = "Stop generation";
750
- status.textContent = "Connecting to TR-Hash 492.1M and Dense 306.5M CPU endpoints…";
751
  status.classList.add("is-live");
752
 
753
  try {
754
- const response = await fetch(COMPARE_ENDPOINT, {
755
  method: "POST",
756
  headers: { "Content-Type": "application/json" },
757
  body: JSON.stringify({
758
- prompt,
 
759
  max_tokens: 128,
760
  temperature: 0.7,
761
  top_k: 40,
@@ -767,32 +762,24 @@
767
  });
768
  if (!response.ok) {
769
  const detail = (await response.text()).slice(0, 240);
770
- throw new Error(`Compare endpoint returned HTTP ${response.status}${detail ? `: ${detail}` : ""}`);
771
  }
772
- denseState.textContent = "streaming";
773
  routedState.textContent = "streaming";
774
- status.textContent = "Receiving two real SSE streams token by token…";
775
  await consumeSSE(response, (event) => {
776
- if (event.error) {
777
- if (event.type === "dense") denseState.textContent = "error";
778
- if (event.type === "tr_moe") routedState.textContent = "error";
779
- return;
780
- }
781
- if (!event.text) return;
782
- if (event.type === "dense") denseOutput.textContent += event.text;
783
- if (event.type === "tr_moe") routedOutput.textContent += event.text;
784
  });
785
- denseState.textContent = denseOutput.textContent ? "complete" : "no output";
786
  routedState.textContent = routedOutput.textContent ? "complete" : "no output";
787
- status.textContent = "Comparison complete · qualitative output only";
788
  } catch (error) {
789
  if (error.name === "AbortError") return;
790
- denseState.textContent = "unavailable";
791
  routedState.textContent = "unavailable";
792
  status.textContent = `Inference temporarily unavailable: ${error.message}`;
793
  } finally {
794
  if (activeController === controller) activeController = null;
795
- runButton.textContent = "Run comparison";
796
  status.classList.remove("is-live");
797
  }
798
  });
 
3
  <head>
4
  <meta charset="utf-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="description" content="Interactive architecture and training report for the final TR-HASH-0.5B checkpoint.">
7
+ <title>TR-HASH-0.5B — Interactive Architecture Report</title>
8
  <link rel="stylesheet" href="./visualize.css">
9
  <script defer src="https://unpkg.com/lucide@1.17.0/dist/umd/lucide.js"></script>
10
  <style>
 
348
  <span class="tr-mark"><i data-lucide="git-branch" aria-hidden="true"></i></span>
349
  <span class="tr-brand-copy">
350
  <strong>COMPLEXITY</strong>
351
+ <span class="text-small">TR-HASH-0.5B companion</span>
352
  </span>
353
  </div>
354
  <nav class="tr-actions" aria-label="Research links">
355
+ <a class="btn btn-ghost" href="https://huggingface.co/Pacific-i64/TR-HASH-MOE-500M-HF" target="_blank" rel="noopener noreferrer"><i data-lucide="file-text" aria-hidden="true"></i> Model card</a>
356
+ <a class="btn btn-ghost" href="https://github.com/Complexity-ML/complexity-framework" target="_blank" rel="noopener noreferrer"><i data-lucide="package-open" aria-hidden="true"></i> Training code</a>
357
+ <a class="btn btn-ghost" href="https://huggingface.co/spaces/Pacific-i64/TR-HASH-0.5B" target="_blank" rel="noopener noreferrer"><i data-lucide="message-square" aria-hidden="true"></i> Live chat</a>
358
  </nav>
359
  </header>
360
 
361
  <section class="tr-hero">
362
  <div class="tr-hero-copy">
363
+ <span class="tr-kicker text-small">Final research checkpoint</span>
364
+ <h2>TR-HASH-0.5B</h2>
365
+ <p>Explore how a balanced token-ID hash selects two narrow residual experts while a shared dense SwiGLU path preserves contextual computation.</p>
366
  <div class="tr-chip-row">
367
+ <span class="viz-badge">492.1M parameters</span>
368
+ <span class="viz-badge">20B pretraining tokens</span>
369
+ <span class="viz-badge">24 layers · fixed top-2</span>
370
  </div>
371
  </div>
372
  <div class="tr-note text-small">
 
378
  <button class="btn tr-tab" type="button" role="tab" aria-selected="true" data-view="overview">Architecture</button>
379
  <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="routing">Routing lab</button>
380
  <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="results">Results</button>
381
+ <button class="btn tr-tab" type="button" role="tab" aria-selected="false" data-view="compare">Live demo</button>
382
  </nav>
383
 
384
  <section class="tr-view tr-overview is-active" data-panel="overview" role="tabpanel">
 
412
  </div>
413
  <div class="tr-node tr-shared">
414
  <strong>Shared SwiGLU</strong>
415
+ <span class="text-small">Width 4,864 · all tokens · contextual computation</span>
416
  </div>
417
  <div class="tr-node tr-table route-active">
418
  <strong>Fixed route table <em>r<sub>l</sub>(t)</em></strong>
419
+ <span class="text-small">Balanced layer-specific hash · two of four experts</span>
420
  </div>
421
  <div class="tr-node tr-experts route-active">
422
+ <strong style="grid-column:1/-1">Residual experts · width 128 each</strong>
423
  <span class="tr-expert" data-expert="0">E0</span>
424
  <span class="tr-expert route-active" data-expert="1">E1</span>
425
  <span class="tr-expert route-active" data-expert="2">E2</span>
 
428
  <button class="btn tr-sum" type="button" data-tooltip="Element-wise branch sum" aria-label="Add the branch outputs">+</button>
429
  <div class="tr-node tr-output">
430
  <strong>Feed-forward output</strong>
431
+ <span class="text-small">Shared + 2 × mean(E<span data-route-a>0</span>, E<span data-route-b>3</span>)</span>
432
  </div>
433
  </div>
434
  </div>
 
436
  <aside class="tr-side">
437
  <div class="tr-metric-grid">
438
  <div class="card viz-stat">
439
+ <span class="text-muted text-small">Final model</span>
440
+ <span class="viz-stat-value">492.1M</span>
441
  <span class="text-small">trainable parameters</span>
442
  </div>
443
  <div class="card viz-stat">
444
+ <span class="text-muted text-small">Pretraining</span>
445
+ <span class="viz-stat-value">20B</span>
446
  <span class="text-small">FineWeb-Edu tokens</span>
447
  </div>
448
  </div>
 
451
  <i data-lucide="route" aria-hidden="true"></i>
452
  <strong>Selected route</strong>
453
  </div>
454
+ <p data-route-copy>“routing” selects E0 + E3 in layer 1. Both assignments are read from the final checkpoint route table.</p>
455
  </div>
456
  <div class="card">
457
  <strong>Scope of evidence</strong>
458
+ <p class="text-muted">One 492.1M pretraining run and one SFT epoch. The recorded losses are diagnostics, not a dense-baseline or general-capability benchmark.</p>
459
  </div>
460
  </aside>
461
  </section>
 
483
  <div class="card">
484
  <div class="tr-route-matrix" aria-label="Expert assignment matrix">
485
  <span></span><span class="text-small text-center">E0</span><span class="text-small text-center">E1</span><span class="text-small text-center">E2</span><span class="text-small text-center">E3</span>
486
+ <span class="text-small">Layer 1</span><span class="tr-route-cell is-on" data-cell="1-0">0.5</span><span class="tr-route-cell" data-cell="1-1"></span><span class="tr-route-cell" data-cell="1-2"></span><span class="tr-route-cell is-on" data-cell="1-3">0.5</span>
487
+ <span class="text-small">Layer 6</span><span class="tr-route-cell is-on" data-cell="6-0">0.5</span><span class="tr-route-cell" data-cell="6-1">—</span><span class="tr-route-cell is-on" data-cell="6-2">0.5</span><span class="tr-route-cell" data-cell="6-3"></span>
488
+ <span class="text-small">Layer 12</span><span class="tr-route-cell" data-cell="12-0"></span><span class="tr-route-cell" data-cell="12-1">—</span><span class="tr-route-cell is-on" data-cell="12-2">0.5</span><span class="tr-route-cell is-on" data-cell="12-3">0.5</span>
489
+ <span class="text-small">Layer 18</span><span class="tr-route-cell is-on" data-cell="18-0">0.5</span><span class="tr-route-cell" data-cell="18-1">—</span><span class="tr-route-cell is-on" data-cell="18-2">0.5</span><span class="tr-route-cell" data-cell="18-3"></span>
490
+ <span class="text-small">Layer 24</span><span class="tr-route-cell" data-cell="24-0">—</span><span class="tr-route-cell is-on" data-cell="24-1">0.5</span><span class="tr-route-cell is-on" data-cell="24-2">0.5</span><span class="tr-route-cell" data-cell="24-3">—</span>
491
  </div>
492
  </div>
493
  </div>
494
+ <div class="tr-note text-small" data-lab-detail>Token “routing” follows the persisted route table of the final checkpoint. Every occurrence keeps the same expert pair at a given layer, while its hidden-state input still changes with context.</div>
495
  </section>
496
 
497
  <section class="tr-view" data-panel="results" role="tabpanel">
 
499
  <div>
500
  <div class="tr-run-head">
501
  <div>
502
+ <strong>Recorded training diagnostics</strong>
503
+ <div class="text-small text-muted">Initial and final scheduled evaluations · NLL, lower is better</div>
504
  </div>
505
  </div>
506
+ <div class="tr-result-chart" role="img" aria-label="Pretraining NLL decreased from 4.8554 to 2.6615. Matched SFT diagnostic NLL decreased from 3.4805 to 2.9669.">
507
  <div class="tr-bar-group">
508
+ <div class="tr-bar" style="height:96%"><span>4.8554</span></div>
509
+ <div class="tr-bar routed" style="height:53%"><span>2.6615</span></div>
510
+ <div class="tr-bar-label text-small">Pretraining held-out</div>
511
  </div>
512
  <div class="tr-bar-group">
513
+ <div class="tr-bar" style="height:69%"><span>3.4805</span></div>
514
+ <div class="tr-bar routed" style="height:59%"><span>2.9669</span></div>
515
+ <div class="tr-bar-label text-small">Matched SFT diagnostic</div>
516
  </div>
517
  </div>
518
  <div class="tr-legend text-small" style="margin-top:30px">
519
+ <span class="tr-swatch"></span><span>Initial</span>
520
+ <span class="tr-swatch routed"></span><span>Final</span>
521
  </div>
522
  </div>
523
  <div class="card">
524
  <table class="table table-sm">
525
  <thead>
526
+ <tr><th>Measurement</th><th class="text-end">Initial</th><th class="text-end">Final</th></tr>
527
  </thead>
528
  <tbody>
529
+ <tr><td>Pretraining held-out NLL</td><td class="text-end">4.8554 @ 1k</td><td class="text-end">2.6615 @ 76k</td></tr>
530
+ <tr><td>Pretraining held-out PPL</td><td class="text-end">128.43</td><td class="text-end">14.32</td></tr>
531
+ <tr><td>Matched SFT NLL</td><td class="text-end">3.4805</td><td class="text-end">2.9669</td></tr>
532
+ <tr><td>Natural-gold SFT NLL</td><td class="text-end">3.0644</td><td class="text-end">2.6866</td></tr>
533
+ <tr><td>Training coverage</td><td class="text-end">20B pretrain</td><td class="text-end">31.37M supervised</td></tr>
534
  </tbody>
535
  </table>
536
+ <p class="text-small text-muted">Pretraining evaluation is held out. SFT diagnostics use a 672-example matched set and a 28-example natural-gold set; the latter is too small for a stable capability claim.</p>
537
  </div>
538
  </div>
539
  </section>
 
542
  <div class="tr-prompt-row">
543
  <label class="form-label">
544
  Prompt
545
+ <input class="form-control" data-prompt value="Explain deterministic token routing in three short sentences." />
546
  </label>
547
  <button class="btn btn-primary" type="button" data-run>
548
+ <i data-lucide="play" aria-hidden="true"></i> Generate
549
  </button>
550
  </div>
551
  <div class="tr-compare-grid">
 
 
 
 
 
 
 
552
  <div class="card">
553
  <div class="tr-run-head">
554
  <strong>TR-HASH-0.5B</strong>
555
  <span class="viz-badge" data-routed-state>ready</span>
556
  </div>
557
+ <p class="tr-generation" data-routed-output aria-live="polite">The model response will stream here token by token.</p>
558
+ </div>
559
+ <div class="card">
560
+ <strong>Decode configuration</strong>
561
+ <p class="text-muted">Chat endpoint · temperature 0.7 · top-k 40 · top-p 0.9 · repetition penalty 1.1 · maximum 128 new tokens.</p>
562
+ <p class="text-small text-muted">This is a qualitative demonstration of the released SFT checkpoint, not an evaluation result.</p>
563
  </div>
564
  </div>
565
+ <div class="tr-status text-small" data-status>TR-HASH-0.5B · live qualitative generation</div>
566
  </section>
567
  </div>
568
 
 
572
  if (!root) return;
573
 
574
  const routes = {
575
+ routing: { id: 22447, layers: [[0, 3], [2, 0], [2, 3], [0, 2], [2, 1]] },
576
+ context: { id: 4057, layers: [[0, 3], [3, 2], [1, 0], [2, 1], [1, 0]] },
577
+ expert: { id: 5217, layers: [[2, 1], [1, 3], [2, 1], [2, 0], [3, 0]] },
578
+ shared: { id: 5586, layers: [[1, 0], [1, 0], [0, 1], [1, 2], [0, 1]] },
579
+ token: { id: 23394, layers: [[2, 3], [1, 0], [0, 1], [0, 2], [0, 3]] },
580
+ model: { id: 2181, layers: [[3, 2], [2, 0], [1, 2], [1, 3], [0, 1]] },
581
+ dense: { id: 8581, layers: [[0, 3], [3, 1], [2, 1], [2, 0], [0, 1]] },
582
+ learned: { id: 4273, layers: [[2, 1], [1, 0], [0, 1], [1, 2], [1, 0]] }
583
  };
584
 
585
  const tabs = [...root.querySelectorAll(".tr-tab")];
 
650
  root.querySelector("[data-route-a]").textContent = String(pair[0]);
651
  root.querySelector("[data-route-b]").textContent = String(pair[1]);
652
  root.querySelector("[data-route-copy]").textContent =
653
+ `“${token}” selects E${pair[0]} + E${pair[1]} in layer 1. Both assignments are read from the final checkpoint route table.`;
654
  root.querySelectorAll("[data-expert]").forEach((expert) => {
655
  expert.classList.toggle("route-active", pair.includes(Number(expert.dataset.expert)));
656
  });
 
666
  const updateMatrix = (token) => {
667
  const route = routes[token];
668
  if (!route) return;
669
+ const layers = [1, 6, 12, 18, 24];
670
  layers.forEach((layer, layerIndex) => {
671
  const [a, b] = route.layers[layerIndex];
672
  for (let expert = 0; expert < 4; expert += 1) {
 
680
  button.classList.toggle("is-selected", button.dataset.labToken === token);
681
  });
682
  root.querySelector("[data-lab-detail]").textContent =
683
+ `Token “${token}” (ID ${route.id}) follows these persisted layer-specific routes in the final checkpoint.`;
684
  };
685
 
686
  root.querySelectorAll(".tr-token-btn").forEach((button) => {
687
  button.addEventListener("click", () => updateMatrix(button.dataset.labToken));
688
  });
689
 
690
+ const CHAT_ENDPOINT = "https://pacific-i64-tr-hash-0-5b.hf.space/v1/chat/completions";
691
  let activeController = null;
692
 
693
  const consumeSSE = async (response, onEvent) => {
 
717
 
718
  root.querySelector("[data-run]").addEventListener("click", async () => {
719
  const runButton = root.querySelector("[data-run]");
 
720
  const routedOutput = root.querySelector("[data-routed-output]");
 
721
  const routedState = root.querySelector("[data-routed-state]");
722
  const status = root.querySelector("[data-status]");
723
  const prompt = root.querySelector("[data-prompt]").value.trim();
 
725
  if (activeController) {
726
  activeController.abort();
727
  activeController = null;
728
+ runButton.textContent = "Generate";
 
729
  routedState.textContent = "stopped";
730
  status.textContent = "Generation stopped.";
731
  status.classList.remove("is-live");
732
  return;
733
  }
734
  if (!prompt) {
735
+ status.textContent = "Enter a prompt before generating.";
736
  return;
737
  }
738
 
739
  const controller = new AbortController();
740
  activeController = controller;
 
741
  routedOutput.textContent = "";
 
742
  routedState.textContent = "connecting";
743
  runButton.textContent = "Stop generation";
744
+ status.textContent = "Connecting to the TR-HASH-0.5B chat endpoint…";
745
  status.classList.add("is-live");
746
 
747
  try {
748
+ const response = await fetch(CHAT_ENDPOINT, {
749
  method: "POST",
750
  headers: { "Content-Type": "application/json" },
751
  body: JSON.stringify({
752
+ model: "tr-hash-moe-500m",
753
+ messages: [{ role: "user", content: prompt }],
754
  max_tokens: 128,
755
  temperature: 0.7,
756
  top_k: 40,
 
762
  });
763
  if (!response.ok) {
764
  const detail = (await response.text()).slice(0, 240);
765
+ throw new Error(`Chat endpoint returned HTTP ${response.status}${detail ? `: ${detail}` : ""}`);
766
  }
 
767
  routedState.textContent = "streaming";
768
+ status.textContent = "Receiving the response token by token…";
769
  await consumeSSE(response, (event) => {
770
+ if (event.error) throw new Error(event.error.message || "Generation failed.");
771
+ const text = event.choices?.[0]?.delta?.content || event.choices?.[0]?.text || event.text || "";
772
+ if (text) routedOutput.textContent += text;
 
 
 
 
 
773
  });
 
774
  routedState.textContent = routedOutput.textContent ? "complete" : "no output";
775
+ status.textContent = "Generation complete · qualitative output only";
776
  } catch (error) {
777
  if (error.name === "AbortError") return;
 
778
  routedState.textContent = "unavailable";
779
  status.textContent = `Inference temporarily unavailable: ${error.message}`;
780
  } finally {
781
  if (activeController === controller) activeController = null;
782
+ runButton.textContent = "Generate";
783
  status.classList.remove("is-live");
784
  }
785
  });