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.
On-Device AI With Transformers.js, WebGPU, and Hugging Face
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.
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.
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.
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.
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
- role at
“I'm CEO and founder at Callstack.”
YouTube Unverified1 source· Talk
- role atNiko Martin is open-source ML engineer at
Hugging Face
“Your job title is actually ... open-source ML engineer.”
YouTube Unverified1 source· Talk
- builtNiko Martin built Tokenizers.js
“We also have Tokenizers.js, a tokenizers library for JavaScript.”
YouTube Unverified1 source· Talk
- builtNiko Martin built Transformers.js
“The main project I'm working on at Hugging Face is, of course, Transformers.js.”
YouTube Unverified1 source· Talk
- featureTransformers.js: Runs machine learning models in the browser through a pipeline API
“With the pipeline API, you define the task and the model you want to use.”
YouTube Unverified1 source· Talk
- uses
“ONNX is the model format we use under the hood.”
YouTube Unverified1 source· Talk
- uses
“Inference isn't done by Transformers.js, but by the ONNX Runtime—in our case, ONNX Runtime Web.”
YouTube Unverified1 source· Talk
- featureTransformers.js: Can select CPU or WebGPU as the device
“One of the options you can pass is device. It can be CPU, WebGPU, or whatever device you want to choose.”
YouTube Unverified1 source· Talk













