> 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/rag-and-vector-databases/qdrant.md).

# Qdrant

> **उच्च-प्रदर्शन वेक्टर डेटाबेस सिमेंटिक खोज और RAG अनुप्रयोगों के लिए — GPU-त्वरित इंडेक्सिंग**

Qdrant एक ओपन-सोर्स, प्रोडक्शन-रेडी वेक्टर डेटाबेस है जो Rust में लिखा गया है। यह विस्तृत फ़िल्टरिंग, पेलोड इंडेक्सिंग, और मल्टी-वेक्टर समर्थन के साथ अरबों वेक्टरों पर तेज़ अनुमानित निकटतम पड़ोसी (ANN) खोज प्रदान करता है। यह कई प्रोडक्शन RAG (Retrieval-Augmented Generation) पाइपलाइनों और सिमेंटिक सर्च अनुप्रयोगों की रीढ़ है।

**GitHub:** [qdrant/qdrant](https://github.com/qdrant/qdrant) — 22K+ ⭐

***

## Qdrant क्यों?

| फ़ीचर                    | ChromaDB | Pinecone       | Milvus | Chroma     |
| ------------------------ | -------- | -------------- | ------ | ---------- |
| ओपन सोर्स                | ✅        | ❌              | ✅      | ✅          |
| Rust प्रदर्शन            | ✅        | आणविक गतिशीलता | ❌ Go   | ❌ Python   |
| क्वेरी समय पर फ़िल्टरिंग | ✅ उन्नत  | ✅ बुनियादी     | ✅      | ✅ बुनियादी |
| मल्टी-वेक्टर             | ✅        | ❌              | ✅      | ❌          |
| डिस्क-आधारित HNSW        | ✅        | ✅              | ✅      | ❌          |
| पेलोड इंडेक्सिंग         | ✅        | सीमित          | ✅      | सीमित      |
| gRPC + REST              | ✅ दोनों  | ✅ REST         | ✅      | REST       |
| स्वयं-होस्टेड            | ✅        | ❌ केवल क्लाउड  | ✅      | ✅          |

{% hint style="success" %}
**Qdrant Rust में लिखा गया है** — मेमोरी सुरक्षा के साथ C-स्तरीय प्रदर्शन प्रदान करता है। बेंचमार्क परीक्षण दिखाते हैं कि Qdrant लगातार **1.5–3x तेज़** उच्च-लोड परिदृश्यों के लिए Chroma जैसे Python-आधारित विकल्पों की तुलना में।
{% endhint %}

***

## मुख्य उपयोग के मामले

* **RAG (Retrieval-Augmented Generation)** — LLM प्रॉम्प्ट्स के लिए प्रासंगिक संदर्भ खोजें
* **सिमेंटिक खोज** — केवल कीवर्ड्स नहीं बल्कि अर्थ के आधार पर खोज
* **सिफारिश प्रणाली** — एम्बेडिंग सादृश्यता के आधार पर समान आइटम खोजें
* **नकल पहचान** — निकट-नकली सामग्री की पहचान करें
* **विचित्रता पहचान (Anomaly detection)** — क्लस्टर केंद्रों से दूर वाले वेक्टर खोजें
* **छवि/ऑडियो सादृश्यता खोज** — मल्टीमॉडल पुनर्प्राप्ति

***

## पूर्व-आवश्यकताएँ

* GPU किराये के साथ Clore.ai खाता
* REST APIs या Python की बुनियादी परिचितता
* आपका चुना हुआ एम्बेडिंग मॉडल (OpenAI, SentenceTransformers, आदि)

***

## चरण 1 — Clore.ai पर सर्वर किराए पर लें

Qdrant मुख्य रूप से सर्विंग के लिए CPU/RAM-बंधित है, लेकिन GPU से लाभ होता है जब:

* सर्विंग के साथ-साथ एम्बेडिंग उत्पन्न करना (एंबेडिंग मॉडल उसी सर्वर पर)
* बड़े पैमाने पर बैच इंडेक्सिंग ऑपरेशंस

1. जाएँ [clore.ai](https://clore.ai) → **मार्केटप्लेस**
2. के लिए **एंबेडिंग + सर्विंग संयोजन:** RTX 3090/4090 के साथ 32GB+ RAM
3. के लिए **केवल सर्विंग:** तेज़ NVMe स्टोरेज वाला CPU-ऑप्टिमाइज़्ड सर्वर

{% hint style="info" %}
**मेमोरी योजना:**

* प्रत्येक float32 वेक्टर 1536 आयामों के साथ = 6KB
* 1 मिलियन वेक्टर = \~6GB RAM
* 10 मिलियन वेक्टर = \~60GB RAM
* बहुत बड़े कलेक्शनों के लिए ऑन-डिस्क स्टोरेज सक्षम करें
  {% endhint %}

***

## चरण 2 — Qdrant कंटेनर तैनात करें

**Docker इमेज:**

```
qdrant/qdrant:latest
```

**पोर्ट्स:**

```
22
6333
6334
```

* **पोर्ट 6333:** REST API (HTTP)
* **पोर्ट 6334:** gRPC API (बुल्क ऑपरेशंस के लिए अधिक प्रदर्शन)

**पर्यावरण चर:**

```
QDRANT__SERVICE__HTTP_PORT=6333
QDRANT__SERVICE__GRPC_PORT=6334
QDRANT__LOG_LEVEL=INFO
QDRANT__STORAGE__STORAGE_PATH=/qdrant/storage
```

**वॉल्यूम/स्थायी स्टोरेज:** माउंट करें `/qdrant/storage` डेटा स्थायित्व के लिए। इसके बिना, कंटेनर पुनःप्रारंभ पर डेटा खो जाता है।

***

## चरण 3 — सत्यापित करें कि Qdrant चल रहा है

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

# जाँचें कि Qdrant चल रहा है
curl http://localhost:6333/

# अपेक्षित उत्तर:
# {"title":"qdrant - vector search engine","version":"..."}

# स्वास्थ्य जाँच करें
curl http://localhost:6333/healthz

# क्लस्टर जानकारी जाँचें
curl http://localhost:6333/cluster
```

***

## चरण 4 — Python क्लाइंट इंस्टॉल करें

```bash
# Qdrant Python क्लाइंट और एम्बेडिंग टूल्स इंस्टॉल करें
pip install qdrant-client sentence-transformers openai numpy

# कनेक्शन सत्यापित करें
python3 << 'EOF'
from qdrant_client import QdrantClient

client = QdrantClient("localhost", port=6333)
print(f"Qdrant connected: {client.get_collections()}")
EOF
```

***

## चरण 5 — एक कलेक्शन बनाएं

एक कलेक्शन नामांकित वेक्टर समूह है जिसमें निश्चित आयामता होती है।

```python
from qdrant_client import QdrantClient
from qdrant_client.models import (
    Distance,
    VectorParams,
    HnswConfigDiff,
    OptimizersConfigDiff,
    QuantizationConfig,
    ScalarQuantizationConfig,
    ScalarType
)

client = QdrantClient("localhost", port=6333)

# OpenAI text-embedding-3-small (1536 dims) के लिए कलेक्शन बनाएं
client.create_collection(
    collection_name="documents",
    vectors_config=VectorParams(
        size=1536,           # वेक्टर आयाम (अपने एम्बेडिंग मॉडल से मिलान करें)
        distance=Distance.COSINE,  # विकल्प: COSINE, EUCLID, DOT
        on_disk=False        # बहुत बड़े कलेक्शनों के लिए True सेट करें
    ),
    hnsw_config=HnswConfigDiff(
        m=16,                # HNSW ग्राफ़ कनेक्टिविटी (ज्यादा = बेहतर रिकॉल, अधिक RAM)
        ef_construct=100,    # बिल्ड-टाइम सर्च गहराई (ज्यादा = बेहतर गुणवत्ता, धीमा इंडेक्सिंग)
        full_scan_threshold=10000  # इस गिनती से नीचे ब्रूट फोर्स उपयोग करें
    ),
    optimizers_config=OptimizersConfigDiff(
        indexing_threshold=20000  # इस कई वेक्टर के बाद HNSW इंडेक्सिंग शुरू करें
    ),
    quantization_config=QuantizationConfig(
        scalar=ScalarQuantizationConfig(
            type=ScalarType.INT8,  # वेक्टर को INT8 में संपीड़ित करें (4x मेमोरी घटाना)
            quantile=0.99,
            always_ram=True        # क्वांटाइज़्ड इंडेक्स को RAM में रखें
        )
    )
)

print("Collection created!")
print(client.get_collection("documents"))
```

### SentenceTransformers के लिए कलेक्शन (384 आयाम)

```python
client.create_collection(
    collection_name="embeddings_384",
    vectors_config=VectorParams(
        size=384,              # all-MiniLM-L6-v2 आउटपुट साइज
        distance=Distance.COSINE
    )
)
```

***

## चरण 6 — दस्तावेज़ों का इंडेक्स बनाएं

### OpenAI एम्बेडिंग के साथ

```python
from qdrant_client import QdrantClient
from qdrant_client.models import PointStruct
from openai import OpenAI
import uuid

client = QdrantClient("localhost", port=6333)
openai_client = OpenAI(api_key="your-openai-api-key")

def get_embeddings(texts: list[str], batch_size: int = 100) -> list[list[float]]:
    """बैचों में एम्बेडिंग जेनरेट करें."""
    all_embeddings = []
    for i in range(0, len(texts), batch_size):
        batch = texts[i:i + batch_size]
        response = openai_client.embeddings.create(
            model="text-embedding-3-small",
            input=batch
        )
        all_embeddings.extend([e.embedding for e in response.data])
    return all_embeddings

# नमूना दस्तावेज़
documents = [
    {
        "id": str(uuid.uuid4()),
        "text": "Qdrant एक उच्च प्रदर्शन के लिए Rust में बना वेक्टर डेटाबेस है.",
        "source": "documentation",
        "category": "database",
        "year": 2024
    },
    {
        "id": str(uuid.uuid4()),
        "text": "मशीन लर्निंग मॉडल टेक्स्ट को घने वेक्टर प्रतिनिधित्व में बदलते हैं.",
        "source": "article",
        "category": "ml",
        "year": 2023
    },
    # और दस्तावेज़ जोड़ें...
]

# एम्बेडिंग जेनरेट करें
texts = [doc["text"] for doc in documents]
embeddings = get_embeddings(texts)

# Qdrant में अपसर्ट करें
points = [
    PointStruct(
        id=str(uuid.uuid4()),
        vector=embedding,
        payload={
            "text": doc["text"],
            "source": doc["source"],
            "category": doc["category"],
            "year": doc["year"]
        }
    )
    for doc, embedding in zip(documents, embeddings)
]

client.upsert(
    collection_name="documents",
    points=points,
    wait=True  # इंडेक्सिंग के पूरा होने तक प्रतीक्षा करें
)

print(f"Indexed {len(points)} documents!")
```

### SentenceTransformers के साथ (स्थानीय, GPU-त्वरित)

```python
from sentence_transformers import SentenceTransformer
from qdrant_client import QdrantClient
from qdrant_client.models import PointStruct
import torch
import uuid

# GPU पर एम्बेडिंग मॉडल लोड करें
model = SentenceTransformer("all-MiniLM-L6-v2", device="cuda")

client = QdrantClient("localhost", port=6333)

documents = [
    {"text": "मैं GPU सर्वर पर Qdrant कैसे सेट अप करूँ?", "tag": "setup"},
    {"text": "वेक्टर डेटाबेस सादृश्यता खोज के लिए उच्च-आयामी एम्बेडिंग संग्रहीत करते हैं.", "tag": "concept"},
    {"text": "HNSW एल्गोरिथ्म अनुमानित निकटतम पड़ोसी खोज प्रदान करता है.", "tag": "algorithm"},
    # ... और दस्तावेज़
]

# GPU-त्वरित बैच एन्कोडिंग
texts = [doc["text"] for doc in documents]
embeddings = model.encode(
    texts,
    batch_size=256,       # GPU दक्षता के लिए बड़े बैच साइज
    show_progress_bar=True,
    normalize_embeddings=True  # cosine सादृश्यता के लिए सामान्यीकृत करें
)

# Qdrant में इंडेक्स करें
points = [
    PointStruct(
        id=str(uuid.uuid4()),
        vector=embedding.tolist(),
        payload=doc
    )
    for doc, embedding in zip(documents, embeddings)
]

# बैच अपसर्ट (अधिक कुशल)
BATCH_SIZE = 1000
for i in range(0, len(points), BATCH_SIZE):
    batch = points[i:i + BATCH_SIZE]
    client.upsert(collection_name="embeddings_384", points=batch)
    print(f"Indexed {min(i + BATCH_SIZE, len(points))}/{len(points)}")
```

***

## चरण 7 — खोज और क्वेरी

### मूल सिमेंटिक खोज

```python
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer

client = QdrantClient("localhost", port=6333)
model = SentenceTransformer("all-MiniLM-L6-v2", device="cuda")

def search(query: str, limit: int = 5, collection: str = "embeddings_384"):
    # क्वेरी एम्बेडिंग जेनरेट करें
    query_vector = model.encode(query, normalize_embeddings=True).tolist()
    
    # खोज
    results = client.search(
        collection_name=collection,
        query_vector=query_vector,
        limit=limit,
        with_payload=True,
        with_vectors=False    # वेक्टर न लौटाएँ (बैंडविड्थ बचता है)
    )
    
    return results

# खोज का परीक्षण करें
results = search("vector database performance")
for r in results:
    print(f"Score: {r.score:.4f} | {r.payload['text'][:100]}")
```

### फ़िल्टर की गई खोज (मेटाडेटा + वेक्टर)

```python
from qdrant_client.models import Filter, FieldCondition, MatchValue, Range

# मेटाडेटा फ़िल्टर के साथ खोज
results = client.search(
    collection_name="documents",
    query_vector=query_vector,
    query_filter=Filter(
        must=[
            FieldCondition(
                key="category",
                match=MatchValue(value="database")
            ),
            FieldCondition(
                key="year",
                range=Range(gte=2023)  # वर्ष >= 2023
            )
        ]
    ),
    limit=10,
    with_payload=True
)
```

### बैच/मल्टी-क्वेरी खोज

```python
from qdrant_client.models import SearchRequest

queries = [
    "how to install vector database",
    "machine learning inference optimization",
    "RAG pipeline architecture"
]

query_vectors = model.encode(queries, normalize_embeddings=True)

# बैच खोज (सभी क्वेरीज़ के लिए एक API कॉल)
results = client.search_batch(
    collection_name="embeddings_384",
    requests=[
        SearchRequest(
            vector=vec.tolist(),
            limit=5,
            with_payload=True
        )
        for vec in query_vectors
    ]
)

for query, res in zip(queries, results):
    print(f"\nQuery: {query}")
    for r in res:
        print(f"  {r.score:.3f}: {r.payload['text'][:80]}")
```

***

## चरण 8 — एक RAG पाइपलाइन बनाएं

```python
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
from openai import OpenAI

# क्लाइंट्स इनिशियलाइज़ करें
qdrant = QdrantClient("localhost", port=6333)
embedder = SentenceTransformer("all-MiniLM-L6-v2", device="cuda")
llm = OpenAI(api_key="your-openai-key")

def rag_query(question: str, n_context: int = 5) -> str:
    # चरण 1: प्रश्न का एम्बेडिंग बनाएं
    query_vector = embedder.encode(question, normalize_embeddings=True).tolist()
    
    # चरण 2: Qdrant से प्रासंगिक संदर्भ पुनःप्राप्त करें
    search_results = qdrant.search(
        collection_name="documents",
        query_vector=query_vector,
        limit=n_context,
        with_payload=True
    )
    
    # चरण 3: संदर्भ स्ट्रिंग बनाएं
    context = "\n\n".join([
        f"[Source: {r.payload.get('source', 'unknown')}]\n{r.payload['text']}"
        for r in search_results
        if r.score > 0.5  # कम-आत्मविश्वास परिणामों को फ़िल्टर करें
    ])
    
    # चरण 4: LLM के साथ उत्तर जेनरेट करें
    response = llm.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {
                "role": "system",
                "content": "दिए गए संदर्भ के आधार पर प्रश्नों का उत्तर दें। संक्षिप्त और सटीक रहें."
            },
            {
                "role": "user",
                "content": f"Context:\n{context}\n\nQuestion: {question}"
            }
        ],
        temperature=0.1
    )
    
    return response.choices[0].message.content

