Image-Text-to-Text
Transformers
TensorBoard
Safetensors
English
qwen2_vl
QvQ
Qwen
Contexr-Explainer
conversational
text-generation-inference
Instructions to use prithivMLmods/QvQ-Step-Tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/QvQ-Step-Tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/QvQ-Step-Tiny") 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("prithivMLmods/QvQ-Step-Tiny") model = AutoModelForImageTextToText.from_pretrained("prithivMLmods/QvQ-Step-Tiny") 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 prithivMLmods/QvQ-Step-Tiny with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/QvQ-Step-Tiny" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/QvQ-Step-Tiny", "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/prithivMLmods/QvQ-Step-Tiny
- SGLang
How to use prithivMLmods/QvQ-Step-Tiny 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 "prithivMLmods/QvQ-Step-Tiny" \ --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": "prithivMLmods/QvQ-Step-Tiny", "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 "prithivMLmods/QvQ-Step-Tiny" \ --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": "prithivMLmods/QvQ-Step-Tiny", "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 prithivMLmods/QvQ-Step-Tiny with Docker Model Runner:
docker model run hf.co/prithivMLmods/QvQ-Step-Tiny
Update README.md
Browse files
README.md
CHANGED
|
@@ -17,6 +17,53 @@ tags:
|
|
| 17 |
|
| 18 |
# **Quickstart with Transformers**
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# **Key Enhancements of QvQ-Step-Tiny**
|
| 21 |
|
| 22 |
1. **State-of-the-Art Visual Understanding**
|
|
|
|
| 17 |
|
| 18 |
# **Quickstart with Transformers**
|
| 19 |
|
| 20 |
+
Here we show a code snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 24 |
+
from qwen_vl_utils import process_vision_info
|
| 25 |
+
|
| 26 |
+
# default: Load the model on the available device(s)
|
| 27 |
+
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 28 |
+
"prithivMLmods/QvQ-Step-Tiny", torch_dtype="auto", device_map="auto"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
messages = [
|
| 32 |
+
{
|
| 33 |
+
"role": "user",
|
| 34 |
+
"content": [
|
| 35 |
+
{
|
| 36 |
+
"type": "image",
|
| 37 |
+
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
|
| 38 |
+
},
|
| 39 |
+
{"type": "text", "text": "Describe this image."},
|
| 40 |
+
],
|
| 41 |
+
}
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
text = processor.apply_chat_template(
|
| 45 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 46 |
+
)
|
| 47 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 48 |
+
inputs = processor(
|
| 49 |
+
text=[text],
|
| 50 |
+
images=image_inputs,
|
| 51 |
+
videos=video_inputs,
|
| 52 |
+
padding=True,
|
| 53 |
+
return_tensors="pt",
|
| 54 |
+
)
|
| 55 |
+
inputs = inputs.to("cuda")
|
| 56 |
+
|
| 57 |
+
# Inference: Generation of the output
|
| 58 |
+
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
| 59 |
+
generated_ids_trimmed = [
|
| 60 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 61 |
+
]
|
| 62 |
+
output_text = processor.batch_decode(
|
| 63 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 64 |
+
)
|
| 65 |
+
print(output_text)
|
| 66 |
+
```
|
| 67 |
# **Key Enhancements of QvQ-Step-Tiny**
|
| 68 |
|
| 69 |
1. **State-of-the-Art Visual Understanding**
|