> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/vision-models/qwen-vl.md).

# Qwen2.5-VL Vision Language Model

Alibaba का Qwen2.5-VL (दिसंबर 2024) सबसे अच्छा प्रदर्शन करने वाला ओपन-वेट विज़न-लैंग्वेज मॉडल (VLM) है। 3B, 7B और 72B पैरामीटर साइज में उपलब्ध, यह इमेज, वीडियो फ्रेम, PDF, चार्ट और जटिल विज़ुअल लेआउट्स को समझता है। 7B वेरिएंट संतुलन बिंदु पर है — यह बेंचमार्क्स पर कई बड़े मॉडलों से बेहतर प्रदर्शन करता है जबकि एक ही 24 GB GPU पर आराम से चल जाता है।

पर [Clore.ai](https://clore.ai/) आप वही सटीक GPU किराये पर ले सकते हैं जिसकी आपको आवश्यकता है — 7B मॉडल के लिए RTX 3090 से लेकर 72B वेरिएंट के लिए मल्टी-GPU सेटअप तक — और मिनटों में विज़ुअल कंटेंट का विश्लेषण शुरू कर सकते हैं।

## प्रमुख विशेषताएँ

* **मल्टीमॉडल इनपुट** — एक ही मॉडल में इमेज, वीडियो, PDF, स्क्रीनशॉट, चार्ट और डायग्राम।
* **तीन पैमाने** — 3B (एज/मोबाइल), 7B (प्रोडक्शन का संतुलित विकल्प), 72B (SOTA गुणवत्ता)।
* **डायनामिक रिज़ॉल्यूशन** — तस्वीरों को उनकी नेटिव रिज़ॉल्यूशन पर प्रोसेस करता है; 224×224 पर जबरन रिसाइज़ नहीं।
* **वीडियो समझ** — समयपरक तर्क के साथ मल्टी-फ्रेम वीडियो इनपुट स्वीकार करता है।
* **डॉक्युमेंट OCR** — स्कैन किए गए दस्तावेज़ों, रसीदों और हस्तलिखित नोट्स से टेक्स्ट निकालता है।
* **बहुभाषी** — अंग्रेजी, चीनी और 20+ अन्य भाषाओं में मजबूत प्रदर्शन।
* **Ollama समर्थन** — स्थानीय रूप से चलाएँ `ollama run qwen2.5vl:7b` शून्य-कोड डिप्लॉयमेंट के लिए।
* **Transformers एकीकरण** — `Qwen2_5_VLForConditionalGeneration` HuggingFace में `transformers`.

## आवश्यकताएँ

| घटक        | 3B    | 7B       | 72B                |
| ---------- | ----- | -------- | ------------------ |
| GPU VRAM   | 8 GB  | 16–24 GB | 80+ GB (मल्टी-GPU) |
| सिस्टम RAM | 16 GB | 32 GB    | 128 GB             |
| डिस्क      | 10 GB | 20 GB    | 150 GB             |
| Python     | 3.10+ | 3.10+    | 3.10+              |
| CUDA       | 12.1+ | 12.1+    | 12.1+              |

**Clore.ai GPU सिफारिश:** के लिए **7B मॉडल**, एक **RTX 4090** (24 GB, \~$0.5–2/दिन) या **RTX 3090** (24 GB, \~$0.3–1/दिन) आदर्श है। के लिए, मार्केटप्लेस में फ़िल्टर करें **72B**, मार्केटप्लेस के लिए फ़िल्टर करें **A100 80 GB** या मल्टी-GPU सेटअप।

## त्वरित प्रारम्भ

### विकल्प A: Ollama (सबसे सरल)

```bash
# ollama इंस्टॉल करें
curl -fsSL https://ollama.ai/install.sh | sh

# 7B विज़न मॉडल पुल और रन करें
ollama run qwen2.5vl:7b
```

फिर ollama प्रॉम्प्ट में:

```
>>> इस इमेज का वर्णन करें: /path/to/photo.jpg
```

### विकल्प B: Python / Transformers

```bash
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install transformers accelerate qwen-vl-utils pillow
```

## उपयोग के उदाहरण

### Transformers के साथ इमेज समझ

```python
import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info

model_name = "Qwen/Qwen2.5-VL-7B-Instruct"

model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_name)

messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"},
            {"type": "text", "text": "यह कीड़ा किस प्रजाति का है? इसकी प्रमुख पहचान योग्य विशेषताओं का वर्णन करें."},
        ],
    }
]

text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)

inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
).to(model.device)

output_ids = model.generate(**inputs, max_new_tokens=512)
response = processor.batch_decode(
    output_ids[:, inputs.input_ids.shape[1]:],
    skip_special_tokens=True,
)[0]

print(response)
```

### वीडियो विश्लेषण

```python
import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info

model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    "Qwen/Qwen2.5-VL-7B-Instruct",
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct")

messages = [
    {
        "role": "user",
        "content": [
            {"type": "video", "video": "file:///workspace/clip.mp4", "max_pixels": 360 * 420, "fps": 1.0},
            {"type": "text", "text": "इस वीडियो में क्या होता है इसका सार दें। मुख्य घटनाओं को क्रम में सूचीबद्ध करें."},
        ],
    }
]

text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)

inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
).to(model.device)

output_ids = model.generate(**inputs, max_new_tokens=1024)
print(processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0])
```

### डॉक्युमेंट OCR और एक्सट्रैक्शन

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "file:///workspace/receipt.jpg"},
            {"type": "text", "text": "इस रसीद से सभी आइटम, मात्राएँ और कीमतें निकालें। JSON के रूप में लौटाएँ."},
        ],
    }
]

