pub struct BgeM3Embedder { /* private fields */ }Expand description
BGE-M3 multi-function embedder via Ollama.
Produces three representations from a single Ollama model call:
- Dense vector — direct from Ollama’s
/api/embedendpoint. - Sparse weights — derived from the BGE-M3 dense vector via explicit top-k thresholding because Ollama does not expose native sparse output.
- ColBERT-style multi-vector — dense vector chunked into pseudo per-token embeddings for late interaction scoring.
§Current Limitations
Ollama’s embedding API (/api/embed) currently returns only dense vectors.
The sparse and multi-vec representations are derived from the dense output.
They are not SPLADE outputs. When Ollama (or another backend) exposes native
BGE-M3 sparse and per-token outputs, this implementation can use those
representations directly without changing the retrieval interface.
The model bge-m3 produces 1024-dimensional dense embeddings.
Implementations§
Source§impl BgeM3Embedder
impl BgeM3Embedder
Sourcepub fn try_new(config: &EmbeddingConfig) -> Result<Self, MemoryError>
pub fn try_new(config: &EmbeddingConfig) -> Result<Self, MemoryError>
Create a new BgeM3Embedder from embedding config.
Uses bge-m3 as the model name with 1024 dimensions by default.
The Ollama URL and timeout are taken from the config.
Sourcepub fn try_new_with_derive(
config: &EmbeddingConfig,
derive_config: BgeM3DeriveConfig,
) -> Result<Self, MemoryError>
pub fn try_new_with_derive( config: &EmbeddingConfig, derive_config: BgeM3DeriveConfig, ) -> Result<Self, MemoryError>
Create a new BgeM3Embedder with custom derivation parameters.
Sourcepub fn with_params(
base_url: &str,
model: &str,
dimensions: usize,
batch_size: usize,
timeout_secs: u64,
derive_config: BgeM3DeriveConfig,
) -> Result<Self, MemoryError>
pub fn with_params( base_url: &str, model: &str, dimensions: usize, batch_size: usize, timeout_secs: u64, derive_config: BgeM3DeriveConfig, ) -> Result<Self, MemoryError>
Create a BgeM3Embedder with explicit parameters (useful for testing
without an EmbeddingConfig).
Trait Implementations§
Source§impl Embedder for BgeM3Embedder
BgeM3Embedder also implements the standard Embedder trait for compatibility,
returning only the dense representation.
impl Embedder for BgeM3Embedder
BgeM3Embedder also implements the standard Embedder trait for compatibility,
returning only the dense representation.