简报·YT
← 返回 GitHub 动态
huggingface/transformers · 📌 手动指定 已完成

huggingface/transformers v5.18.0

2026-09-30 16:46 · ⭐ 16.7万 · GitHub Release 原文 ↗
#模型发布 #版本更新 #开源生态

huggingface/transformers v5.18.0

本版本新增 4 个模型架构(Nemotron 3 Diarization、NemotronH Omni、HyperCLOVAX Vision V2、GTE),并包含 6 项 breaking change 与大量针对 MoE/专家并行、GGUF 量化、XPU/MPS/ROCm 后端的修复与改进。

新增模型能力

Breaking Changes

关键修复与改进

▸ Release Notes 英文原文(28582 字符)
## New Model additions ### Nemotron 3 Diarization <img width="1680" height="900" alt="image" src="https://github.com/user-attachments/assets/fe735cb3-9e5b-43ad-8f60-9dec8425aec7" /> Nemotron 3 Diarization is an open-weight streaming speaker diarization model designed to determine "who spoke when" in real-world audio. It supports both streaming and offline inference, handles up to eight speakers, and orders speaker outputs by each speaker's first arrival in the input audio. The model uses the Arrival-Order Speaker Cache (AOSC) [1](https://huggingface.co/papers/2507.18446) and FIFO queue introduced for Streaming Sortformer [1](https://huggingface.co/papers/2507.18446), [2](https://huggingface.co/papers/2409.06656). A single checkpoint supports configurable latency profiles, from an 80 ms input buffer to a 30.4 s offline-style buffer, and configurable output frame resolution in multiples of 10 ms. With chunked inference, the maximum audio duration is not limited. **Links:** [Documentation](https://huggingface.co/docs/transformers/main/en/model_doc/nemotron3_diarization) * Add Nemotron3Diarization (#49056) by @eustlb in [#49056](https://github.com/huggingface/transformers/pull/49056) ### NemotronH Omni NemotronH Omni is a multimodal reasoning model from NVIDIA that pairs the [NemotronH](https://huggingface.co/docs/transformers/main/en/model_doc/nemotron_h) hybrid Mamba-Transformer language model with a [RADIO](https://huggingface.co/docs/transformers/main/en/model_doc/radio) vision encoder and an optional Parakeet-based sound encoder. Image (and video) patches are projected through a RADIO tower and a pixel-shuffle MLP into the language model's embedding space at the `<image>` / `<video>` context-token positions; audio clips are projected in the same way at `<audio>` positions. The result is a single autoregressive model that reasons jointly over text, images, video and sound. **Links:** [Documentation](https://huggingface.co/docs/transformers/main/en/model_doc/nemotron_h_omni) * Add support for Nemotron Omni (#46509) by @meatybobby in [#46509](https://github.com/huggingface/transformers/pull/46509) ### HyperCLOVAX Vision V2 HyperCLOVAX Vision V2 is a multimodal vision-language model developed by NAVER. It combines the [HyperClovaX](https://huggingface.co/docs/transformers/main/en/model_doc/hyperclovax) language model backbone with a [Qwen2.5-VL](https://huggingface.co/docs/transformers/main/en/model_doc/qwen2_5_vl) vision encoder. The model supports text, image, and video inputs and is capable of chain-of-thought reasoning via built-in thinking tokens (`<think>...</think>`). **Links:** [Documentation](https://huggingface.co/docs/transformers/main/en/model_doc/hyperclovax_vision_v2) * add HyperClovaX Vision (#44314) by @jp1924 in [#44314](https://github.com/huggingface/transformers/pull/44314) ### GTE GTE was proposed in [mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval](https://huggingface.co/papers/2407.19669) by Xin Zhang, Yanzhao Zhang, Dingkun Long, Wen Xie, Ziqi Dai, Jialong Tang, Huan Lin, Baosong Yang, Pengjun Xie, Fei Huang, Meishan Zhang, Wenjie Li and Min Zhang. GTE is a BERT-style bidirectional encoder that replaces absolute position embeddings with RoPE, uses a gated MLP, and applies layer normalization after each residual connection. The same architecture backs Alibaba's `gte-*-v1.5`, `gte-multilingual-*` and `gte-en-mlm-*` checkpoints as well as Snowflake's `snowflake-arctic-embed-m-v2.0`. **Links:** [Documentation](https://huggingface.co/docs/transformers/main/en/model_doc/gte) * model: Add GTE to Transformers (#48416) by @harshaljanjani in [#48416](https://github.com/huggingface/transformers/pull/48416) ## Breaking changes * 🚨 [ROCm] gpt-oss: route FA3 to aiter-flash-attn, generate ROCm fixtures (#46837) by @Abdennacer-Badaoui * 🚨 Speed up detr image processing (#48066) by @guarin * 🚨 Remap indexers layer_type (#48974) by @Cyrilvallez * 🚨 [vLLM] Fix video token counting for Transformers backend video inputs (Part 1) (#48894) by @harshaljanjani * 🚨 🚨Bring some dinos to modern standards (#46266) by @molbap * :rotating_light: [`Kernels`] Bump version (#48714) by @vasqu ## Bugfixes and improvements * fix incorrect hub tokenizer class (#48641) by @itazap * [CI] Deduplicate Nvidia/AMD CI reply comments and add headers (#48655) by @ydshieh * Update dev (#48654) by @vasqu * [tests] Fix NougatModelIntegrationTest: pin artifact revision and update golden values (#48638) by @ydshieh * [fix] Fix GlmOcr integration tests: wrong token IDs and image token decode bug (#48650) by @ydshieh * [GLM 5.3 Flash] Preserve original names when saving text checkpoints (#48676) by @Dovis01 * Register activation kernel layers on XPU (#47858) by @jiqing-feng * Mirror the registered pytree flatten when building automatic dynamic shapes (#48578) by @IlyasMoutawwakil * Fix `AutoImageProcessor` requiring torchvision when only Pillow is installed (#48616) by @blipbyte * Assert cached decode matches recomputing without a cache (#48289) by @IlyasMoutawwakil * [higgs_audio_v2] Fix: use config.num_codebooks in audio labels tensor (Simple Fix!) (#48560) by @b-re-w * [`MoE`] Fix eager EP (#48653) by @vasqu * [MusicgenMelody] Fix conditioning silently dropped at generation step 0 (#48679) by @ydshieh * Fix deepspeed ci (#48640) by @SunMarc * Synthetic test assets (#48589) by @tarekziade * Skip the expert-parallel sentinel masking when expert parallelism is off (#48201) by @qgallouedec * [Fix] yolos offload issue (#48688) by @molbap * [serge] Fix 2 integration tests for model `minimax` failing with `output_mismatch` (tensor values differ (2)) (#48515) by @sergereview[bot] * [serge] Fix 2 integration tests for model `mistral` failing with `other` (other (2)) (#48429) by @sergereview[bot] * Fix Qwen2.5-VL temporal RoPE for fractional video intervals (#48669) by @yeyeyeping * Fix slow integration tests on XPU (#48611) by @jiqing-feng * QA: Added a `MemoryCleanupMixin` class for tests (#48681) by @tarekziade * [serge] Fix 1 integration test for model `flex_olmo` failing with `other` (other (1)) (#48668) by @sergereview[bot] * Fix D-FINE / RT-DETR main loss being computed over the denoising queries (#48528) by @stefan-it * [CI] Replace hardcoded username allowlists with author_association check in workflow triggers (#48712) by @ydshieh * Add flash_attention_4 in attn_implementation AutoModel docstring (#48684) by @3manifold * Keep the expert-parallel sentinel slots out of the router gradient (#48689) by @qgallouedec * [DeepseekV3] OOM cascade root-cause investigation (generator ref leak in conversion_mapping) (#48720) by @ydshieh * Use huggingface_hub httpx export (#48685) by @Wauplin * unifying device_mesh init to enable PP + TP inference (#48155) by @3outeille * Enable FSDP2 + expert parallelism via a 2-D (fsdp, tp) device mesh (#48516) by @qgallouedec * Switch daily CI to torch 2.14 — update expected outputs (#48750) by @ydshieh * fix videomae load error (#48675) by @sywangyi * Fix silently random-initializing `RTDetrModel`/`SEWDForCTC` loads (wrong `base_model_prefix`) (#48744) by @<NOT FOUND> * Fix Glm4vMoeIntegrationTest: offload_folder + MemoryCleanupMixin (#48776) by @ydshieh * [InternVL] Normalize num_patches before np.cumsum (#48469) by @lorenzozanee * Kernel api doc, part 2 (#46889) by @michaelbenayoun * Fix hidden state selection on Gemma4 assistant's first prefill step (#48704) by @glistening * Fix inkling embedding norm (#48786) by @Cyrilvallez * Fix TextToAudioPipeline crash for tokenizer-only models (#48505) by @jiqing-feng * Cast pixel values to the patch embedding dtype in DeepSeek-OCR-2 (#48632) by @jiqing-feng * add kernel mapping entry for RMSNormGated, KDA, Conv1D on XPU (#48702) by @kaixuanliu * Bump `peft` version requirement (#48716) by @shniubobo * [serge] Fix 12 integration tests for model `edgetam` failing with `import_or_config` (other (12)) (#48322) by @sergereview[bot] * Restore legacy tensor-parallel initialization for compatibility (#48797) by @3outeille * Fix kosmos flaky test (#48800) by @IlyasMoutawwakil * Add integration tests for MuseGlimmerAssistantModel (#48796) by @ydshieh * Fix `AutoModel.from_pretrained` not restoring `modules_to_save` weights (#48595) by @shniubobo * [docs] mrope and axial rope (#48717) by @stevhliu * Fix decoder only path for older bert variants (#48785) by @Cyrilvallez * [Fix] Clean-up ternaries in the DeepSeek family (#48447) by @remi-or * [utils] Add MUSA support for Flash Attention 2 (#48612) by @XiaomingFun233 * [generate] Drop attention mask early without padding (#48814) by @Cyrilvallez * Pin utf-8 in test_can_init_all_missing_weights source read (Windows non-UTF-8 locale fix) (#48819) by @dltsum * Relax static-cache tolerance in test_generate_with_static_cache (1e-5 → 5e-5) (#48815) by @ydshieh * Detect nested rope_parameters without relying on layer_types (#48798) by @hmellor * Support for MoE in the GGUF integration (#48529) by @SunMarc * [docs] gguf (#46357) by @stevhliu * [apply_chat_template] pass sampling_rate to call (#48794) by @eustlb * [CI] Add link checker (#48160) by @stevhliu * Qwen3.8 GGUF (#48660) by @SunMarc * docs: fix broken #combining-with-fsdp2 anchor in expert_parallelism.md (#48854) by @ydshieh * [GPTNeoXJapanese] Fix RoPE ignoring partial_rotary_factor (#48652) by @blipbyte * QA: deactivate rule 41 (#48852) by @tarekziade * Fix `reset` on the dynamic cache layers (#48809) by @jiqing-feng * [generate] Make all methods and logits processors agnostic to lm_head output size (#48846) by @Cyrilvallez * Fix kosmos (#48853) by @Cyrilvallez * Add test for causal only variant of some encoder-decoder models (#48760) by @nandan2003 * Fix ESMFold2 ligand iPLDDT weighting: mol_type non-polymer code is 3, not 4 (#48831) by @faustomilletari * Fix flaky RfDetr test_save_load (#48869) by @ydshieh * fix(ci): harden GitHub Actions workflows (#48160) (#48834) by @hf-security-analysis[bot] * Fix Glm4MoeIntegrationTest: split into 3 tests, switch to GLM-4.5-Air (#48820) by @ydshieh * Fix `StaticCache` for Mllama and enable `torch.compile` (#48141) by @jiqing-feng * Fix Minimax M2 partial_rotary_factor by remapping legacy rotary_dim (#48486) by @dajiaohuang * Fix Pixtral image processor do_pad option (#48872) by @jzakrzew * [CB] Add pause mechanism (#48462) by @remi-or * Fix DFlash sampled candidates losing the batch dimension (#48281) by @VaggelisGian * Fix sliding window cache when assistant model calls generate (#48280) by @VaggelisGian * Fix GLM rope_parameters dict shared mutation across test instances (#48895) by @ydshieh * [`feat`] Allow untying `hidden_states[-1]` from `last_hidden_state` via the model config (#48087) by @tomaarsen * Fix Idefics2 padding when the first example has no image (#48753) by @Arnavsharma2 * Don't fail model loading when the accelerator can't report free memory (#48136) by @studioego * [Improvement] Rework the docstring and comments of mHC (#48888) by @remi-or * [serge] Fix 3 integration tests for model `deepseek_vl` failing with `other` (other (3)) (#48536) by @sergereview[bot] * Add auto_docstring task model overrides (#47815) by @guarin * Make LongcatFlashConfig self-consistent without building the model (#48899) by @hmellor * [`DSA`] Only save latents on dsa with indexer as well (#48876) by @vasqu * [Chat Parsing] Coerce oneOf tool arguments (#48719) by @yonigozlan * Always materialize the causal mask in Doge so sdpa stays causal (#48821) by @blipbyte * Fix docstring argument names that don't match signatures (#48474) by @IshaanPotle * Mark test_generate_with_static_cache as flaky for olmo and bigbird_pegasus (#48856) by @ydshieh * Clean up some MoE models' integration tests (#48833) by @ydshieh * Fix T5 tied weights order for lm_head (#48238) by @vaibhavmashal * Size the device_map buffer from the largest leaf module (#47211) by @dhruv7477 * Fix compile cache tests (#48923) by @Cyrilvallez * Update arXiv citation in NeoMME model doc (#48926) by @tonywu71 * Standardise Aria's MoE onto the experts interface (#48907) by @hmellor * Fix possessive typo in Whisper long-form warning (#48877) by @erikdw * Modular conversion small fix (#48934) by @zucchini-nlp * fix(vibevoice-asr): use integer ceiling division for audio token count (#48864) by @ege-arhan * Improve lazy import error messages (#48602) by @karatarassul4-max * Fix tests due to dropping attn mask (#48903) by @SunMarc * docs: fix docstring parameters that do not match signatures (#48904) by @simpleqt * DOC: Improve documentation for remap_legacy_layer_types function (#48651) by @mathewOracle * Align special tokens on the text config (#48847) by @qgallouedec * docs: fix dead doc links in i18n READMEs and the xlnet docstring (#48905) by @simpleqt * Fix AXK2 integration test: update CUDA expected text and rename class (#48941) by @ydshieh * Resolve the Hub revision once per load instead of passing a private _commit_hash around (#47611) by @Wauplin * Keep image processor backends in sync on keys and dtypes (#48739) by @yupengtang * Fix infeasible cost matrix errors in hugarian matcher losses (#47730) by @guarin * Fix more stuff (#48979) by @zucchini-nlp * Skip an unnecessary image copy in the torchvision image normalization path (#48897) by @jzakrzew * Better attn default for gguf (#48935) by @SunMarc * Add pose estimation keypoint preprocessing to Sapiens2ImageProcessor (#47199) by @Sainava * Fix image processor class-level size mutation and min_pixels handling (#48916) by @Gracy769 * Contract the mamba2 chunk scan with einsum instead of broadcast-then-sum (#48978) by @tarekziade * Fix typos in DeepseekV4 comments (#48953) by @Janiarafath * Reduce peak memory in examples_torch CI job (OOM fix) (#48983) by @ydshieh * Fix vibevoice TTS batched audio index (#48902) by @ebezzam * [CB] [Major] Upgrade the cache to support different attention types (#47809) by @remi-or * Fix SwitchTransformers Top1 router: raw logits, expert capacity accounting, and router losses (#48421) by @yurekami * Fix Qwen3OmniMoeIntegrationTest OOM (#48987) by @ydshieh * Let `prefix_allowed_tokens_fn` override model `-inf` and raise an exception on unsatisfiable generation constraints. (#48927) by @ksh108405 * [generate] Simplify candidate generators by removing required `update_candidate_strategy` (#48982) by @Cyrilvallez * [generate] Always correctly restrict assisted decoding with max length/eos token (#48981) by @Cyrilvallez * QA: applied ruff rule PLW1514 (#48990) by @tarekziade * Update tokenizer gguf support (#48656) by @SunMarc * [vLLM] Fix video token counting for Transformers backend video inputs (Part 2) (#48900) by @harshaljanjani * Update ggml kernels path (#48991) by @SunMarc * Enable compressed-tensors FP8 kernels on MPS (torch >= 2.15) (#48985) by @Isalia20 * Fix mps autocast handling in rotary embeddings (#49006) by @Isalia20 * Fix static cache per layer head shapes (#48619) by @dacorvo * Summarization examples: download NLTK punkt_tab, not punkt (#49014) by @davanstrien * [docs] Fix legacy hf CLI references (transformers) (#48988) by @Wauplin * Fix RecurrentGemma compiled generation with StaticCache (#48961) by @sywangyi * updated GraniteMoeHybrid expectations (CPU) (#49016) by @tarekziade * OpenVINO HF Exporter (#47003) by @IlyasMoutawwakil * fix noisy comments (#49013) by @tarekziade * Fix assisted decoding for VLM due to dropping attn mask (#49019) by @SunMarc * Deprecate min-max pixels (#49021) by @zucchini-nlp * Keep special token ids the tokenizer does not define (#48708) by @albertvillanova * Added more usage of MemoryCleanupMixin (#49011) by @tarekziade * Shorten noisy OpenVINO SDPA comment (#49033) by @tarekziade * PEFT x Dtensor-based TP integration (#48485) by @michaelbenayoun * fix(zamba): add use_associative_scan config flag to avoid torch.compile slowdown (#48331) by @msnliu * Scope GITHUB_TOKEN permissions per job (#49046) by @hf-security-analysis[bot] * Fix mask creation not being skipped under `torch.compile` (#48975) by @jiqing-feng * [Chat] Loading GGUF models served with the Chat CLI (#49031) by @ariG23498 * Pin GitHub Actions to commit SHAs (#49049) by @hf-security-analysis[bot] * Only seed numpy in BigBird block-sparse attention during training (#49037) by @jiqing-feng * QA: Fix llama4 leak (#49042) by @tarekziade * Fix startup failures: drop permissions reusable-workflow callers cannot grant (#49055) by @paulinebm * Fix startup failures: drop pull-requests: read from check_failed_tests.yml (#49057) by @paulinebm * Register the remaining mamba-ssm kernel layers on XPU (#49035) by @jiqing-feng * Add workflow for building XPU CI Docker images (#49039) by @regisss * Fix assistant masks for processors (#48793) by @Rocketknight1 * Add MPS maintainer (#49052) by @Rocketknight1 * [docs] Loading behavior (#49023) by @stevhliu * [Nemotron3Diarization] nit: hub pr merged to main (#49065) by @eustlb * fix(ci): harden GitHub Actions workflows (#49057) (#49059) by @hf-security-analysis[bot] * Honor `config.output_router_logits` in the MoE VLM wrappers (#48885) by @qgallouedec * Fix XPU Docker image build (#49073) by @regisss * Fix assisted eos token condition (#49075) by @Cyrilvallez * [serge] Fix OOM in Moshi integration tests with MemoryCleanupMixin (#48839) by @sergereview[bot] * Fix odd head_dim validation for RoPE configurations (#48524) by @somuai * Keep already-decoded array arguments unchanged (#49062) by @yonigozlan * Fix NaN in Parakeet eager attention with padded batches (#49070) by @ArthurZucker * Bump huggingface_hub upper bound to <3.0 (transformers) (#49083) by @Wauplin * Keep `attention_mask` as `None` in OPT's causal mask creation (#49002) by @jiqing-feng * Add `Trainer.end` (#48875) by @qgallouedec * Add image processing tester init (#48829) by @guarin * [Executorch] Add MLX recipe (#48910) by @metascroy * [Zamba] Fix associative scan breaking ONNX export and OOM in integration test (#49092) by @ydshieh * Fix RGB early-return skipping PNG tRNS compositing (#49005) by @cs-fisha * Use namespaced dataset ids in docs and PyTorch examples (#49017) by @davanstrien * Fix MaskFormerSwin attention mask dtype to follow hidden states (#49032) by @kaixuanliu * [NemotronH-Omni] Fix device mismatch in test tensor creation (#49102) by @ydshieh * [serge] Fix 2 integration tests for model `cvt` failing with `output_mismatch` (tensor values differ (2)) (#49076) by @sergereview[bot] * [serge] Fix 2 integration tests for model `hy_v3` failing with `output_mismatch` (tensor values differ (2)) (#49068) by @sergereview[bot] * [serge] Fix 2 integration tests for model `pvt_v2` failing with `other` (#49067) by @sergereview[bot] * Keep the eos ids the config declares (#49082) by @albertvillanova * Use grouped_mm on TPU devices under torch.compile (#49097) by @salkan0 * [serge] Fix 2 integration tests for model `jamba` failing with `other` (other (2)) (#49044) by @sergereview[bot] * Remap the legacy Gemma 1 hidden_act in the config post-init (#49084) by @PCfVW * Fix exporters import on torch < 2.9 (is_contiguous_or_false) (#49124) by @ydshieh * [gemma3n] fix audio test fixture: use hf_hub_download instead of load_dataset (#49128) by @ydshieh * qwen3 models map to wrong tokenizer class on the hub (#49116) by @itazap * Restore the Unicode whitespace set in the GPT-SW3 tokenizer (#48912) by @David-Wu1119 * [AMD] Fix some integration tests (#49153) by @Abdennacer-Badaoui * [Gemma] Fix test_model_7b_fp16_static_cache expected value for cuda 8 after #49084 (#49133) by @ydshieh * Fix UMT5 decoder self-attention not being causal (#49135) by @the-cross-art * Skip flash tests that fall back to a hub kernel when kernels is missing (#49129) by @Abdennacer-Badaoui * Auto generate model inits (#47829) by @guarin * Fix get_json_schema dropping items/enum for unions of list/dict/Literal types (#49136) by @JoeyTan21 * Pick the default flash implementation based on the current hardware (#49109) by @Abdennacer-Badaoui * Deprecate the use_mamba_kernels config flag that no longer has any effect (#49155) by @albertvillanova * [CI] ssh-runner: add optional cache_type input to switch between bucket and EFS runners (#49159) by @ydshieh * [generation] Encode multimodal data only once (#45783) by @zucchini-nlp * No more -hf repo names for ESMC (#49158) by @Rocketknight1 * [MPS] Remove cu_seqlens_k clone workaround for metal-flash-sdpa (#49091) by @Isalia20 * [PerceptionLM] Restore test_inputs_embeds overrides to fix flaky test (#49165) by @ydshieh * [CB] Fix failing tests discovered when using the B200 (#49171) by @remi-or * [imagegpt/vilt/trocr] fix cache fixture tests: use hf_hub_download instead of load_dataset (#49178) by @ydshieh * Fix lost call (#49163) by @molbap * Document image_like_kwargs (#49180) by @guarin * [CacheHardIntegrationTest] use dedicated safetensors repo to fix Xet bucket cache corruption (#49182) by @ydshieh * Document running the example scripts on Hugging Face Jobs (#49050) by @davanstrien * Fix backslash handling in generate flag values in transformers chat (#48709) by @JHC56 * Finish removing the MPS autocast workaround (#49157) by @rubenG1009 * Fix Trainer checkpoint resume crashing on CPU with multiple processes (#49123) by @neevmodh * Fix command syntax for optimum-cli export (#46451) by @Ahwar * QA: fix noisy comment checker (#49184) by @tarekziade * update to torch 2.14 (#49199) by @sywangyi * Video processors - general maintenance (#48251) by @zucchini-nlp * [Parakeet] Convert NeMo's stochastic depth to layerdrop (#49191) by @Deep-unlearning * [MPS] Let mps sdpa handle grouped query attention directly (#49187) by @Isalia20 * Replace datasets that no longer load with maintained uploads (#49018) by @davanstrien * Fail fast on eval OOM under `auto_find_batch_size` (#49198) by @qgallouedec * Fix SequenceBiasLogitsProcessor edge cases: token id 0 and prefix equal to context (#49117) by @lucaluo925 * Map bare list, tuple and dict annotations to the right JSON schema type in get_json_schema (#49145) by @825pranav * [`Kernels`] Sync mamba version (#49205) by @vasqu * gguf user defined tokens (#49008) by @SunMarc * QA: restore masking_utils export comment with a noqa (#49209) by @tarekziade * Fix deepstack features for mixed-input (#49177) by @zucchini-nlp * Fix stale _added_tokens_encoder entries in cpmant and wav2vec2 (#47440) by @ishan-1010 * Fix additional_special_tokens data loss with extra_special_tokens (#47848) by @erichanwang * Fix MPS GQA version gating (#49210) by @Isalia20 * Add Strix Halo (gfx1151) Atlas Inference Hub-kernel path for Qwen3.5/3.6/3.8 Gated DeltaNet (#49127) by @AzeezIsh * Fix MiniMax M3 partial 3D vision rotary embeddings (#49164) by @cuichenx * Fix missing router_logits in Qwen3.5-MoE and other MoE models (#49179) by @zucchini-nlp * [Nemotron3Diarization] fix streaming last stft frame dropped (#49167) by @eustlb ## Significant community contributions The following contributors have made significant changes to the library over the last release: * @harshaljanjani * model: Add GTE to Transformers (#48416) * [vLLM] Fix video token counting for Transformers backend video inputs (Part 2) (#48900) * 🚨 [vLLM] Fix video token counting for Transformers backend video inputs (Part 1) (#48894) * @eustlb * [Nemotron3Diarization] fix streaming last stft frame dropped (#49167) * [Nemotron3Diarization] nit: hub pr merged to main (#49065) * Add Nemotron3Diarization (#49056) * [apply_chat_template] pass sampling_rate to call (#48794) * @tarekziade * QA: restore masking_utils export comment with a noqa (#49209) * QA: fix noisy comment checker (#49184) * QA: Fix llama4 leak (#49042) * Shorten noisy OpenVINO SDPA comment (#49033) * Added more usage of MemoryCleanupMixin (#49011) * fix noisy comments (#49013) * updated GraniteMoeHybrid expectations (CPU) (#49016) * QA: applied ruff rule PLW1514 (#48990) * Contract the mamba2 chunk scan with einsum instead of broadcast-then-sum (#48978) * QA: deactivate rule 41 (#48852) * QA: Added a `MemoryCleanupMixin` class for tests (#48681) * Synthetic test assets (#48589) * @ydshieh * [CacheHardIntegrationTest] use dedicated safetensors repo to fix Xet bucket cache corruption (#49182) * [imagegpt/vilt/trocr] fix cache fixture tests: use hf_hub_download instead of load_dataset (#49178) * [PerceptionLM] Restore test_inputs_embeds overrides to fix flaky test (#49165) * [CI] ssh-runner: add optional cache_type input to switch between bucket and EFS runners (#49159) * [Gemma] Fix test_model_7b_fp16_static_cache expected value for cuda 8 after #49084 (#49133) * [gemma3n] fix audio test fixture: use hf_hub_download instead of load_dataset (#49128) * Fix exporters import on torch < 2.9 (is_contiguous_or_false) (#49124) * [NemotronH-Omni] Fix device mismatch in test tensor creation (#49102) * [Zamba] Fix associative scan breaking ONNX export and OOM in integration test (#49092) * Fix Qwen3OmniMoeIntegrationTest OOM (#48987) * Reduce peak memory in examples_torch CI job (OOM fix) (#48983) * Fix AXK2 integration test: update CUDA expected text and rename class (#48941) * Clean up some MoE models' integration tests (#48833) * Mark test_generate_with_static_cache as flaky for olmo and bigbird_pegasus (#48856) * Fix GLM rope_parameters dict shared mutation across test instances (#48895) * Fix Glm4MoeIntegrationTest: split into 3 tests, switch to GLM-4.5-Air (#48820) * Fix flaky RfDetr test_save_load (#48869) * docs: fix broken #combining-with-fsdp2 anchor in expert_parallelism.md (#48854) * Relax static-cache tolerance in test_generate_with_static_cache (1e-5 → 5e-5) (#48815) * Add integration tests for MuseGlimmerAssistantModel (#48796) * Fix Glm4vMoeIntegrationTest: offload_folder + MemoryCleanupMixin (#48776) * Switch daily CI to torch 2.14 — update expected outputs (#48750) * [DeepseekV3] OOM cascade root-cause investigation (generator ref leak in conversion_mapping) (#48720) * [CI] Replace hardcoded username allowlists with author_association check in workflow triggers (#48712) * [MusicgenMelody] Fix conditioning silently dropped at generation step 0 (#48679) * [fix] Fix GlmOcr integration tests: wrong token IDs and image token decode bug (#48650) * [tests] Fix NougatModelIntegrationTest: pin artifact revision and update golden values (#48638) * [CI] Deduplicate Nvidia/AMD CI reply comments and add headers (#48655) * @molbap * Fix lost call (#49163) * 🚨 🚨Bring some dinos to modern standards (#46266) * [Fix] yolos offload issue (#48688) * @remi-or * [CB] Fix failing tests discovered when using the B200 (#49171) * [CB] [Major] Upgrade the cache to support different attention types (#47809) * [Improvement] Rework the docstring and comments of mHC (#48888) * [CB] Add pause mechanism (#48462) * [Fix] Clean-up ternaries in the DeepSeek family (#48447) * @jiqing-feng * Keep `attention_mask` as `None` in OPT's causal mask creation (#49002) * Register the remaining mamba-ssm kernel layers on XPU (#49035) * Only seed numpy in BigBird block-sparse attention during training (#49037) * Fix mask creation not being skipped under `torch.compile` (#48975) * Fix `StaticCache` for Mllama and enable `torch.compile` (#48141) * Fix `reset` on the dynamic cache layers (#48809) * Cast pixel values to the patch embedding dtype in DeepSeek-OCR-2 (#48632) * Fix TextToAudioPipeline crash for tokenizer-only models (#48505) * Fix slow integration tests on XPU (#48611) * Register activation kernel layers on XPU (#47858) * @Wauplin * Bump huggingface_hub upper bound to <3.0 (transformers) (#49083) * [docs] Fix legacy hf CLI references (transformers) (#48988) * Resolve the Hub revision once per load instead of passing a private _commit_hash around (#47611) * Use huggingface_hub httpx export (#48685) * @meatybobby * Add support for Nemotron Omni (#46509) * @Sainava * Add pose estimation keypoint preprocessing to Sapiens2ImageProcessor (#47199) * @jp1924 * add HyperClovaX Vision (#44314)
▸ 主项目介绍 · huggingface/transformers
▸ README 原文(同步于 2026-07-19 13:24)
<!--- Copyright 2020 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-light.svg"> <img alt="Hugging Face Transformers Library" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/transformers-logo-light.svg" width="352" height="59" style="max-width: 100%;"> </picture> <br/> <br/> </p> <p align="center"> <a href="https://huggingface.com/models"><img alt="Checkpoints on Hub" src="https://img.shields.io/endpoint?url=https://huggingface.co/api/shields/models&color=brightgreen"></a> <a href="https://circleci.com/gh/huggingface/transformers"><img alt="Build" src="https://img.shields.io/circleci/build/github/huggingface/transformers/main"></a> <a href="https://github.com/huggingface/transformers/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/huggingface/transformers.svg?color=blue"></a> <a href="https://huggingface.co/docs/transformers/index"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/transformers/index.svg?down_color=red&down_message=offline&up_message=online"></a> <a href="https://github.com/huggingface/transformers/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/transformers.svg"></a> <a href="https://github.com/huggingface/transformers/blob/main/CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg"></a> <a href="https://zenodo.org/badge/latestdoi/155220641"><img src="https://zenodo.org/badge/155220641.svg" alt="DOI"></a> </p> <h4 align="center"> <p> <b>English</b> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hans.md">简体中文</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_zh-hant.md">繁體中文</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ko.md">한국어</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_es.md">Español</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ja.md">日本語</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_hd.md">हिन्दी</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ru.md">Русский</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_pt-br.md">Português</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_te.md">తెలుగు</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_fr.md">Français</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_de.md">Deutsch</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_it.md">Italiano</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_vi.md">Tiếng Việt</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ar.md">العربية</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_ur.md">اردو</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_bn.md">বাংলা</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_fa.md">فارسی</a> | <a href="https://github.com/huggingface/transformers/blob/main/i18n/README_tr.md">Türkçe</a> | </p> </h4> <h3 align="center"> <p>State-of-the-art pretrained models for inference and training</p> </h3> <h3 align="center"> <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/transformers_as_a_model_definition.png"/> </h3> Transformers acts as the model-definition framework for state-of-the-art machine learning with text, computer vision, audio, video, and multimodal models, for both inference and training. It centralizes the model definition so that this definition is agreed upon across the ecosystem. `transformers` is the pivot across frameworks: if a model definition is supported, it will be compatible with the majority of training frameworks (Axolotl, Unsloth, DeepSpeed, FSDP, PyTorch-Lightning, ...), inference engines (vLLM, SGLang, TGI, ...), and adjacent modeling libraries (llama.cpp, mlx, ...) which leverage the model definition from `transformers`. We pledge to help support new state-of-the-art models and democratize their usage by having their model definition be simple, customizable, and efficient. There are over 1M+ Transformers [model checkpoints](https://huggingface.co/models?library=transformers&sort=trending) on the [Hugging Face Hub](https://huggingface.co/models) you can use. Explore the [Hub](https://huggingface.co/) today to find a model and use Transformers to help you get started right away. ## Installation Transformers works with Python 3.10+, and [PyTorch](https://pytorch.org/get-started/locally/) 2.4+. Create and activate a virtual environment with [venv](https://docs.python.org/3/library/venv.html) or [uv](https://docs.astral.sh/uv/), a fast Rust-based Python package and project manager. ```py # venv python -m venv .my-env source .my-env/bin/activate # uv uv venv .my-env source .my-env/bin/activate ``` Install Transformers in your virtual environment. ```py # pip pip install "transformers[torch]" # uv uv pip install "transformers[torch]" ``` Install Transformers from source if you want the latest changes in the library or are interested in contributing. However, the *latest* version may not be stable. Feel free to open an [issue](https://github.com/huggingface/transformers/issues) if you encounter an error. ```shell git clone https://github.com/huggingface/transformers.git cd transformers # pip pip install '.[torch]' # uv uv pip install '.[torch]' ``` ## Quickstart Get started with Transformers right away with the [Pipeline](https://huggingface.co/docs/transformers/pipeline_tutorial) API. The `Pipeline` is a high-level inference class that supports text, audio, vision, and multimodal tasks. It handles preprocessing the input and returns the appropriate output. Instantiate a pipeline and specify model to use for text generation. The model is downloaded and cached so you can easily reuse it again. Finally, pass some text to prompt the model. ```py from transformers import pipeline pipeline = pipeline(task="text-generation", model="Qwen/Qwen2.5-1.5B") pipeline("the secret to baking a really good cake is ") [{'generated_text': 'the secret to baking a really good cake is 1) to use the right ingredients and 2) to follow the recipe exactly. the recipe for the cake is as follows: 1 cup of sugar, 1 cup of flour, 1 cup of milk, 1 cup of butter, 1 cup of eggs, 1 cup of chocolate chips. if you want to make 2 cakes, how much sugar do you need? To make 2 cakes, you will need 2 cups of sugar.'}] ``` To chat with a model, the usage pattern is the same. The only difference is you need to construct a chat history (the input to `Pipeline`) between you and the system. > [!TIP] > You can also chat with a model directly from the command line, as long as [`transformers serve` is running](https://huggingface.co/docs/transformers/main/en/serving). > ```shell > transformers chat Qwen/Qwen2.5-0.5B-Instruct > ``` ```py import torch from transformers import pipeline chat = [ {"role": "system", "content": "You are a sassy, wise-cracking robot as imagined by Hollywood circa 1986."}, {"role": "user", "content": "Hey, can you tell me any fun things to do in New York?"} ] pipeline = pipeline(task="text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct", dtype=torch.bfloat16, device_map="auto") response = pipeline(chat, max_new_tokens=512) print(response[0]["generated_text"][-1]["content"]) ``` Expand the examples below to see how `Pipeline` works for different modalities and tasks. <details> <summary>Automatic speech recognition</summary> ```py from transformers import pipeline pipeline = pipeline(task="automatic-speech-recognition", model="openai/whisper-large-v3") pipeline("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac") {'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'} ``` </details> <details> <summary>Image classification</summary> <h3 align="center"> <a><img src="https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png"></a> </h3> ```py from transformers import pipeline pipeline = pipeline(task="image-classification", model="facebook/dinov2-small-imagenet1k-1-layer") pipeline("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png") [{'label': 'macaw', 'score': 0.997848391532898}, {'label': 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', 'score': 0.0016551691805943847}, {'label': 'lorikeet', 'score': 0.00018523589824326336}, {'label': 'African grey, African gray, Psittacus erithacus', 'score': 7.85409429227002e-05}, {'label': 'quail', 'score': 5.502637941390276e-05}] ``` </details> <details> <summary>Visual question answering</summary> <h3 align="center"> <a><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-few-shot.jpg"></a> </h3> ```py from transformers import pipeline pipeline = pipeline(task="visual-question-answering", model="Salesforce/blip-vqa-base") pipeline( image="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/idefics-few-shot.jpg", question="What is in the image?", ) [{'answer': 'statue of liberty'}] ``` </details> ## Why should I use Transformers? 1. Easy-to-use state-of-the-art models: - High performance on natural language understanding & generation, computer vision, audio, video, and multimodal tasks. - Low barrier to entry for researchers, engineers, and developers. - Few user-facing abstractions with just three classes to learn. - A unified API for using all our pretrained models. 1. Lower compute costs, smaller carbon footprint: - Share trained models instead of training from scratch. - Reduce compute time and production costs. - Hundreds of model architectures with 1M+ pretrained checkpoints across all modalities. 1. Choose the right framework for every part of a model's lifetime: - Train state-of-the-art models in 3 lines of code. - Move a single model between PyTorch/JAX/TF2.0 frameworks at will. - Pick the right framework for training, evaluation, and production. 1. Easily customize a model or an example to your needs: - We provide examples for each architecture to reproduce the results published by its original authors. - Model internals are exposed as consistently as possible. - Model files can be used independently of the library for quick experiments. <a target="_blank" href="https://huggingface.co/enterprise"> <img alt="Hugging Face Enterprise Hub" src="https://github.com/user-attachments/assets/247fb16d-d251-4583-96c4-d3d76dda4925"> </a><br> ## When shouldn't I use Transformers? - This library is not a modular toolbox of building blocks for neural nets. The code in the model files is not refactored with additional abstractions on purpose, so that researchers can quickly iterate on each of the models without diving into additional abstractions/files. - The training API is optimized to work with PyTorch models provided by Transformers. For generic machine learning loops, you should use another library like [Accelerate](https://huggingface.co/docs/accelerate). - The [example scripts](https://github.com/huggingface/transformers/tree/main/examples) are only *examples*. They may not necessarily work out-of-the-box on your specific use case and you'll need to adapt the code for it to work. ## 100 projects using Transformers Transformers is more than a toolkit to use pretrained models, it's a community of projects built around it and the Hugging Face Hub. We want Transformers to enable developers, researchers, students, professors, engineers, and anyone else to build their dream projects. In order to celebrate Transformers 100,000 stars, we wanted to put the spotlight on the community with the [awesome-transformers](./awesome-transformers.md) page which lists 100 incredible projects built with Transformers. If you own or use a project that you believe should be part of the list, please open a PR to add it! ## Example models You can test most of our models directly on their [Hub model pages](https://huggingface.co/models). Expand each modality below to see a few example models for various use cases. <details> <summary>Audio</summary> - Audio classification with [CLAP](https://huggingface.co/laion/clap-htsat-fused) - Automatic speech recognition with [Parakeet](https://huggingface.co/nvidia/parakeet-ctc-1.1b#transcribing-using-transformers-%F0%9F%A4%97), [Whisper](https://huggingface.co/openai/whisper-large-v3-turbo), [GLM-ASR](https://huggingface.co/zai-org/GLM-ASR-Nano-2512) and [Moonshine-Streaming](https://huggingface.co/UsefulSensors/moonshine-streaming-medium) - Keyword spotting with [Wav2Vec2](https://huggingface.co/superb/wav2vec2-base-superb-ks) - Speech to speech generation with [Moshi](https://huggingface.co/kyutai/moshiko-pytorch-bf16) - Text to audio with [MusicGen](https://huggingface.co/facebook/musicgen-large) - Text to speech with [CSM](https://huggingface.co/sesame/csm-1b) </details> <details> <summary>Computer vision</summary> - Automatic mask generation with [SAM](https://huggingface.co/facebook/sam-vit-base) - Depth estimation with [DepthPro](https://huggingface.co/apple/DepthPro-hf) - Image classification with [DINO v2](https://huggingface.co/facebook/dinov2-base) - Keypoint detection with [SuperPoint](https://huggingface.co/magic-leap-community/superpoint) - Keypoint matching with [SuperGlue](https://huggingface.co/magic-leap-community/superglue_outdoor) - Object detection with [RT-DETRv2](https://huggingface.co/PekingU/rtdetr_v2_r50vd) - Pose Estimation with [VitPose](https://huggingface.co/usyd-community/vitpose-base-simple) - Universal segmentation with [OneFormer](https://huggingface.co/shi-labs/oneformer_ade20k_swin_large) - Video classification with [VideoMAE](https://huggingface.co/MCG-NJU/videomae-large) </details> <details> <summary>Multimodal</summary> - Audio or text to text with [Voxtral](https://huggingface.co/mistralai/Voxtral-Mini-3B-2507), [Audio Flamingo](https://huggingface.co/nvidia/audio-flamingo-3-hf) - Document question answering with [LayoutLMv3](https://huggingface.co/microsoft/layoutlmv3-base) - Image or text to text with [Qwen-VL](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct) - Image captioning [BLIP-2](https://huggingface.co/Salesforce/blip2-opt-2.7b) - OCR-based document understanding with [GOT-OCR2](https://huggingface.co/stepfun-ai/GOT-OCR-2.0-hf) - Table question answering with [TAPAS](https://huggingface.co/google/tapas-base) - Unified multimodal understanding and generation with [Emu3](https://huggingface.co/BAAI/Emu3-Gen) - Vision to text with [Llava-OneVision](https://huggingface.co/llava-hf/llava-onevision-qwen2-0.5b-ov-hf) - Visual question answering with [Llava](https://huggingface.co/llava-hf/llava-1.5-7b-hf) - Visual referring expression segmentation with [Kosmos-2](https://huggingface.co/microsoft/kosmos-2-patch14-224) </details> <details> <summary>NLP</summary> - Masked word completion with [ModernBERT](https://huggingface.co/answerdotai/ModernBERT-base) - Named entity recognition with [Gemma](https://huggingface.co/google/gemma-2-2b) - Question answering with [Mixtral](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1) - Summarization with [BART](https://huggingface.co/facebook/bart-large-cnn) - Translation with [T5](https://huggingface.co/google-t5/t5-base) - Text generation with [Llama](https://huggingface.co/meta-llama/Llama-3.2-1B) - Text classification with [Qwen](https://huggingface.co/Qwen/Qwen2.5-0.5B) </details> ## Citation We now have a [paper](https://aclanthology.org/2020.emnlp-demos.6/) you can cite for the 🤗 Transformers library: ```bibtex @inproceedings{wolf-etal-2020-transformers, title = "Transformers: State-of-the-Art Natural Language Processing", author = "Thomas Wolf and Lysandre Debut and Victor Sanh and Julien Chaumond and Clement Delangue and Anthony Moi and Pierric Cistac and Tim Rault and Rémi Louf and Morgan Funtowicz and Joe Davison and Sam Shleifer and Patrick von Platen and Clara Ma and Yacine Jernite and Julien Plu and Canwen Xu and Teven Le Scao and Sylvain Gugger and Mariama Drame and Quentin Lhoest and Alexander M. Rush", booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations", month = oct, year = "2020", address = "Online", publisher = "Association for Computational Linguistics", url = "https://aclanthology.org/2020.emnlp-demos.6/", pages = "38--45" } ```