Skip to main content

Scorer

Trait Scorer 

Source
pub trait Scorer: Send + Sync {
    // Required methods
    fn score_fact(
        &self,
        fact: &Fact,
        semantic: Option<f32>,
        lexical: f32,
        now: DateTime<Utc>,
    ) -> Option<Score>;
    fn score_episode(
        &self,
        episode: &Episode,
        semantic: Option<f32>,
        lexical: f32,
        now: DateTime<Utc>,
    ) -> Option<Score>;

    // Provided method
    fn score_fact_with_graph(
        &self,
        fact: &Fact,
        semantic: Option<f32>,
        lexical: f32,
        _graph: f32,
        now: DateTime<Utc>,
    ) -> Option<Score> { ... }
}
Expand description

Turns retrieval signals into a ranking score, or drops the candidate.

crate::Memory gathers the raw signals (cosine similarity from the embedder, the store’s lexical score) and asks the scorer. Replace it to change ranking without touching storage; a store that ranks on its own can bypass scoring entirely through crate::MemoryStore::search_facts.

Required Methods§

Source

fn score_fact( &self, fact: &Fact, semantic: Option<f32>, lexical: f32, now: DateTime<Utc>, ) -> Option<Score>

semantic is None when either side has no usable embedding. Return None to drop the fact.

Source

fn score_episode( &self, episode: &Episode, semantic: Option<f32>, lexical: f32, now: DateTime<Utc>, ) -> Option<Score>

Provided Methods§

Source

fn score_fact_with_graph( &self, fact: &Fact, semantic: Option<f32>, lexical: f32, _graph: f32, now: DateTime<Utc>, ) -> Option<Score>

Scorer::score_fact with the fact’s graph relation to the query’s other hits (0.0-1.0). The default ignores it, so a scorer written before this signal existed keeps ranking as it did.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§