tinkersnot commited on
Commit
aa65f55
·
verified ·
1 Parent(s): 272f7bf

Upload spike-qwen2b.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. spike-qwen2b.html +6 -4
spike-qwen2b.html CHANGED
@@ -26,8 +26,10 @@ import * as webllm from "https://esm.run/@mlc-ai/web-llm";
26
  const $ = (id) => document.getElementById(id);
27
  const log = (m) => { $("log").textContent += m + "\n"; $("log").scrollTop = 1e9; };
28
  const esc = (s) => String(s).replace(/[&<>]/g, (c) => ({ "&":"&amp;","<":"&lt;",">":"&gt;" }[c]));
29
- // Official web-llm prebuilt web-llm resolves weights + wasm from its own config.
30
- const MODEL_ID = "Qwen3.5-2B-q4f16_1-MLC";
 
 
31
 
32
  // Qwen3.5 native tool-call format (XML). Parse both the native <function=…> and
33
  // the Hermes <tool_call>{json}</tool_call> shapes, since which one the q4 build
@@ -106,13 +108,13 @@ async function main() {
106
  if (!adapter) { try { adapter = await gpu.requestAdapter({ forceFallbackAdapter: true }); if (adapter) info = "FALLBACK/software [tok/s NOT representative]"; } catch {} }
107
  if (!adapter) { $("env").innerHTML = '<span class="bad">✗ no WebGPU adapter</span> — needs real GPU hardware.'; return; }
108
  $("env").innerHTML = `<span class="ok">✓ WebGPU adapter OK</span> ${info ? "— " + info : ""} · <b>${THINK ? "THINK-ON" : "think-off"}</b> · temp ${SAMP.temperature} top_p ${SAMP.top_p} pp ${SAMP.presence_penalty}`;
109
- document.getElementById("sub").innerHTML += ` · <b>${THINK ? "THINK-ON (?think=1)" : "think-off — add ?think=1 for think-on"}</b>`;
110
  $("run").disabled = false;
111
 
112
  $("run").onclick = async () => {
113
  $("run").disabled = true; $("tests").innerHTML = ""; $("metrics").innerHTML = ""; $("log").textContent = "";
114
  const t0 = performance.now();
115
- log(`loading ${MODEL_ID} (first run downloads ~1.3GB to browser cache)…`);
116
  let engine;
117
  try {
118
  engine = await webllm.CreateMLCEngine(MODEL_ID, { initProgressCallback: (p) => { $("env").innerHTML = `<span class="warn">loading… ${(p.progress*100|0)}%</span> ${esc(p.text||"")}`; } });
 
26
  const $ = (id) => document.getElementById(id);
27
  const log = (m) => { $("log").textContent += m + "\n"; $("log").scrollTop = 1e9; };
28
  const esc = (s) => String(s).replace(/[&<>]/g, (c) => ({ "&":"&amp;","<":"&lt;",">":"&gt;" }[c]));
29
+ // Official web-llm prebuilts (web-llm resolves weights+wasm from its own config).
30
+ // ?model=2b|4b selects the tier — 4B is the reasoner half of the 0.8B/4B pairing.
31
+ const MODELS = { "2b": "Qwen3.5-2B-q4f16_1-MLC", "4b": "Qwen3.5-4B-q4f16_1-MLC" };
32
+ const MODEL_ID = MODELS[new URLSearchParams(location.search).get("model")] || MODELS["2b"];
33
 
34
  // Qwen3.5 native tool-call format (XML). Parse both the native <function=…> and
35
  // the Hermes <tool_call>{json}</tool_call> shapes, since which one the q4 build
 
108
  if (!adapter) { try { adapter = await gpu.requestAdapter({ forceFallbackAdapter: true }); if (adapter) info = "FALLBACK/software [tok/s NOT representative]"; } catch {} }
109
  if (!adapter) { $("env").innerHTML = '<span class="bad">✗ no WebGPU adapter</span> — needs real GPU hardware.'; return; }
110
  $("env").innerHTML = `<span class="ok">✓ WebGPU adapter OK</span> ${info ? "— " + info : ""} · <b>${THINK ? "THINK-ON" : "think-off"}</b> · temp ${SAMP.temperature} top_p ${SAMP.top_p} pp ${SAMP.presence_penalty}`;
111
+ document.getElementById("sub").innerHTML += ` · <b>${MODEL_ID}</b> · <b>${THINK ? "THINK-ON (?think=1)" : "think-off — add ?think=1 for think-on"}</b>`;
112
  $("run").disabled = false;
113
 
114
  $("run").onclick = async () => {
115
  $("run").disabled = true; $("tests").innerHTML = ""; $("metrics").innerHTML = ""; $("log").textContent = "";
116
  const t0 = performance.now();
117
+ log(`loading ${MODEL_ID} (first run downloads to browser cache: ~1.3GB for 2B, ~2.5GB for 4B)…`);
118
  let engine;
119
  try {
120
  engine = await webllm.CreateMLCEngine(MODEL_ID, { initProgressCallback: (p) => { $("env").innerHTML = `<span class="warn">loading… ${(p.progress*100|0)}%</span> ${esc(p.text||"")}`; } });