pub struct MmrExampleSelector<E> { /* private fields */ }Expand description
Maximal Marginal Relevance selector: trades relevance to the input
against novelty among already-selected examples. lambda controls
the trade-off — 1.0 is pure similarity (equivalent to the semantic
selector); 0.0 is pure diversity.
Implementations§
Source§impl<E> MmrExampleSelector<E>
impl<E> MmrExampleSelector<E>
Sourcepub fn new<F>(
embeddings: Arc<dyn Embeddings>,
k: usize,
lambda: f32,
text_of: F,
) -> Self
pub fn new<F>( embeddings: Arc<dyn Embeddings>, k: usize, lambda: f32, text_of: F, ) -> Self
Build with lambda clamped to [0, 1]. k is the number of
examples returned.
Sourcepub fn with_distance(self, d: Distance) -> Self
pub fn with_distance(self, d: Distance) -> Self
Override the distance metric.
Trait Implementations§
Source§impl<E> AsyncExampleSelector<E> for MmrExampleSelector<E>
impl<E> AsyncExampleSelector<E> for MmrExampleSelector<E>
Source§fn select_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 str,
examples: &'life2 [E],
) -> Pin<Box<dyn Future<Output = Result<Vec<E>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn select_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 str,
examples: &'life2 [E],
) -> Pin<Box<dyn Future<Output = Result<Vec<E>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Select examples to include for
input.Source§impl<E> ExampleSelector<E> for MmrExampleSelector<E>
impl<E> ExampleSelector<E> for MmrExampleSelector<E>
Auto Trait Implementations§
impl<E> Freeze for MmrExampleSelector<E>
impl<E> !RefUnwindSafe for MmrExampleSelector<E>
impl<E> Send for MmrExampleSelector<E>
impl<E> Sync for MmrExampleSelector<E>
impl<E> Unpin for MmrExampleSelector<E>
impl<E> UnsafeUnpin for MmrExampleSelector<E>
impl<E> !UnwindSafe for MmrExampleSelector<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