huggingface/transformers.js
58.4
Adequate · 1 October 2026
37.5k
lines of production code
JavaScript
with TypeScript
2
measurements over time
What this system is
This system is Transformers.js, a JavaScript library that enables running machine learning models directly in browsers and Node.js environments. It provides a comprehensive suite of pipelines for processing audio, images, and text, supported by a flexible backend that leverages ONNX, WebGPU, and WebNN for hardware acceleration. The library includes infrastructure for text generation with constrained output, robust caching mechanisms for model assets, and utilities for managing model registries and device configurations.
Features
Expanded model support and new auto-loading utilities
This update adds support for several new model architectures including AFMoE, Apertus, Arcee, and Chatterbox, alongside existing models like Albert, BART, and Bloom. It also introduces new auto-loading classes (AutoFeatureExtractor, AutoImageProcessor, AutoProcessor) to simplify the instantiation of preprocessors and models based on configuration files, and includes a feature extractor for the Audio Spectrogram Transformer.
packages/transformers/src/models · high confidence
Introduce experimental Cross-Origin Storage cache backend
Added a new \CrossOriginStorageCache\ implementation that leverages the experimental \navigator.crossOriginStorage\ API to share cached model files across different browser origins. This backend allows resources to be stored once and accessed by any origin, improving cache efficiency in multi-origin environments. The implementation includes type definitions for the API, handles SHA-256 hash-based lookups, and ensures that \Content-Length\ headers are correctly preserved in cached responses. A corresponding \FileCache\ implementation for Node.js environments was also added to provide a consistent caching interface across browser and server-side runtimes.
packages/transformers/src/utils/cache · high confidence
New @huggingface/transformers-structured-output package for constrained generation
A new dependency-free package, @huggingface/transformers-structured-output, has been added to provide constrained generation for Transformers.js. It exports a StructuredOutputProcessor that can be passed as a logits\_processor to model.generate() to enforce output against a JSON Schema (including a practical JSON Schema 2020-12 profile), a simple JSON object, or a regular expression. The processor works by building and caching tokenizer-derived token tries and masks, applying them to logits to block invalid tokens, and supporting features like deep const/enum, numeric bounds, tuples, uniqueItems, conditionals, and local/recursive $ref. It currently supports a single generated sequence at a time (batch size 1) and requires the model generation config and tokenizer to use the same eos\_token\_id.
packages/transformers-structured-output · high confidence
New ModelRegistry API for model file and cache management
The \ModelRegistry\ utility class has been introduced in \packages/transformers/src/utils/model\_registry\ to centralize model file discovery and cache operations. This new API allows users to programmatically determine which files are required for a model or specific pipeline task (via \get\_files\, \get\_pipeline\_files\, \get\_model\_files\, \get\_tokenizer\_files\, and \get\_processor\_files\), detect available quantization levels (dtypes) using \get\_available\_dtypes\, and inspect file metadata without downloading content. It also provides fast boolean checks to see if a model is fully cached (\is\_cached\, \is\_pipeline\_cached\) along with detailed per-file cache status (\is\_cached\_files\, \is\_pipeline\_cached\_files\), and utilities to clear cached model files (\clear\_cache\, \clear\_pipeline\_cache\).
_packages/transformers/src/utils/model\registry · high confidence
New development and build utility scripts for pnpm workspaces
The repository now includes a set of new Node.js scripts in the \scripts/\ directory to support the pnpm workspace structure. These include \dev.mjs\ for starting development servers for all packages in parallel, \logger.mjs\ for standardized colored console output, \prepareOutDir.mjs\ for cleaning build directories, \rebuildPlugin.mjs\ for logging build times in watch mode, and \reportSize.mjs\ for displaying file and gzip sizes. These tools streamline the local development and build experience for the monorepo.
scripts · high confidence
New hub utility module for file handling and validation
The \packages/transformers/src/utils/hub\ directory now includes a new \FileResponse\ class that wraps local files into a standard response interface (supporting \blob\, \arrayBuffer\, \text\, and \json\ reads) with automatic MIME type detection, alongside \constants.js\ defining error mappings and validation regexes, and \utils.js\ providing helpers for path joining, URL/model ID validation, and streaming response reading with progress callbacks.
packages/transformers/src/utils/hub · high confidence
New pipeline implementations for audio, image, and text tasks
This change introduces a comprehensive set of new pipeline classes in the \packages/transformers/src/pipelines\ directory, providing ready-to-use interfaces for various machine learning tasks. The \AutomaticSpeechRecognitionPipeline\ now supports multiple model architectures including Whisper, Wav2Vec2, Moonshine, and Cohere ASR, with features like chunking and timestamping. New pipelines include \AudioClassificationPipeline\ for categorizing audio, \BackgroundRemovalPipeline\ for image processing, \DepthEstimationPipeline\ for predicting depth maps, \DocumentQuestionAnsweringPipeline\ for answering questions about document images, \FeatureExtractionPipeline\ with pooling and quantization options, \FillMaskPipeline\ for masked language modeling, \ImageClassificationPipeline\, \ImageFeatureExtractionPipeline\, \ImageSegmentationPipeline\ supporting panoptic, instance, and semantic subtasks, and \ImageToImagePipeline\. These are built upon a new \Pipeline\ base class defined in \\_base.js\ which handles common initialization and disposal logic.
packages/transformers/src/pipelines · high confidence
New text generation configuration, sampling, and streaming infrastructure
This change introduces the core JavaScript infrastructure for text generation within the \@huggingface/transformers\ library. It adds a \GenerationConfig\ class to centralize generation parameters (such as \max\_new\_tokens\, \temperature\, \top\_k\, and \repetition\_penalty\), and implements the \LogitsSampler\ hierarchy to handle greedy, multinomial, and beam-search decoding strategies. Additionally, it provides \LogitsProcessor\ and \StoppingCriteria\ classes to allow fine-grained control over token selection and generation termination, alongside a \TextStreamer\ class that enables real-time output of generated text to the console or custom callbacks.
packages/transformers/src/generation · high confidence
New utility modules for audio, image, caching, and device configuration
The \packages/transformers/src/utils\ directory now includes a suite of new utility modules that enhance core functionality. \audio.js\ provides helpers to load and decode audio files into \Float32Array\ buffers, including stereo-to-mono downmixing and signal processing windows (Hanning, Hamming). \image.js\ introduces a \RawImage\ class for reading, manipulating, and saving images across browser and Node.js environments. \cache.js\ and \cache/\ submodules implement a flexible caching system supporting custom backends, browser Cache API, and file system storage. \devices.js\ and \dtypes.js\ add configuration utilities for selecting hardware devices (e.g., GPU, WebGPU) and data types (e.g., fp16, quantized formats) with auto-detection and per-file overrides. \core.js\ defines progress tracking types and a \DefaultProgressCallback\ for aggregate download progress. \hub.js\ centralizes file retrieval logic with caching and header management. \logger.js\ adds configurable log levels. \lru\_cache.js\ and \memoize\_promise.js\ provide reusable caching primitives. \maths.js\ includes numerical helpers like interpolation and softmax. \io.js\ handles blob saving for browser and Node.js. \constants.js\ and \generic.js\ provide shared constants and a callable base class.
packages/transformers/src/utils · high confidence
Behavioural changes
Improved WASM binary and factory loading with caching and Deno compatibility
The WASM loading utilities now cache fetched files to improve performance on subsequent loads. Additionally, the WASM factory loader has been updated to patch out Node.js detection in the bundled library code, ensuring correct execution in Deno environments when using blob URLs. The loader also safely handles environments like Service Workers and Chrome extensions by bypassing blob URL creation where dynamic imports are restricted.
packages/transformers/src/backends/utils · high confidence
Replaced build system with esbuild-based scripts
The build and development scripts for the transformers package have been rewritten to use esbuild instead of the previous tooling. This introduces a new build pipeline that produces multiple output variants (ESM/CJS, web/node) via a plugin-based configuration, including specific handling for Node.js built-ins and module ignoring. The new \dev.mjs\ script now orchestrates esbuild in watch mode alongside TypeScript declaration generation, providing a unified development experience.
packages/transformers/scripts · high confidence
Transformers.js v4.3.0: Major backend and generation overhaul
This release introduces Transformers.js v4.3.0, featuring a complete restructuring of the ONNX backend to support WebGPU, WebNN, and native Node.js execution with automatic device detection. It adds a new \DynamicCache\ class for preserving decoder past key/value tensors across generation turns, enabling more efficient multi-turn conversations. The library also introduces a configurable logging system via \env.logLevel\, a new \TensorOpRegistry\ for in-memory ONNX operator execution, and expanded support for various model architectures and processors.
packages/transformers/src · high confidence
Test coverage
Added TypeScript type tests for pipelines, tokenizers, and cache utilities; Added comprehensive test suite for transformers.js; Added pipeline test coverage for audio, image, and text tasks; Added test coverage for transformers.js utility modules; Expanded test coverage for model architectures and tokenizers.
Dependencies
Transformers.js v4.3.0 release with structured-output package
This update introduces version 4.3.0 of the core @huggingface/transformers library and adds a new @huggingface/transformers-structured-output package for dependency-free constrained generation. The monorepo now uses pnpm workspaces, upgrading the package manager to v10.28.1 and TypeScript to 5.9.3. Key dependencies include onnxruntime-node 1.30.0, onnxruntime-web 1.31.0-dev, sharp 0.35.4, and @huggingface/jinja 0.5.10.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 57 → 58 (+1.6)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 66 → 66 (+0.0)
- Architecture 73 → 73 (-0.1)
- Maturity 64 → 64 (+0.2)
- Readiness 53 → 53 (+0.7)
- Security 55 → 64 (+9.1)
- Performance 60 (new)
Resolved (7)
- Hotspot: packages/transformers/src/backends/onnx.js (packages/transformers/src/backends/onnx.js)
- Hotspot: packages/transformers/src/models/modeling_utils.js (packages/transformers/src/models/modeling_utils.js)
- Hotspot: packages/transformers/src/tokenization_utils.js (packages/transformers/src/tokenization_utils.js)
- Hotspot: packages/transformers/src/utils/audio.js (packages/transformers/src/utils/audio.js)
- Hotspot: packages/transformers/src/utils/image.js (packages/transformers/src/utils/image.js)
- Hotspot: packages/transformers/src/utils/tensor.js (packages/transformers/src/utils/tensor.js)
- Workflow token permissions not restricted
New (5)
- Base-context workflow trigger runs with an unscoped token
- Outdated (npm): sharp
- PR-triggered workflow without a permissions block
- Split packages/transformers
- Workflow holding a long-lived secret is unscoped
Changes since last survey
- 2 commits — 2 feature/other, 0 fixes
By area
- .github/workflows — 2 commits
Notable commits
- change: Bump the actions group across 1 directory with 6 updates (#1703)
- change: Scope GITHUB_TOKEN permissions per job (#1777)
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
huggingface/transformers.js was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 836b9cb1b3542f217eab330f6fc62768bdf314f9 — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.