Embedding

Vektorerzeugung für semantische Suche und RAG.

Modelmxbai-embed-large
Dimensionen1024
ProviderOllama (lokal)
FallbackOpenAI (optional)

Qdrant Collections

CollectionZweckDimensionen
documentsDokument-Chunks1024
mailE-Mail-Inhalte1024
entitiesEntitäten-Embeddings1024

Qdrant-Konfiguration

{
  "vectors": {
    "size": 1024,
    "distance": "Cosine"
  },
  "hnsw_config": {
    "m": 16,
    "ef_construct": 100
  }
}

Model installieren

ollama pull mxbai-embed-large
ollama list

API-Aufruf

curl http://localhost:11434/api/embeddings -d '{
  "model": "mxbai-embed-large",
  "prompt": "Text zum Embedden"
}'

Python-Integration

import requests

def get_embedding(text: str) -> list[float]:
    response = requests.post(
        'http://localhost:11434/api/embeddings',
        json={
            'model': 'mxbai-embed-large',
            'prompt': text
        }
    )
    return response.json()['embedding']

Qdrant-Speicherung

from qdrant_client import QdrantClient
from qdrant_client.models import PointStruct

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

client.upsert(
    collection_name="documents",
    points=[
        PointStruct(
            id=uuid4().hex,
            vector=embedding,
            payload={
                "document_id": 123,
                "chunk_id": 1,
                "content_preview": text[:200]
            }
        )
    ]
)