Download code/falcon_demo/test2.mjs from LiteMind/homunculus: direct link, hf CLI and curl.
- Browser
- Download file 915 Bytes
-
https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon_demo/test2.mjs
- Command line
-
hf download hf://LiteMind/homunculus/code/falcon_demo/test2.mjs
-
curl -L -o test2.mjs https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon_demo/test2.mjs
915 Bytes
| 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 base = buildModel(parseSafetensors(fs.readFileSync('../model.safetensors').buffer.slice(0)), cfg); | |
| const axes = process.argv[2].split('+'), k = +process.argv[3], np = +process.argv[4]; | |
| const M = widen(base, axes, k); let mx = 0, am = 0; | |
| for (let p = 0; p < np; p++) { | |
| const A = newState(base), B = newState(M); let la, lb; | |
| for (const t of ref.ids[p]) { la = step(base, A, t); lb = step(M, B, t); } | |
| let m = 0; for (let i = 0; i < la.length; i++) m = Math.max(m, Math.abs(la[i] - lb[i])); mx = Math.max(mx, m); if (argmax(la) === argmax(lb)) am++; | |
| } | |
| console.log(`JS orig vs JS widened ${process.argv[2]} k=${k}: ${np} prompts, max|dlogit| ${mx.toExponential(2)}, argmax same ${am}/${np}`); | |