Struct MaxMarginalRelevanceExampleSelector

Source
pub struct MaxMarginalRelevanceExampleSelector {
    pub vectorstore: Box<dyn VectorStore>,
    pub k: usize,
    pub fetch_k: usize,
    pub example_keys: Option<Vec<String>>,
    pub input_keys: Option<Vec<String>>,
    pub vectorstore_kwargs: Option<HashMap<String, Value>>,
}
Expand description

Select examples based on Max Marginal Relevance (MMR).

MMR balances relevance and diversity in example selection, often leading to better performance than simple similarity search.

Note: This is a placeholder implementation. MMR requires additional methods in the VectorStore trait that are not yet implemented.

Fields§

§vectorstore: Box<dyn VectorStore>

Vector store containing the examples

§k: usize

Number of examples to select

§fetch_k: usize

Number of examples to fetch for reranking

§example_keys: Option<Vec<String>>

Optional keys to filter examples to

§input_keys: Option<Vec<String>>

Optional keys to filter input to

§vectorstore_kwargs: Option<HashMap<String, Value>>

Extra arguments passed to similarity search

Implementations§

Source§

impl MaxMarginalRelevanceExampleSelector

Source

pub fn new( vectorstore: Box<dyn VectorStore>, k: usize, fetch_k: usize, example_keys: Option<Vec<String>>, input_keys: Option<Vec<String>>, vectorstore_kwargs: Option<HashMap<String, Value>>, ) -> Self

Create a new MMR example selector.

§Arguments
  • vectorstore - Vector store containing the examples
  • k - Number of examples to select
  • fetch_k - Number of examples to fetch for reranking
  • example_keys - Optional keys to filter examples to
  • input_keys - Optional keys to filter input to
  • vectorstore_kwargs - Extra arguments for similarity search

Trait Implementations§

Source§

impl BaseExampleSelector for MaxMarginalRelevanceExampleSelector

Source§

fn add_example(&mut self, _example: Example) -> Result<()>

Add a new example to the store. Read more
Source§

fn aadd_example<'life0, 'async_trait>( &'life0 mut self, example: Example, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Async add a new example to the store. Read more
Source§

fn select_examples(&self, _input_variables: &Example) -> Result<Vec<Example>>

Select which examples to use based on the inputs. Read more
Source§

fn aselect_examples<'life0, 'life1, 'async_trait>( &'life0 self, input_variables: &'life1 Example, ) -> Pin<Box<dyn Future<Output = Result<Vec<Example>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Async select which examples to use based on the inputs. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,