Repository navigation
Add LLaVA-OneVision-1.5 model and related configurations #41095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <!--Copyright 2025 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. | ||
| ⚠️ 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 contributed to Hugging Face Transformers on 2026-11-11.* | ||
|
|
||
| # LLaVA-OneVision-1.5 | ||
|
|
||
| LLaVA-OneVision-1.5 was introduced in [LLaVA-OneVision-1.5: Fully Open Framework for Democratized Multimodal Training](https://huggingface.co/papers/2509.23661). | ||
| It combines a native resolution vision encoder with a Qwen3 language backbone. The vision encoder adds a learned class token to each image, applies full attention, removes the class token, and merges spatial patches into visual features for the language model. The language backbone uses ordinary one dimensional rotary positions for the combined image and text sequence. | ||
|
|
||
| The implementation reuses the Qwen2.5-VL processor and supports the converted [4B checkpoint](https://huggingface.co/Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf). Use left padding for batched generation. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to mentioned code implem here, can just say we support these ckpts/hub collection |
||
|
|
||
| ## Abstract | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no new section needed, abstract is part of overview and is usually formatted in italics |
||
|
|
||
| The [paper's abstract](https://arxiv.org/abs/2509.23661) describes an open framework for training vision-language models from scratch at a reduced cost. Its release includes a concept-balanced collection of 85 million pretraining examples, a curated instruction dataset containing 22 million examples, and a training system that uses offline parallel packing. The authors report a training budget of $16,000. In their evaluation, the 8B model exceeds Qwen2.5-VL-7B on 18 out of 27 benchmarks, while the 4B model exceeds Qwen2.5-VL-3B on all 27. The report also describes a lightweight reinforcement learning stage that improves multimodal reasoning through chain-of-thought responses. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from transformers import AutoProcessor, LlavaOnevision15ForConditionalGeneration | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use |
||
|
|
||
| model_id = "Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf" | ||
| processor = AutoProcessor.from_pretrained(model_id) | ||
| model = LlavaOnevision15ForConditionalGeneration.from_pretrained(model_id, device_map="auto") | ||
| messages = [{"role": "user", "content": [ | ||
| {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"}, | ||
| {"type": "text", "text": "Describe the image."}, | ||
| ]}] | ||
| inputs = processor.apply_chat_template( | ||
| messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt" | ||
| ).to(model.device) | ||
| output = model.generate(**inputs, max_new_tokens=64) | ||
| processor.batch_decode(output[:, inputs.input_ids.shape[1]:], skip_special_tokens=True) | ||
| ``` | ||
|
Comment on lines
+31
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. niit: just a little more spacing for readability would be nice |
||
|
|
||
| ## Export | ||
|
|
||
| The vision encoder can be exported with `DynamoExporter`, which prepares grid metadata before tracing. The shared vision attention export adapter requires equal patch counts per frame. The number of frames and their patch counts are specialized to the export inputs; export a new graph when these change. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, imo not needed, many VLM models uspport tracing by default atp |
||
|
|
||
| ## LlavaOnevision15Config | ||
|
|
||
| [[autodoc]] LlavaOnevision15Config | ||
|
|
||
| ## LlavaOnevision15VisionConfig | ||
|
|
||
| [[autodoc]] LlavaOnevision15VisionConfig | ||
|
|
||
| ## LlavaOnevision15VisionModel | ||
|
|
||
| [[autodoc]] LlavaOnevision15VisionModel | ||
| - forward | ||
|
|
||
| ## LlavaOnevision15Model | ||
|
|
||
| [[autodoc]] LlavaOnevision15Model | ||
| - forward | ||
|
|
||
| ## LlavaOnevision15ForConditionalGeneration | ||
|
|
||
| [[autodoc]] LlavaOnevision15ForConditionalGeneration | ||
| - forward | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,12 @@ def _build_checkpoint_conversion_mapping(): | |
| WeightRenaming(r"\.mlp\.up_proj\.", ".mlp.fc1."), | ||
| WeightRenaming(r"\.mlp\.down_proj\.", ".mlp.fc2."), | ||
| ], | ||
| "llava_onevision1_5": [ | ||
| WeightRenaming(r"merger\.mlp\.0\.", "merger.fc1."), | ||
| WeightRenaming(r"merger\.mlp\.2\.", "merger.fc2."), | ||
| WeightRenaming(r"^visual\.", "model.visual."), | ||
| WeightRenaming(r"^model\.(?!language_model\.|visual\.)", "model.language_model."), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is same as below and imo better to point/alias it Same as this: Then can point like this:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and to check if Base model also needs conversion, has to be loadable from real ckpt without errors |
||
| ], | ||
| "inkling_mm_model": [ | ||
| WeightRenaming(source_patterns=r"model\.llm\.layers", target_patterns=r"model.language_model.layers"), | ||
| WeightRenaming( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -520,6 +520,9 @@ def _prepare_grid_thw_vision_inputs(model: torch.nn.Module, inputs: dict[str, An | |
| include_temporal = getattr(model, "include_temporal", False) | ||
| inputs["position_ids"] = get_vision_position_ids(grid_thw, spatial_merge_size, include_temporal=include_temporal) | ||
|
|
||
| if model.config.model_type == "llava_onevision1_5_vision": | ||
| inputs["frame_lengths"] = module.get_vision_frame_lengths(inputs["cu_seqlens"]) | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use same convention as in kimi with |
||
| window_size = _find_submodule_attr(model, "window_size") | ||
| patch_size = _find_submodule_attr(model, "patch_size") | ||
| if window_size is not None and patch_size is not None: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ | |
| ("hyperclovax_vision_v2", {"torchvision": "Qwen2VLVideoProcessor"}), | ||
| ("instructblip", {"torchvision": "InstructBlipVideoVideoProcessor"}), | ||
| ("lfm3_vl", {"torchvision": "Qwen3VLVideoProcessor"}), | ||
| ("llava_onevision1_5", {"torchvision": "Qwen2VLVideoProcessor"}), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super super nice on mapping processors to existing classes 🫶 |
||
| ("minicpmv4_7", {"torchvision": "MiniCPMV4_6VideoProcessor"}), | ||
| ("muse_spark", {"torchvision": "MuseGlimmerVideoProcessor"}), | ||
| ("pe_audio_video", {"torchvision": "PeVideoVideoProcessor"}), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to re-check that it's 2026 everywhere :)