Image-Text-to-Text
Transformers
Safetensors
llava_onevision2_5
text-generation
multimodal
video-understanding
streaming
llava-onevision
conversational
custom_code
Instructions to use lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct
- SGLang
How to use lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct with Docker Model Runner:
docker model run hf.co/lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct
Model card: shorter quickstart, settings as superscripts in the video table
Browse files- README.md +33 -85
- README_CN.md +33 -85
README.md
CHANGED
|
@@ -44,35 +44,35 @@ LLaVA-OneVision-2.5-4B-Instruct is a 4B vision-language model for single-image,
|
|
| 44 |
| Benchmark | Qwen3.5-4B | OV2.5-4B (frames) | OV2.5-4B (codec) |
|
| 45 |
|:---|:---:|:---:|:---:|
|
| 46 |
| **General video understanding** | | | |
|
| 47 |
-
| MotionBench | 60.1 | 62.4 | **64.2** |
|
| 48 |
-
| TOMATO \* | 34.9 | 33.6 | **38.6** |
|
| 49 |
-
| MVBench | 64.0 | 72.0 | **75.5** |
|
| 50 |
-
| NextQA MC test | 80.7 | 86.1 | **86.4** |
|
| 51 |
-
| TempCompass MC | 73.4 | 75.8 | **79.7** |
|
| 52 |
-
| MMVU val | **52.6** | 44.1 | -- |
|
| 53 |
-
| Video-MME-v2 | 15.5 | 16.4 | **17.2** |
|
| 54 |
-
| EgoSchema subset | 68.2 | **80.0** | -- |
|
| 55 |
-
| Video-Index 512f | 19.6 | **20.0** | 19.8 |
|
| 56 |
-
| MMOU test-mini | -- | 46.0 | -- |
|
| 57 |
| **VideoMME** | | | |
|
| 58 |
-
| short, no subtitles | **81.7** | 79.7 | 81.1 |
|
| 59 |
-
| medium, no subtitles | 70.3 | 70.6 | **74.1** |
|
| 60 |
-
| long, no subtitles | **63.0** | 59.0 | 60.6 |
|
| 61 |
-
| short, subtitles | -- | 82.4 | **82.7** |
|
| 62 |
-
| medium, subtitles | -- | 75.4 | **75.6** |
|
| 63 |
-
| long, subtitles | -- | 65.8 | **65.9** |
|
| 64 |
| **Video spatial** | | | |
|
| 65 |
-
| VSI-Bench | 59.2 | **68.6** | 67.7 |
|
| 66 |
-
| ReVSI 64f | 47.1 | **55.9** | 55.5 |
|
| 67 |
| **Long video** | | | |
|
| 68 |
-
| LVBench | 56.5 | **62.0** | 61.6 |
|
| 69 |
-
| MLVU dev | 73.8 | **75.3** | -- |
|
| 70 |
-
| LongVideoBench val | 62.7 | 69.0 | **71.1** |
|
| 71 |
-
| VideoEval-Pro | 62.8 | 64.4 | **64.6** |
|
| 72 |
| **Temporal grounding (mIoU)** | | | |
|
| 73 |
-
| TimeLens ActivityNet | 53.8 | 58.8 | **59.1** |
|
| 74 |
-
| TimeLens Charades | 48.1 | 60.6 | **61.3** |
|
| 75 |
-
| TimeLens QVHighlights | 67.5 | 68.4 | **70.3** |
|
| 76 |
|
| 77 |
### Image
|
| 78 |
|
|
@@ -87,7 +87,7 @@ LLaVA-OneVision-2.5-4B-Instruct is a 4B vision-language model for single-image,
|
|
| 87 |
| OCRBench | **85.2** | 79.8 | EmbSpatial | 74.7 | **83.0** |
|
| 88 |
| DocVQA val | **95.2** | 92.9 | MMSI-Bench | 31.4 | **33.3** |
|
| 89 |
|
| 90 |
-
<sub>Compared with Qwen3.5-4B, thinking disabled. **Bold** is the best score in each row; `--` means not available. Each side reports its best score over the settings tried, from single runs. `*` On TOMATO the two sides use different frame settings. The image table shows selected benchmarks; full results, settings and protocol will be given in the technical report.</sub>
|
| 91 |
|
| 92 |
## Model Overview
|
| 93 |
|
|
@@ -140,9 +140,7 @@ with torch.inference_mode():
|
|
| 140 |
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 141 |
```
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
### Video: frame sampling
|
| 146 |
|
| 147 |
```python
|
| 148 |
messages = [{"role": "user", "content": [
|
|
@@ -159,16 +157,7 @@ inputs = processor(
|
|
| 159 |
).to(model.device)
|
| 160 |
```
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
```
|
| 165 |
-
<0.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 166 |
-
<1.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 167 |
-
```
|
| 168 |
-
|
| 169 |
-
### Video: codec mode
|
| 170 |
-
|
| 171 |
-
Codec mode packs the informative regions of the video into a few canvases. Patches on one canvas may come from different source frames, and each keeps its own `(source frame, row, column)` position. Preprocessing comes from `codec-video-prep` (Linux x86_64, CPython 3.10/3.11; H.264, HEVC, VP9 and AV1 files):
|
| 172 |
|
| 173 |
```bash
|
| 174 |
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \
|
|
@@ -181,57 +170,16 @@ inputs = processor(text=text, videos=["example.mp4"],
|
|
| 181 |
video_backend="codec", return_tensors="pt").to(model.device)
|
| 182 |
```
|
| 183 |
|
| 184 |
-
Defaults live in the `codec` field of `preprocessor_config.json` (512 candidate frames, 64 canvases, 313600 pixels per canvas) and can be overridden per call with `codec_config={"target_canvas": 32, ...}`.
|
| 185 |
-
|
| 186 |
### Streaming
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
| Mode | Call | Default system |
|
| 191 |
-
|---|---|---|
|
| 192 |
-
| Offline (default) | `apply_chat_template(messages, ...)` | `You are a helpful assistant.` |
|
| 193 |
-
| Streaming | `apply_chat_template(messages, ..., streaming=True)` | `You are a real-time streaming video assistant.` |
|
| 194 |
-
|
| 195 |
-
| Token | Id | Meaning |
|
| 196 |
-
|---|---|---|
|
| 197 |
-
| `<silence>` | 248077 | this turn: say nothing |
|
| 198 |
-
| `<response>` | 248078 | this turn: speak |
|
| 199 |
-
| `<question_memory>` / `</question_memory>` | 248079 / 248080 | a new question, written once when it is asked |
|
| 200 |
-
| `<answer_memory>` / `</answer_memory>` | 248081 / 248082 | an earlier answer, re-injected once it is due |
|
| 201 |
-
| `<captioning>` | 248083 | this turn: speak, as event-level captioning |
|
| 202 |
-
| `<caption_begin>` | 248084 | user-side marker that this stream is a captioning task |
|
| 203 |
-
|
| 204 |
-
Turns strictly alternate between user and assistant, with at most one frame per user turn. Give each frame its `timestamp`:
|
| 205 |
-
|
| 206 |
-
```python
|
| 207 |
-
messages = [{"role": "user", "content": [
|
| 208 |
-
{"type": "text", "text": '<question_memory>{"timestep": "00:00:00", "content": "What is he doing next?"}</question_memory>\n'},
|
| 209 |
-
{"type": "image", "timestamp": 0.0},
|
| 210 |
-
{"type": "text", "text": "\n"},
|
| 211 |
-
]}]
|
| 212 |
-
text = processor.apply_chat_template(
|
| 213 |
-
messages, tokenize=False, add_generation_prompt=True, streaming=True)
|
| 214 |
-
```
|
| 215 |
-
|
| 216 |
-
```
|
| 217 |
-
<|im_start|>user
|
| 218 |
-
<question_memory>{"timestep": "00:00:00", "content": "..."}</question_memory>
|
| 219 |
-
<0.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 220 |
-
<|im_end|>
|
| 221 |
-
<|im_start|>assistant
|
| 222 |
-
<silence><|im_end|>
|
| 223 |
-
```
|
| 224 |
-
|
| 225 |
-
The eight tokens are ordinary added tokens, so they survive `skip_special_tokens=True`: the state token is the output you read. The real-time loop around the model (frame scheduling, stopping, memory re-injection) is not part of this repository.
|
| 226 |
|
| 227 |
## Usage Tips
|
| 228 |
|
| 229 |
-
-
|
| 230 |
-
-
|
| 231 |
-
-
|
| 232 |
-
-
|
| 233 |
-
- **Ask for the format you will parse.** For multiple choice, add `Answer with the option's letter from the given choices directly.` For grounding, state the coordinate range, e.g. integers 0–1000.
|
| 234 |
-
- **Warm up before going multi-process.** Load the model once in a single process so the remote code is compiled before workers start.
|
| 235 |
|
| 236 |
## Citation
|
| 237 |
|
|
|
|
| 44 |
| Benchmark | Qwen3.5-4B | OV2.5-4B (frames) | OV2.5-4B (codec) |
|
| 45 |
|:---|:---:|:---:|:---:|
|
| 46 |
| **General video understanding** | | | |
|
| 47 |
+
| MotionBench | 60.1 <sup>128f×153,664</sup> | 62.4 <sup>128f×153,664</sup> | **64.2** <sup>TC128×313,600</sup> |
|
| 48 |
+
| TOMATO \* | 34.9 <sup>16f×153,664, fps=2</sup> | 33.6 <sup>model default</sup> | **38.6** <sup>TC128×313,600</sup> |
|
| 49 |
+
| MVBench | 64.0 <sup>64f×153,664</sup> | 72.0 <sup>64f×153,664</sup> | **75.5** <sup>TC64×313,600</sup> |
|
| 50 |
+
| NextQA MC test | 80.7 <sup>64f×153,664</sup> | 86.1 <sup>64f×153,664</sup> | **86.4** <sup>TC64×313,600</sup> |
|
| 51 |
+
| TempCompass MC | 73.4 <sup>64f×153,664</sup> | 75.8 <sup>64f×153,664</sup> | **79.7** <sup>TC64×313,600</sup> |
|
| 52 |
+
| MMVU val | **52.6** <sup>64f×153,664</sup> | 44.1 <sup>64f×153,664</sup> | -- |
|
| 53 |
+
| Video-MME-v2 | 15.5 <sup>64f×330,000</sup> | 16.4 <sup>64f×330,000</sup> | **17.2** <sup>TC64×313,600</sup> |
|
| 54 |
+
| EgoSchema subset | 68.2 <sup>64f×153,664</sup> | **80.0** <sup>64f×153,664</sup> | -- |
|
| 55 |
+
| Video-Index 512f | 19.6 <sup>task frames, ≤262,144/f</sup> | **20.0** <sup>task frames, ≤262,144/f</sup> | 19.8 <sup>TC≤256×313,600</sup> |
|
| 56 |
+
| MMOU test-mini | -- | 46.0 <sup>model default</sup> | -- |
|
| 57 |
| **VideoMME** | | | |
|
| 58 |
+
| short, no subtitles | **81.7** <sup>128f×321,489</sup> | 79.7 <sup>128f×321,489</sup> | 81.1 <sup>TC256×313,600</sup> |
|
| 59 |
+
| medium, no subtitles | 70.3 <sup>256f×136,900</sup> | 70.6 <sup>256f×136,900</sup> | **74.1** <sup>TC512×313,600</sup> |
|
| 60 |
+
| long, no subtitles | **63.0** <sup>1450f×120,000</sup> | 59.0 <sup>750f×250,000</sup> | 60.6 <sup>TC512×313,600</sup> |
|
| 61 |
+
| short, subtitles | -- | 82.4 <sup>128f×321,489</sup> | **82.7** <sup>TC256×313,600</sup> |
|
| 62 |
+
| medium, subtitles | -- | 75.4 <sup>256f×136,900</sup> | **75.6** <sup>TC256×313,600</sup> |
|
| 63 |
+
| long, subtitles | -- | 65.8 <sup>750f×250,000</sup> | **65.9** <sup>TC256×313,600</sup> |
|
| 64 |
| **Video spatial** | | | |
|
| 65 |
+
| VSI-Bench | 59.2 <sup>128f×153,664</sup> | **68.6** <sup>128f×153,664</sup> | 67.7 <sup>TC128×313,600</sup> |
|
| 66 |
+
| ReVSI 64f | 47.1 <sup>64f×153,664</sup> | **55.9** <sup>64f×153,664</sup> | 55.5 <sup>TC64×313,600</sup> |
|
| 67 |
| **Long video** | | | |
|
| 68 |
+
| LVBench | 56.5 <sup>2048f×120,000</sup> | **62.0** <sup>950f×200,000</sup> | 61.6 <sup>TC1024×156,800</sup> |
|
| 69 |
+
| MLVU dev | 73.8 <sup>512f×72,900</sup> | **75.3** <sup>512f×72,900</sup> | -- |
|
| 70 |
+
| LongVideoBench val | 62.7 <sup>700f×300,000</sup> | 69.0 <sup>1280f×80,000</sup> | **71.1** <sup>TC768×235,200</sup> |
|
| 71 |
+
| VideoEval-Pro | 62.8 <sup>2048f×100,000</sup> | 64.4 <sup>950f×200,000</sup> | **64.6** <sup>TC768×235,200</sup> |
|
| 72 |
| **Temporal grounding (mIoU)** | | | |
|
| 73 |
+
| TimeLens ActivityNet | 53.8 <sup>2048f×409,600, fps=4</sup> | 58.8 <sup>2048f×409,600, fps=4</sup> | **59.1** <sup>TC128×313,600</sup> |
|
| 74 |
+
| TimeLens Charades | 48.1 <sup>2048f×409,600, fps=4</sup> | 60.6 <sup>2048f×409,600, fps=4</sup> | **61.3** <sup>TC128×313,600</sup> |
|
| 75 |
+
| TimeLens QVHighlights | 67.5 <sup>2048f×409,600, fps=4</sup> | 68.4 <sup>2048f×409,600, fps=4</sup> | **70.3** <sup>TC128×313,600</sup> |
|
| 76 |
|
| 77 |
### Image
|
| 78 |
|
|
|
|
| 87 |
| OCRBench | **85.2** | 79.8 | EmbSpatial | 74.7 | **83.0** |
|
| 88 |
| DocVQA val | **95.2** | 92.9 | MMSI-Bench | 31.4 | **33.3** |
|
| 89 |
|
| 90 |
+
<sub>Compared with Qwen3.5-4B, thinking disabled. **Bold** is the best score in each row; `--` means not available. The superscript on each video score is the setting that produced it: frames × pixels per frame, or for codec, canvases (TC) × pixels per canvas. Each side reports its best score over the settings tried, from single runs. `*` On TOMATO the two sides use different frame settings. The image table shows selected benchmarks; full results, settings and protocol will be given in the technical report.</sub>
|
| 91 |
|
| 92 |
## Model Overview
|
| 93 |
|
|
|
|
| 140 |
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 141 |
```
|
| 142 |
|
| 143 |
+
### Video
|
|
|
|
|
|
|
| 144 |
|
| 145 |
```python
|
| 146 |
messages = [{"role": "user", "content": [
|
|
|
|
| 157 |
).to(model.device)
|
| 158 |
```
|
| 159 |
|
| 160 |
+
For codec mode, install `codec-video-prep` and pass `video_backend="codec"`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
```bash
|
| 163 |
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \
|
|
|
|
| 170 |
video_backend="codec", return_tensors="pt").to(model.device)
|
| 171 |
```
|
| 172 |
|
|
|
|
|
|
|
| 173 |
### Streaming
|
| 174 |
|
| 175 |
+
The checkpoint already supports streaming: pass `streaming=True` to `apply_chat_template`. The runtime library for real-time online inference is coming soon.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
## Usage Tips
|
| 178 |
|
| 179 |
+
- Pass video paths rather than pre-decoded frames, so the processor can recover real timestamps.
|
| 180 |
+
- Tune frame count and per-frame pixels together: cost is roughly their product.
|
| 181 |
+
- Decode greedily (`do_sample=False`) and leave a generous `max_new_tokens`.
|
| 182 |
+
- For multiple choice or grounding, state the answer format you expect in the prompt.
|
|
|
|
|
|
|
| 183 |
|
| 184 |
## Citation
|
| 185 |
|
README_CN.md
CHANGED
|
@@ -44,35 +44,35 @@ LLaVA-OneVision-2.5-4B-Instruct 是一个 4B 视觉语言模型,支持单图
|
|
| 44 |
| Benchmark | Qwen3.5-4B | OV2.5-4B(抽帧) | OV2.5-4B(codec) |
|
| 45 |
|:---|:---:|:---:|:---:|
|
| 46 |
| **通用视频理解** | | | |
|
| 47 |
-
| MotionBench | 60.1 | 62.4 | **64.2** |
|
| 48 |
-
| TOMATO \* | 34.9 | 33.6 | **38.6** |
|
| 49 |
-
| MVBench | 64.0 | 72.0 | **75.5** |
|
| 50 |
-
| NextQA MC test | 80.7 | 86.1 | **86.4** |
|
| 51 |
-
| TempCompass MC | 73.4 | 75.8 | **79.7** |
|
| 52 |
-
| MMVU val | **52.6** | 44.1 | -- |
|
| 53 |
-
| Video-MME-v2 | 15.5 | 16.4 | **17.2** |
|
| 54 |
-
| EgoSchema subset | 68.2 | **80.0** | -- |
|
| 55 |
-
| Video-Index 512f | 19.6 | **20.0** | 19.8 |
|
| 56 |
-
| MMOU test-mini | -- | 46.0 | -- |
|
| 57 |
| **VideoMME** | | | |
|
| 58 |
-
| short,无字幕 | **81.7** | 79.7 | 81.1 |
|
| 59 |
-
| medium,无字幕 | 70.3 | 70.6 | **74.1** |
|
| 60 |
-
| long,无字幕 | **63.0** | 59.0 | 60.6 |
|
| 61 |
-
| short,有字幕 | -- | 82.4 | **82.7** |
|
| 62 |
-
| medium,有字幕 | -- | 75.4 | **75.6** |
|
| 63 |
-
| long,有字幕 | -- | 65.8 | **65.9** |
|
| 64 |
| **视频空间** | | | |
|
| 65 |
-
| VSI-Bench | 59.2 | **68.6** | 67.7 |
|
| 66 |
-
| ReVSI 64f | 47.1 | **55.9** | 55.5 |
|
| 67 |
| **长视频** | | | |
|
| 68 |
-
| LVBench | 56.5 | **62.0** | 61.6 |
|
| 69 |
-
| MLVU dev | 73.8 | **75.3** | -- |
|
| 70 |
-
| LongVideoBench val | 62.7 | 69.0 | **71.1** |
|
| 71 |
-
| VideoEval-Pro | 62.8 | 64.4 | **64.6** |
|
| 72 |
| **时间定位(mIoU)** | | | |
|
| 73 |
-
| TimeLens ActivityNet | 53.8 | 58.8 | **59.1** |
|
| 74 |
-
| TimeLens Charades | 48.1 | 60.6 | **61.3** |
|
| 75 |
-
| TimeLens QVHighlights | 67.5 | 68.4 | **70.3** |
|
| 76 |
|
| 77 |
### 图像
|
| 78 |
|
|
@@ -87,7 +87,7 @@ LLaVA-OneVision-2.5-4B-Instruct 是一个 4B 视觉语言模型,支持单图
|
|
| 87 |
| OCRBench | **85.2** | 79.8 | EmbSpatial | 74.7 | **83.0** |
|
| 88 |
| DocVQA val | **95.2** | 92.9 | MMSI-Bench | 31.4 | **33.3** |
|
| 89 |
|
| 90 |
-
<sub>对比对象为关闭 thinking 的 Qwen3.5-4B。**加粗**为该行最高分,`--` 表示暂无结果。两边各取
|
| 91 |
|
| 92 |
## 模型概览
|
| 93 |
|
|
@@ -140,9 +140,7 @@ with torch.inference_mode():
|
|
| 140 |
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 141 |
```
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
### 视频:抽帧
|
| 146 |
|
| 147 |
```python
|
| 148 |
messages = [{"role": "user", "content": [
|
|
@@ -159,16 +157,7 @@ inputs = processor(
|
|
| 159 |
).to(model.device)
|
| 160 |
```
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
```
|
| 165 |
-
<0.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 166 |
-
<1.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 167 |
-
```
|
| 168 |
-
|
| 169 |
-
### 视频:codec 模式
|
| 170 |
-
|
| 171 |
-
codec 模式把视频中信息量大的区域打包进少量画布。同一张画布上的 patch 可以来自不同源帧,各自保留 `(源帧, 行, 列)` 位置。预处理来自 `codec-video-prep`(Linux x86_64,CPython 3.10/3.11;支持 H.264、HEVC、VP9、AV1 文件):
|
| 172 |
|
| 173 |
```bash
|
| 174 |
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \
|
|
@@ -181,57 +170,16 @@ inputs = processor(text=text, videos=["example.mp4"],
|
|
| 181 |
video_backend="codec", return_tensors="pt").to(model.device)
|
| 182 |
```
|
| 183 |
|
| 184 |
-
默认配置在 `preprocessor_config.json` 的 `codec` 字段(512 候选帧、64 画布、每画布 313600 像素),单次调用可用 `codec_config={"target_canvas": 32, ...}` 覆盖。
|
| 185 |
-
|
| 186 |
### 流式
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
| 模式 | 调用 | 默认 system |
|
| 191 |
-
|---|---|---|
|
| 192 |
-
| 离线(默认) | `apply_chat_template(messages, ...)` | `You are a helpful assistant.` |
|
| 193 |
-
| 流式 | `apply_chat_template(messages, ..., streaming=True)` | `You are a real-time streaming video assistant.` |
|
| 194 |
-
|
| 195 |
-
| Token | Id | 含义 |
|
| 196 |
-
|---|---|---|
|
| 197 |
-
| `<silence>` | 248077 | 当前轮不发言 |
|
| 198 |
-
| `<response>` | 248078 | 当前轮发言 |
|
| 199 |
-
| `<question_memory>` / `</question_memory>` | 248079 / 248080 | 新问题,在提问时刻写入一次 |
|
| 200 |
-
| `<answer_memory>` / `</answer_memory>` | 248081 / 248082 | 此前回答到期后回插一次 |
|
| 201 |
-
| `<captioning>` | 248083 | 当前轮发言,且是事件级 caption |
|
| 202 |
-
| `<caption_begin>` | 248084 | user 侧标记,说明这条流是 caption 任务 |
|
| 203 |
-
|
| 204 |
-
user 与 assistant 严格交替,每个 user 轮最多一帧。每帧给上 `timestamp`:
|
| 205 |
-
|
| 206 |
-
```python
|
| 207 |
-
messages = [{"role": "user", "content": [
|
| 208 |
-
{"type": "text", "text": '<question_memory>{"timestep": "00:00:00", "content": "接下来他在做什么?"}</question_memory>\n'},
|
| 209 |
-
{"type": "image", "timestamp": 0.0},
|
| 210 |
-
{"type": "text", "text": "\n"},
|
| 211 |
-
]}]
|
| 212 |
-
text = processor.apply_chat_template(
|
| 213 |
-
messages, tokenize=False, add_generation_prompt=True, streaming=True)
|
| 214 |
-
```
|
| 215 |
-
|
| 216 |
-
```
|
| 217 |
-
<|im_start|>user
|
| 218 |
-
<question_memory>{"timestep": "00:00:00", "content": "..."}</question_memory>
|
| 219 |
-
<0.0 seconds><|vision_start|><|image_pad|>×N<|vision_end|>
|
| 220 |
-
<|im_end|>
|
| 221 |
-
<|im_start|>assistant
|
| 222 |
-
<silence><|im_end|>
|
| 223 |
-
```
|
| 224 |
-
|
| 225 |
-
八个 token 都是普通 added token,`skip_special_tokens=True` 不会过滤它们:状态 token 就是要读取的输出。围绕模型的实时循环(取帧调度、停止生成、记忆回插)不在本仓库内。
|
| 226 |
|
| 227 |
## 使用建议
|
| 228 |
|
| 229 |
-
-
|
| 230 |
-
-
|
| 231 |
-
-
|
| 232 |
-
-
|
| 233 |
-
- **要什么格式就在 prompt 里说。** 选择题加上 `Answer with the option's letter from the given choices directly.`;grounding 任务写明坐标范围,例如 0~1000 的整数。
|
| 234 |
-
- **多进程前先预热。** 先在单进程里完整加载一次模型,让 remote code 编译完成后再启动多个 worker。
|
| 235 |
|
| 236 |
## 引用
|
| 237 |
|
|
|
|
| 44 |
| Benchmark | Qwen3.5-4B | OV2.5-4B(抽帧) | OV2.5-4B(codec) |
|
| 45 |
|:---|:---:|:---:|:---:|
|
| 46 |
| **通用视频理解** | | | |
|
| 47 |
+
| MotionBench | 60.1 <sup>128f×153,664</sup> | 62.4 <sup>128f×153,664</sup> | **64.2** <sup>TC128×313,600</sup> |
|
| 48 |
+
| TOMATO \* | 34.9 <sup>16f×153,664, fps=2</sup> | 33.6 <sup>model default</sup> | **38.6** <sup>TC128×313,600</sup> |
|
| 49 |
+
| MVBench | 64.0 <sup>64f×153,664</sup> | 72.0 <sup>64f×153,664</sup> | **75.5** <sup>TC64×313,600</sup> |
|
| 50 |
+
| NextQA MC test | 80.7 <sup>64f×153,664</sup> | 86.1 <sup>64f×153,664</sup> | **86.4** <sup>TC64×313,600</sup> |
|
| 51 |
+
| TempCompass MC | 73.4 <sup>64f×153,664</sup> | 75.8 <sup>64f×153,664</sup> | **79.7** <sup>TC64×313,600</sup> |
|
| 52 |
+
| MMVU val | **52.6** <sup>64f×153,664</sup> | 44.1 <sup>64f×153,664</sup> | -- |
|
| 53 |
+
| Video-MME-v2 | 15.5 <sup>64f×330,000</sup> | 16.4 <sup>64f×330,000</sup> | **17.2** <sup>TC64×313,600</sup> |
|
| 54 |
+
| EgoSchema subset | 68.2 <sup>64f×153,664</sup> | **80.0** <sup>64f×153,664</sup> | -- |
|
| 55 |
+
| Video-Index 512f | 19.6 <sup>task frames, ≤262,144/f</sup> | **20.0** <sup>task frames, ≤262,144/f</sup> | 19.8 <sup>TC≤256×313,600</sup> |
|
| 56 |
+
| MMOU test-mini | -- | 46.0 <sup>model default</sup> | -- |
|
| 57 |
| **VideoMME** | | | |
|
| 58 |
+
| short,无字幕 | **81.7** <sup>128f×321,489</sup> | 79.7 <sup>128f×321,489</sup> | 81.1 <sup>TC256×313,600</sup> |
|
| 59 |
+
| medium,无字幕 | 70.3 <sup>256f×136,900</sup> | 70.6 <sup>256f×136,900</sup> | **74.1** <sup>TC512×313,600</sup> |
|
| 60 |
+
| long,无字幕 | **63.0** <sup>1450f×120,000</sup> | 59.0 <sup>750f×250,000</sup> | 60.6 <sup>TC512×313,600</sup> |
|
| 61 |
+
| short,有字幕 | -- | 82.4 <sup>128f×321,489</sup> | **82.7** <sup>TC256×313,600</sup> |
|
| 62 |
+
| medium,有字幕 | -- | 75.4 <sup>256f×136,900</sup> | **75.6** <sup>TC256×313,600</sup> |
|
| 63 |
+
| long,有字幕 | -- | 65.8 <sup>750f×250,000</sup> | **65.9** <sup>TC256×313,600</sup> |
|
| 64 |
| **视频空间** | | | |
|
| 65 |
+
| VSI-Bench | 59.2 <sup>128f×153,664</sup> | **68.6** <sup>128f×153,664</sup> | 67.7 <sup>TC128×313,600</sup> |
|
| 66 |
+
| ReVSI 64f | 47.1 <sup>64f×153,664</sup> | **55.9** <sup>64f×153,664</sup> | 55.5 <sup>TC64×313,600</sup> |
|
| 67 |
| **长视频** | | | |
|
| 68 |
+
| LVBench | 56.5 <sup>2048f×120,000</sup> | **62.0** <sup>950f×200,000</sup> | 61.6 <sup>TC1024×156,800</sup> |
|
| 69 |
+
| MLVU dev | 73.8 <sup>512f×72,900</sup> | **75.3** <sup>512f×72,900</sup> | -- |
|
| 70 |
+
| LongVideoBench val | 62.7 <sup>700f×300,000</sup> | 69.0 <sup>1280f×80,000</sup> | **71.1** <sup>TC768×235,200</sup> |
|
| 71 |
+
| VideoEval-Pro | 62.8 <sup>2048f×100,000</sup> | 64.4 <sup>950f×200,000</sup> | **64.6** <sup>TC768×235,200</sup> |
|
| 72 |
| **时间定位(mIoU)** | | | |
|
| 73 |
+
| TimeLens ActivityNet | 53.8 <sup>2048f×409,600, fps=4</sup> | 58.8 <sup>2048f×409,600, fps=4</sup> | **59.1** <sup>TC128×313,600</sup> |
|
| 74 |
+
| TimeLens Charades | 48.1 <sup>2048f×409,600, fps=4</sup> | 60.6 <sup>2048f×409,600, fps=4</sup> | **61.3** <sup>TC128×313,600</sup> |
|
| 75 |
+
| TimeLens QVHighlights | 67.5 <sup>2048f×409,600, fps=4</sup> | 68.4 <sup>2048f×409,600, fps=4</sup> | **70.3** <sup>TC128×313,600</sup> |
|
| 76 |
|
| 77 |
### 图像
|
| 78 |
|
|
|
|
| 87 |
| OCRBench | **85.2** | 79.8 | EmbSpatial | 74.7 | **83.0** |
|
| 88 |
| DocVQA val | **95.2** | 92.9 | MMSI-Bench | 31.4 | **33.3** |
|
| 89 |
|
| 90 |
+
<sub>对比对象为关闭 thinking 的 Qwen3.5-4B。**加粗**为该行最高分,`--` 表示暂无结果。视频分数的上标是取得该分数时的设置:帧数 × 每帧像素;codec 为画布数(TC)× 每画布像素。两边各取��测设置中的最高分,均为单次运行。`*` TOMATO 两边帧数设置不同。图像表为代表性 bench 的节选,完整结果、设置与评测口径见后续技术报告。</sub>
|
| 91 |
|
| 92 |
## 模型概览
|
| 93 |
|
|
|
|
| 140 |
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 141 |
```
|
| 142 |
|
| 143 |
+
### 视频
|
|
|
|
|
|
|
| 144 |
|
| 145 |
```python
|
| 146 |
messages = [{"role": "user", "content": [
|
|
|
|
| 157 |
).to(model.device)
|
| 158 |
```
|
| 159 |
|
| 160 |
+
使用 codec 模式时,安装 `codec-video-prep` 并传入 `video_backend="codec"`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
```bash
|
| 163 |
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \
|
|
|
|
| 170 |
video_backend="codec", return_tensors="pt").to(model.device)
|
| 171 |
```
|
| 172 |
|
|
|
|
|
|
|
| 173 |
### 流式
|
| 174 |
|
| 175 |
+
权重本身已支持流式:给 `apply_chat_template` 传 `streaming=True` 即可。用于实时在线推理的运行库即将发布。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
## 使用建议
|
| 178 |
|
| 179 |
+
- 传视频路径,不要传自己解码好的帧,这样 processor 才能拿到真实时间戳。
|
| 180 |
+
- 帧数与逐帧像素一起调:开销约等于两者之积。
|
| 181 |
+
- 使用贪心解码(`do_sample=False`),并给足 `max_new_tokens`。
|
| 182 |
+
- 选择题或 grounding 任务,在 prompt 里写明期望的回答格式。
|
|
|
|
|
|
|
| 183 |
|
| 184 |
## 引用
|
| 185 |
|