pub struct CrossEncoderEngine { /* private fields */ }Expand description
Cross-encoder reranking engine.
Thread-safe — can be wrapped in Arc and shared across tasks.
Implementations§
Source§impl CrossEncoderEngine
impl CrossEncoderEngine
Sourcepub async fn new(cache_dir: Option<String>) -> Result<Self>
pub async fn new(cache_dir: Option<String>) -> Result<Self>
Load or download the reranker model.
Downloads Xenova/bge-reranker-base ONNX INT8 model from HuggingFace Hub
if not already cached.
Sourcepub async fn score_pairs(
&self,
query: &str,
passages: &[String],
) -> Result<Vec<f32>>
pub async fn score_pairs( &self, query: &str, passages: &[String], ) -> Result<Vec<f32>>
Score a batch of (query, passage) pairs.
Returns a relevance score in [0, 1] for each passage.
Higher scores indicate greater relevance to the query.
Each pair is tokenized as [CLS] query [SEP] passage [SEP].
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CrossEncoderEngine
impl !RefUnwindSafe for CrossEncoderEngine
impl Send for CrossEncoderEngine
impl Sync for CrossEncoderEngine
impl Unpin for CrossEncoderEngine
impl UnsafeUnpin for CrossEncoderEngine
impl !UnwindSafe for CrossEncoderEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more