Add weightlift — in-browser ML model load progress library - #55
Merged
Conversation
Extract the multi-file download progress aggregation used by the Whisper worker into a publishable zero-dep TypeScript package (weightlift) with Transformers.js / WebLLM adapters, a worker postMessage bridge, and a thin React useSyncExternalStore hook. Wire the transcription worker to consume it and cover the core with unit tests. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Reshape the package around define/load/get/unload with cache-aware messaging, per-model progress, dispose, and preload — progress aggregation stays as the engine underneath. Add useModel/useModelManager React hooks and wire Rescript's ASR singleton through ModelManager. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
UI copy and Transformers.js/WebLLM adapters are implementer concerns — keep ModelManager focused on lifecycle, bytes, and fromCache. Map progress callbacks at the call site; works the same for Whisper, CLIP, SigLIP, or any other T. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
packages/weightlift is now self-contained (own gitignore, lockfile, CI, npmignore) so it can be copied into its own repo and published. Drop npm workspaces / local build glue from Rescript and consume weightlift@^0.1.0 as a normal dependency. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Point the lockfile at the registry package and drop the local packages/weightlift copy now that it lives in its own repo. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
A lost GPU device invalidates every WebGPU session, so unload all cached ASR models (equivalent to asrPromises.clear()), not only the current choice. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Switch the transcription worker to weightlift's registry-first API (seed ModelManager with all Whisper sizes, then load(id)). Depends on weightlift@^0.2.0. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Drop the local transformers.js progress/cache helpers from the worker in favor of the optional weightlift/transformers entry. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Register ASR models with weightlift/transformers helpers that own device pick, progress, cache checks, and WebGPU→WASM retry. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Drop per-worker device policy construction; preferWasm goes through the shared fallbackDevicePolicy export. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Resolve the lockfile against the registry now that the registry-first API and transformersModel helpers are published. Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
wassgha
marked this pull request as ready for review
August 1, 2026 03:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires Rescript to published
weightlift@^0.2.1with a registry-first API and optional Transformers.js load plumbing.Rescript
No per-app device policy setup —
transformersModeluses sharedfallbackDevicePolicyby default. UI status strings stay local in the worker. No monorepo / workspaces.