---
title: "Transformers.js v4: Now Available on NPM!"
description: "Transformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno."
url: "https://swe.quest/articles/transformers-js-v4-now-available-on-npm-60e5d316d3e108bd"
canonical: "https://huggingface.co/blog/transformersjs-v4"
source: "Hugging Face"
published: "2026-02-09"
difficulty: "medium"
kind: "Release"
reading_minutes: 7
tags: ["inference","javascript","llms","browsers","build-systems"]
---

# Transformers.js v4: Now Available on NPM!

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-02-09, 7 min read, Release. Original: [https://huggingface.co/blog/transformersjs-v4](https://huggingface.co/blog/transformersjs-v4)

## Summary

Transformers.js v4 ships on NPM with a new C++ WebGPU runtime built with the ONNX Runtime team, enabling WebGPU-accelerated models in browsers as well as Node, Bun and Deno. Models are re-exported operation by operation using ONNX Runtime contrib operators such as GroupQueryAttention, MatMulNBits and MultiHeadAttention, giving about a 4x speedup for BERT embedding models. The release also adds Mamba, MLA and MoE architectures such as GPT-OSS 20B, which runs at about 60 tokens/s on an M4 Pro Max. Other changes include a move from Webpack to esbuild (10x faster builds, 53% smaller default bundle), a pnpm monorepo, a ModelRegistry API for inspecting and caching pipeline assets, and a standalone 8.8kB tokenizers library.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)

## Prerequisites

- JavaScript/npm ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- ONNX models
- WebGPU basics

## Keywords

Transformers.js, WebGPU, ONNX Runtime, esbuild, pnpm, GPT-OSS, Tokenizers.js

## Related posts

- [Transformers.js v3: WebGPU Support, New Models & Tasks, and More…](https://swe.quest/articles/transformers-js-v3-webgpu-support-new-models-tasks-and-more-3627acdd60e7ffe6.md): Hugging Face · 2024-10-22 · Medium · 11 min read · Inference & serving, JavaScript, Browsers, Machine learning
  Transformers.js v3 adds WebGPU acceleration via ONNX Runtime Web, claimed up to 100x faster than WASM and enabled by passing \`device: 'webgpu'\` when loading a pipeline.
- [Introducing @huggingface/kernels: 200+ WebGPU Kernels for Local AI](https://swe.quest/articles/introducing-huggingface-kernels-200-webgpu-kernels-for-local-ai-9e38d7de6105d26d.md): Hugging Face · 2026-09-01 · Medium · 9 min read · Inference & serving, Browsers, Performance engineering, JavaScript, Open source
  Hugging Face released @huggingface/kernels, a JavaScript loader for 207 Apache-2.0 WebGPU kernels published as versioned Hub repositories.
- [Tricks from OpenAI gpt-oss YOU 🫵 can use with transformers](https://swe.quest/articles/tricks-from-openai-gpt-oss-you-can-use-with-transformers-aad70bf42c0bd3ff.md): Hugging Face · 2025-09-11 · Hard · 15 min read · Inference & serving, LLMs, Python, Performance engineering
  Hugging Face upgraded transformers to support OpenAI's gpt-oss models, and most of the new features carry over to other models.
- [Convert Transformers to ONNX with Hugging Face Optimum](https://swe.quest/articles/convert-transformers-to-onnx-with-hugging-face-optimum-86f6804aa2e19f43.md): Hugging Face · 2022-06-22 · Medium · 5 min read · Inference & serving, Machine learning, Python
  Hugging Face Transformers models can be exported to ONNX in three ways, shown here on a DistilBERT text-classification checkpoint.
- [Accelerating Hugging Face Transformers with AWS Inferentia2](https://swe.quest/articles/accelerating-hugging-face-transformers-with-aws-inferentia2-732d2daf15bc9874.md): Hugging Face · 2023-04-17 · Easy · 5 min read · Inference & serving, Hardware, Performance engineering, Cloud platforms
  Hugging Face benchmarked popular Transformer models on AWS Inferentia2 (inf2.xlarge) against Inferentia1 (inf1.2xlarge) and an NVIDIA A10G GPU (g5.2xlarge), running 144 p95-latency experiments at batch size 1 across six architectures and sequence lengths from 8 to 512.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
