LiteMind commited on
Commit
d3dd96f
·
verified ·
1 Parent(s): ab51c3e

Sync mobile+console fixes from Space

Browse files
Files changed (1) hide show
  1. code/falcon_demo/index.html +3 -2
code/falcon_demo/index.html CHANGED
@@ -13,6 +13,7 @@ textarea{width:100%;direction:auto}label{margin-inline-end:14px;white-space:nowr
13
  .out{min-height:120px;white-space:pre-wrap;direction:auto;background:#0d1117;border:1px solid var(--line);border-radius:8px;padding:10px;font-family:ui-monospace,Consolas,monospace;font-size:14px}
14
  .bar{height:8px;background:#21262d;border-radius:4px;overflow:hidden}.bar>i{display:block;height:100%;width:0;background:var(--acc)}
15
  .big{font-size:19px;font-weight:600}.ok{color:var(--ok)}.bad{color:var(--bad)}table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid var(--line);padding:4px 8px;text-align:start;font-size:13px}
 
16
  </style></head><body><main>
17
  <h1>Falcon-H1-Tiny-90M: same model, wider, no training</h1>
18
  <div class="mut">The official Falcon model from TII (91 million parameters, hybrid attention + Mamba2 + MLP). The page downloads the original weights from Hugging Face, widens them in the browser by copying units and dividing the outgoing weights by the number of copies (no noise, no training), then generates text with both models side by side and measures the logit difference at every step. The engine is plain JavaScript and agrees with HF transformers to about 1e-5 to 1e-4 on logits of magnitude tens.</div>
@@ -53,10 +54,10 @@ const HF='https://huggingface.co/tiiuae/Falcon-H1-Tiny-90M-Instruct/resolve/main
53
  const $=id=>document.getElementById(id);let base=null,wide=null,tok=null,cfg=null,stopFlag=false,wdesc='';
54
  const nparams=M=>{let n=M.E.length+M.fn.length;for(const l of M.L)for(const v of Object.values(l))n+=v.length;return n};
55
  const fmt=n=>(n/1e6).toFixed(1)+'M';
56
- async function getJSON(u,fb){try{const r=await fetch(u);if(!r.ok)throw 0;return await r.json()}catch(e){return await (await fetch(fb)).json()}}
57
  $('load').onclick=async()=>{
58
  $('load').disabled=true;$('lstat').textContent='Loading config and tokenizer...';
59
- cfg=await getJSON('./config.json',HF+'config.json');tok=makeTokenizer(await getJSON('./tokenizer.json',HF+'tokenizer.json'));
60
  let r;try{r=await fetch(HF+'model.safetensors')}catch(e){r=await fetch('https://hf-mirror.com/tiiuae/Falcon-H1-Tiny-90M-Instruct/resolve/main/model.safetensors')}const tot=+r.headers.get('content-length')||182304120,rd=r.body.getReader(),buf=new Uint8Array(tot);let got=0;
61
  for(;;){const {done,value}=await rd.read();if(done)break;buf.set(value,got);got+=value.length;$('lbar').style.width=(100*got/tot)+'%';$('lstat').textContent=(got/1e6).toFixed(0)+' / '+(tot/1e6).toFixed(0)+' MB'}
62
  $('lstat').textContent='Converting weights...';await new Promise(r=>setTimeout(r,20));
 
13
  .out{min-height:120px;white-space:pre-wrap;direction:auto;background:#0d1117;border:1px solid var(--line);border-radius:8px;padding:10px;font-family:ui-monospace,Consolas,monospace;font-size:14px}
14
  .bar{height:8px;background:#21262d;border-radius:4px;overflow:hidden}.bar>i{display:block;height:100%;width:0;background:var(--acc)}
15
  .big{font-size:19px;font-weight:600}.ok{color:var(--ok)}.bad{color:var(--bad)}table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid var(--line);padding:4px 8px;text-align:start;font-size:13px}
16
+ @media(max-width:760px){main{padding:12px}label{white-space:normal;display:inline-block;padding:6px 0}input[type=checkbox]{width:18px;height:18px;vertical-align:middle}button,select,input[type=text]{min-height:40px}.card{overflow-x:auto}}
17
  </style></head><body><main>
18
  <h1>Falcon-H1-Tiny-90M: same model, wider, no training</h1>
19
  <div class="mut">The official Falcon model from TII (91 million parameters, hybrid attention + Mamba2 + MLP). The page downloads the original weights from Hugging Face, widens them in the browser by copying units and dividing the outgoing weights by the number of copies (no noise, no training), then generates text with both models side by side and measures the logit difference at every step. The engine is plain JavaScript and agrees with HF transformers to about 1e-5 to 1e-4 on logits of magnitude tens.</div>
 
54
  const $=id=>document.getElementById(id);let base=null,wide=null,tok=null,cfg=null,stopFlag=false,wdesc='';
55
  const nparams=M=>{let n=M.E.length+M.fn.length;for(const l of M.L)for(const v of Object.values(l))n+=v.length;return n};
56
  const fmt=n=>(n/1e6).toFixed(1)+'M';
57
+ async function getJSON(u){const r=await fetch(u);if(!r.ok)throw new Error('HTTP '+r.status+' '+u);return await r.json()}
58
  $('load').onclick=async()=>{
59
  $('load').disabled=true;$('lstat').textContent='Loading config and tokenizer...';
60
+ cfg=await getJSON(HF+'config.json');tok=makeTokenizer(await getJSON(HF+'tokenizer.json'));
61
  let r;try{r=await fetch(HF+'model.safetensors')}catch(e){r=await fetch('https://hf-mirror.com/tiiuae/Falcon-H1-Tiny-90M-Instruct/resolve/main/model.safetensors')}const tot=+r.headers.get('content-length')||182304120,rd=r.body.getReader(),buf=new Uint8Array(tot);let got=0;
62
  for(;;){const {done,value}=await rd.read();if(done)break;buf.set(value,got);got+=value.length;$('lbar').style.width=(100*got/tot)+'%';$('lstat').textContent=(got/1e6).toFixed(0)+' / '+(tot/1e6).toFixed(0)+' MB'}
63
  $('lstat').textContent='Converting weights...';await new Promise(r=>setTimeout(r,20));