Transformers.js: State-of-the-Art Machine Learning for the Web

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2025
November 18 - 21, 2025
New York, US & Online
The biggest React conference in the US
Learn More
In partnership with Focus Reactive
Upcoming event
React Summit US 2025
React Summit US 2025
November 18 - 21, 2025. New York, US & Online
Learn more
Bookmark
Rate this content

Learn about Transformers.js, an innovative JavaScript library for running state-of-the-art machine learning models 100% locally in your browser. With support for nearly 2 000 pretrained models, spanning a wide range of modalities and tasks, Transformers.js empowers developers to seamlessly integrate advanced ML capabilities into their web applications. We'll also explore how we leverage emerging web technologies like WebGPU and WebNN to create interactive, privacy-preserving, and scalable web experiences.

This talk has been presented at JSNation 2025, check out the latest edition of this JavaScript Conference.

FAQ

Joshua, a 25-year-old machine learning engineer from South Africa, is the creator of Transformers JS.

Hugging Face is a platform where the machine learning community collaborates on models, datasets, and applications, aiming to democratize machine learning.

There are around 1.7 million pre-trained models available on the Hugging Face Hub.

Running models in the browser with Transformers JS offers benefits such as improved security and privacy, real-time applications without network latency, lower costs, and high scalability.

Transformers JS supports a variety of tasks including text, vision, audio, and multimodal tasks, with around 155 different architectures across 27 tasks.

Transformers JS leverages web technologies like WebGPU and WebNN to run models in modern browsers, and it is compatible with multiple environments including Node.js and Electron.

Recent developments include support for 155 architectures, integration with WebGPU and WebNN, and a growing community with 1.4 million unique monthly users.

The licensing status of models varies. Some models are commercially usable under licenses like Apache 2, but it is essential to check the specific license on the model's card on the Hugging Face Hub.

Yes, models can be pre-cached in applications, allowing them to run without fetching from a server.

The main goal of Transformers JS is to bring state-of-the-art pre-trained models directly to the web and browsers, allowing easy integration of machine learning functionality into web applications.

 Joshua Lochner
Joshua Lochner
27 min
12 Jun, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Joshua introduces Transformers JS and Hugging Face, emphasizing community collaboration and pre-trained models. Transformers JS evolution led to 1.4 million monthly users, supporting 155 architectures. The library's browser-based capabilities offer real-time processing, cost-efficiency, and scalability. Integration enhancements include native web GPU execution and React Native implementation. Web ML implementation focuses on Onyx Runtime for device execution and web GPU for resource optimization. Browser-based ML applications cover vision, speech recognition, and text-to-speech. Advanced implementations include multimodal applications and educational tools. Interactive AI demonstrations showcase semantic search and conversational AI scenarios. Model licensing transitions to ECMAScript for efficiency and model redownloading factors are discussed.

1. Introduction to Transformers JS and Hugging Face

Short description:

Joshua introduces Transformers JS and his background as a machine learning engineer. Hugging Face is a platform for collaboration on models, data sets, and applications with a vast community. The platform offers a large number of pre-trained models, data sets, and applications for interaction and exploration.

Hi there, everyone. My name is Joshua and I'm really excited to talk to you today about Transformers JS. So, first up, a little introduction. Starting with who am I? Well, I'm a 25-year-old machine learning engineer from South Africa and one of my main goals when I joined Hugging Face in 2023 was to bring the power of machine learning directly to the web and to your browser. One of the missions at Hugging Face is to democratize good machine learning and incorporating and expanding our Python libraries and our set of our ecosystem on that front to the JavaScript developer community was really important and that is where this project came from. So, and lastly, I'm very passionate about open source, creator of, I guess, Transformers JS, GingerJS, I think you see a pattern there and a few more.

