Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
647ac9d
add: hcx vision model
jp1924 Feb 27, 2026
f420da6
add: modeling test
jp1924 Feb 27, 2026
3aeac2e
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Feb 27, 2026
c3f0231
fix: update vision model selection logic for HCXVisionModel
jp1924 Feb 27, 2026
d231dff
fix: prepare_inputs_for_generation to handle first iteration logic
jp1924 Feb 27, 2026
e67eaf7
fix: IndentationError:
jp1924 Feb 27, 2026
a33087b
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 1, 2026
26ad483
fix: lint
jp1924 Mar 1, 2026
7df5a6d
fix: update conditional checks for model type comparisons
jp1924 Mar 1, 2026
8638c8b
fix: set pixel_values and pixel_values_videos to None when not first …
jp1924 Mar 1, 2026
f459f54
fix: remove unnecessary coding declaration from HyperClovaX configura…
jp1924 Mar 1, 2026
2fff572
fix: streamline imports in test_modeling_hyperclovax_vision.py
jp1924 Mar 1, 2026
0212ef5
fix: add hyperclovax model type to SPECIAL_MODEL_TYPE_TO_MODULE_NAME …
jp1924 Mar 1, 2026
eb222b7
fix: add docstrings for image and video grid dimensions in HCXVisionF…
jp1924 Mar 1, 2026
781c956
fix: update docstrings for parameters in HyperClovaX configuration an…
jp1924 Mar 1, 2026
c59d586
test: add unit tests for HyperClovaXProcessor functionality and chat …
jp1924 Mar 1, 2026
21816a2
fix: update image processing logic and enhance multimodal token handl…
jp1924 Mar 1, 2026
843f314
fix: update parameter types and docstrings in HyperClovaX configurati…
jp1924 Mar 1, 2026
bd62dfa
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 3, 2026
05ff2e9
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 10, 2026
a509a21
'models/auto' change
jp1924 Mar 12, 2026
82b81f0
remove image processor
jp1924 Mar 12, 2026
ab921aa
Refactor HyperClovaX configuration classes and update type hints for …
jp1924 Mar 12, 2026
6add4b7
Change the class name to HCXVisionV2Processor and update the image/vi…
jp1924 Mar 12, 2026
23040f4
Refactor HCXVisionModel and related classes: rename HyperClovaXConfig…
jp1924 Mar 12, 2026
9b03a52
Add checkpoint conversion mapping for hcxvision model
jp1924 Mar 12, 2026
a5955d1
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 12, 2026
85b38c1
Fix formatting issue in processor mapping section
jp1924 Mar 13, 2026
76182ab
HyperClovaXForCausalLM -> HyperClovaXTextModel
jp1924 Mar 13, 2026
8a0aae6
add hyperclovax_vision conversion mapping
jp1924 Mar 13, 2026
148254b
rm breakpoint()
jp1924 Mar 13, 2026
97ba6f4
Remove unused imports and refactor
jp1924 Mar 13, 2026
b36fe34
add modular file
jp1924 Mar 13, 2026
f3a116b
HCXVisionConfig: remove model_type from kwargs in constructor
jp1924 Mar 13, 2026
72473dc
HCXVisionModelTester: refactor imports and update config usage to HCX…
jp1924 Mar 13, 2026
aeb2b0e
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 13, 2026
434d253
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 16, 2026
1a66ff5
Add video support and update image handling in HCXVision integration …
jp1924 Mar 16, 2026
851d8e8
fix: video in-place error
jp1924 Mar 16, 2026
bd14fe8
refactor: simplify auto_map handling and update model_type for HCXVis…
jp1924 Mar 16, 2026
5968960
fix: update sub_configs to use AutoConfig for text_config in HCXVisio…
jp1924 Mar 16, 2026
bbbc25e
fix: update HCXVisionModel to use Qwen2_5_VLVisionConfig for vision c…
jp1924 Mar 16, 2026
c2eecb5
fix: add inv_freq initialization for Qwen2_5_VisionRotaryEmbedding in…
jp1924 Mar 16, 2026
1cdac66
fix: remove mm_projector_type parameter from HCXVisionModelTester
jp1924 Mar 16, 2026
41cea6a
fix: add mm_projector_type parameter to HCXVisionModelTester and remo…
jp1924 Mar 16, 2026
714e3ae
fix: remove mm_projector_type parameter and skip unsupported tests in…
jp1924 Mar 16, 2026
30f2e46
fix: remove unsupported test cases and add reverse loading mapping te…
jp1924 Mar 16, 2026
2b85eeb
fix: remove unused parameters from HyperClovaXConfig and HCXVisionConfig
jp1924 Mar 16, 2026
ab7e019
fix: format code for better readability in HCXVisionV2Processor
jp1924 Mar 16, 2026
6b9c917
fix: simplify weight renaming patterns in checkpoint conversion mappi…
jp1924 Mar 16, 2026
9818509
fix: update copyright year and correct processor import in HyperClova…
jp1924 Mar 16, 2026
d5f814f
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 16, 2026
5ac0ec1
fix: remove 'hcxvision' from VLMS model list
jp1924 Mar 16, 2026
7667b0d
feat: add 'hyperclovax_vision' to VLMS model list
jp1924 Mar 16, 2026
058e84c
fix: remove 'hcxvision' conversion mapping from checkpoint conversion
jp1924 Mar 16, 2026
55cdd31
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 16, 2026
f2199fc
fix: update HyperClovaX vision model names in configuration and proce…
jp1924 Mar 16, 2026
bb7c123
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 17, 2026
8c48213
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 17, 2026
5af4a31
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 18, 2026
0d5d548
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 18, 2026
f77d904
fix: update weight renaming for hyperclovax_vision mapping
jp1924 Mar 19, 2026
3b7cc5b
fix: update copyright year and refactor HyperClovaX configuration cla…
jp1924 Mar 19, 2026
f14d8df
refactor: clean up imports and remove unused classes in modular_hyper…
jp1924 Mar 19, 2026
113c360
Refactor HyperClovaX model components and update class names
jp1924 Mar 19, 2026
50acbe9
feat: model configuration mappings for Qwen2_5_VL and HyperClovaX
jp1924 Mar 19, 2026
db81d86
feat: update model type to 'qwen2_5_vl_image' and add VisionTransform…
jp1924 Mar 19, 2026
eb498d6
fix: ename vision_config to vision_model in HCXVisionModel
jp1924 Mar 19, 2026
4c02f57
fix: rename vision_config to vision_model in HCXVisionModel
jp1924 Mar 19, 2026
2d64070
add weight renaming mappings for HyperClovaX model
jp1924 Mar 19, 2026
9725d57
fix: update HyperClovaX and HCXVision model type mappings
jp1924 Mar 19, 2026
1b99fa9
fix: update output handling in HCXVisionModel and modify processor cl…
jp1924 Mar 19, 2026
f341f97
fix: update HCXVisionModel and processor class attributes for improve…
jp1924 Mar 19, 2026
4b3ed30
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 19, 2026
2a3b4ac
feat: enhance HCXVisionModel with new methods for handling video and …
jp1924 Mar 19, 2026
a8fb5bd
feat: refactor HCXVisionModel to extend VideoLlama3Model and streamli…
jp1924 Mar 19, 2026
23fd708
feat: update HCXVisionModel and configuration for improved handling o…
jp1924 Mar 19, 2026
9838ff3
feat: remove redundant pixel_values type conversion in HCXVisionModel
jp1924 Mar 19, 2026
f69d101
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 19, 2026
d65cfce
apply fix-repo
jp1924 Mar 19, 2026
532768c
feat: refactor HCXVisionModel to streamline forward method and enhanc…
jp1924 Mar 19, 2026
57695f9
feat: update hyperclovax model configurations and rename mappings for…
jp1924 Mar 20, 2026
6865715
feat: update weight renaming mappings for VLM and hyperclovax models
jp1924 Mar 20, 2026
dbf1a4d
feat: update HCXVisionModel to support optional video_merge_sizes par…
jp1924 Mar 20, 2026
c3d26ac
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 26, 2026
ea1e6b7
Edit review 3999491762
jp1924 Mar 30, 2026
5cef112
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Mar 30, 2026
92c75e0
refactor: simplify weight renaming patterns and enhance vision config…
jp1924 Apr 1, 2026
7ef1cc9
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 1, 2026
2d24b65
refactor: hyperclovax_vision > hyperclovax_vision_v2
jp1924 Apr 6, 2026
6602e5b
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 6, 2026
2589d01
fix: update config type in HCXVisionV2ForSequenceClassification to HC…
jp1924 Apr 6, 2026
3d9662d
config & processor to modular
jp1924 Apr 7, 2026
bb5769f
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 7, 2026
361d35f
fix test-error
jp1924 Apr 8, 2026
8d873c3
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 8, 2026
ef7b049
update processor test
jp1924 Apr 8, 2026
8f085c8
remove unused import
jp1924 Apr 8, 2026
9000231
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 10, 2026
c2bc144
fix: syntax error
jp1924 Apr 10, 2026
83748fb
feat: add forward method for HCXVisionV2ForSequenceClassification wit…
jp1924 Apr 13, 2026
dbea6b5
fix date
jp1924 Apr 13, 2026
9437fb8
Merge branch 'main' into feat/hcx-seed-32b
jp1924 Apr 13, 2026
7fb344a
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 11, 2026
41b1a00
remove hypercloax & fix test error
jp1924 May 11, 2026
a56fd5c
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 11, 2026
01c4964
fix `image_newline` failures
jp1924 May 11, 2026
3db1711
fix `test_transformers_specific_model_import` failures
jp1924 May 11, 2026
dcbc59e
rm hyperclovax docs
jp1924 May 11, 2026
23a8be5
refactor: simplify import statements in configuration_auto.py
jp1924 May 11, 2026
c03e704
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 18, 2026
4c8d788
Update HyperCLOVAX Vision V2 documentation and code structure
jp1924 May 18, 2026
c2cf581
hyperclovax: update conversion mapping and simplify reverse loading test
jp1924 May 18, 2026
fbb6a4d
revert hyperclovax_vlm
jp1924 May 18, 2026
7f89129
add comment to clarify model type usage in HCXVisionV2Config
jp1924 May 18, 2026
ed957e7
HCXVisionV2Model refactor inheritance to include HCXVisionV2PreTraine…
jp1924 May 18, 2026
e941367
Update src/transformers/models/hyperclovax_vision_v2/modular_hyperclo…
jp1924 May 26, 2026
0c64154
Update docs/source/en/model_doc/hyperclovax_vision_v2.md
jp1924 May 26, 2026
80a9622
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 26, 2026
d2740d3
Refactor HyperCLOVAX Vision V2 model and processor classes
jp1924 May 26, 2026
a4e7a48
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 26, 2026
42a028a
refactor test and modular
jp1924 May 26, 2026
88e9c63
docs: update HyperCLOVAX Vision V2 model documentation and examples
jp1924 May 27, 2026
36388fa
Merge branch 'main' into feat/hcx-seed-32b
jp1924 May 27, 2026
0d112c7
fix: remove hyperclovax tokenizer
jp1924 May 27, 2026
724f795
Merge branch 'huggingface:main' into feat/hcx-seed-32b
jp1924 May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@
title: Grounding DINO
- local: model_doc/groupvit
title: GroupViT
- local: model_doc/hyperclovax_vision_v2
title: HyperCLOVAX Vision V2
- local: model_doc/idefics
title: IDEFICS
- local: model_doc/idefics2
Expand Down
265 changes: 265 additions & 0 deletions docs/source/en/model_doc/hyperclovax_vision_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
<!--Copyright 2026 NAVER Corp. 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 {release_date} and added to Hugging Face Transformers on 2026-05-26.*

