embeddings
embeddings
¶
Embeddings abstraction for dense retrieval backends.
Classes¶
Embedder
¶
SentenceTransformerEmbedder
¶
Bases: Embedder
Embedder backed by sentence-transformers.
| PARAMETER | DESCRIPTION |
|---|---|
model_name
|
HuggingFace model identifier. Defaults to the lightweight
TYPE:
|
Source code in src/openjarvis/tools/storage/embeddings.py
OllamaEmbedder
¶
OllamaEmbedder(model: str = 'nomic-embed-text', base_url: str = 'http://localhost:11434', *, batch_size: int = 16, max_parallel: int = 8, timeout_s: float = 120.0)
Bases: Embedder
Embedder backed by an Ollama server's /api/embed endpoint.
Sends batches in parallel (up to max_parallel) since Ollama
serializes items within a single HTTP request but happily serves
multiple concurrent connections.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Ollama model tag; defaults to
TYPE:
|
base_url
|
Ollama server base URL. Defaults to
TYPE:
|
batch_size
|
Items per HTTP request. Tuned for Ollama — larger batches help throughput but increase memory on the server.
TYPE:
|
max_parallel
|
How many concurrent HTTP requests to issue. Ollama CPU/GPU saturation is typically hit around 8.
TYPE:
|
timeout_s
|
Per-request timeout.
TYPE:
|
Source code in src/openjarvis/tools/storage/embeddings.py
Functions¶
embed
¶
Return a numpy array of shape (len(texts), dim).
Float32, L2-normalized per row so callers can use dot-product
as cosine similarity. Empty input → shape (0, dim).
Source code in src/openjarvis/tools/storage/embeddings.py
dim
¶
Return the embedding dimensionality (probes the server on first call).