Instructions to use trl-internal-testing/tiny-Qwen2VLForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Qwen2VLForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-Qwen2VLForConditionalGeneration") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-Qwen2VLForConditionalGeneration") model = AutoModelForImageTextToText.from_pretrained("trl-internal-testing/tiny-Qwen2VLForConditionalGeneration") 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
- vLLM
How to use trl-internal-testing/tiny-Qwen2VLForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", "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/trl-internal-testing/tiny-Qwen2VLForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-Qwen2VLForConditionalGeneration 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 "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", "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 "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Qwen2VLForConditionalGeneration", "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 trl-internal-testing/tiny-Qwen2VLForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Qwen2VLForConditionalGeneration
Upload Qwen2VLForConditionalGeneration
#5
by albertvillanova HF Staff - opened
- config.json +8 -6
- generation_config.json +1 -1
- model.safetensors +1 -1
- preprocessor_config.json +0 -2
- tokenizer.json +2 -2
- video_preprocessor_config.json +2 -1
config.json
CHANGED
|
@@ -20,9 +20,8 @@
|
|
| 20 |
"rms_norm_eps": 1e-06,
|
| 21 |
"rope_scaling": {
|
| 22 |
"mrope_section": [
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
24
|
| 26 |
],
|
| 27 |
"rope_type": "default",
|
| 28 |
"type": "default"
|
|
@@ -39,6 +38,7 @@
|
|
| 39 |
"eos_token_id": 151645,
|
| 40 |
"hidden_act": "silu",
|
| 41 |
"hidden_size": 16,
|
|
|
|
| 42 |
"initializer_range": 0.02,
|
| 43 |
"intermediate_size": 8960,
|
| 44 |
"layer_types": [
|
|
@@ -65,10 +65,13 @@
|
|
| 65 |
"tie_word_embeddings": true,
|
| 66 |
"use_cache": true,
|
| 67 |
"use_sliding_window": false,
|
|
|
|
|
|
|
|
|
|
| 68 |
"vision_token_id": 151654,
|
| 69 |
"vocab_size": 151936
|
| 70 |
},
|
| 71 |
-
"transformers_version": "4.
|
| 72 |
"use_cache": true,
|
| 73 |
"use_sliding_window": false,
|
| 74 |
"video_token_id": 151656,
|
|
@@ -82,8 +85,7 @@
|
|
| 82 |
"initializer_range": 0.02,
|
| 83 |
"mlp_ratio": 4,
|
| 84 |
"model_type": "qwen2_vl",
|
| 85 |
-
"
|
| 86 |
-
"num_heads": 16,
|
| 87 |
"num_hidden_layers": 2,
|
| 88 |
"num_key_value_heads": 2,
|
| 89 |
"patch_size": 14,
|
|
|
|
| 20 |
"rms_norm_eps": 1e-06,
|
| 21 |
"rope_scaling": {
|
| 22 |
"mrope_section": [
|
| 23 |
+
1,
|
| 24 |
+
1
|
|
|
|
| 25 |
],
|
| 26 |
"rope_type": "default",
|
| 27 |
"type": "default"
|
|
|
|
| 38 |
"eos_token_id": 151645,
|
| 39 |
"hidden_act": "silu",
|
| 40 |
"hidden_size": 16,
|
| 41 |
+
"image_token_id": null,
|
| 42 |
"initializer_range": 0.02,
|
| 43 |
"intermediate_size": 8960,
|
| 44 |
"layer_types": [
|
|
|
|
| 65 |
"tie_word_embeddings": true,
|
| 66 |
"use_cache": true,
|
| 67 |
"use_sliding_window": false,
|
| 68 |
+
"video_token_id": null,
|
| 69 |
+
"vision_end_token_id": 151653,
|
| 70 |
+
"vision_start_token_id": 151652,
|
| 71 |
"vision_token_id": 151654,
|
| 72 |
"vocab_size": 151936
|
| 73 |
},
|
| 74 |
+
"transformers_version": "4.56.2",
|
| 75 |
"use_cache": true,
|
| 76 |
"use_sliding_window": false,
|
| 77 |
"video_token_id": 151656,
|
|
|
|
| 85 |
"initializer_range": 0.02,
|
| 86 |
"mlp_ratio": 4,
|
| 87 |
"model_type": "qwen2_vl",
|
| 88 |
+
"num_heads": 4,
|
|
|
|
| 89 |
"num_hidden_layers": 2,
|
| 90 |
"num_key_value_heads": 2,
|
| 91 |
"patch_size": 14,
|
generation_config.json
CHANGED
|
@@ -9,5 +9,5 @@
|
|
| 9 |
"temperature": 0.01,
|
| 10 |
"top_k": 1,
|
| 11 |
"top_p": 0.001,
|
| 12 |
-
"transformers_version": "4.
|
| 13 |
}
|
|
|
|
| 9 |
"temperature": 0.01,
|
| 10 |
"top_k": 1,
|
| 11 |
"top_p": 0.001,
|
| 12 |
+
"transformers_version": "4.56.2"
|
| 13 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 7081872
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:71a6a57d13133e42a74dfe4323c7dbb53374b97eb0617dee972d2346ab4e847a
|
| 3 |
size 7081872
|
preprocessor_config.json
CHANGED
|
@@ -7,7 +7,6 @@
|
|
| 7 |
"do_center_crop": null,
|
| 8 |
"do_convert_rgb": true,
|
| 9 |
"do_normalize": true,
|
| 10 |
-
"do_pad": null,
|
| 11 |
"do_rescale": true,
|
| 12 |
"do_resize": true,
|
| 13 |
"image_mean": [
|
|
@@ -25,7 +24,6 @@
|
|
| 25 |
"max_pixels": 12845056,
|
| 26 |
"merge_size": 2,
|
| 27 |
"min_pixels": 3136,
|
| 28 |
-
"pad_size": null,
|
| 29 |
"patch_size": 14,
|
| 30 |
"processor_class": "Qwen2VLProcessor",
|
| 31 |
"resample": 3,
|
|
|
|
| 7 |
"do_center_crop": null,
|
| 8 |
"do_convert_rgb": true,
|
| 9 |
"do_normalize": true,
|
|
|
|
| 10 |
"do_rescale": true,
|
| 11 |
"do_resize": true,
|
| 12 |
"image_mean": [
|
|
|
|
| 24 |
"max_pixels": 12845056,
|
| 25 |
"merge_size": 2,
|
| 26 |
"min_pixels": 3136,
|
|
|
|
| 27 |
"patch_size": 14,
|
| 28 |
"processor_class": "Qwen2VLProcessor",
|
| 29 |
"resample": 3,
|
tokenizer.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:88a3a6fcb80132f76da8aa40cdc3fccd7e5d8468ef15421f5b0c2715e85217d2
|
| 3 |
+
size 11420538
|
video_preprocessor_config.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
"do_center_crop": null,
|
| 7 |
"do_convert_rgb": true,
|
| 8 |
"do_normalize": true,
|
|
|
|
| 9 |
"do_rescale": true,
|
| 10 |
"do_resize": true,
|
| 11 |
"do_sample_frames": false,
|
|
@@ -27,7 +28,6 @@
|
|
| 27 |
"min_frames": 4,
|
| 28 |
"min_pixels": 3136,
|
| 29 |
"num_frames": null,
|
| 30 |
-
"pad_size": null,
|
| 31 |
"patch_size": 14,
|
| 32 |
"processor_class": "Qwen2VLProcessor",
|
| 33 |
"resample": 3,
|
|
@@ -37,6 +37,7 @@
|
|
| 37 |
"longest_edge": 12845056,
|
| 38 |
"shortest_edge": 3136
|
| 39 |
},
|
|
|
|
| 40 |
"temporal_patch_size": 2,
|
| 41 |
"video_metadata": null,
|
| 42 |
"video_processor_type": "Qwen2VLVideoProcessor"
|
|
|
|
| 6 |
"do_center_crop": null,
|
| 7 |
"do_convert_rgb": true,
|
| 8 |
"do_normalize": true,
|
| 9 |
+
"do_pad": null,
|
| 10 |
"do_rescale": true,
|
| 11 |
"do_resize": true,
|
| 12 |
"do_sample_frames": false,
|
|
|
|
| 28 |
"min_frames": 4,
|
| 29 |
"min_pixels": 3136,
|
| 30 |
"num_frames": null,
|
|
|
|
| 31 |
"patch_size": 14,
|
| 32 |
"processor_class": "Qwen2VLProcessor",
|
| 33 |
"resample": 3,
|
|
|
|
| 37 |
"longest_edge": 12845056,
|
| 38 |
"shortest_edge": 3136
|
| 39 |
},
|
| 40 |
+
"size_divisor": null,
|
| 41 |
"temporal_patch_size": 2,
|
| 42 |
"video_metadata": null,
|
| 43 |
"video_processor_type": "Qwen2VLVideoProcessor"
|