How to Use Transformers.js in a Chrome Extension

AI-generated summary of reporting by Huggingface Blog. Read the original for the full story.

Why it matters

Developers can now build Chrome extensions that run LLM inference fully locally using Transformers.js, avoiding server costs and keeping user data on-device under Manifest V3 constraints.

Read this as

Hugging Face published a guide and open-source example showing how to run its Transformers.js tool, software that runs AI models directly in a web browser, inside a Chrome browser extension. The example extension uses the Gemma 4 E2B model as a local chat assistant that can read web pages, manage tabs, and search browsing history without sending data to any server. It matters for developers building browser-based AI helpers and for users who want AI features that process data entirely on their own computer.

Hugging Face released a working reference architecture and open-source code for shipping local AI in Chrome extensions under Manifest V3, using Gemma 4 E2B plus a MiniLM embedding model. The pattern, background service worker hosting models, side panel chat UI, content script for page access, lets teams offer privacy-friendly AI features without inference servers or per-token API spend. The trade-off is managing model downloads, MV3 service-worker restarts, and broad host permissions that raise store-review risk.

The guide recreates Hugging Face's Gemma 4 Browser Assistant: a background service worker hosts Transformers.js pipelines, text-generation with onnx-community/gemma-4-E2B-it-ONNX (q4f16) using DynamicCache KV caching, and feature-extraction with all-MiniLM-L6-v2 (fp32) for semantic search over history and page content. Typed message contracts link side panel and content script; tool calls are parsed from Gemma-4 chat-template tokens via extractToolCalls. State is split across background memory, chrome.storage.local, and IndexedDB; artifacts cache under the extension origin. MV3 service-worker suspension requires re-initializable model state.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Transformers.js Gemma 4 E2B Manifest V3 Chrome DynamicCache IndexedDB chrome.storage.local

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading

datasette-charts 0.5a0

Datasette Charts 0.5a0 adds calendar heatmaps, box plots and active-over-time charts, enabling richer data visualisation directly in the browser without extra libraries.