pub struct SemanticSimilarityExampleSelector<E> { /* private fields */ }Expand description
Pick the top-k examples whose embeddings are most similar to the
input.
Implementations§
Source§impl<E> SemanticSimilarityExampleSelector<E>
impl<E> SemanticSimilarityExampleSelector<E>
Sourcepub fn new<F>(embeddings: Arc<dyn Embeddings>, k: usize, text_of: F) -> Self
pub fn new<F>(embeddings: Arc<dyn Embeddings>, k: usize, text_of: F) -> Self
Build a selector that picks the top-k examples by similarity.
Sourcepub fn with_distance(self, d: Distance) -> Self
pub fn with_distance(self, d: Distance) -> Self
Override the distance metric (default: Cosine).
Sourcepub fn with_embed_mode(self, m: EmbedMode) -> Self
pub fn with_embed_mode(self, m: EmbedMode) -> Self
Override the embed mode (default: Cached).
Trait Implementations§
Source§impl<E> AsyncExampleSelector<E> for SemanticSimilarityExampleSelector<E>
impl<E> AsyncExampleSelector<E> for SemanticSimilarityExampleSelector<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 SemanticSimilarityExampleSelector<E>
impl<E> ExampleSelector<E> for SemanticSimilarityExampleSelector<E>
Auto Trait Implementations§
impl<E> Freeze for SemanticSimilarityExampleSelector<E>
impl<E> !RefUnwindSafe for SemanticSimilarityExampleSelector<E>
impl<E> Send for SemanticSimilarityExampleSelector<E>
impl<E> Sync for SemanticSimilarityExampleSelector<E>
impl<E> Unpin for SemanticSimilarityExampleSelector<E>
impl<E> UnsafeUnpin for SemanticSimilarityExampleSelector<E>
impl<E> !UnwindSafe for SemanticSimilarityExampleSelector<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