Expand description
Tunable composite scoring, normalization, adjustments, and language routing.
See crates/khive-pack-memory/docs/api/scoring.md for the complete scoring model.
Structs§
- Candidate
Context - Context passed to condition evaluation — properties of the candidate + query.
- Score
Adjustment - A conditional score adjustment: if
conditionmatches, applyoperation. - Score
Input - Input data for
calculate_score— groups per-candidate fields to stay within clippy’s 7-argument limit. - Scoring
Config - Complete, tunable scoring configuration for the memory recall pipeline. DoS caps: max_recall_candidates≤500, default_token_budget≤16000, default_recall_limit≤200.
- Scoring
Weights - Weights for the combined memory score:
score = w_rel × relevance × (1 + w_temp × recency) × (1 + w_imp × salience).
Enums§
- Adjustment
Condition - A condition that determines whether a score adjustment applies to a candidate.
- Adjustment
Op - The operation to apply when a condition matches.
Constants§
- ENTITY_
POSTERIOR_ CLAMP_ MAX - Upper bound of the per-entity posterior multiplier — the term can never move a score up by more than 15%.
- ENTITY_
POSTERIOR_ CLAMP_ MIN - Lower bound of the per-entity posterior multiplier — the term can never move a score down by more than 15%.
- ENTITY_
POSTERIOR_ WEIGHT - Default weight for the per-entity posterior term. Chosen so the clamp
bounds below are exactly reachable at posterior means of 0.0 and 1.0
(
1 + 0.3 * (0.0 - 0.5) = 0.85,1 + 0.3 * (1.0 - 0.5) = 1.15). - MAX_
AUTO_ ENTITY_ NAMES - Maximum heuristic entity names per query; it bounds scans, not boosted memories.
- MAX_
ENTITY_ LOOKUP_ CANDIDATES - Maximum candidate strings sent to one batched KG entity-name lookup.
- MAX_
RECALL_ CANDIDATES - Maximum candidates a caller may request (server-side cap).
- MAX_
RECALL_ LIMIT - Maximum result limit a caller may request (server-side cap).
- MAX_
TOKEN_ BUDGET - Maximum token budget a caller may request (server-side cap).
Functions§
- calculate_
score - Composite score for a single memory candidate.
- contains_
cjk - Returns
truewhen >15% of the query’s characters are CJK. - default_
adjustments - Default score adjustments: episodic recency bonus, semantic age penalty, entity boost.
- entity_
lookup_ candidates - Build bounded strings for recall’s batched, case-insensitive KG entity lookup.
- entity_
posterior_ term clamp(1 + w_ent * (entity_posterior_mean - 0.5), 0.85, 1.15).- extract_
entity_ candidates - Extract capitalized, non-stopword entity names for the default entity boost.
- is_
cjk_ char - Returns
trueifcis a CJK character (Unified, Extension A/B, Hiragana, Katakana, Hangul). - is_
meaningful_ query - Returns
trueif the query has enough semantic content for meaningful recall. - needs_
multilingual - Return whether more than 15% of alphabetic characters are non-ASCII.
- normalize_
min_ score - Normalize
min_score: 0–1 passes through, 1–100 divides by 100, others return Err. - normalize_
rank_ fusion_ scores - Normalize raw-cosine or BM25 scores (single-source) into a calibrated relevance band.
- normalize_
rrf_ scores - Normalize RRF-fused scores (dual-source) into a calibrated relevance band.