pub struct QueryClassifier;Expand description
Heuristic classifier that determines the best retrieval strategy for a free-text query without any model inference.
Implementations§
Source§impl QueryClassifier
impl QueryClassifier
Sourcepub fn classify(query: &str) -> QueryKind
pub fn classify(query: &str) -> QueryKind
Classify a raw query string into a QueryKind.
Heuristics (in priority order):
- Natural language question (has
?or starts with a question word) →QueryKind::HybridBM25 finds exact names/dates while vector captures semantic intent. This covers all LoCoMo benchmark queries which are long NL questions. - ≥ 8 words or sentence ends in
.(prose, no question) →QueryKind::Semantic - ≤ 3 words with no sentence structure →
QueryKind::Keyword - Everything else →
QueryKind::Hybrid
Auto Trait Implementations§
impl Freeze for QueryClassifier
impl RefUnwindSafe for QueryClassifier
impl Send for QueryClassifier
impl Sync for QueryClassifier
impl Unpin for QueryClassifier
impl UnsafeUnpin for QueryClassifier
impl UnwindSafe for QueryClassifier
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