Download code/falcon_demo/test.mjs from LiteMind/homunculus: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon_demo/test.mjs
- Command line
-
hf download hf://LiteMind/homunculus/code/falcon_demo/test.mjs
-
curl -L -o test.mjs https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon_demo/test.mjs
1.05 kB
| import fs from 'fs'; | |
| import { parseSafetensors, buildModel, widen, newState, step, argmax } from './engine.js'; | |
| const cfg = JSON.parse(fs.readFileSync('config.json')), ref = JSON.parse(fs.readFileSync('ref.json')); | |
| const raw = parseSafetensors(fs.readFileSync('../model.safetensors').buffer.slice(0)); | |
| const base = buildModel(raw, cfg); | |
| const axes = (process.argv[2] || '').split('+').filter(Boolean), k = +(process.argv[3] || 1), np = +(process.argv[4] || 4); | |
| const M = widen(base, axes, k); | |
| let mx = 0, am = 0, ntok = 0; const t0 = Date.now(); | |
| for (let p = 0; p < np; p++) { | |
| const S = newState(M); let lg; for (const t of ref.ids[p]) { lg = step(M, S, t); ntok++; } | |
| let m = 0; for (let i = 0; i < lg.length; i++) m = Math.max(m, Math.abs(lg[i] - ref.last[p][i])); | |
| mx = Math.max(mx, m); if (argmax(lg) === argmax(Float32Array.from(ref.last[p]))) am++; | |
| } | |
| console.log(`${axes.join('+') || 'orig'} k=${k}: prompts ${np}, max|dlogit| vs HF fp32 ${mx.toExponential(2)}, argmax same ${am}/${np}, ${((Date.now() - t0) / ntok).toFixed(0)} ms/token`); | |