Skip to main content

BayesianBM25Params

Struct BayesianBM25Params 

Source
pub struct BayesianBM25Params {
    pub bm25: BM25Params,
    pub alpha: f64,
    pub beta: f64,
    pub base_rate: f64,
    pub calibration_tokens: f64,
    pub beta_slope: f64,
    pub sigma_slope: f64,
}

Fields§

§bm25: BM25Params§alpha: f64§beta: f64§base_rate: f64

Corpus relevance prior in [0, 1); zero means “not estimated”. The prior never enters the posterior transform (which matches Lucene’s BayesianScoreQuery exactly); it is metadata for fusion, where it converts posteriors to evidence and enters the fused score exactly once.

§calibration_tokens: f64

Query length (analyzed term count) the calibration was fitted at. Zero disables query-length scaling, so hand-written and learner-fitted parameters apply verbatim.

§beta_slope: f64

Fitted per-token slope of the sigmoid midpoint: raw BM25 sums grow with the number of query terms, and beta must track that scale for the posterior to stay in its linear region.

§sigma_slope: f64

Fitted per-token slope of the score spread (1 / alpha).

Implementations§

Source§

impl BayesianBM25Params

Source

pub fn evidence_params(&self) -> Self

Parameters whose posterior equals this calibration’s prior-free evidence sigmoid(alpha * (raw - beta) - logit(base_rate)), expressed through the equivalent midpoint shift beta + logit(base_rate) / alpha. With no estimated prior the calibration is returned unchanged.

Source

pub fn scaled_for_query_terms(&self, term_count: usize) -> Self

The calibration translated to a query with term_count analyzed terms. Raw BM25 query scores are sums over query terms, so both the midpoint and the spread of the matching-score distribution move with the term count; the estimator fits those slopes and this method applies them:

beta_q = beta + beta_slope * (q - q_ref) sigma_q = max(sigma_ref + sigma_slope * (q - q_ref), floor)

Parameters without a fitted reference length (or a zero term count) are returned unchanged. Scaling happens per query, never per document, so within-query ranking stays monotone in the raw score.

Trait Implementations§

Source§

impl Clone for BayesianBM25Params

Source§

fn clone(&self) -> BayesianBM25Params

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BayesianBM25Params

Source§

impl Debug for BayesianBM25Params

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BayesianBM25Params

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for BayesianBM25Params

Source§

fn eq(&self, other: &BayesianBM25Params) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BayesianBM25Params

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.