OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Transformers.js

Transformers.js is a JavaScript library for running pretrained Transformer models in web browsers through an API similar to Hugging Face’s Python Transformers library. It uses ONNX Runtime and supports language, computer-vision, audio and multimodal tasks.

Independent OpenViST project profile, based on linked sources.

Transformers.js — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

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.
Before you choose

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.

Source-based practical guide

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

  1. Install the package with the command below, or import it as an ES module from the documented CDN example.

    Documented command
    npm i @huggingface/transformers
  2. Import pipeline from @huggingface/transformers.

  3. Create a pipeline with the sentiment-analysis task 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.
Source-based practical guide

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

  1. Import env from @huggingface/transformers.

  2. Set env.localModelPath to the model directory.

  3. Set env.allowRemoteModels to false to disable loading remote models from the Hugging Face Hub.

  4. Set env.backends.onnx.wasm.wasmPaths to 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.
Evidence and transparency

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