<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<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>

# HyperCLOVAX Vision V2

HyperCLOVAX Vision V2 is a multimodal vision-language model developed by NAVER. It combines the [HyperClovaX](./hyperclovax.md) language model backbone with a [Qwen2.5-VL](./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>`).

You can find the original HyperCLOVAX-SEED-Think-32B checkpoint on the [naver-hyperclovax/HyperCLOVAX-SEED-Think-32B](https://huggingface.co/naver-hyperclovax/HyperCLOVAX-SEED-Think-32B) page.

The example below demonstrates how to generate text based on an image with [`HyperCLOVAXVisionV2ForConditionalGeneration`].

<hfoptions id="usage">
<hfoption id="Image input">

```python
from transformers import HyperCLOVAXVisionV2ForConditionalGeneration, HyperCLOVAXVisionV2Processor

model = HyperCLOVAXVisionV2ForConditionalGeneration.from_pretrained(
"naver-hyperclovax/HyperCLOVAX-SEED-Think-32B",
device_map="auto",
)
processor = HyperCLOVAXVisionV2Processor.from_pretrained("naver-hyperclovax/HyperCLOVAX-SEED-Think-32B")

messages = [
{
"role": "system",
"content": "You are a helpful assistant.",
},
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {"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,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)

generated_ids = model.generate(**inputs, max_new_tokens=256)
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>
<hfoption id="Video input">

```python
from transformers import HyperCLOVAXVisionV2ForConditionalGeneration, HyperCLOVAXVisionV2Processor

model = HyperCLOVAXVisionV2ForConditionalGeneration.from_pretrained(
"naver-hyperclovax/HyperCLOVAX-SEED-Think-32B",
device_map="auto",
)
processor = HyperCLOVAXVisionV2Processor.from_pretrained("naver-hyperclovax/HyperCLOVAX-SEED-Think-32B")

messages = [
{
"role": "system",
"content": "You are a helpful assistant.",
},
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {"url": "/path/to/video.mp4"},
},
{"type": "text", "text": "Describe this video."},
],
},
]

# Use processor.tokenizer.apply_chat_template for video inputs.
# processor.apply_chat_template rewrites image_url to image before the
# template runs, which breaks HCX's extension-based video detection.
text = processor.tokenizer.apply_chat_template(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird, why are we even using image url --> shouldnt it be video url to properly distinguish between img/video? cc @zucchini-nlp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, didn't see it. I believe related ti how the jinja template is saved on the hub

This indeed looks weird, lets' ping the Naver team to change model-type/jinja/etc or ask them to host a non-remote version. @jp1924 , when you are done passing over comments, could you list the things we need to change on the hub and ping @ (bigshanedogg). We need to either push directly to the existing repo or upload a new repo with {{MODELNAME}}-hf suffix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#44314 (comment)
You can check the details via this link.
Sharing the text below as well since the link is dead.

I added this logic because video handling for HCX is broken on recent versions of transformers.

If you look at HCX's chat_template.jinja, it handles image/video differently from most models.  
Models like `Qwen2_5_vl` or `VideoLLaMA3` expect multimodal items in a normalized form such as `{"type": "image"}` or `{"type": "video"}`.  
HCX, however, uses `{"type": "image_url", "image_url": {"url": "video.mp4"}}` and `{"type": "image_url", "image_url": {"url": "image.png"}}`, then branches by file extension inside the template.

In newer transformers, this block rewrites image_url into image:
https://github.com/huggingface/transformers/blob/2da00a3cec88fac160d481406e7961cf59472894/src/transformers/processing_utils.py#L1792-L1799

Because of that rewrite, HCX's image_url-based branch no longer triggers correctly. As a result, even when a video is provided, it gets rendered like plain text:

    ```
    >>> from transformers import AutoProcessor
    >>> processor = AutoProcessor.from_pretrained("naver-hyperclovax/HyperCLOVAX-SEED-Think-32B", trust_remote_code=False)
    You are using a model of type `vlm` to instantiate a model of type ``. This may be expected if you are loading a checkpoint that shares a subset of the architecture (e.g., loading a `sam2_video` checkpoint into `Sam2Model`), but is otherwise not supported and can yield errors. Please verify that the checkpoint is compatible with the model you are instantiating.
    >>> video_messages = [
    ...     {
    ...         "role": "user",
    ...         "content": [
    ...             {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/bedroom.mp4"}},
    ...             {"type": "text", "text": "What is shown in this video?"},
    ...         ],
    ...     }
    ... ]
    >>> text = processor.apply_chat_template(video_messages, tokenize=False, add_generation_prompt=True)
    >>> text
    '<|im_start|>user\n\nWhat is shown in this video?<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n'
    >>> video_messages
    [{'role': 'user', 'content': [{'type': 'image', 'url': 'https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/bedroom.mp4'}, {'type': 'text', 'text': 'What is shown in this video?'}]}]

    ```

If it were working correctly, the output should include the video MIME and video tokens, e.g. mime_start / video_aux_start / VIDEO_PAD, not the plain-text-only prompt above.

bigshanedogg The current multimodal input contract in naver-hyperclovax/HyperCLOVAX-SEED-Think-32B is non-standard.  
I opened a Hub discussion/PR to update chat_template.jinja so it aligns with current processor behavior:
https://huggingface.co/naver-hyperclovax/HyperCLOVAX-SEED-Think-32B/discussions/12

zucchini-nlp Until that template update is merged, we need to keep this compatibility code in this PR.  
I'll follow up again once we have a decision on the Hub-side template PR.

messages,
add_generation_prompt=True,
tokenize=False,
)
inputs = processor(
text=text,
videos=["/path/to/video.mp4"],
return_tensors="pt",
).to(model.device)

generated_ids = model.generate(**inputs, max_new_tokens=256)
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>

Quantization reduces the memory burden of large models by representing the weights in a lower precision. Refer to the [Quantization](../quantization/overview) overview for more available quantization backends.

The example below uses [bitsandbytes](../quantization/bitsandbytes) to load the model in 4-bit.

```python
from transformers import BitsAndBytesConfig, HyperCLOVAXVisionV2ForConditionalGeneration, HyperCLOVAXVisionV2Processor

quantization_config = BitsAndBytesConfig(load_in_4bit=True)
model = HyperCLOVAXVisionV2ForConditionalGeneration.from_pretrained(
"naver-hyperclovax/HyperCLOVAX-SEED-Think-32B",
device_map="auto",
quantization_config=quantization_config,
)
processor = HyperCLOVAXVisionV2Processor.from_pretrained("naver-hyperclovax/HyperCLOVAX-SEED-Think-32B")
```

## Notes

- HyperCLOVAX Vision V2 uses a unique media input format. Both images and videos are specified using `{"type": "image_url", "image_url": {"url": "..."}}`. The processor and chat template distinguish images from videos by file extension (`.mp4`, `.avi`, `.mov`, `.mkv`, `.webm`, `.flv`, `.wmv`, `.m4v` are treated as video; everything else is treated as image).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok this is the explicit change, imo would maybe make sense to have a different chat template if possible. This really is weird


```python
# Image input
{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}

# Video input (identified by file extension)
{"type": "image_url", "image_url": {"url": "/path/to/video.mp4"}}
```

> [!WARNING]
> Video input via `processor.apply_chat_template` is currently broken. Recent Transformers versions rewrite `image_url` entries to `image` before the chat template runs, so the video-detection branch in HCX's template never triggers and video inputs are silently dropped. As a workaround, use `processor.tokenizer.apply_chat_template` to render the prompt text, then pass the video path separately to `processor(...)`. See [this review comment](https://github.com/huggingface/transformers/pull/44314#discussion_r3008382827) for details.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the review comment is closed, cant load via url it seems

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reopened the comment.


- The model supports chain-of-thought reasoning. By default, the generation prompt prepends an empty `<think>\n\n</think>` block. To generate an explicit reasoning trace inside `<think>...</think>` tags, pass `thinking=True` to `apply_chat_template` (image/text inputs only):

```python
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
thinking=True,
).to(model.device)
```

- The model supports multi-turn conversations with mixed media. Images and videos can appear across multiple turns. For turns containing video, use the `processor.tokenizer.apply_chat_template` workaround described above.

```python
messages = [
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://example.com/image1.jpg"}},
{"type": "text", "text": "What do you see in this image?"},
],
},
{
"role": "assistant",
"content": "I see a cat sitting on a couch.",
},
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://example.com/image2.jpg"}},
{"type": "text", "text": "How does this compare to the first image?"},
],
},
]
```

- The model supports function/tool calling. Pass tools using the `tools` parameter in `apply_chat_template`:

```python
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location.",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"},
},
"required": ["location"],
},
},
}
]

