pub struct Retriever { /* private fields */ }Expand description
Orchestrates the retrieval modes over a store + embedder (+ optional LLM).
Implementations§
Source§impl Retriever
impl Retriever
Sourcepub fn new(
store: Arc<dyn VectorStore>,
embedder: Arc<dyn Embedder>,
chat: Option<Arc<dyn ChatModel>>,
) -> Self
pub fn new( store: Arc<dyn VectorStore>, embedder: Arc<dyn Embedder>, chat: Option<Arc<dyn ChatModel>>, ) -> Self
Build a retriever. Pass chat = None to run without an LLM (vector/bm25/hybrid only).
Sourcepub fn with_rrf_k(self, k: f32) -> Self
pub fn with_rrf_k(self, k: f32) -> Self
Override the RRF constant (default 60).
Sourcepub fn with_multiquery_n(self, n: usize) -> Self
pub fn with_multiquery_n(self, n: usize) -> Self
Override the number of Multi-Query rewrites (default 4).
Sourcepub async fn retrieve(
&self,
mode: RetrievalMode,
query: &str,
k: usize,
) -> Result<Vec<Scored>>
pub async fn retrieve( &self, mode: RetrievalMode, query: &str, k: usize, ) -> Result<Vec<Scored>>
Retrieve the top k chunks for query using mode.
Sourcepub async fn bm25(&self, query: &str, k: usize) -> Result<Vec<Scored>>
pub async fn bm25(&self, query: &str, k: usize) -> Result<Vec<Scored>>
Sparse BM25 keyword search over the whole chunk corpus.
Sourcepub async fn hybrid(&self, query: &str, k: usize) -> Result<Vec<Scored>>
pub async fn hybrid(&self, query: &str, k: usize) -> Result<Vec<Scored>>
Hybrid RAG: fuse dense + sparse results with RRF. Over-fetches each arm so fusion has depth to work with.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Retriever
impl !UnwindSafe for Retriever
impl Freeze for Retriever
impl Send for Retriever
impl Sync for Retriever
impl Unpin for Retriever
impl UnsafeUnpin for Retriever
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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