Add in-browser sentiment analysis or text classification to a web app without sending user data to a server.
Build a privacy-friendly browser extension that does speech recognition or translation entirely on the user's device.
Run image object detection in a Node.js script without a GPU or cloud API.
Create an offline-capable web app that generates text embeddings for semantic search without a backend.
Models must be in ONNX format, most popular models are pre-converted on the Hugging Face Hub, but custom models need an Optimum conversion step.
Transformers.js is a JavaScript library that lets web pages and Node.js apps run pretrained machine-learning models directly on the user's device, with no server doing the work. The README pitches it as state-of-the-art machine learning for the web and describes it as functionally equivalent to Hugging Face's Python transformers library, so similar code works in both places. The library covers a broad mix of tasks. For text it can do sentiment classification, named-entity recognition, question answering, summarization, translation, and text generation. For images it handles classification, object detection, segmentation, and depth estimation. For sound there is automatic speech recognition, audio classification, and text-to-speech. Multimodal tasks like embeddings and zero-shot classification across text, images, and audio are also supported. The main entry point is a pipeline function that bundles a model with input preprocessing and output postprocessing, so a sentiment-analysis call is a one-liner returning labels and scores. Under the hood it uses ONNX Runtime to execute models, which is why you convert PyTorch, TensorFlow, or JAX models to the ONNX format (typically via Optimum) before using them. By default it runs on the CPU through WebAssembly, setting a device option to webgpu uses the GPU through the experimental WebGPU API, and a dtype option picks a quantized variant such as fp16, q8, or q4 to shrink downloads. Someone would reach for Transformers.js to build privacy-friendly browser demos, offline-capable extensions, or embedded AI features that avoid the cost and latency of a server. It is JavaScript, installed via npm or loaded directly from a CDN.
← huggingface on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.