npm / @huggingface/transformers
@huggingface/transformers
What changed in @huggingface/transformers 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-28.
2 breaking9 new APIs and options1 performance3 behavior and defaults10 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@huggingface/transformers 425 changes
Breaking changes 2
For EmbeddingGemma 2, the feature-extraction pipeline returns normalized embeddings, making their dot product equal to cosine similarity.
Generation now always sets this parameter to
1.
New APIs and options 9
Exposes getSupportedDevices() under env.backends.onnx.
Adds support for LFM3 models.
Adds support for LFM3-VL models.
Adds support for EmbeddingGemma 2, a multimodal embedding model that maps text, images, video, and audio into a shared vector space.
Adds support for the DeepSeek-V4 model architecture.
Adds support for the HRM-Text model architecture.
Adds an experimental, dependency-free package for constraining generation to a JSON schema, JSON object, or regular expression.
Provides a logits processor for constraining generated output using a JSON schema, JSON object, or regular expression.
Adds support for the Zaya model architecture.
Performance 1
The KV cache is disposed of after generation.
Behavior and default changes 3
Cross-Origin Storage now allows all origins.
Cross-Origin Storage now uses
requestFileHandle().Enables WebGPU support for Safari 26 and above.
Fixes and other changes 10
External data download failures no longer cause from_pretrained to hang.
Fixes handling of negative integer random seeds.
Browser cache writes are skipped for non-HTTP(S) resources.
Restores missing global exports.
Fixes the number of features in the processor.
Fixes token decoding for Moonshine ASR.
Fixes duplicate model file downloads when this callback is active.
Fixes
toBlob()so it respects typed-array byte offsets and lengths.Pins the WebGPU KV cache for Gemma3n and Gemma4 image-audio-text-to-text models.
Fixes progress callbacks for Whisper.