symfonic.memory.graph.scoring¶
scoring ¶
RetrievalScorer -- multi-signal scoring engine.
Computes composite scores using four signals
semantic_similarity * w1 + recency * w2 + frequency * w3 + graph_proximity * w4
where weights come from ScoringWeights configuration.
RetrievalScorer ¶
RetrievalScorer(
weights: ScoringWeights,
half_life_days: float = _DEFAULT_HALF_LIFE_DAYS,
*,
scope_blend: bool = False,
)
Multi-signal scoring engine for memory retrieval.
Combines semantic similarity, recency, frequency, and graph proximity into a single composite score using configurable weights.
Source code in src/symfonic/memory/graph/scoring.py
score
async
¶
score(
node: MemoryNode,
query_embedding: list[float],
query_context_node: NodeId | None,
traversal: GraphTraversal,
scope: TenantScope,
vector_similarity_score: float | None = None,
) -> float
Compute composite score for a single node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
MemoryNode
|
The node to score. |
required |
query_embedding
|
list[float]
|
Embedding vector for the query. |
required |
query_context_node
|
NodeId | None
|
Optional context node for graph proximity. |
required |
traversal
|
GraphTraversal
|
GraphTraversal instance for proximity computation. |
required |
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
vector_similarity_score
|
float | None
|
Optional pre-computed cosine similarity
between |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Composite score as a float. |
Source code in src/symfonic/memory/graph/scoring.py
score_batch
async
¶
score_batch(
nodes: list[MemoryNode],
query_embedding: list[float],
query_context_node: NodeId | None,
traversal: GraphTraversal,
scope: TenantScope,
precomputed_similarities: list[float | None]
| None = None,
) -> list[tuple[MemoryNode, float]]
Score a batch of nodes and return sorted results (descending).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
list[MemoryNode]
|
Nodes to score. |
required |
query_embedding
|
list[float]
|
Embedding vector for the query. |
required |
query_context_node
|
NodeId | None
|
Optional context node for graph proximity. |
required |
traversal
|
GraphTraversal
|
GraphTraversal instance for proximity computation. |
required |
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
precomputed_similarities
|
list[float | None] | None
|
Optional list aligned 1:1 with
|
None
|
Returns:
| Type | Description |
|---|---|
list[tuple[MemoryNode, float]]
|
List of (node, score) tuples sorted by score descending. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
Source code in src/symfonic/memory/graph/scoring.py
scope_specificity_score ¶
Multiplicative scope-specificity gate (design §4.c Shape 1 / §4.b).
Exponential decay over hierarchy distance: exp(-ln2/half_life * d),
then linearly lifted off the floor. At distance 0 (tip) the result is
always 1.0 (tip memories unaffected — byte-stable with pre-v8.0). With
half_life_levels=1.0 and floor=0.0: tip 1.0, parent 0.5, grandparent 0.25.