pub struct CrossEncoderRerank { /* private fields */ }Expand description
Cross-encoder rerank layer.
Replaces every result’s (chunk_idx, score) similarity with a
fresh score from the cross-encoder, then re-sorts. The reranker
joins query and document text and runs a BERT-with-classifier
forward pass per pair, which is structurally higher quality than
the bi-encoder’s dual-tower similarity but O(candidates) cost.
Construct via Self::new. Holds an [Arc] to a
crate::rerank::Reranker so the layer chain can be cheaply
cloned and the model isn’t reloaded per call.
§Auto-detect via query
The layer’s score-rewrite is unconditional: if it’s in the pipeline, it runs. Auto-detect (skip rerank for symbol-shaped queries) belongs at the call site that builds the layer chain, not here. The call site already knows the query; it can decide whether to push this layer into the chain at all.
Implementations§
Source§impl CrossEncoderRerank
impl CrossEncoderRerank
Sourcepub fn new(reranker: Arc<Reranker>, query: String, candidates: usize) -> Self
pub fn new(reranker: Arc<Reranker>, query: String, candidates: usize) -> Self
Build a rerank layer over reranker for query. Limits the
pool to candidates (typical: 100). Uses the default blend
factor of 0.7 (heavy cross-encoder, tiebroken by bi-encoder).
Sourcepub fn with_blend(self, blend: f32) -> Self
pub fn with_blend(self, blend: f32) -> Self
Override the bi/cross-encoder blend factor. 0.0 = pure
bi-encoder (rerank is a no-op), 1.0 = pure cross-encoder
(replace).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CrossEncoderRerank
impl !RefUnwindSafe for CrossEncoderRerank
impl Send for CrossEncoderRerank
impl Sync for CrossEncoderRerank
impl Unpin for CrossEncoderRerank
impl UnsafeUnpin for CrossEncoderRerank
impl !UnwindSafe for CrossEncoderRerank
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.