> 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/rag-and-vektordatenbanken/ragflow.md).

# RAGFlow

RAGFlow ist eine Open-Source- **Retrieval-Augmented-Generation-(RAG)-Engine** mit tiefgehenden Dokumentenverständnis-Fähigkeiten. Mit über **50.000 GitHub-Sternen**, ist es eine der umfassendsten RAG-Plattformen — konzipiert, um komplexe Dokumente einschließlich PDFs, Word-Dateien, Tabellenkalkulationen, Bildern und mehr zu extrahieren, zu zerteilen und darüber zu schlussfolgern.

Im Gegensatz zu einfachen RAG-Systemen, die Dokumente naiv in Fragmente aufteilen, verwendet RAGFlow layout- und struktur-aware Parsing, um Dokumentenaufbau, Tabellen, Abbildungen und Mehrspaltentexte zu verstehen. Das führt zu deutlich höherer Retrieval-Genauigkeit und besserer Antwortqualität.

Wichtige Funktionen:

* 📄 **Tiefgehendes Dokumentenverständnis** — OCR, Tabellenerkennung, Abbildungserkennung
* 🔍 **Mehrere Chunking-Strategien** — semantisch, layout-bewusst, feste Größe, Q\&A-Stil
* 🤖 **LLM-Integration** — funktioniert mit OpenAI, Ollama, Anthropic, lokalen Modellen
* 🌐 **Voll ausgestattetes WebUI** — Drag-and-Drop-Dokumentenverwaltung
* 🔌 **REST-API** — integrieren Sie RAGFlow in jede Anwendung
* 📊 **Zitationsverfolgung** — Antworten enthalten Referenzen auf Quelldokumente
* 🏗️ **Mandantenfähig** — Team-Arbeitsbereiche mit Berechtigungskontrolle

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

***

## Serveranforderungen

| Parameter      | Minimum                 | Empfohlen               |
| -------------- | ----------------------- | ----------------------- |
| GPU            | NVIDIA RTX 3080 (10 GB) | NVIDIA RTX 4090 (24 GB) |
| VRAM           | 8 GB                    | 16–24 GB                |
| RAM            | 16 GB                   | 32–64 GB                |
| CPU            | 8 Kerne                 | 16+ Kerne               |
| Festplatte     | 50 GB                   | 100–500 GB              |
| Betriebssystem | Ubuntu 20.04+           | Ubuntu 22.04            |
| CUDA           | 11.8+                   | 12.1+                   |
| Ports          | 22, 9380, 80            | 22, 9380, 80            |
| Docker         | Erforderlich            | Docker + Docker Compose |

{% hint style="warning" %}
RAGFlow betreibt mehrere Dienste (Elasticsearch, MinIO, MySQL, Redis, Nginx) neben der Hauptanwendung. Stellen Sie sicher, dass Sie ausreichenden RAM (mindestens 16 GB, 32 GB empfohlen) und Festplattenspeicher haben.
{% endhint %}

***

## Schnelle Bereitstellung auf CLORE.AI

### 1. Finden Sie einen geeigneten Server