So maybe a quick step back, what is Hugging Face? Well, Hugging Face is a platform where the machine learning community is able to collaborate on models, data sets and applications. We're a very large community, a very large and growing community and if you have any models, data sets or spaces or applications as we like to call them, we'd love you to join and share those demos on our platform. So, yeah, if you want to search for models on the Hugging Face Hub, we have around 1.7 million pre-trained models that you can search for with a bunch of filters and tags that you can select to basically filter down your search from the 1.7 million to something you're really looking for.

It stays up to date and of course you can select the Transformers JS library tag as well to ensure that you can see which models are compatible with the Transformers JS library. We also have a large selection of data sets. So in this demo, you can see that if you have a data set you'd like to view, you can go to the data set viewer and then even interact with it with natural language and then that will be converted into a query where you can basically select the data in an interactive way from the data set. And lastly, spaces which is what we call our application directory. You can also search for if you want to, let's say, generate a 3D model from the image then you search that in the interface and it'll pop up with something that you can use. And this is where our community really shines. We have a very large community of people who really want to showcase their applications, the models that they've created and this is the best way that people have been able to showcase their models directly from the browser. We also maintain a large collection of open source libraries. You may be familiar with the Transformers library, diffusers, tokenizers, just to name a few. But today we'll be focusing on one in particular, Transformers JS.

2. Evolution and Growth of Transformers JS

Short description:

Transformers JS is a JavaScript library enabling browser-based use of pre-trained models with ease. The project, fully open source and community-driven, experienced rapid growth to 1.4 million monthly users. Starting from a spam classifier, the library evolved through various versions, now supporting 155 architectures. The community's contributions and engagement are highly appreciated.

So what is Transformers JS? Well, Transformers JS is a JavaScript library that allows you to run state of the art pre-trained models directly in the browser. The goal is to make it extremely easy to use, allowing you to create and add machine learning functionality directly into your web applications with as few as three lines of code. Of course, I mentioned before, we're fully open source, publishing everything on GitHub and it's very community driven development. So people would like a feature request, they make a, you know, open up an issue on GitHub. We love the community when we're able to collaborate in that way.

And just another indication of the growth over time. So this is our unique monthly users of the Transformers JS set of models. We're at around 1.4 million unique monthly users currently. And this is basically up double from what we saw around six months ago. And the trend is continuing upwards. We're really, really grateful for the support and the people who have been able to create really cool applications with the library. And also just a little bit of development timeline for those interested. It's a relatively new project. So the idea was basically to, well, the origin of the library was to basically take a pre-trained like spam classifier that I had created in my spare time and I wanted to run it as a browser extension. Unfortunately nothing really existed at the time to allow me to do so. So the next logical step was to do it myself. To basically try to get my pre-trained model in the browser.

