llm-inference / library
Transformers.js
Capability: Transformers.js
Use it when
- You want text classification, embeddings, translation, object detection, or speech recognition inside a web app without standing up any inference backend
- User audio, images, or documents must stay on-device, so inference has to run client-side in the browser via WASM or WebGPU
What it solves
Not the fit when
- Unsupported tasks in the README matrix, including text-to-image, visual question answering, mask generation, video classification, and tabular tasks
- High-throughput backend serving; the primary surface is JavaScript inference in browsers and compatible JavaScript runtimes
- Models must have compatible ONNX artifacts, or be converted with Optimum
- The default configuration downloads models from Hugging Face and WASM binaries from a CDN; set localModelPath, allowRemoteModels=false, and a local wasmPaths value when offline asset loading is required
- The Apache-2.0 library license does not replace the separate license and usage terms of each downloaded model
- training or fine-tuning models
- high-throughput backend model serving
- text-to-image generation
Install
npm i @huggingface/transformers (or import from the jsDelivr CDN as an ES module)
Invoke
import { pipeline } from '@huggingface/transformers'; const pipe = await pipeline('sentiment-analysis'); await pipe('I love transformers!') - pass { device: 'webgpu' } or { dtype: 'q4' } for GPU or quantized runsAlternatives
No reviewed alternatives recorded yet.