# RAG पाइपलाइन का परीक्षण करें
answer = rag_query("What is Qdrant and how does it work?")
print(answer)
```

***

## चरण 9 — कलेक्शनों की निगरानी और प्रबंधन

```python
# कलेक्शन सांख्यिकी
info = client.get_collection("documents")
print(f"Vectors count: {info.vectors_count:,}")
print(f"Points count: {info.points_count:,}")
print(f"Indexed vectors: {info.indexed_vectors_count:,}")
print(f"Status: {info.status}")
print(f"Disk usage: {info.disk_data_size / 1024 / 1024:.1f} MB")

# सभी कलेक्शनों की सूची बनाएं
collections = client.get_collections()
for c in collections.collections:
    print(f" - {c.name}")

# फ़िल्टर द्वारा पॉइंट्स हटाएँ
client.delete(
    collection_name="documents",
    points_selector=Filter(
        must=[FieldCondition(key="source", match=MatchValue(value="old_source"))]
    )
)

# कलेक्शन अनुकूलित करें (इंडेक्स बनाना फोर्स करें)
client.update_collection(
    collection_name="documents",
    optimizer_config=OptimizersConfigDiff(indexing_threshold=0)  # तात्कालिक इंडेक्सिंग जबरदस्ती करें
)
```

***

## समस्या निवारण

### कनेक्शन अस्वीकृत

```bash
# जाँचें कि Qdrant चल रहा है
docker ps | grep qdrant
# या प्रक्रिया जाँचें
ps aux | grep qdrant

