> 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-de/vision-modelle/qwen-vl.md).

# Qwen2.5-VL Vision-Language-Modell

Qwen2.5-VL von Alibaba (Dezember 2024) ist das leistungsstärkste offene Vision-Language-Modell (VLM) in seiner Gewichtsklasse. Erhältlich in 3B-, 7B- und 72B-Parametergrößen, versteht es Bilder, Videoframes, PDFs, Diagramme und komplexe visuelle Layouts. Die 7B-Variante trifft den Sweet Spot — sie übertrifft viele größere Modelle in Benchmarks und läuft bequem auf einer einzelnen 24-GB-GPU.

An [Clore.ai](https://clore.ai/) können Sie genau die GPU mieten, die Sie benötigen — von einer RTX 3090 für das 7B-Modell bis hin zu Multi-GPU-Setups für die 72B-Variante — und in wenigen Minuten mit der Analyse visueller Inhalte beginnen.

## Hauptmerkmale

* **Multimodale Eingabe** — Bilder, Videos, PDFs, Screenshots, Diagramme und Schaubilder in einem einzigen Modell.
* **Drei Skalen** — 3B (Edge/Mobil), 7B (Produktions-Sweet-Spot), 72B (SOTA-Qualität).
* **Dynamische Auflösung** — verarbeitet Bilder in ihrer nativen Auflösung; kein erzwungenes Skalieren auf 224×224.
* **Videoverstehen** — akzeptiert mehrbildige Videoeingaben mit zeitlicher Argumentation.
* **Dokumenten-OCR** — extrahiert Text aus gescannten Dokumenten, Quittungen und handschriftlichen Notizen.
* **Mehrsprachig** — starke Leistung in Englisch, Chinesisch und über 20 weiteren Sprachen.
* **Ollama-Unterstützung** — lokal ausführen mit `ollama run qwen2.5vl:7b` für eine bereitzustellung ohne Code.
* **Transformers-Integration** — `Qwen2_5_VLForConditionalGeneration` in HuggingFace `transformers`.

## Anforderungen

| Komponente | 3B    | 7B       | 72B                |
| ---------- | ----- | -------- | ------------------ |
| GPU-VRAM   | 8 GB  | 16–24 GB | 80+ GB (Multi-GPU) |
| System-RAM | 16 GB | 32 GB    | 128 GB             |
| Festplatte | 10 GB | 20 GB    | 150 GB             |
| Python     | 3.10+ | 3.10+    | 3.10+              |
| CUDA       | 12.1+ | 12.1+    | 12.1+              |

**Clore.ai GPU-Empfehlung:** Für das **7B-Modell**, ein **RTX 4090** (24 GB, \~0,5–2 $/Tag) oder **RTX 3090** (24 GB, \~0,3–1 $/Tag) ist ideal. Für **72B**, filtern Sie den Marktplatz nach **A100 80 GB** oder Multi-GPU-Setups.

## Schnellstart

### Option A: Ollama (Einfachste)

```bash
# Installiere ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Ziehe und starte das 7B-Vision-Modell
ollama run qwen2.5vl:7b
```

Dann im ollama-Prompt:

```
>>> Beschreibe dieses Bild: /path/to/photo.jpg
```

### Option B: Python / Transformers

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

## Beispielanwendungen

### Bildverständnis mit 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": "Welche Art ist dieses Insekt? Beschreibe seine wichtigsten Erkennungsmerkmale."},
        ],
    }
]

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)
```

### Videoanalyse

```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": "Fasse zusammen, was in diesem Video passiert. Liste die wichtigsten Ereignisse in der Reihenfolge auf."},
        ],
    }
]

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])
```

### Dokumenten-OCR und Extraktion

```python
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "file:///workspace/receipt.jpg"},
            {"type": "text", "text": "Extrahiere alle Artikel, Mengen und Preise aus dieser Quittung. Gib das Ergebnis als JSON zurück."},
        ],
    }
]

# Verarbeitung mit dem oben verwendeten Modell/Processor
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 für Batch-Verarbeitung

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

def analyze_image(image_path: str, question: str) -> str:
    """Sende ein Bild an Qwen2.5-VL über die Ollama-API."""
    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"]

# Verarbeite einen Ordner mit Bildern im Batch
from pathlib import Path
for img in sorted(Path("./photos").glob("*.jpg")):
    result = analyze_image(str(img), "Beschreibe dieses Bild in einem Satz.")
    print(f"{img.name}: {result}")
```

## Tipps für Clore.ai-Nutzer

1. **Ollama für schnelle Bereitstellung** — `ollama run qwen2.5vl:7b` ist der schnellste Weg zu einem funktionierenden VLM. Keine Python-Code nötig für interaktive Nutzung.
2. **7B ist der Sweet Spot** — die 7B Instruct-Variante passt mit 4-Bit-Quantisierung in 16 GB VRAM und liefert eine Qualität, die mit deutlich größeren Modellen konkurriert.
3. **Dynamische Auflösung ist wichtig** — Qwen2.5-VL verarbeitet Bilder in nativer Auflösung. Bei großen Bildern (>4K) auf maximal 1920px Breite verkleinern, um übermäßigen VRAM-Verbrauch zu vermeiden.
4. **Video-fps-Einstellung** — für Videoeingaben setze `fps=1.0` um 1 Frame pro Sekunde zu sampeln. Höhere Werte verbrauchen schnell VRAM; 1 fps reicht für die meisten Analyseaufgaben aus.
5. **Persistenter Speicher** — setze `HF_HOME=/workspace/hf_cache`; das 7B-Modell ist \~15 GB. Bei ollama landen Modelle in `~/.ollama/models/`.
6. **Strukturierte Ausgabe** — Qwen2.5-VL befolgt JSON-Formatierungsanweisungen gut. Fordere "Als JSON zurückgeben" an und du erhältst die meiste Zeit parsefähige Ausgaben.
7. **Mehrfachbild-Vergleich** — du kannst mehrere Bilder in einer einzigen Nachricht übergeben für Vergleichsaufgaben (z. B. "Welches dieser beiden Produkte wirkt hochwertiger?").
8. **tmux** — führe es immer innerhalb von `tmux` bei Clore.ai-Mietinstanzen aus.

## Fehlerbehebung

| Problem                                                 | Behebe                                                                                                     |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` mit 7B                               | Verwenden Sie `load_in_4bit=True` in `from_pretrained()` mit `bitsandbytes`; oder verwende die 3B-Variante |
| Ollama-Modell nicht gefunden                            | `ollama pull qwen2.5vl:7b` — stelle sicher, dass du das richtige Tag hast                                  |
| Langsame Videoverarbeitung                              | Reduzieren `fps` auf 0,5 und `max_pixels` auf `256 * 256`; weniger Frames = schnellere Inferenz            |
| Wirre oder leere Ausgabe                                | Erhöhe `max_new_tokens`; der Standardwert kann für detaillierte Beschreibungen zu niedrig sein             |
| `ImportError: qwen_vl_utils`                            | `pip install qwen-vl-utils` — erforderlich für `process_vision_info()`                                     |
| 72B-Modell passt nicht                                  | Verwende 2× A100 80 GB mit `device_map="auto"` oder wende AWQ-Quantisierung an                             |
| Bildpfad nicht gefunden                                 | Für lokale Dateien in Nachrichten verwende `file:///absolute/path` Format                                  |
| Chinesisch in der Ausgabe bei Aufforderung auf Englisch | Füge "Nur auf Englisch antworten." zu deinem Prompt hinzu                                                  |


---

# 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:

```
GET https://docs.clore.ai/guides/guides_v2-de/vision-modelle/qwen-vl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
