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
# 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")LLaVA-OneVision-2.5-4B-Instruct is a 4B vision-language model for single-image, multi-image and video input. Beyond the usual offline tasks, it is trained for streaming video: frames arrive one at a time, and at every step the model decides whether to stay silent or speak. The same weights and the same chat template serve both modes.
Highlights
- Offline and streaming in one model.
apply_chat_template(..., streaming=True)switches mode; eight protocol tokens carry the per-frame decision to stay silent, respond or caption. Nothing else about the input changes. - Codec-aligned video. Besides uniform frame sampling, codec mode uses the encoder's bit-cost to pack the informative regions of a video into a handful of canvases.
- 9ร spatial compression. A patch-16 vision tower with 3ร3 merging gives one visual token per 48ร48 pixels, so long videos fit comfortably in the 262k context.
Performance
Video
| Benchmark | OV2.5-4B (codec) | OV2.5-4B (frames) | Qwen3.5-4B |
|---|---|---|---|
| General video understanding | |||
| VideoMME (no subtitles) | 71.9 | 69.7 | 71.7 |
| VideoMME (subtitles) | 74.7 | 75.2 | 75.9 |
| MotionBench | 64.2 TC128ร313,600 | 62.4 128fร153,664 | 60.1 128fร153,664 |
| TOMATO | 36.0 TC16ร153,664 | 39.2 16fร153,664 | 32.4 16fร153,664 |
| MVBench | 75.5 TC64ร313,600 | 72.0 64fร153,664 | 64.0 64fร153,664 |
| NextQA MC test | 86.4 TC64ร313,600 | 86.1 64fร153,664 | 80.7 64fร153,664 |
| TempCompass MC | 79.7 TC64ร313,600 | 75.8 64fร153,664 | 73.4 64fร153,664 |
| Video-MME-v2 | 17.2 TC64ร313,600 | 16.4 64fร330,000 | 15.5 64fร330,000 |
| EgoSchema subset | 79.8 TC64ร313,600 | 80.0 64fร153,664 | 68.2 64fร153,664 |
| Video-Index | 23.1 TC512ร55,296 | 20.0 1fps, โค512fร55,296 | 19.6 1fps, โค512fร55,296 |
| Long video | |||
| LVBench | 61.6 TC1024ร156,800 | 62.0 950fร200,000 | 56.5 2048fร120,000 |
| MLVU dev | 77.1 TC512ร313,600 | 75.3 512fร72,900 | 73.8 512fร72,900 |
| LongVideoBench val | 71.1 TC768ร235,200 | 69.0 1280fร80,000 | 62.7 700fร300,000 |
| VideoEval-Pro | 64.6 TC768ร235,200 | 64.4 950fร200,000 | 62.8 2048fร100,000 |
| Temporal grounding (mIoU) | |||
| TimeLens ActivityNet | 59.1 TC128ร313,600 | 58.8 2048fร409,600, fps=4 | 53.8 2048fร409,600, fps=4 |
| TimeLens Charades | 61.3 TC128ร313,600 | 60.6 2048fร409,600, fps=4 | 48.1 2048fร409,600, fps=4 |
| TimeLens QVHighlights | 70.3 TC128ร313,600 | 68.4 2048fร409,600, fps=4 | 67.5 2048fร409,600, fps=4 |
Streaming video
| Benchmark | OV2.5-4B (codec, 24 fps) |
MOSS-VL-Realtime 11B (1 fps) |
JoyAI-VL-Interaction 8B (1 fps) |
|---|---|---|---|
| OVO-Bench | |||
| Real-Time Visual Perception (RTVP) | 81.0 | 75.9 | 76.4 |
| Backward Tracing (BT) | 68.8 | 72.6 | 53.3 |
| Forward Active Responding (FAR) | 60.7 | 62.1 | 54.6 |
| Overall | 70.2 | 70.2 | 61.4 |
| StreamingBench | |||
| Real-Time Visual Understanding (RTVU) | 85.3 | 82.9 | 83.2 |
| Misleading Context Understanding (MCU) | 36.8 | -- | 37.2 |
| Anomaly Context Understanding (ACU) | 67.6 | -- | 51.6 |
| Sequential Question Answering (SQA) | 54.8 | 50.4 | 53.6 |
| Proactive Output (PO) | 63.6 | 60.0 | 39.6 |
| Contextual Understanding (CU) | 55.7 | 56.4 | 45.5 |
| Proactive and interactive | |||
| OmniMMI: Proactive Alerting (PA) | 68.5 | 66.0 | 13.5 |
| ProactiveVideoQA: PAUC (ฯ=0.5) | 33.1 | 47.2 | 37.0 |
| InteractionBench: Total | 38.6 | -- | -- |
| StreamArena: Proactive Interaction (Pro) | 25.5 | 11.8 | 9.4 |
Image
| General perception and reading | OV2.5-4B | Qwen3.5-4B | Grounding and spatial | OV2.5-4B | Qwen3.5-4B |
|---|---|---|---|---|---|
| MMStar | 63.9 | 66.9 | RefCOCO val (Acc@0.5) | 92.6 | 89.1 |
| MMBench-EN dev | 88.2 | 88.8 | RefCOCOg val (Acc@0.5) | 88.9 | 87.7 |
| RealWorldQA | 73.9 | 74.4 | RefSpatial-Bench | 62.1 | 29.1 |
| AI2D | 82.2 | 82.4 | CrossPoint | 80.5 | 33.7 |
| BLINK | 67.1 | 63.6 | CV-Bench 2D | 83.3 | 80.7 |
| V*-Bench | 89.5 | 81.7 | CV-Bench 3D | 94.5 | 92.0 |
| OCRBench | 79.8 | 85.2 | EmbSpatial | 83.0 | 74.7 |
| DocVQA val | 92.9 | 95.2 | MMSI-Bench | 33.3 | 31.4 |
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. VideoMME is the mean over the short, medium and long splits. Each side reports its best score over the settings tried, from single runs. The image table shows selected benchmarks; full results, settings and protocol will be given in the technical report.
Model Overview
| Type | instruction-tuned vision-language model, LLaVA-OneVision-2.5 architecture |
| Parameters | 5.25B total (4B language model plus vision tower and adapter) |
| Language side | 32 layers, hidden size 2560, FFN 9216, 16 attention heads / 4 KV heads, linear attention with one full-attention layer every 4 |
| Vision side | 24 layers, hidden size 1024, patch_size=16, spatial_merge_size=3, attention within a frame |
| Vocabulary | 248320, including the 8 streaming protocol tokens |
| Context length | 262144 |
| Weights | bfloat16, 3 safetensors shards, about 9.9 GB |
Quickstart
The modeling code ships with the weights, so trust_remote_code=True is required.
pip install "transformers>=5.7.0" accelerate torch torchvision
pip install flash-attn --no-build-isolation # optional, recommended
pip install decord # frame-sampling video path only
Image
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForImageTextToText
MODEL = "lmms-lab-encoder/LLaVA-OneVision-2.5-4B-Instruct"
processor = AutoProcessor.from_pretrained(MODEL, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
MODEL, trust_remote_code=True, dtype=torch.bfloat16,
attn_implementation="flash_attention_2", # "sdpa" without flash-attn
device_map="auto",
).eval()
messages = [{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": "Describe this image in detail."},
]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=text, images=[Image.open("example.jpg").convert("RGB")],
return_tensors="pt").to(model.device)
with torch.inference_mode():
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Video
messages = [{"role": "user", "content": [
{"type": "video"},
{"type": "text", "text": "What is happening in this video?"},
]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(
text=text, videos=["example.mp4"],
max_frames=64,
min_pixels=153664, max_pixels=153664, # set equal to fix the per-frame budget
return_tensors="pt",
).to(model.device)
For codec mode, install codec-video-prep and pass video_backend="codec":
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \
"codec-video-prep==0.3.0"
codec-video-prep-doctor
inputs = processor(text=text, videos=["example.mp4"],
video_backend="codec", return_tensors="pt").to(model.device)
Streaming
The checkpoint already supports streaming: pass streaming=True to apply_chat_template. The runtime library for real-time online inference is coming soon.
License
Apache-2.0.
- Downloads last month
- 75
# 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)