# जाँचें कि पोर्ट खुले हैं
curl http://localhost:6333/
netstat -tlnp | grep 6333
```

### धीमी खोज प्रदर्शन

```python
# बेहतर रिकॉल के लिए HNSW पैरामीटर अनुकूलित करें
client.update_collection(
    collection_name="documents",
    hnsw_config=HnswConfigDiff(ef=128)  # खोज-समय ef बढ़ाएँ (डिफ़ॉल्ट 100)
)

# अधिक वेक्टर RAM में फिट करने के लिए INT8 क्वांटाइज़ेशन का उपयोग करें
```

### उच्च मेमोरी उपयोग

```python
# बड़े कलेक्शनों के लिए ऑन-डिस्क स्टोरेज सक्षम करें
client.create_collection(
    collection_name="large_collection",
    vectors_config=VectorParams(
        size=1536,
        distance=Distance.COSINE,
        on_disk=True  # वेक्टरों को RAM के बजाय डिस्क पर स्टोर करें
    )
)
```

***

## REST API शीघ्र संदर्भ

```bash
# कलेक्शन्स सूचीबद्ध करें
curl http://localhost:6333/collections

# कलेक्शन बनाएं
curl -X PUT http://localhost:6333/collections/my_collection \
    -H "Content-Type: application/json" \
    -d '{"vectors": {"size": 384, "distance": "Cosine"}}'

