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
impl LegacyCompositePriorTransform
pub fn new(alpha: f64, beta: f64, base_rate: Option<f64>) -> ScoringResult<Self>
Sourcepub fn score_signal(&self, score: f64) -> f64
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.
Sourcepub fn tf_prior(tf: f64) -> f64
pub fn tf_prior(tf: f64) -> f64
Term-frequency prior (Eq. 25):
P_tf(tf) = 0.2 + 0.7 * min(1, tf / 10).
Sourcepub fn norm_prior(doc_len_ratio: f64) -> f64
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].
Sourcepub fn composite_prior(tf: f64, doc_len_ratio: f64) -> f64
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).
Sourcepub fn no_match_floor() -> f64
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.
Sourcepub fn combined_score(
score_signal: f64,
prior: f64,
base_rate: Option<f64>,
) -> f64
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)).
Sourcepub fn transform_score(&self, score: f64, tf: f64, doc_len_ratio: f64) -> f64
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.
Sourcepub fn heuristic_upper_bound(&self, bm25_upper_bound: f64, p_max: f64) -> f64
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
impl Clone for LegacyCompositePriorTransform
Source§fn clone(&self) -> LegacyCompositePriorTransform
fn clone(&self) -> LegacyCompositePriorTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more