How to Set Up a Vector Database (Qdrant) for AI Applications

Vector databases store and search data by semantic similarity rather than exact matches — the essential backbone for AI applications like semantic search, recommendation systems, and retrieval-augmented generation (RAG).

What Vector Databases Solve

Traditional databases search for exact or pattern matches; vector databases search for conceptual similarity by comparing numerical "embeddings" — letting you find documents about similar topics even when they don't share the same keywords.

Why Qdrant

Qdrant is a fast, open-source vector database with a straightforward API and reasonable resource requirements, making it a practical choice for self-hosting on a VPS compared to some heavier alternatives.

Step 1 — Run Qdrant with Docker

docker run -d \
  --name qdrant \
  --restart unless-stopped \
  -p 6333:6333 \
  -v qdrant-data:/qdrant/storage \
  qdrant/qdrant

Step 2 — Verify It's Running

curl http://localhost:6333/healthz

Step 3 — Create a Collection

curl -X PUT http://localhost:6333/collections/my_documents \
  -H "Content-Type: application/json" \
  -d '{
    "vectors": {
      "size": 384,
      "distance": "Cosine"
    }
  }'

size must match the dimension of the embedding model you're using (384 is common for smaller embedding models; larger models produce longer vectors).

Step 4 — Generate Embeddings for Your Data

Use an embedding model (via a Python library like sentence-transformers, or a hosted embedding API) to convert your text into vectors before storing them — Qdrant stores and searches vectors, but doesn't generate them itself.

from sentence_transformers import SentenceTransformer

model = SentenceTransformer('all-MiniLM-L6-v2')
embedding = model.encode("Your document text here")

Step 5 — Insert Vectors into Qdrant

curl -X PUT http://localhost:6333/collections/my_documents/points \
  -H "Content-Type: application/json" \
  -d '{
    "points": [
      {
        "id": 1,
        "vector": [0.1, 0.2, ...],
        "payload": {"text": "Your document text here"}
      }
    ]
  }'

Step 6 — Perform a Similarity Search

curl -X POST http://localhost:6333/collections/my_documents/points/search \
  -H "Content-Type: application/json" \
  -d '{
    "vector": [0.15, 0.22, ...],
    "limit": 5
  }'

Returns the most semantically similar stored documents to your query vector.

Securing Qdrant

Qdrant has no authentication enabled by default — restrict network access via firewall, or enable Qdrant's API key authentication feature for anything beyond local-only access:

sudo ufw allow from YOUR_APP_SERVER_IP to any port 6333

Using Qdrant in a RAG Pipeline

See How to Deploy a RAG (Retrieval-Augmented Generation) Pipeline on a VPS for how Qdrant fits into a complete question-answering system combined with a language model.

Backing Up Qdrant Data

docker run --rm -v qdrant_qdrant-data:/data -v $(pwd):/backup alpine tar czf /backup/qdrant-backup.tar.gz /data

Common Errors

"vector dimension mismatch" — the vector size in your insert/search request doesn't match the collection's configured dimension; verify your embedding model's output size matches the collection definition.

Continue Reading

Browse more articles in AI & Machine Learning on a VPS.

  • qdrant, vector database, semantic search, embeddings database
  • 0 משתמשים שמצאו מאמר זה מועיל
?האם התשובה שקיבלתם הייתה מועילה

מאמרים קשורים

VPS Requirements for Running AI and Machine Learning Workloads

Before installing any AI tooling, it's worth understanding what a VPS can and can't realistically...

How to Install Ollama and Run Local LLMs on a VPS

Ollama makes running open-source large language models locally straightforward — handling...

How to Set Up a Private ChatGPT-Style Interface with Open WebUI

Open WebUI provides a familiar, browser-based chat interface for locally-run language models...

How to Install LocalAI as an OpenAI-Compatible API Alternative

LocalAI provides a drop-in, OpenAI-API-compatible endpoint backed by open-source models running...

How to Run Stable Diffusion for AI Image Generation on a VPS

Stable Diffusion generates images from text prompts using an open-source diffusion model. This...