hackbuild-browser-ai.models

model registry records with device and dtype ladders, quirks and weight licences, and a hub that routes a capability request to a record, loads it under a memory budget, and runs gpu work one job at a time.

how this works
how it works

licence is required; createRegistry refuses a record without one.

ladderFor(record, env) drops rungs the device cannot run: a webgpu rung without an adapter, an f16 dtype (also inside per sub graph dtypes) without shader-f16, a prompt api rung without LanguageModel.

ortLadder() is the onnxruntime-web walk from the transcription build: webgpu plus wasm at optimization basic, all, disabled, then wasm alone. pair it with store.once(ref) from @hackbuild/weights so every attempt reads one download.

packages@hackbuild/models
install
sh
npm install @hackbuild/models
code
ts
import { createHub, createRegistry, CATALOG } from "@hackbuild/models";

const hub = createHub({ registry: createRegistry(CATALOG), env: await probe(), budgetMB: 4000 });
hub.provide("tjs", async ({ record, rung }) => pipeline(task, record.source.modelId, { device: rung.device, dtype: rung.dtype }));
const depth = await hub.use("depth");                 // routed, ladder walked, cached
const map = await hub.run(depth, (pipe) => pipe(image)); // webgpu models take the gpu lock
hub.release(depth);