Gehe zu [CLORE.AI Marketplace](https://clore.ai/marketplace) und filtern Sie nach:

* **VRAM**: ≥ 8 GB
* **RAM**: ≥ 16 GB
* **Festplatte**: ≥ 50 GB
* **GPU**: RTX 3090, 4090, A100, H100

### 2. Konfigurieren Sie Ihre Bereitstellung

**Docker-Image:**

```
infiniflow/ragflow:latest
```

**Portzuordnungen:**

```
22   → SSH-Zugriff
80   → RAGFlow Web-UI (HTTP)
9380 → RAGFlow API
```

**Startbefehl:**

```bash
bash -c "docker-compose -f docker/docker-compose.yml up -d"
```

### 3. Greifen Sie auf das WebUI zu

```
http://<your-clore-server-ip>:80
```

Standardanmeldedaten: `admin@ragflow.io` / `admin`

***

## Schritt-für-Schritt-Einrichtung

### Schritt 1: SSH auf Ihren Server

```bash
ssh root@<your-clore-server-ip> -p <ssh-port>
```

### Schritt 2: Docker Compose installieren

```bash
apt-get update && apt-get install -y docker-compose-plugin

# Überprüfen
docker compose version
```

### Schritt 3: Das RAGFlow-Repository klonen

```bash
cd /workspace
git clone https://github.com/infiniflow/ragflow.git
cd ragflow
```

### Schritt 4: Umgebung konfigurieren

```bash
# Kopieren und die Umgebungsdatei bearbeiten
cp docker/.env.example docker/.env
nano docker/.env
```

Wichtige Einstellungen zum Konfigurieren:

```env
# LLM-Konfiguration
OPENAI_API_KEY=your-openai-api-key

# Oder verwenden Sie eine lokale Ollama-Instanz
OLLAMA_BASE_URL=http://localhost:11434

# Speichereinstellungen
MINIO_USER=ragflow
MINIO_PASSWORD=infini_rag_flow

# MySQL-Einstellungen
MYSQL_PASSWORD=infini_rag_flow

# Anwendungsport
HTTP_PORT=80
RAGFLOW_API_PORT=9380
```

### Schritt 5: Wählen Sie die richtige Image-Variante

```bash
# Verfügbare Tags prüfen
# Für CUDA 12.1 (die meisten RTX-Karten)
docker pull infiniflow/ragflow:latest

# Für eine bestimmte CUDA-Version
docker pull infiniflow/ragflow:v0.7.0-cuda12.1
```

### Schritt 6: Starten Sie alle Dienste

```bash
cd /workspace/ragflow/docker

# Starten mit GPU-Unterstützung
docker compose -f docker-compose.yml up -d

# Startvorgang überwachen (dauert 2–5 Minuten)
docker compose logs -f
```

Warten auf:

```
ragflow-server | INFO: Application startup complete.
```

### Schritt 7: Administratorkonto anlegen

Offen `http://<server-ip>:80` und registrieren Sie das erste Administratorkonto.

### Schritt 8: LLM-Modell konfigurieren

1. Gehe zu **Einstellungen → Modellanbieter**
2. Fügen Sie Ihr LLM hinzu (OpenAI, Ollama, etc.)
3. Setzen Sie das Standard-Chat-Modell und das Embedding-Modell

***

## Beispielanwendungen

### Beispiel 1: Dokumente per WebUI hochladen und abfragen

1. Melden Sie sich an bei `http://<server-ip>:80`
2. Klicken Sie **"Knowledge Base"** → **"Knowledge Base erstellen"**
3. Benennen Sie es: `"Clore.ai Dokumentation"`
4. PDF/Word/TXT-Dateien per Drag-and-Drop hochladen
5. Warten Sie auf das Parsen (Fortschritt im UI angezeigt)
6. Gehe zu **"Chat"** → Erstellen Sie einen neuen Assistenten, der mit Ihrer Knowledge Base verknüpft ist
7. Stellen Sie Fragen zu Ihren Dokumenten

***

### Beispiel 2: API — Knowledge Base erstellen und Dokumente hochladen

```python
import requests
import json
from pathlib import Path

BASE_URL = "http://<your-clore-server-ip>:9380"
API_KEY = "your-ragflow-api-key"  # Abruf unter Einstellungen → API

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# Schritt 1: Eine Knowledge Base erstellen
kb_payload = {
    "name": "Clore.ai Technical Docs",
    "description": "GPU-Cloud-Marktplatz-Dokumentation und Leitfäden",
    "language": "English",
    "embedding_model": "text-embedding-ada-002",
    "chunk_method": "naive",  # oder 'qa', 'table', 'paper', 'book'
}

response = requests.post(
    f"{BASE_URL}/api/v1/knowledgebase",
    headers=headers,
    json=kb_payload
)
kb = response.json()
kb_id = kb["data"]["id"]
print(f"Erstellte Knowledge Base: {kb_id}")

# Schritt 2: Ein Dokument hochladen
pdf_path = Path("technical_manual.pdf")

with open(pdf_path, "rb") as f:
    files = {"file": (pdf_path.name, f, "application/pdf")}
    upload_response = requests.post(
        f"{BASE_URL}/api/v1/document/upload?kb_id={kb_id}",
        headers={"Authorization": f"Bearer {API_KEY}"},
        files=files
    )

doc = upload_response.json()
doc_id = doc["data"]["id"]
print(f"Hochgeladenes Dokument: {doc_id}")

# Schritt 3: Parsen starten
parse_response = requests.post(
    f"{BASE_URL}/api/v1/document/run",
    headers=headers,
    json={"doc_ids": [doc_id]}
)
print(f"Parsen gestartet: {parse_response.json()}")
```

***

### Beispiel 3: Dokumente per API abfragen

```python
import requests
import json

BASE_URL = "http://<your-clore-server-ip>:9380"
API_KEY = "your-ragflow-api-key"
CHAT_ID = "your-chat-assistant-id"  # Aus WebUI → Chat

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

def ask_ragflow(question, chat_id, session_id=None):
    """Senden Sie eine Frage an RAGFlow und erhalten Sie eine Antwort mit Zitaten."""
    payload = {
        "question": question,
        "stream": False
    }

    if session_id:
        payload["session_id"] = session_id

    response = requests.post(
        f"{BASE_URL}/api/v1/chat/{chat_id}/completion",
        headers=headers,
        json=payload
    )

    result = response.json()
    if result.get("code") == 0:
        data = result["data"]
        answer = data.get("answer", "")
        references = data.get("reference", {}).get("chunks", [])
        return answer, references
    else:
        return None, []

# Beispielanfragen
questions = [
    "Welche GPU-Spezifikationen sind auf Clore.ai verfügbar?",
    "Wie miete ich einen GPU-Server auf dem Marktplatz?",
    "Wie sieht das Preismodell für GPU-Instanzen aus?",
    "Welche Deep-Learning-Frameworks werden unterstützt?",
]

for question in questions:
    print(f"\n📌 Q: {question}")
    answer, refs = ask_ragflow(question, CHAT_ID)
    print(f"💬 A: {answer}")
    if refs:
        print(f"📚 Quellen ({len(refs)} Chunks):")
        for ref in refs[:2]:
            print(f"   - {ref.get('docnm_kwd', 'Unbekannt')}: {ref.get('content_ltks', '')[:100]}...")
```

***

### Beispiel 4: Batch-Dokumentenverarbeitungspipeline

```python
import requests
import time
from pathlib import Path

BASE_URL = "http://<your-clore-server-ip>:9380"
API_KEY = "your-ragflow-api-key"

headers = {"Authorization": f"Bearer {API_KEY}"}

def upload_and_parse_documents(kb_id, document_paths):
    """Mehrere Dokumente hochladen und auf Abschluss des Parsens warten."""
    doc_ids = []

    # Alle Dokumente hochladen
    for doc_path in document_paths:
        path = Path(doc_path)
        with open(path, "rb") as f:
            mime = "application/pdf" if path.suffix == ".pdf" else "text/plain"
            files = {"file": (path.name, f, mime)}
            resp = requests.post(
                f"{BASE_URL}/api/v1/document/upload?kb_id={kb_id}",
                headers=headers,
                files=files
            )
            if resp.status_code == 200:
                doc_id = resp.json()["data"]["id"]
                doc_ids.append(doc_id)
                print(f"✓ Hochgeladen: {path.name} → {doc_id}")
            else:
                print(f"✗ Fehlgeschlagen: {path.name}")

    # Batch-Parsing starten
    if doc_ids:
        requests.post(
            f"{BASE_URL}/api/v1/document/run",
            headers={**headers, "Content-Type": "application/json"},
            json={"doc_ids": doc_ids}
        )
        print(f"\nParsen von {len(doc_ids)} Dokumenten...")

        # Abfragen, bis abgeschlossen
        while True:
            time.sleep(5)
            status_resp = requests.get(
                f"{BASE_URL}/api/v1/document/list?kb_id={kb_id}",
                headers=headers
            )
            docs = status_resp.json().get("data", {}).get("docs", [])
            pending = [d for d in docs if d.get("status") == "1"]  # 1 = Verarbeitung
            done = [d for d in docs if d.get("status") == "2"]     # 2 = abgeschlossen

            print(f"  In Bearbeitung: {len(pending)} | Fertig: {len(done)}/{len(doc_ids)}")

            if len(pending) == 0:
                break

    print("✓ Alle Dokumente geparst!")
    return doc_ids

# Verwendung
docs = ["manual_v1.pdf", "faq.txt", "api_reference.pdf"]
doc_ids = upload_and_parse_documents(kb_id="your-kb-id", document_paths=docs)
```

***

### Beispiel 5: RAGFlow mit lokalem Ollama-LLM

```bash
# 1. Ollama auf demselben Clore.ai-Server installieren
curl -fsSL https://ollama.ai/install.sh | sh

# 2. Ein lokales Modell herunterladen
ollama pull llama3:8b
ollama pull nomic-embed-text  # Für Embeddings

# 3. RAGFlow so konfigurieren, dass Ollama verwendet wird
# Im WebUI: Einstellungen → Modellanbieter → Ollama hinzufügen
# Basis-URL: http://host.docker.internal:11434
# Oder wenn Ollama in Docker läuft: http://ollama:11434
```

```python
# Ollama-Integration testen
import requests

# Überprüfen, ob Ollama läuft
resp = requests.get("http://localhost:11434/api/tags")
models = [m["name"] for m in resp.json()["models"]]
print(f"Verfügbare Ollama-Modelle: {models}")

# RAGFlow mit lokalem LLM abfragen (im WebUI konfiguriert)
BASE_URL = "http://localhost:9380"
API_KEY = "your-api-key"
CHAT_ID = "your-chat-id"

response = requests.post(
    f"{BASE_URL}/api/v1/chat/{CHAT_ID}/completion",
    headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
    json={"question": "Explain the RAGFlow architecture", "stream": False}
)
print(response.json()["data"]["answer"])
```

***

## Konfiguration

### docker-compose.yml Schlüsselservices

```yaml
services:
  ragflow:
    image: infiniflow/ragflow:latest
    ports:
      - "9380:9380"
      - "80:80"
    environment:
      - HF_ENDPOINT=https://huggingface.co
      - MACOS=0
    depends_on:
      - mysql
      - minio
      - es01
      - redis

  es01:
    image: elasticsearch:8.11.3
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
    volumes:
      - esdata01:/usr/share/elasticsearch/data

  mysql:
    image: mysql:8.0.39
    environment:
      - MYSQL_ROOT_PASSWORD=infini_rag_flow

  minio:
    image: quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
    command: server /data --console-address ":9001"

  redis:
    image: redis:7.2.4
```

### Chunking-Strategien

| Methode  | Am besten für                   | Beschreibung                          |
| -------- | ------------------------------- | ------------------------------------- |
| `naiv`   | Allgemeine Dokumente            | Chunks fester Größe mit Überlappung   |
| `qa`     | FAQ-/Q\&A-Dokumente             | Teilt anhand von Frage-Antwort-Paaren |
| `table`  | Tabellenkalkulationen, Tabellen | Bewahrt Tabellenstruktur              |
| `paper`  | Wissenschaftliche Artikel       | Abschnitte, Abstract, Referenzen      |
| `book`   | Lange Bücher, Handbücher        | Kapitelerkennendes Chunking           |
| `laws`   | Rechtliche Dokumente            | Artikelbasiertes Chunking             |
| `manual` | Technische Handbücher           | Erhaltung der Abschnittshierarchie    |

***

## Leistungs-Tipps

### 1. Elasticsearch-Speicher skalieren

```yaml
# In docker-compose.yml
es01:
  environment:
    - ES_JAVA_OPTS=-Xms4g -Xmx4g  # Für große Dokumentensätze erhöhen
```

### 2. GPU-beschleunigte Embeddings

Konfigurieren Sie RAGFlow so, dass ein GPU-basiertes Embedding-Modell verwendet wird:

* In Einstellungen → Modellanbieter ein lokales GPU-Modell über Ollama verwenden
* Oder verweisen Sie auf einen dedizierten Embedding-Dienst, der auf der Clore.ai-GPU läuft

### 3. Parallele Dokumentenverarbeitung

RAGFlow verarbeitet Dokumente standardmäßig parallel. Konfigurieren Sie die Anzahl der Worker:

```env
# In docker/.env
TASK_WORKER_COUNT=4  # An CPU-Kerne anpassen
```

### 4. MinIO für große Dokumentensätze

Für Deployments mit tausenden Dokumenten konfigurieren Sie dedizierten MinIO-Speicher mit größerer Festplattenzuweisung in Ihrer CLORE.AI-Bestellung.

***

## Fehlerbehebung

### Problem: Dienste starten nicht (Speicher)

```bash
# Speicherverbrauch prüfen
free -h
docker stats

# Elasticsearch-Speicher reduzieren
# Edit docker/.env: ES_JAVA_OPTS=-Xms1g -Xmx1g
```

### Problem: Kein Zugriff auf WebUI über Port 80

```bash
# Prüfen, ob nginx läuft
docker compose ps

# Überprüfen Sie die Port-Bindung
docker port ragflow-nginx-1

# Überprüfen in CLORE.AI: Port 80 muss in Ihrer Serverbestellung gemappt sein
```

### Problem: Dokumentenparsing hängt

```bash
# Task-Worker-Logs prüfen
docker compose logs ragflow-worker

# Worker neu starten
docker compose restart ragflow-worker
```

### Problem: Elasticsearch-Heap out of memory

```bash
# Heap in .env erhöhen
ES_JAVA_OPTS=-Xms2g -Xmx2g
docker compose restart es01
```

### Problem: Embedding-Modell nicht gefunden

```bash
# HuggingFace-Modell-Download prüfen
docker exec ragflow-server ls /ragflow/models/

# Erneut herunterladen
docker exec ragflow-server python -c "
from huggingface_hub import snapshot_download
snapshot_download('BAAI/bge-large-en-v1.5')
"
```

***

## Links

* **GitHub**: <https://github.com/infiniflow/ragflow>
* **Offizielle Dokumentation**: <https://ragflow.io/docs>
* **Docker Hub**: <https://hub.docker.com/r/infiniflow/ragflow>
* **API-Referenz**: <https://ragflow.io/docs/dev/http_api_reference>
* **Discord**: <https://discord.gg/4XxujFgUN7>
* **CLORE.AI Marketplace**: <https://clore.ai/marketplace>

***

## Clore.ai GPU-Empfehlungen

| Anwendungsfall          | Empfohlene GPU  | Geschätzte Kosten auf Clore.ai |
| ----------------------- | --------------- | ------------------------------ |
| Entwicklung/Tests       | RTX 3090 (24GB) | \~$0.12/gpu/hr                 |
| Produktion RAG          | RTX 3090 (24GB) | \~$0.12/gpu/hr                 |
| Hochdurchsatz-Embedding | RTX 4090 (24GB) | \~$0.70/gpu/hr                 |

> 💡 Alle Beispiele in diesem Leitfaden können bereitgestellt werden auf [Clore.ai](https://clore.ai/marketplace) GPU-Servern. Durchsuchen Sie verfügbare GPUs und mieten Sie stundenweise — keine Verpflichtungen, voller Root-Zugriff.


---

# 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-de/rag-and-vektordatenbanken/ragflow.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.
