Files
landing_page/qdrant-landing/content/documentation/embeddings/ollama.md
T
Bastian Hofmann b098b8fc44 Merge pull request #1850 from notemptylist/fix/typos
Update ollama.md to update default qdrant port to 6333
2025-12-16 13:45:31 +01:00

1.6 KiB

title
title
Ollama

Using Ollama with Qdrant

Ollama provides specialized embeddings for niche applications. Ollama supports a variety of embedding models, making it possible to build retrieval augmented generation (RAG) applications that combine text prompts with existing documents or other data in specialized areas.

Installation

You can install the required packages using the following pip command:

pip install ollama qdrant-client

Integration Example

The following code assumes Ollama is accessible at port 11434 and Qdrant at port 6333.

from qdrant_client import QdrantClient, models
import ollama

COLLECTION_NAME = "NicheApplications"

# Initialize Ollama client
oclient = ollama.Client(host="localhost")

# Initialize Qdrant client
qclient = QdrantClient(host="localhost", port=6333)

# Text to embed
text = "Ollama excels in niche applications with specific embeddings"

# Generate embeddings
response = oclient.embeddings(model="qwen3-embedding", prompt=text)
embeddings = response["embedding"]

# Create a collection if it doesn't already exist
if not qclient.collection_exists(COLLECTION_NAME):
    qclient.create_collection(
        collection_name=COLLECTION_NAME,
        vectors_config=models.VectorParams(
            size=len(embeddings), distance=models.Distance.COSINE
        ),
    )

# Upload the vectors to the collection along with the original text as payload
qclient.upsert(
    collection_name=COLLECTION_NAME,
    points=[models.PointStruct(id=1, vector=embeddings, payload={"text": text})],
)