The V1 release of Transformers JS happened in March of 2023. And at that point we only supported around five different architectures, but as you'll soon see the number slowly and then quickly started to grow. So next V2, the next logical step was to do a complete rewrite from CommonJS to ECMAScript. And at that point maybe like two months later we were at 19 supported architectures. And then V3, which is our largest release yet, was basically introducing WebGPU and WebNN support. And then we were able to support 119 different architectures. And then where we are currently we're at around 155 different architectures and there's a lot of things planned for the library which I guess I'll cover shortly. And once again just a huge shout out to our community all over the world. Creating demos, contributing to the library, and posting to social media about what they've created, it's really, really great to see from our side as well. So thank you. And one more set of slides on statistics. We're at around a million NPM downloads in the last 30 days.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Embracing WebGPU and WebXR With Three.js
JSNation 2024JSNation 2024
27 min
Embracing WebGPU and WebXR With Three.js
Top Content
The 3JS project has evolved into a community-driven effort with numerous contributors over the past 14 years. It started with 3D engine work in Flash and transitioned to using SVGs for rendering in HTML5 before adopting WebGL. The project showcases various projects and frameworks, including a no-code tool powered by 3.js. The team is working on a new render using WebGPU and developing a new shader language called TSL. The hope is that WebGPU will eventually replace WebGL, offering better control and performance.
TensorFlow.js 101: ML in the Browser and Beyond
ML conf EU 2020ML conf EU 2020
41 min
TensorFlow.js 101: ML in the Browser and Beyond
TensorFlow.js enables machine learning in the browser and beyond, with features like face mesh, body segmentation, and pose estimation. It offers JavaScript prototyping and transfer learning capabilities, as well as the ability to recognize custom objects using the Image Project feature. TensorFlow.js can be used with Cloud AutoML for training custom vision models and provides performance benefits in both JavaScript and Python development. It offers interactivity, reach, scale, and performance, and encourages community engagement and collaboration between the JavaScript and machine learning communities.
Unreal Engine in WebAssembly/WebGPU
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Unreal Engine in WebAssembly/WebGPU
Top Content
Alex Saint-Louis, co-founder of Wunder Interactive, shares the mission of bringing Unreal Engine to the browser, enabling cross-platform 3D applications and games. They are working on a WebGPU back end for Unreal Engine to push the limits of 3D on the web. Wunder Interactive has improved compression, built their own asset file system, and offers powerful tools for game developers. They are utilizing modern web technologies like WebAssembly, WebGL, and WebGPU, and plan to support other engines like Unity and Godot. The team aims to transform the industry by bringing console-quality games to the browser and providing an alternative distribution path. They are excited to bring Unreal Engine 5 to the web with WebGPU support and are working on WebXR support for cross-platform 3D experiences, including VR.
Using MediaPipe to Create Cross Platform Machine Learning Applications with React
React Advanced 2021React Advanced 2021
21 min
Using MediaPipe to Create Cross Platform Machine Learning Applications with React
Top Content
MediaPipe is a cross-platform framework that helps build perception pipelines using machine learning models. It offers ready-to-use solutions for various applications, such as selfie segmentation, face mesh, object detection, hand tracking, and more. MediaPipe can be integrated with React using NPM modules provided by the MediaPipe team. The demonstration showcases the implementation of face mesh and selfie segmentation solutions. MediaPipe enables the creation of amazing applications without needing to understand the underlying computer vision or machine learning processes.
Makepad - Leveraging Rust + Wasm + WebGL to Build Amazing Cross-platform Applications
JSNation 2022JSNation 2022
22 min
Makepad - Leveraging Rust + Wasm + WebGL to Build Amazing Cross-platform Applications
Top Content
Welcome to MakePad, a new way to build UI for web and native using WebAssembly and Rust. JavaScript is not suitable for complex applications like IDEs and design tools. Rust, a new programming language, was used to reimagine MakePad, resulting in a fast and efficient platform. MakePad offers live editing, high CPU performance, and the ability to load native instrument components. The future of MakePad includes an open-source release, a design tool, and support for importing 3D models.
Extending Unity WebGL With Javascript
JS GameDev Summit 2022JS GameDev Summit 2022
32 min
Extending Unity WebGL With Javascript
Top Content
Unity targets over 25 platforms and technologies, including desktop, mobile, and virtual reality. They use Emscripten to compile the engine and game logic into WebAssembly for web development. Unity can be extended with plugins to access browser features like WebXR's augmented reality mode. The speaker demonstrates intercepting Unity's calls to the browser to modify its behavior. Unity is actively working on mobile support for web export and improving documentation for extending Unity with web plugins.

Workshops on related topic

