Practical overview
When it fits
Use it when an application needs supported pretrained-model inference in the browser rather than through a server-side inference call.
Who it is for
- JavaScript developers adding machine-learning inference to browser-based applications.
- Teams adapting Hugging Face Transformers workflows for client-side use.
Documented uses
- Add browser-side text classification, question answering, summarization, translation or text generation.
- Build browser features for image classification, object detection, speech recognition or text-to-speech.
- Use supported pretrained models through a JavaScript pipeline API.
Requirements & limits
The public GitHub repository identifies the project as open source under the Apache-2.0 license. The README documents npm installation and browser ES-module imports.
- Check the supported task and model lists before selecting a model; not every task or architecture is necessarily supported.
- Browser inference defaults to CPU through WASM; WebGPU can be selected but is experimental in many browsers.
- The default setup uses hosted pretrained models and precompiled WASM binaries; environment settings can instead specify local paths and disable remote model loading.
- PyTorch, TensorFlow and JAX models can be converted to ONNX, with Optimum recommended for conversion.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Transformers.js and create a text-classification pipeline
Add the library to a JavaScript project and use its documented pipeline API for sentiment analysis.
Before you start
- A JavaScript project using npm, or a browser page that can import an ES module.
- A pretrained model supported by Transformers.js.
Steps
Install the package with the command below, or import it as an ES module from the documented CDN example.
npm i @huggingface/transformersImport
pipelinefrom@huggingface/transformers.Create a pipeline with the
sentiment-analysistask and pass text to the pipeline.
Expected outcome
The pipeline returns a sentiment label and score for the supplied text.
Guide limitations
- The README’s example uses the default model; a different model can be selected by supplying its model ID or path.
- Browser inference defaults to CPU via WASM. WebGPU is an available option, but is experimental in many browsers.
Configure local model and WASM file paths
Set the documented library options for local models and locally hosted WASM files.
Before you start
- The Transformers.js package installed in a JavaScript project.
- Local model files and WASM files available at paths the application can use.
Steps
Import
envfrom@huggingface/transformers.Set
env.localModelPathto the model directory.Set
env.allowRemoteModelstofalseto disable loading remote models from the Hugging Face Hub.Set
env.backends.onnx.wasm.wasmPathsto the location of the WASM files.
Expected outcome
The library is configured with the specified local model and WASM locations and remote model loading disabled.
Guide limitations
- The README gives configuration settings, not a complete model-download or application-execution procedure.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 13 October 2026
- Original website title
- huggingface/transformers.js · Official homepage title · retained in its source language

