---
title: "Transformers.js v4: Now Available on NPM!"
description: "Transformers.js v4 is now available on NPM, marking a major release after a year of development. It introduces a C++-rewritten WebGPU runtime tested across about 200 supported model architectures, enabling the same JavaScript code to run WebGPU-accelerated models in browsers, Node, Bun, Deno, and desktop applications. Specialized ONNX Runtime Contrib Operators support new export strategies for large language models, and the post reports a roughly fourfold speedup for BERT-based embedding models using MultiHeadAttention. The release also restructures the repository as a pnpm-workspaces monorepo, modularizes model definitions, moves examples to a separate repository, and switches from Webpack to esbuild, reducing build times from two seconds to 200 milliseconds and shrinking transformers.web.js by 53%. New APIs cover model asset inspection, caching, environment fetch controls, logging, and standalone tokenization, while added architectures include Mamba, MLA, and MoE models compatible with WebGPU."
---

# Transformers.js v4: Now Available on NPM!

[Hugging Face](https://yomu.fyi/company/hugging-face) · Joshua, Nico Martin · Feb 9, 2026

**Type:** Announcement

## Summary

Transformers.js v4 is now available on NPM, marking a major release after a year of development. It introduces a C++-rewritten WebGPU runtime tested across about 200 supported model architectures, enabling the same JavaScript code to run WebGPU-accelerated models in browsers, Node, Bun, Deno, and desktop applications. Specialized ONNX Runtime Contrib Operators support new export strategies for large language models, and the post reports a roughly fourfold speedup for BERT-based embedding models using MultiHeadAttention. The release also restructures the repository as a pnpm-workspaces monorepo, modularizes model definitions, moves examples to a separate repository, and switches from Webpack to esbuild, reducing build times from two seconds to 200 milliseconds and shrinking transformers.web.js by 53%. New APIs cover model asset inspection, caching, environment fetch controls, logging, and standalone tokenization, while added architectures include Mamba, MLA, and MoE models compatible with WebGPU.

## Context

The release addresses performance, runtime coverage, maintainability, package structure, model-loading visibility, and production-use needs. The previous repository exposed a single library, models.js had grown beyond 8,000 lines, examples were stored in the main repository, and the project needed better support for large language models and additional architectures.

## Approach / What changed

The release adopts a C++-rewritten WebGPU runtime and specialized ONNX Runtime Contrib Operators, reworks model export strategies, converts the repository to pnpm workspaces, splits model definitions into focused modules, moves examples to a dedicated repository, and migrates the build system from Webpack to esbuild. It also adds ModelRegistry, environment and logging controls, a standalone tokenizers package, dynamic pipeline types, and support for larger models.

## Takeaways

- The new WebGPU runtime allows Transformers.js code to run hardware-accelerated models across browsers, Node, Bun, Deno, and desktop applications.
- Using the com.microsoft.MultiHeadAttention operator produced a reported roughly 4x speedup for BERT-based embedding models.
- The esbuild migration reduced build times from 2 seconds to 200 milliseconds, while transformers.web.js became 53% smaller.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Open Source](https://yomu.fyi/topic/open-source), [Performance](https://yomu.fyi/topic/performance)

- Source: [Hugging Face](https://huggingface.co/blog/transformersjs-v4)
- Source URL: https://huggingface.co/blog/transformersjs-v4
- Ingested by Yomu: 2026-08-28T12:00:56.014Z

[Read original post](https://huggingface.co/blog/transformersjs-v4)
