pub struct MaxSimScorer { /* private fields */ }Expand description
A reusable MaxSim scorer with pre-computed query data.
Use this when scoring the same query against multiple documents to avoid redundant computation.
§Example
use manifoldb_vector::ops::maxsim::MaxSimScorer;
use manifoldb_vector::types::MultiVectorEmbedding;
let query = MultiVectorEmbedding::new(vec![
vec![1.0, 0.0],
vec![0.0, 1.0],
]).unwrap();
let scorer = MaxSimScorer::new(query);
let doc1 = MultiVectorEmbedding::new(vec![vec![1.0, 0.0]]).unwrap();
let doc2 = MultiVectorEmbedding::new(vec![vec![0.5, 0.5]]).unwrap();
let score1 = scorer.score(&doc1);
let score2 = scorer.score(&doc2);Implementations§
Source§impl MaxSimScorer
impl MaxSimScorer
Sourcepub fn new(query: MultiVectorEmbedding) -> Self
pub fn new(query: MultiVectorEmbedding) -> Self
Create a new MaxSim scorer for the given query.
Sourcepub fn score(&self, document: &MultiVectorEmbedding) -> f32
pub fn score(&self, document: &MultiVectorEmbedding) -> f32
Score a document against the query.
Sourcepub fn score_batch(
&self,
documents: &[MultiVectorEmbedding],
) -> Vec<(usize, f32)>
pub fn score_batch( &self, documents: &[MultiVectorEmbedding], ) -> Vec<(usize, f32)>
Score multiple documents and return results sorted by score descending.
Sourcepub fn query(&self) -> &MultiVectorEmbedding
pub fn query(&self) -> &MultiVectorEmbedding
Get the query multi-vector.
Trait Implementations§
Source§impl Clone for MaxSimScorer
impl Clone for MaxSimScorer
Source§fn clone(&self) -> MaxSimScorer
fn clone(&self) -> MaxSimScorer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MaxSimScorer
impl RefUnwindSafe for MaxSimScorer
impl Send for MaxSimScorer
impl Sync for MaxSimScorer
impl Unpin for MaxSimScorer
impl UnwindSafe for MaxSimScorer
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