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
impl MaxMarginalRelevanceExampleSelector
Sourcepub 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
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 examplesk
- Number of examples to selectfetch_k
- Number of examples to fetch for rerankingexample_keys
- Optional keys to filter examples toinput_keys
- Optional keys to filter input tovectorstore_kwargs
- Extra arguments for similarity search
Trait Implementations§
Source§impl BaseExampleSelector for MaxMarginalRelevanceExampleSelector
impl BaseExampleSelector for MaxMarginalRelevanceExampleSelector
Source§fn add_example(&mut self, _example: Example) -> Result<()>
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,
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>>
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,
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§
impl Freeze for MaxMarginalRelevanceExampleSelector
impl !RefUnwindSafe for MaxMarginalRelevanceExampleSelector
impl Send for MaxMarginalRelevanceExampleSelector
impl Sync for MaxMarginalRelevanceExampleSelector
impl Unpin for MaxMarginalRelevanceExampleSelector
impl !UnwindSafe for MaxMarginalRelevanceExampleSelector
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