Skip to content

embeddings

diapason.connectors.embeddings

Dense embedding clients for the IngestionPipeline.

A thin HTTP wrapper around a local Ollama <https://ollama.com>_ daemon running an embedding model (default nomic-embed-text, 768-dim). Embeddings are serialised as float32 bytes for storage in the embedding BLOB column of knowledge_chunks.

The client degrades gracefully when the daemon is unreachable: embed returns None and is_available() reports False instead of raising, so ingestion never fails because a sidecar service is down.

OllamaEmbedder

Embed text via a local Ollama daemon.

Parameters

model: Ollama model tag (e.g. nomic-embed-text, mxbai-embed-large). host: Base URL for the Ollama HTTP API. Defaults to http://localhost:11434. timeout: Per-request timeout in seconds.

dim property

Embedding dimensionality, learned after the first successful call.

model_version property

Stable identifier persisted alongside each embedding row.

embed(text)

Embed a single string. Returns float32 bytes or None on failure.

embed_batch(texts)

Embed a list of strings sequentially.

Ollama's HTTP API serves one prompt per call; on the same host the round-trip overhead is negligible relative to model inference.

is_available()

Return True iff the daemon answers and the model is installed.

decode_embedding(blob, *, dtype=None)

Reconstruct a 1-D vector from a BLOB written by OllamaEmbedder.embed.

Returns None when the input is missing or zero-length so callers can treat absent embeddings uniformly. dtype defaults to np.float32 (resolved lazily; passing np.float32 as a default arg would import numpy at module load).