Skip to content
4 changes: 4 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@
title: Qwen2Audio
- local: model_doc/qwen2_vl
title: Qwen2VL
- local: model_doc/qwen3_vl
title: Qwen3VL
- local: model_doc/qwen3_vl_moe
title: Qwen3VLMoe
- local: model_doc/sam2
title: SAM2
- local: model_doc/sam2_video
Expand Down
117 changes: 117 additions & 0 deletions docs/source/en/model_doc/qwen3_vl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!--Copyright 2025 The Qwen Team and The HuggingFace Inc. 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.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was released on None and added to Hugging Face Transformers on 2025-08-16.*

<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&logo=pytorch&logoColor=white">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"> </div>
</div>

# Qwen3-VL

[Qwen3-VL](https://huggingface.co/papers/2502.13923) is a multimodal vision-language model series, encompassing both dense and MoE variants, as well as Instruct and Thinking versions. Building upon its predecessors, Qwen3-VL delivers significant improvements in visual understanding while maintaining strong pure text capabilities. Key architectural advancements include: enhanced MRope with interleaved layout for better spatial-temporal modeling, DeepStack integration to effectively leverage multi-level features from the Vision Transformer (ViT), and improved video understanding through text-based time alignment—evolving from T-RoPE to text timestamp alignment for more precise temporal grounding. These innovations collectively enable Qwen3-VL to achieve superior performance in complex multimodal tasks.

Model usage

<hfoptions id="usage">
<hfoption id="AutoModel">

```py
import torch
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor

model = Qwen3VLForConditionalGeneration.from_pretrained(
"Qwen/Qwen3-VL",
dtype=torch.float16,
device_map="auto",
attn_implementation="sdpa"
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL")
messages = [
{
"role":"user",
"content":[
{
"type":"image",
"url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
},
{
"type":"text",
"text":"Describe this image."
}
]
}

]

inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
inputs.pop("token_type_ids", None)

generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
```
</hfoption>
</hfoptions>

## Qwen3VLConfig

[[autodoc]] Qwen3VLConfig

## Qwen3VLTextConfig

[[autodoc]] Qwen3VLTextConfig

## Qwen3VLProcessor

[[autodoc]] Qwen3VLProcessor

## Qwen3VLVideoProcessor

[[autodoc]] Qwen3VLVideoProcessor

## Qwen3VLVisionModel

[[autodoc]] Qwen3VLVisionModel
- forward

## Qwen3VLTextModel

[[autodoc]] Qwen3VLTextModel
- forward

## Qwen3VLModel

[[autodoc]] Qwen3VLModel
- forward

## Qwen3VLForConditionalGeneration

[[autodoc]] Qwen3VLForConditionalGeneration
- forward
109 changes: 109 additions & 0 deletions docs/source/en/model_doc/qwen3_vl_moe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<!--Copyright 2025 The Qwen Team and The HuggingFace Inc. 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.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was released on None and added to Hugging Face Transformers on 2025-08-17.*

<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&logo=pytorch&logoColor=white">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"> </div>
</div>

# Qwen3-VL-Moe

[Qwen3-VL](https://huggingface.co/papers/2502.13923) is a multimodal vision-language model series, encompassing both dense and MoE variants, as well as Instruct and Thinking versions. Building upon its predecessors, Qwen3-VL delivers significant improvements in visual understanding while maintaining strong pure text capabilities. Key architectural advancements include: enhanced MRope with interleaved layout for better spatial-temporal modeling, DeepStack integration to effectively leverage multi-level features from the Vision Transformer (ViT), and improved video understanding through text-based time alignment—evolving from T-RoPE to text timestamp alignment for more precise temporal grounding. These innovations collectively enable Qwen3-VL to achieve superior performance in complex multimodal tasks.

Model usage

<hfoptions id="usage">
<hfoption id="AutoModel">

```py
import torch
from transformers import Qwen3VLMoeForConditionalGeneration, AutoProcessor

model = Qwen3VLMoeForConditionalGeneration.from_pretrained(
"Qwen/Qwen3-VL-Moe",
dtype=torch.float16,
device_map="auto",
attn_implementation="sdpa"
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-Moe")
messages = [
{
"role":"user",
"content":[
{
"type":"image",
"url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
},
{
"type":"text",
"text":"Describe this image."
}
]
}

]

inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
inputs.pop("token_type_ids", None)

generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
```
</hfoption>
</hfoptions>

## Qwen3VLMoeConfig

[[autodoc]] Qwen3VLMoeConfig

## Qwen3VLMoeTextConfig

[[autodoc]] Qwen3VLMoeTextConfig

## Qwen3VLMoeVisionModel

[[autodoc]] Qwen3VLMoeVisionModel
- forward

## Qwen3VLMoeTextModel

[[autodoc]] Qwen3VLMoeTextModel
- forward

## Qwen3VLMoeModel

[[autodoc]] Qwen3VLMoeModel
- forward

## Qwen3VLMoeForConditionalGeneration

[[autodoc]] Qwen3VLMoeForConditionalGeneration
- forward
2 changes: 2 additions & 0 deletions src/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
from .qwen3 import *
from .qwen3_moe import *
from .qwen3_next import *
from .qwen3_vl import *
from .qwen3_vl_moe import *
from .rag import *
from .recurrent_gemma import *
from .reformer import *
Expand Down
10 changes: 10 additions & 0 deletions src/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@
("qwen3", "Qwen3Config"),
("qwen3_moe", "Qwen3MoeConfig"),
("qwen3_next", "Qwen3NextConfig"),
("qwen3_vl", "Qwen3VLConfig"),
("qwen3_vl_moe", "Qwen3VLMoeConfig"),
("qwen3_vl_moe_text", "Qwen3VLMoeTextConfig"),
("qwen3_vl_text", "Qwen3VLTextConfig"),
("rag", "RagConfig"),
("realm", "RealmConfig"),
("recurrent_gemma", "RecurrentGemmaConfig"),
Expand Down Expand Up @@ -763,6 +767,10 @@
("qwen3", "Qwen3"),
("qwen3_moe", "Qwen3MoE"),
("qwen3_next", "Qwen3Next"),
("qwen3_vl", "Qwen3VL"),
("qwen3_vl_moe", "Qwen3VLMoe"),
("qwen3_vl_moe_text", "Qwen3VLMoe"),
("qwen3_vl_text", "Qwen3VL"),
("rag", "RAG"),
("realm", "REALM"),
("recurrent_gemma", "RecurrentGemma"),
Expand Down Expand Up @@ -950,6 +958,8 @@
("internvl_vision", "internvl"),
("qwen2_5_vl_text", "qwen2_5_vl"),
("qwen2_vl_text", "qwen2_vl"),
("qwen3_vl_text", "qwen3_vl"),
("qwen3_vl_moe_text", "qwen3_vl_moe"),
("sam_vision_model", "sam"),
("sam2_vision_model", "sam2"),
("sam2_hiera_det_model", "sam2"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/image_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
("pvt_v2", ("PvtImageProcessor", "PvtImageProcessorFast")),
("qwen2_5_vl", ("Qwen2VLImageProcessor", "Qwen2VLImageProcessorFast")),
("qwen2_vl", ("Qwen2VLImageProcessor", "Qwen2VLImageProcessorFast")),
("qwen3_vl", ("Qwen2VLImageProcessor", "Qwen2VLImageProcessorFast")),
("regnet", ("ConvNextImageProcessor", "ConvNextImageProcessorFast")),
("resnet", ("ConvNextImageProcessor", "ConvNextImageProcessorFast")),
("rt_detr", ("RTDetrImageProcessor", "RTDetrImageProcessorFast")),
Expand Down
8 changes: 8 additions & 0 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ class _BaseModelWithGenerate(PreTrainedModel, GenerationMixin):
("qwen3", "Qwen3Model"),
("qwen3_moe", "Qwen3MoeModel"),
("qwen3_next", "Qwen3NextModel"),
("qwen3_vl", "Qwen3VLModel"),
("qwen3_vl_moe", "Qwen3VLMoeModel"),
("qwen3_vl_moe_text", "Qwen3VLMoeTextModel"),
("qwen3_vl_text", "Qwen3VLTextModel"),
("recurrent_gemma", "RecurrentGemmaModel"),
("reformer", "ReformerModel"),
("regnet", "RegNetModel"),
Expand Down Expand Up @@ -972,6 +976,8 @@ class _BaseModelWithGenerate(PreTrainedModel, GenerationMixin):
("pix2struct", "Pix2StructForConditionalGeneration"),
("qwen2_5_vl", "Qwen2_5_VLForConditionalGeneration"),
("qwen2_vl", "Qwen2VLForConditionalGeneration"),
("qwen3_vl", "Qwen3VLForConditionalGeneration"),
("qwen3_vl_moe", "Qwen3VLMoeForConditionalGeneration"),
("video_llava", "VideoLlavaForConditionalGeneration"),
("vipllava", "VipLlavaForConditionalGeneration"),
("vision-encoder-decoder", "VisionEncoderDecoderModel"),
Expand Down Expand Up @@ -1026,6 +1032,8 @@ class _BaseModelWithGenerate(PreTrainedModel, GenerationMixin):
("pixtral", "LlavaForConditionalGeneration"),
("qwen2_5_vl", "Qwen2_5_VLForConditionalGeneration"),
("qwen2_vl", "Qwen2VLForConditionalGeneration"),
("qwen3_vl", "Qwen3VLForConditionalGeneration"),
("qwen3_vl_moe", "Qwen3VLMoeForConditionalGeneration"),
("shieldgemma2", "Gemma3ForConditionalGeneration"),
("smolvlm", "SmolVLMForConditionalGeneration"),
("udop", "UdopForConditionalGeneration"),
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
("qwen2_5_vl", "Qwen2_5_VLProcessor"),
("qwen2_audio", "Qwen2AudioProcessor"),
("qwen2_vl", "Qwen2VLProcessor"),
("qwen3_vl", "Qwen3VLProcessor"),
("qwen3_vl_moe", "Qwen3VLProcessor"),
("sam", "SamProcessor"),
("sam2", "Sam2Processor"),
("sam_hq", "SamHQProcessor"),
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/tokenization_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@
"Qwen2TokenizerFast" if is_tokenizers_available() else None,
),
),
("qwen3_vl", ("Qwen2Tokenizer", "Qwen2TokenizerFast" if is_tokenizers_available() else None)),
("qwen3_vl_moe", ("Qwen2Tokenizer", "Qwen2TokenizerFast" if is_tokenizers_available() else None)),
("rag", ("RagTokenizer", None)),
("realm", ("RealmTokenizer", "RealmTokenizerFast" if is_tokenizers_available() else None)),
(
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/video_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
("qwen2_5_omni", "Qwen2VLVideoProcessor"),
("qwen2_5_vl", "Qwen2VLVideoProcessor"),
("qwen2_vl", "Qwen2VLVideoProcessor"),
("qwen3_vl", "Qwen3VLVideoProcessor"),
("qwen3_vl_moe", "Qwen3VLVideoProcessor"),
("sam2_video", "Sam2VideoVideoProcessor"),
("smolvlm", "SmolVLMVideoProcessor"),
("video_llava", "VideoLlavaVideoProcessor"),
Expand Down
29 changes: 29 additions & 0 deletions src/transformers/models/qwen3_vl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2025 The Qwen Team and The HuggingFace Inc. 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.
from typing import TYPE_CHECKING

from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure


if TYPE_CHECKING:
from .configuration_qwen3_vl import *
from .modeling_qwen3_vl import *
from .processing_qwen3_vl import *
from .video_processing_qwen3_vl import *
else:
import sys

_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
Loading