← all repositories
huggingface/transformers.js

Python ML models, now running in your browser tab

Transformers.js ports Hugging Face's Python library to JavaScript so you can run NLP, vision, and audio models client-side without a server roundtrip.

transformers.js
Velocity · 7d
+13
★ / day
Trend
steady
star history

What it does Transformers.js runs Hugging Face transformer models directly in the browser using ONNX Runtime. It covers the same tasks as the Python library—sentiment analysis, text generation, image classification, speech recognition, and more—through a nearly identical pipeline API. You npm install it, import pipeline, and point it at a model ID from the Hub.

The interesting bit The library doesn’t just wrap a remote API; it actually executes models locally via WASM (CPU) or WebGPU, with quantization down to 4-bit to keep downloads reasonable. That’s a lot of matrix multiplication happening inside a browser sandbox.

Key highlights

  • API mirrors the Python transformers library almost line-for-line
  • Supports NLP, computer vision, audio, and multimodal tasks
  • CPU inference via WASM by default; WebGPU available with device: 'webgpu'
  • Quantization options: fp32, fp16, q8, q4 to trade accuracy for bandwidth
  • Models auto-download from Hugging Face Hub; can be pinned to local paths or fully offline
  • PyTorch/TensorFlow/JAX models convert to ONNX via Hugging Face Optimum

Caveats

  • WebGPU is explicitly flagged as experimental and browser support is spotty
  • Not every task is supported (e.g., table question answering is marked ❌)
  • Default WASM path means you’re running on CPU unless you opt into WebGPU

Verdict Worth a look if you’re building client-side features that need ML without server costs or latency—think in-browser transcription, image tagging, or text analysis. Skip it if you need guaranteed GPU performance or tasks outside the supported list; a traditional server deployment is still the safer bet for heavy or exotic workloads.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.