Can LLMs Learn? Let’s Customize an LLM to Chat With Your Own Data
C3 Dev Festival 2024C3 Dev Festival 2024
48 min
Can LLMs Learn? Let’s Customize an LLM to Chat With Your Own Data
WorkshopFree
Andreia Ocanoaia
Andreia Ocanoaia
Feeling the limitations of LLMs? They can be creative, but sometimes lack accuracy or rely on outdated information. In this workshop, we’ll break down the process of building and easily deploying a Retrieval-Augmented Generation system. This approach enables you to leverage the power of LLMs with the added benefit of factual accuracy and up-to-date information.
Leveraging LLMs to Build Intuitive AI Experiences With JavaScript
JSNation 2024JSNation 2024
108 min
Leveraging LLMs to Build Intuitive AI Experiences With JavaScript
Workshop
Roy Derks
Shivay Lamba
2 authors
Today every developer is using LLMs in different forms and shapes, from ChatGPT to code assistants like GitHub CoPilot. Following this, lots of products have introduced embedded AI capabilities, and in this workshop we will make LLMs understandable for web developers. And we'll get into coding your own AI-driven application. No prior experience in working with LLMs or machine learning is needed. Instead, we'll use web technologies such as JavaScript, React which you already know and love while also learning about some new libraries like OpenAI, Transformers.js
Let AI Be Your Docs
JSNation 2024JSNation 2024
69 min
Let AI Be Your Docs
Workshop
Jesse Hall
Jesse Hall
Join our dynamic workshop to craft an AI-powered documentation portal. Learn to integrate OpenAI's ChatGPT with Next.js 14, Tailwind CSS, and cutting-edge tech to deliver instant code solutions and summaries. This hands-on session will equip you with the knowledge to revolutionize how users interact with documentation, turning tedious searches into efficient, intelligent discovery.
Key Takeaways:
- Practical experience in creating an AI-driven documentation site.- Understanding the integration of AI into user experiences.- Hands-on skills with the latest web development technologies.- Strategies for deploying and maintaining intelligent documentation resources.
Table of contents:- Introduction to AI in Documentation- Setting Up the Environment- Building the Documentation Structure- Integrating ChatGPT for Interactive Docs
Hands on with TensorFlow.js
ML conf EU 2020ML conf EU 2020
160 min
Hands on with TensorFlow.js
Workshop
Jason Mayes
Jason Mayes
Come check out our workshop which will walk you through 3 common journeys when using TensorFlow.js. We will start with demonstrating how to use one of our pre-made models - super easy to use JS classes to get you working with ML fast. We will then look into how to retrain one of these models in minutes using in browser transfer learning via Teachable Machine and how that can be then used on your own custom website, and finally end with a hello world of writing your own model code from scratch to make a simple linear regression to predict fictional house prices based on their square footage.
The Hitchhiker's Guide to the Machine Learning Engineering Galaxy
ML conf EU 2020ML conf EU 2020
112 min
The Hitchhiker's Guide to the Machine Learning Engineering Galaxy
Workshop
Alyona Galyeva
Alyona Galyeva
Are you a Software Engineer who got tasked to deploy a machine learning or deep learning model for the first time in your life? Are you wondering what steps to take and how AI-powered software is different from traditional software? Then it is the right workshop to attend.
The internet offers thousands of articles and free of charge courses, showing how it is easy to train and deploy a simple AI model. At the same time in reality it is difficult to integrate a real model into the current infrastructure, debug, test, deploy, and monitor it properly. In this workshop, I will guide you through this process sharing tips, tricks, and favorite open source tools that will make your life much easier. So, at the end of the workshop, you will know where to start your deployment journey, what tools to use, and what questions to ask.
Introduction to Machine Learning on the Cloud
ML conf EU 2020ML conf EU 2020
146 min
Introduction to Machine Learning on the Cloud
Workshop
Dmitry Soshnikov
Dmitry Soshnikov
This workshop will be both a gentle introduction to Machine Learning, and a practical exercise of using the cloud to train simple and not-so-simple machine learning models. We will start with using Automatic ML to train the model to predict survival on Titanic, and then move to more complex machine learning tasks such as hyperparameter optimization and scheduling series of experiments on the compute cluster. Finally, I will show how Azure Machine Learning can be used to generate artificial paintings using Generative Adversarial Networks, and how to train language question-answering model on COVID papers to answer COVID-related questions.