Skip to content

[ENH] Temporal and importance weighting in EMC retrieval #26

@OppaAI

Description

@OppaAI

Summary

EMC retrieval currently uses similarity-only (top-K cosine). True cognitive retrieval needs more dimensions — recency, emotional weight, and task relevance — to decide what is useful right now, not just what looks similar.

Current Behavior

# Only semantic similarity
scored.sort(key=lambda x: x["similarity"], reverse=True)
results = scored[:top_k]

"What looks similar" — not "what is useful right now."

Proposed Enhancement

Multi-dimensional retrieval scoring:

def _retrieval_score(self, episode: dict, query_vec: list, now: datetime) -> float:
    # 1. Semantic similarity (what's related)
    semantic = _cosine(query_vec, stored_vec)
    
    # 2. Temporal recency (recent > old)
    age_days = (now - datetime.fromisoformat(episode["date"])).days
    recency = 1.0 / (1.0 + age_days * RECENCY_WEIGHT)
    
    # 3. Emotional weight (emotionally significant > neutral)
    emotional = abs(episode.get("emotional_valence", 0.0))
    
    # Weighted combination
    return (
        semantic  * SEMANTIC_WEIGHT  +   # 0.5
        recency   * RECENCY_WEIGHT   +   # 0.3
        emotional * EMOTIONAL_WEIGHT     # 0.2
    )

Weights configurable in mcc.yaml:

emc:
  retrieval:
    semantic_weight: 0.5
    recency_weight: 0.3
    emotional_weight: 0.2

Impact

  • Retrieval becomes "what's useful now" not just "what's similar"
  • Recent important memories surface naturally
  • Emotionally significant memories have appropriate weight
  • Configurable balance between dimensions

Notes

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions