Skip to content

feat(memory): add MEMTIER five-signal retrieval scoring#4463

Merged
bug-ops merged 2 commits into
mainfrom
memtier-retrieval-signals
May 18, 2026
Merged

feat(memory): add MEMTIER five-signal retrieval scoring#4463
bug-ops merged 2 commits into
mainfrom
memtier-retrieval-signals

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 18, 2026

Summary

Implements four retrieval scoring signals from arXiv:2605.03675 (MEMTIER) in tiered_retrieval.rs, addressing issue #3987.

  • Recency decay: exp(-ln2 / half_life_days * age_days) — entries decay exponentially; lambda expressed as half-life in days for intuitive config
  • BM25/TF-IDF: inline implementation (~60 lines), no new dependencies; scores each candidate against query tokens across the candidate set
  • Cognitive signal: fact_access_log count proxy (normalized) — entries accessed more frequently after tool calls rank higher
  • Tier boost: additive weight for consolidated/semantic entries over episodic ones

Design

All signals are applied in a new score_candidates() step inserted between recall_routed() and assemble_within_budget(). Combined via weighted sum:

final = sim_weight * similarity
      + recency_weight * recency
      + tfidf_weight * tfidf
      + cognitive_signal_weight * cognitive
      + tier_boost_weight * tier_boost

All new config fields in TieredRetrievalConfig default to 0.0 except similarity_weight = 1.0, preserving exact backward-compatible behaviour with no config changes.

Performance

  • DB queries for recency and tier signals are weight-guarded — zero extra SQL in default config
  • TF-IDF: O(n×m) for n≤20 candidates × ~10 query terms ≈ 10 µs
  • All three new store functions instrumented with tracing::instrument

Test plan

  • 1425 unit tests pass (21 skipped — require Qdrant)
  • 13 signal-specific unit tests added: recency math, TF-IDF scoring, empty input, all-zero weights guard, weighted-sum formula + sort order, backward compat with default config, tier boost ranking, cognitive signal normalization

Closes #3987

@github-actions github-actions Bot added memory zeph-memory crate (SQLite) rust Rust code changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels May 18, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 18, 2026 22:46
@bug-ops bug-ops force-pushed the memtier-retrieval-signals branch from 66a5008 to 400d01d Compare May 18, 2026 22:46
bug-ops added 2 commits May 19, 2026 00:54
Extends tiered_retrieval.rs with four new scoring signals applied after
recall_routed() and before assemble_within_budget():

1. Recency decay: exp(-ln2 / half_life_days * age_days)
2. BM25/TF-IDF: inline implementation, no new dependencies
3. Cognitive signal: fact_access_log count proxy (normalized)
4. Tier boost: additive weight for consolidated/semantic entries

All new config fields in TieredRetrievalConfig default to 0.0 except
similarity_weight=1.0, preserving backward-compatible behaviour.

DB queries for recency and tier signals are weight-guarded — no extra
SQL in default config. All three new store functions are instrumented
with tracing::instrument.

Closes #3987
@bug-ops bug-ops force-pushed the memtier-retrieval-signals branch from e2f4765 to d252ccc Compare May 18, 2026 22:54
@bug-ops bug-ops merged commit 9513a5c into main May 18, 2026
32 checks passed
@bug-ops bug-ops deleted the memtier-retrieval-signals branch May 18, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(memory): MEMTIER five-signal retrieval — add BM25 + cognitive weight scoring to tiered_retrieval.rs

1 participant