Experimenting with the proposed Cross-Origin Storage API in Transformers.js
Browser cache partitioning (in Chrome, keying by Network Isolation Key plus URL) forces every origin running Transformers.js to re-download identical model weights and the ONNX Runtime Wasm file. In the toy example that duplication costs 177 MB for Whisper alone. The proposed Cross-Origin Storage API (navigator.crossOriginStorage) fixes this by addressing files by SHA-256 hash instead of URL, with an OPFS-like getFileHandle interface. It also verifies hashes on write and lets developers scope visibility via an origins list that can be widened but never narrowed. Privacy is handled through availability gating for rarely seen resources, so apps must treat any error as a cache miss. Transformers.js already ships an experimental opt-in COS backend via env.experimental_useCrossOriginStorage, testable today with a polyfill extension.
Related posts
- How to build scalable web apps with OpenAI's Privacy Filter
Hugging Face mediumAdeptOpenAI's open-source Privacy Filter (1.5B params, 50M active, Apache 2.0) detects PII across eight categories in a single forward pass over 128k tokens. Three demo apps built with gradio.Server show how to use it: a document reader that highlights PII spans, an image anonymizer that maps OCR char offsets to pixel redaction boxes on a client-side canvas, and a redacting pastebin with public and token-gated URLs. All three follow one pattern: model calls go through queued @server.api endpoints, which handle ZeroGPU and are callable from both the JS and Python clients, while static pages and cheap lookups stay on plain FastAPI routes.
- Transformers.js v3: WebGPU Support, New Models & Tasks, and More…
Hugging Face mediumAdeptTransformers.js v3 adds WebGPU acceleration via ONNX Runtime Web, claimed up to 100x faster than WASM and enabled by passing `device: 'webgpu'` when loading a pipeline. A new `dtype` option replaces the old boolean `quantized` flag and supports fp32, fp16, 8-bit and 4-bit variants, including per-module dtypes for quantization-sensitive encoder-decoder models like Whisper and Florence-2. The release also expands support to 120 architectures and over 1200 pre-converted Hub models, and adds Node.js, Deno and Bun compatibility under the new @huggingface/transformers npm package. WebGPU reaches only about 70% of browsers, so some users need feature flags.
- How to Use Transformers.js in a Chrome Extension
Hugging Face mediumAdeptRunning local AI in a Chrome Manifest V3 extension works best when the background service worker hosts all Transformers.js models and agent state, while the side panel UI and content scripts act as thin clients over a typed messaging contract. The reference build (a Gemma 4 E2B browser assistant) uses Gemma 4 E2B (q4f16, WebGPU) for tool-calling reasoning and MiniLM embeddings for semantic search over pages and history. Inference in the background gives one model instance, one cache under the extension origin, and a responsive UI. The guide also covers parsing Gemma tool-call tokens into deterministic tool executions, splitting the internal model transcript from the UI transcript, and placing state by lifecycle across memory, chrome.storage and IndexedDB. Service workers can be suspended, so model runtime state should be recoverable, and Vite should produce one artifact per manifest entry point.
- Experimenting with local alt text generation in Firefox Nightly
Mozilla Hacks mediumAdeptFirefox 130 adds experimental on-device alt text generation for images in the built-in PDF editor, using a 182M-parameter ViT image encoder paired with DistilGPT-2, fine-tuned on COCO, quantized to under 200MB and running in a few seconds on a laptop CPU. The inference stack reuses the Firefox Translations architecture: the ONNX runtime compiled to WASM runs in a separate process, Transformers.js is vendored with Node pieces and eval() calls removed, and a custom cache serves models from Mozilla's servers into IndexedDB instead of Hugging Face. Small local models trade some accuracy against GPT-4o for privacy, lower resource use and quick retraining. The longer-term goal is to offer generated alt text during general browsing for screen reader users.
- Transformers.js v4: Now Available on NPM!
Hugging Face mediumAdeptTransformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno. Models are re-exported operation by operation using ONNX Runtime contrib operators such as GroupQueryAttention, MatMulNBits and MultiHeadAttention, giving about a 4x speedup for BERT embedding models. The release also adds Mamba, MLA and MoE architectures such as GPT-OSS 20B, which runs at about 60 tokens/s on an M4 Pro Max. Other changes include a move from Webpack to esbuild (10x faster builds, 53% smaller default bundle), a pnpm monorepo, a ModelRegistry API for inspecting and caching pipeline assets, and a standalone 8.8kB tokenizers library.