pub struct HybridRetriever<E: Embedder> { /* private fields */ }Expand description
Hybrid retriever combining dense and sparse retrieval
Implementations§
Source§impl<E: Embedder> HybridRetriever<E>
impl<E: Embedder> HybridRetriever<E>
Sourcepub fn new(dense: VectorStore, sparse: BM25Index, embedder: E) -> Self
pub fn new(dense: VectorStore, sparse: BM25Index, embedder: E) -> Self
Create a new hybrid retriever
Sourcepub fn with_config(self, config: HybridRetrieverConfig) -> Self
pub fn with_config(self, config: HybridRetrieverConfig) -> Self
Set the configuration
Sourcepub fn dense_store(&self) -> &VectorStore
pub fn dense_store(&self) -> &VectorStore
Get the dense store
Sourcepub fn dense_store_mut(&mut self) -> &mut VectorStore
pub fn dense_store_mut(&mut self) -> &mut VectorStore
Get the dense store mutably
Sourcepub fn sparse_index(&self) -> &BM25Index
pub fn sparse_index(&self) -> &BM25Index
Get the sparse index
Sourcepub fn sparse_index_mut(&mut self) -> &mut BM25Index
pub fn sparse_index_mut(&mut self) -> &mut BM25Index
Get the sparse index mutably
Sourcepub fn index(&mut self, chunk: Chunk) -> Result<()>
pub fn index(&mut self, chunk: Chunk) -> Result<()>
Index a chunk (adds to both dense and sparse indices)
Sourcepub fn retrieve(&self, query: &str, k: usize) -> Result<Vec<RetrievalResult>>
pub fn retrieve(&self, query: &str, k: usize) -> Result<Vec<RetrievalResult>>
Retrieve relevant chunks for a query
Sourcepub fn retrieve_dense(
&self,
query: &str,
k: usize,
) -> Result<Vec<RetrievalResult>>
pub fn retrieve_dense( &self, query: &str, k: usize, ) -> Result<Vec<RetrievalResult>>
Retrieve using only dense (vector) search
Sourcepub fn retrieve_sparse(
&self,
query: &str,
k: usize,
) -> Result<Vec<RetrievalResult>>
pub fn retrieve_sparse( &self, query: &str, k: usize, ) -> Result<Vec<RetrievalResult>>
Retrieve using only sparse (BM25) search
Auto Trait Implementations§
impl<E> Freeze for HybridRetriever<E>where
E: Freeze,
impl<E> !RefUnwindSafe for HybridRetriever<E>
impl<E> Send for HybridRetriever<E>
impl<E> Sync for HybridRetriever<E>
impl<E> Unpin for HybridRetriever<E>where
E: Unpin,
impl<E> UnsafeUnpin for HybridRetriever<E>where
E: UnsafeUnpin,
impl<E> !UnwindSafe for HybridRetriever<E>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more