messages = [
{"role": "user", "content": "What is the weather in Seoul?"}
]

inputs = processor.apply_chat_template(
messages,
tools=tools,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
```

## HyperCLOVAXVisionV2Config

[[autodoc]] HyperCLOVAXVisionV2Config

## HyperCLOVAXVisionV2Processor

[[autodoc]] HyperCLOVAXVisionV2Processor
- __call__

## HyperCLOVAXVisionV2Model

[[autodoc]] HyperCLOVAXVisionV2Model
- forward
- get_image_features
- get_video_features

## HyperCLOVAXVisionV2ForConditionalGeneration

[[autodoc]] HyperCLOVAXVisionV2ForConditionalGeneration
- forward
- get_image_features
- get_video_features

## HyperCLOVAXVisionV2ForSequenceClassification

[[autodoc]] HyperCLOVAXVisionV2ForSequenceClassification
- forward
33 changes: 21 additions & 12 deletions docs/source/en/model_doc/qwen2_5_vl.md
Comment thread
jp1924 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
],
}
]

inputs = processor.apply_chat_template(
conversation,
fps=1,
Expand All @@ -150,7 +150,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
return_dict=True,
return_tensors="pt"
).to(model.device)

# Inference: Generation of the output
output_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs.input_ids, output_ids)]
Expand All @@ -164,7 +164,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
```python
import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor

model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"Qwen/Qwen2.5-VL-7B-Instruct",
device_map="auto",
Expand All @@ -175,7 +175,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
{
"role": "user",
"content": [
{"type": "image"},
{"type": "image"},
{"type": "text", "text": "Hello, how are you?"}
]
},
Expand All @@ -186,10 +186,10 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
{
"role": "user",
"content": [
{"type": "text", "text": "Can you describe these images and video?"},
{"type": "image"},
{"type": "image"},
{"type": "video"},
{"type": "text", "text": "Can you describe these images and video?"},
{"type": "image"},
{"type": "image"},
{"type": "video"},
{"type": "text", "text": "These are from my vacation."}
]
},
Expand All @@ -202,12 +202,12 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"content": "It was a trip to the mountains. Can you see the details in the images and video?"
}
]