# ऊपर के समान मॉडल/प्रोसेसर सेटअप का उपयोग करके प्रोसेस करें
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(text=[text], images=image_inputs, videos=video_inputs, padding=True, return_tensors="pt").to(model.device)
output_ids = model.generate(**inputs, max_new_tokens=2048)
print(processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0])
```

### बैच प्रोसेसिंग के लिए Ollama API

```python
import ollama
import base64
from pathlib import Path

def analyze_image(image_path: str, question: str) -> str:
    """Ollama API के माध्यम से Qwen2.5-VL को एक इमेज भेजें."""
    image_data = base64.b64encode(Path(image_path).read_bytes()).decode()
    response = ollama.chat(
        model="qwen2.5vl:7b",
        messages=[{
            "role": "user",
            "content": question,
            "images": [image_data],
        }],
    )
    return response["message"]["content"]

# इमेज के फ़ोल्डर को बैच में प्रोसेस करें
from pathlib import Path
for img in sorted(Path("./photos").glob("*.jpg")):
    result = analyze_image(str(img), "इस इमेज का एक वाक्य में वर्णन करें।")
    print(f"{img.name}: {result}")
```

## Clore.ai उपयोगकर्ताओं के लिए सुझाव

1. **त्वरित डिप्लॉयमेंट के लिए Ollama** — `ollama run qwen2.5vl:7b` एक कार्यशील VLM तक पहुँचने का सबसे तेज़ मार्ग है। इंटरैक्टिव उपयोग के लिए किसी Python कोड की आवश्यकता नहीं है।
2. **7B संतुलन बिंदु है** — 7B Instruct वेरिएंट 4-बिट क्वांटाइज़ेशन के साथ 16 GB VRAM में फिट हो जाता है और बहुत बड़े मॉडलों के साथ प्रतिस्पर्धात्मक गुणवत्ता देता है।
3. **डायनामिक रिज़ॉल्यूशन महत्वपूर्ण है** — Qwen2.5-VL इमेजेस को नेटिव रिज़ॉल्यूशन पर प्रोसेस करता है। बड़ी इमेजेस (>4K) के लिए, अत्यधिक VRAM उपयोग से बचने के लिए अधिकतम चौड़ाई 1920px पर रिसाइज़ करें।
4. **वीडियो fps सेटिंग** — वीडियो इनपुट के लिए, सेट करें `fps=1.0` ताकि प्रति सेकंड 1 फ़्रेम सैम्पल हो। उच्च मान तेजी से VRAM खा लेते हैं; अधिकांश विश्लेषण कार्यों के लिए 1 fps पर्याप्त है।
5. **स्थायी स्टोरेज** — सेट करें `HF_HOME=/workspace/hf_cache`; 7B मॉडल \~15 GB है। ollama के लिए, मॉडल यहाँ जाते हैं `~/.ollama/models/`.
6. **संरचित आउटपुट** — Qwen2.5-VL JSON फॉर्मेटिंग निर्देशों का अच्छी तरह पालन करता है। "Return as JSON" माँगें और आपको अधिकांश समय पार्स करने योग्य आउटपुट मिलेगा।
7. **मल्टी-इमेज तुलना** — तुलना कार्यों के लिए आप एक ही संदेश में कई इमेज पास कर सकते हैं (उदा., "इन दो उत्पादों में से कौन अधिक प्रीमियम दिखता है?")।
8. **tmux** — Clore.ai किराए पर हमेशा के अंदर चलाएँ `tmux` पर।

## समस्याओं का निवारण

| समस्या                                          | समाधान                                                                                                    |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` 7B के साथ                    | उपयोग करें `load_in_4bit=True` में `from_pretrained()` के साथ `bitsandbytes`; या 3B वेरिएंट का उपयोग करें |
| Ollama मॉडल नहीं मिला                           | `ollama pull qwen2.5vl:7b` — सुनिश्चित करें कि आपके पास सही टैग है                                        |
| धीमी वीडियो प्रोसेसिंग                          | घटाएँ `fps` को 0.5 पर और `max_pixels` को `256 * 256`; कम फ़्रेम = तेज़ इनफरेंस                            |
| फ़्लफ़ या खाली आउटपुट                           | बढ़ाएँ `max_new_tokens`; डिफ़ॉल्ट विस्तृत वर्णनों के लिए बहुत कम हो सकता है                               |
| `ImportError: qwen_vl_utils`                    | `pip install qwen-vl-utils` — के लिए आवश्यक है `process_vision_info()`                                    |
| 72B मॉडल फिट नहीं होता                          | 2× A100 80 GB का उपयोग करें साथ में `device_map="auto"` या AWQ क्वांटाइज़ेशन लागू करें                    |
| इमेज पाथ नहीं मिला                              | मैसेज में स्थानीय फ़ाइलों के लिए, उपयोग करें `file:///absolute/path` फॉर्मैट                              |
| अंग्रेज़ी में प्रॉम्प्ट करने पर आउटपुट में चीनी | अपने प्रॉम्प्ट में "Respond in English only." जोड़ें                                                      |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/vision-models/qwen-vl.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
