huggingface/transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!

What it solves

Transformers.js allows developers to run state-of-the-art machine learning models directly in the web browser without needing a backend server. This eliminates the need for server-side infrastructure for AI tasks, enabling private, offline-capable, and low-latency AI experiences.

How it works

It is designed to be functionally equivalent to the Hugging Face transformers Python library, using a similar API. It utilizes ONNX Runtime to execute models in the browser. Users can convert existing PyTorch, TensorFlow, or JAX models to the ONNX format using the 🤗 Optimum library. Models can be run on the CPU via WASM or on the GPU via WebGPU for better performance.

Who it’s for

Web developers who want to integrate AI capabilities—such as text generation, image classification, and speech recognition—directly into their frontend applications.

Highlights

  • Multi-modal support: Handles NLP (summarization, translation, text generation), Computer Vision (object detection, segmentation), and Audio (ASR, text-to-speech).
  • WebGPU Acceleration: Supports GPU execution for faster inference in compatible browsers.
  • Quantization: Supports 4-bit and 8-bit quantization to reduce model size and bandwidth for resource-constrained environments.
  • Pipeline API: Provides a simple pipeline function that groups preprocessing, model execution, and postprocessing into a single call.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project