Run Hugging Face Transformers models in the browser
open sourceApache-2.0free
Transformers.js is Hugging Face's JavaScript library for running pretrained machine learning models directly in the browser, with no server, designed to be functionally equivalent to the Python Transformers library with a very similar pipeline API. It covers natural language processing (classification, question answering, summarization, translation, text generation), computer vision (classification, object detection, segmentation, depth estimation), audio (speech recognition, text-to-speech) and multimodal tasks such as embeddings and zero-shot classification. Models run with ONNX Runtime, on the CPU through WebAssembly by default or on the GPU through WebGPU, and PyTorch, TensorFlow or JAX models can be converted to ONNX with Optimum. It installs from npm or loads from a CDN without a bundler.
Problems it solves
- run a sentiment or embedding model in the browser without a server
- transcribe speech client-side in a web app
- use Hugging Face models from JavaScript
Features
- pipeline API like the Python Transformers library
- NLP, vision, audio and multimodal tasks
- runs in the browser on CPU (WebAssembly) or GPU (WebGPU)
- loads from npm or a CDN without a bundler
- convert PyTorch, TensorFlow or JAX models to ONNX with Optimum
Alternatives
The same job
These do what Transformers.js does.
- TensorFlow.js Models Pretrained models for TensorFlow.js as npm packages: image, pose, face, hand, speech and text
