pub struct Bgem3Provider { /* private fields */ }Expand description
BGE-M3 joint embedder — dense + sparse from one pass.
§Memory
fastembed’s BGE-M3 graph always emits a third, ColBERT (multi-vector)
output, and accumulates it for every text passed in a single call —
roughly seq_len × 1024 × 4 bytes each, about 2 MB for a 512-token chunk.
Handing it a million chunks at once would therefore exhaust memory long
before it finished. This provider slices its input into
with_batch_cap-sized runs and drops the ColBERT
tensors as soon as each run is converted, so bulk indexing stays flat.
§Model
fastembed ships BGE-M3 as an int8-quantized ONNX export
(gpahal/bge-m3-onnx-int8), not full precision.
Implementations§
Source§impl Bgem3Provider
impl Bgem3Provider
Sourcepub fn new(cache_dir: Option<PathBuf>) -> Result<Self>
pub fn new(cache_dir: Option<PathBuf>) -> Result<Self>
Load BGE-M3, downloading it on first use.
cache_dir overrides the HuggingFace model cache directory.
Sourcepub fn with_max_length(
max_length: usize,
cache_dir: Option<PathBuf>,
) -> Result<Self>
pub fn with_max_length( max_length: usize, cache_dir: Option<PathBuf>, ) -> Result<Self>
Load BGE-M3 with an explicit maximum sequence length. Longer inputs are truncated; BGE-M3 itself supports up to 8192 tokens.
Sourcepub fn with_batch_cap(self, cap: usize) -> Self
pub fn with_batch_cap(self, cap: usize) -> Self
Cap how many texts are sent to the model per call.
This bounds peak memory: the discarded ColBERT output is accumulated per call, so a larger cap trades memory for slightly fewer invocations. A cap of 0 is treated as 1.
Sourcepub fn with_sparse_top_k(self, k: usize) -> Self
pub fn with_sparse_top_k(self, k: usize) -> Self
Keep only the k highest-magnitude weights of each sparse vector.
Set this when the target store bounds non-zero elements — pgvector
refuses to build an HNSW index over a sparsevec beyond its cap. Off by
default, since the limit belongs to the backend, not the model.
Sourcepub fn vocab_size(&self) -> usize
pub fn vocab_size(&self) -> usize
Vocabulary size — the sparsevec(N) dimension for the sparse side.
Auto Trait Implementations§
impl !Freeze for Bgem3Provider
impl RefUnwindSafe for Bgem3Provider
impl Send for Bgem3Provider
impl Sync for Bgem3Provider
impl Unpin for Bgem3Provider
impl UnsafeUnpin for Bgem3Provider
impl UnwindSafe for Bgem3Provider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.