WhoBuilt

On-Device AI With Transformers.js, WebGPU, and Hugging Face

Sep 7, 2026· 56 min· 1.2K views·Watch on YouTube

Speakers

Niko Martin, an open-source ML engineer at Hugging Face, joins Callstack CEO Mike on React Universe On Air to discuss running machine learning models in the browser with Transformers.js.

What Transformers.js supports

Martin works on Transformers.js and Tokenizers.js to bring machine learning to JavaScript. Transformers.js supports tasks including text embeddings, audio transcription, image processing, and vision-language work. Its pipeline API accepts task-appropriate inputs and handles preprocessing, inference, and postprocessing.

Models, pipelines, and runtimes

Models take tensors as input, while pipelines let developers provide text, images, or audio and receive task-specific results. Transformers.js uses ONNX models with ONNX Runtime Web in browsers, and can also use other runtimes across JavaScript environments. Martin recommends WebGPU in general, while noting developers can check for support and select CPU as a fallback.

Model downloads and device limits

Transformers.js downloads the files a pipeline needs from the Hugging Face Hub and stores them in the browser cache. Large language models can take several gigabytes, while some task-specific models are around 100 to 200 MB and speech detection models can be only a few megabytes. Download size and inference speed vary by model and device, so Martin recommends considering the user experience before loading a model.

Browser AI and agent workflows

Martin says browser-based AI can handle tasks such as background removal and speech recognition, sometimes avoiding the time needed to upload data and receive a result from a server. He has built offline browser agent demos where a language model selects JavaScript tools to run. He describes these agents as demos for now, while suggesting that individual tasks such as transcription and tool execution can already run in the browser alongside a cloud model.

What the team is exploring

Martin identifies cross-origin storage as a potential way to avoid downloading the same model separately for each site, though the API is still early. Transformers.js is also exploring structured output for text generation and an in-house WebGPU inference engine with custom kernels. He says the early project aims to optimize operations for specific devices, with potential speedups of 5x or 10x.

Takeaways

  • Choose a model based on the task and its supported architecture, not just its ONNX format.
  • Make model downloads explicit when files are large, and account for repeat downloads across website origins.
  • Benchmark inference on the devices your users have; performance can differ substantially.
  • Consider moving latency-sensitive steps such as speech detection or image processing into the browser.
  • Use browser agents experimentally today, or run selected local tasks alongside a cloud-based agent.

Mentioned in this talk

Search inside this talk

What was claimed 15

Show all 15 facts

Related talks