Expand description
codemem-embeddings: Pluggable embedding providers for Codemem.
Supports multiple backends:
- Candle (default): Local BERT models via pure Rust ML (any HF BERT model)
- Ollama: Local Ollama server with any embedding model
- OpenAI: OpenAI API or any compatible endpoint (Together, Azure, etc.)
Modules§
Structs§
- Cached
Provider - Wraps any
EmbeddingProviderwith an LRU cache. - Embedding
Service - Embedding service with Candle inference (no internal cache — use
CachedProviderwrapper).
Constants§
- CACHE_
CAPACITY - Default LRU cache capacity.
- DEFAULT_
BATCH_ SIZE - Default batch size for batched embedding forward passes.
Configurable via
EmbeddingConfig.batch_sizeorCODEMEM_EMBED_BATCH_SIZE. - DEFAULT_
HF_ REPO - Default HuggingFace model repo ID.
Used internally and by
commands_initfor the default model download. - DEFAULT_
REMOTE_ DIMENSIONS - Default embedding dimensions for remote providers (Ollama/OpenAI).
Candle reads
hidden_sizefrom the model’s config.json instead. - MODEL_
NAME - Default model name (short form used for directory naming).
Traits§
- Embedding
Provider - Trait for pluggable embedding providers.
Functions§
- from_
env - Create an embedding provider from environment variables.
- parse_
dtype - Parse a dtype string into a Candle DType.