Skip to main content

LegacyCompositePriorTransform

Struct LegacyCompositePriorTransform 

Source
pub struct LegacyCompositePriorTransform {
    pub alpha: f64,
    pub beta: f64,
    pub base_rate: Option<f64>,
}
Expand description

Historical score transform that combines several dependent BM25-derived signals. It is intentionally named Legacy so callers do not mistake the output for a probability-model contract.

Fields§

§alpha: f64§beta: f64§base_rate: Option<f64>

Optional corpus-level base rate. None is equivalent to 0.5 (logit = 0, i.e. no base-rate correction).

Implementations§

Source§

impl LegacyCompositePriorTransform

Source

pub fn new(alpha: f64, beta: f64, base_rate: Option<f64>) -> ScoringResult<Self>

Source

pub fn score_signal(&self, score: f64) -> f64

Bounded monotone score signal: sigma(alpha * (score - beta)).

This value is not a normalized P(score | relevant) likelihood.

Source

pub fn tf_prior(tf: f64) -> f64

Term-frequency prior (Eq. 25): P_tf(tf) = 0.2 + 0.7 * min(1, tf / 10).

Source

pub fn norm_prior(doc_len_ratio: f64) -> f64

Document-length normalisation prior (Eq. 26): P_norm(r) = 0.3 + 0.6 * (1 - min(1, |r - 0.5| * 2)), peaks at 0.9 when r = 0.5, floor 0.3 outside [0, 1].

Source

pub fn composite_prior(tf: f64, doc_len_ratio: f64) -> f64

Composite prior (Eq. 27): clamp(0.7 * P_tf + 0.3 * P_norm, 0.1, 0.9).

Source

pub fn no_match_floor() -> f64

Historical no-match floor obtained from zero term frequency and the document-length normalization floor. This is a ranking-policy value, not a corpus relevance prior.

Source

pub fn combined_score( score_signal: f64, prior: f64, base_rate: Option<f64>, ) -> f64

Combine a bounded score signal and log-odds biases using the legacy two-stage probability-space arithmetic.

Without base_rate: P = L*p / (L*p + (1-L)*(1-p)).

With base_rate (the second update is equivalent to adding logit(base_rate) in log-odds space): Step 1: p1 = L*p / (L*p + (1-L)*(1-p)) Step 2: P = p1*br / (p1*br + (1-p1)*(1-br)).

Source

pub fn transform_score(&self, score: f64, tf: f64, doc_len_ratio: f64) -> f64

Convert a BM25 score to the legacy bounded ranking score. tf is term frequency and doc_len_ratio is doc_length / avg_doc_length.

Source

pub fn heuristic_upper_bound(&self, bm25_upper_bound: f64, p_max: f64) -> f64

Monotone upper bound for this transform, given a BM25 upper bound and an upper bound on the composite bias.

Trait Implementations§

Source§

impl Clone for LegacyCompositePriorTransform

Source§

fn clone(&self) -> LegacyCompositePriorTransform

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 LegacyCompositePriorTransform

Source§

impl Debug for LegacyCompositePriorTransform

Source§

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

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

impl Default for LegacyCompositePriorTransform

Source§

fn default() -> Self

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

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.