# पॉइंट्स गिनें
curl http://localhost:6333/collections/my_collection/points/count

# खोज
curl -X POST http://localhost:6333/collections/my_collection/points/search \
    -H "Content-Type: application/json" \
    -d '{
        "vector": [0.1, 0.2, ...],
        "limit": 5,
        "with_payload": true
    }'

# कलेक्शन हटाएँ
curl -X DELETE http://localhost:6333/collections/my_collection
```

***

## Clore.ai पर लागत अनुमान

| सेटअप       | सर्वर              | मासिक लागत | क्षमता       |
| ----------- | ------------------ | ---------- | ------------ |
| छोटा RAG    | RTX 3090, 32GB RAM | \~$60–80   | \~5M वेक्टर  |
| मध्यम खोज   | RTX 4090, 64GB RAM | \~$120–150 | \~15M वेक्टर |
| बड़े पैमाने | A100, 128GB RAM    | \~$250–350 | \~30M वेक्टर |

***

## अतिरिक्त संसाधन

* [Qdrant दस्तावेज़ीकरण](https://qdrant.tech/documentation/)
* [Qdrant GitHub](https://github.com/qdrant/qdrant)
* [Qdrant Python क्लाइंट](https://github.com/qdrant/qdrant-client)
* [Qdrant उदाहरण](https://github.com/qdrant/examples)
* [वेक्टर डेटाबेस बेंचमार्क](https://qdrant.tech/benchmarks/)
* [Sentence Transformers](https://www.sbert.net/)

***

*Clore.ai पर Qdrant आपको एक स्वयं-होस्टेड, उच्च-प्रदर्शन वेक्टर डेटाबेस देता है बिना Pinecone या Weaviate Cloud के प्रति-क्वेरी लागत के। यह लाखों दस्तावेज़ों को प्रोसेस करने वाली RAG पाइपलाइनों के लिए परफेक्ट है।*

***

## Clore.ai GPU सिफारिशें

| उपयोग केस             | सिफारिश की गई GPU | Clore.ai पर अनुमानित लागत |
| --------------------- | ----------------- | ------------------------- |
| डेवलपमेंट/टेस्टिंग    | RTX 3090 (24GB)   | \~$0.12/gpu/hr            |
| प्रोडक्शन वेक्टर सर्च | RTX 3090 (24GB)   | \~$0.12/gpu/hr            |
| हाई-थ्रूपुट एम्बेडिंग | RTX 4090 (24GB)   | \~$0.70/gpu/hr            |

> 💡 इस गाइड के सभी उदाहरण तैनात किए जा सकते हैं [Clore.ai](https://clore.ai/marketplace) GPU सर्वरों पर। उपलब्ध GPUs ब्राउज़ करें और घंटे के हिसाब से किराए पर लें — कोई प्रतिबद्धता नहीं, पूर्ण रूट एक्सेस।


---

# 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/rag-and-vector-databases/qdrant.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.