# default:
prompt_without_id = processor.apply_chat_template(conversation, add_generation_prompt=True)
# Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Hello, how are you?<|im_end|>\n<|im_start|>assistant\nI'm doing well, thank you for asking. How can I assist you today?<|im_end|>\n<|im_start|>user\nCan you describe these images and video?<|vision_start|><|image_pad|><|vision_end|><|vision_start|><|image_pad|><|vision_end|><|vision_start|><|video_pad|><|vision_end|>These are from my vacation.<|im_end|>\n<|im_start|>assistant\nI'd be happy to describe the images and video for you. Could you please provide more context about your vacation?<|im_end|>\n<|im_start|>user\nIt was a trip to the mountains. Can you see the details in the images and video?<|im_end|>\n<|im_start|>assistant\n'


# add ids
prompt_with_id = processor.apply_chat_template(conversation, add_generation_prompt=True, add_vision_id=True)
# Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nPicture 1: <|vision_start|><|image_pad|><|vision_end|>Hello, how are you?<|im_end|>\n<|im_start|>assistant\nI'm doing well, thank you for asking. How can I assist you today?<|im_end|>\n<|im_start|>user\nCan you describe these images and video?Picture 2: <|vision_start|><|image_pad|><|vision_end|>Picture 3: <|vision_start|><|image_pad|><|vision_end|>Video 1: <|vision_start|><|video_pad|><|vision_end|>These are from my vacation.<|im_end|>\n<|im_start|>assistant\nI'd be happy to describe the images and video for you. Could you please provide more context about your vacation?<|im_end|>\n<|im_start|>user\nIt was a trip to the mountains. Can you see the details in the images and video?<|im_end|>\n<|im_start|>assistant\n'
Expand All @@ -225,7 +225,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(

```python
min_pixels = 256*28*28
max_pixels = 1024*28*28
max_pixels = 1024*28*28
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
```

Expand All @@ -241,6 +241,10 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(

[[autodoc]] Qwen2_5_VLTextConfig

## Qwen2_5_VLVisionConfig

[[autodoc]] Qwen2_5_VLVisionConfig

## Qwen2_5_VLProcessor

[[autodoc]] Qwen2_5_VLProcessor
Expand All @@ -251,6 +255,11 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
[[autodoc]] Qwen2_5_VLTextModel
- forward

## Qwen2_5_VisionTransformerPretrainedModel

[[autodoc]] Qwen2_5_VisionTransformerPretrainedModel
Comment thread
jp1924 marked this conversation as resolved.
- forward

## Qwen2_5_VLModel

[[autodoc]] Qwen2_5_VLModel
Expand Down
2 changes: 2 additions & 0 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,8 @@
title: Grounding DINO
- local: in_translation
title: GroupViT
- local: model_doc/hyperclovax_vision_v2
title: HyperCLOVAX Vision V2
- local: in_translation
title: IDEFICS
- local: in_translation
Expand Down
Loading
Loading