Instructions to use llava-hf/llava-onevision-qwen2-7b-ov-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llava-hf/llava-onevision-qwen2-7b-ov-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="llava-hf/llava-onevision-qwen2-7b-ov-hf") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("llava-hf/llava-onevision-qwen2-7b-ov-hf") model = AutoModelForMultimodalLM.from_pretrained("llava-hf/llava-onevision-qwen2-7b-ov-hf", device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use llava-hf/llava-onevision-qwen2-7b-ov-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "llava-hf/llava-onevision-qwen2-7b-ov-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llava-hf/llava-onevision-qwen2-7b-ov-hf", "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/llava-hf/llava-onevision-qwen2-7b-ov-hf
- SGLang
How to use llava-hf/llava-onevision-qwen2-7b-ov-hf 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 "llava-hf/llava-onevision-qwen2-7b-ov-hf" \ --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": "llava-hf/llava-onevision-qwen2-7b-ov-hf", "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 "llava-hf/llava-onevision-qwen2-7b-ov-hf" \ --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": "llava-hf/llava-onevision-qwen2-7b-ov-hf", "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 llava-hf/llava-onevision-qwen2-7b-ov-hf with Docker Model Runner:
docker model run hf.co/llava-hf/llava-onevision-qwen2-7b-ov-hf
Upload LlavaOnevisionForConditionalGeneration
Browse files- config.json +4 -9
- model-00001-of-00004.safetensors +1 -1
- model-00004-of-00004.safetensors +1 -1
config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "/raid/raushan/
|
| 3 |
"architectures": [
|
| 4 |
-
"
|
| 5 |
],
|
| 6 |
"ignore_index": -100,
|
| 7 |
"image_grid_pinpoints": [
|
|
@@ -151,7 +151,7 @@
|
|
| 151 |
]
|
| 152 |
],
|
| 153 |
"image_token_index": 151646,
|
| 154 |
-
"model_type": "
|
| 155 |
"projector_hidden_act": "gelu",
|
| 156 |
"text_config": {
|
| 157 |
"_name_or_path": "Qwen/Qwen2-7B-Instruct",
|
|
@@ -162,29 +162,24 @@
|
|
| 162 |
"eos_token_id": 151645,
|
| 163 |
"hidden_size": 3584,
|
| 164 |
"intermediate_size": 18944,
|
| 165 |
-
"max_position_embeddings": 32768,
|
| 166 |
-
"max_window_layers": 28,
|
| 167 |
"model_type": "qwen2",
|
| 168 |
"num_attention_heads": 28,
|
| 169 |
"num_hidden_layers": 28,
|
| 170 |
"num_key_value_heads": 4,
|
| 171 |
"rope_theta": 1000000.0,
|
| 172 |
-
"sliding_window": null,
|
| 173 |
"torch_dtype": "bfloat16",
|
| 174 |
-
"use_sliding_window": false,
|
| 175 |
"vocab_size": 152128
|
| 176 |
},
|
| 177 |
"tie_word_embeddings": false,
|
| 178 |
"torch_dtype": "float16",
|
| 179 |
"transformers_version": "4.45.0.dev0",
|
| 180 |
"use_image_newline_parameter": true,
|
|
|
|
| 181 |
"vision_aspect_ratio": "anyres_max_9",
|
| 182 |
"vision_config": {
|
| 183 |
-
"hidden_act": "gelu_pytorch_tanh",
|
| 184 |
"hidden_size": 1152,
|
| 185 |
"image_size": 384,
|
| 186 |
"intermediate_size": 4304,
|
| 187 |
-
"layer_norm_eps": 1e-06,
|
| 188 |
"model_type": "siglip_vision_model",
|
| 189 |
"num_attention_heads": 16,
|
| 190 |
"num_hidden_layers": 26,
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "/raid/raushan/si-7b",
|
| 3 |
"architectures": [
|
| 4 |
+
"LlavaOnevisionForConditionalGeneration"
|
| 5 |
],
|
| 6 |
"ignore_index": -100,
|
| 7 |
"image_grid_pinpoints": [
|
|
|
|
| 151 |
]
|
| 152 |
],
|
| 153 |
"image_token_index": 151646,
|
| 154 |
+
"model_type": "llava_onevision",
|
| 155 |
"projector_hidden_act": "gelu",
|
| 156 |
"text_config": {
|
| 157 |
"_name_or_path": "Qwen/Qwen2-7B-Instruct",
|
|
|
|
| 162 |
"eos_token_id": 151645,
|
| 163 |
"hidden_size": 3584,
|
| 164 |
"intermediate_size": 18944,
|
|
|
|
|
|
|
| 165 |
"model_type": "qwen2",
|
| 166 |
"num_attention_heads": 28,
|
| 167 |
"num_hidden_layers": 28,
|
| 168 |
"num_key_value_heads": 4,
|
| 169 |
"rope_theta": 1000000.0,
|
|
|
|
| 170 |
"torch_dtype": "bfloat16",
|
|
|
|
| 171 |
"vocab_size": 152128
|
| 172 |
},
|
| 173 |
"tie_word_embeddings": false,
|
| 174 |
"torch_dtype": "float16",
|
| 175 |
"transformers_version": "4.45.0.dev0",
|
| 176 |
"use_image_newline_parameter": true,
|
| 177 |
+
"video_token_index": 151647,
|
| 178 |
"vision_aspect_ratio": "anyres_max_9",
|
| 179 |
"vision_config": {
|
|
|
|
| 180 |
"hidden_size": 1152,
|
| 181 |
"image_size": 384,
|
| 182 |
"intermediate_size": 4304,
|
|
|
|
| 183 |
"model_type": "siglip_vision_model",
|
| 184 |
"num_attention_heads": 16,
|
| 185 |
"num_hidden_layers": 26,
|
model-00001-of-00004.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4911200360
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ad4cb27d2a3f6e987147619cf2508a5bbb1b6b4c2d5533501fcc4a287a90e5af
|
| 3 |
size 4911200360
|
model-00004-of-00004.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1226266240
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2d1e40e47e9b524efcbbcab68e97fe4e7aadfe9a51bc14b54cc2331c48ebff6
|
| 3 |
size 1226266240
|