Skip to content

Conversation

CaralHsi
Copy link
Collaborator

@CaralHsi CaralHsi commented Sep 8, 2025

Description

Summary:

This PR introduces a pluggable Reranker layer to MemOS, wires it into Tree Textual Memory and MOS product configs, and tweaks memory filtering thresholds. It adds two backends out-of-the-box—cosine_local (uses embeddings) and http_bge (OpenAI-style rerank API)—plus an example script and configuration factories.
GitHub

  • New reranker module & factory:
    Adds memos/reranker/ with base.py, cosine_local.py, http_bge.py, noop.py, and factory.py to construct rerankers via config.

  • Config plumbing
    New RerankerConfigFactory (src/memos/configs/reranker.py) to describe backend & options.

  • TreeTextMemoryConfig gains optional reranker and memory_size fields so tree memories can specify reranker and bucket caps.

  • APIConfig: adds get_reranker_config() and injects it into both create_user_config() and default cube config; supports env-driven selection (MOS_RERANKER_BACKEND, MOS_RERANKER_URL). Defaults to http_bge else cosine_local.

  • Product behavior
    Slightly raises retrieval acceptance threshold and removes minimum count: threshold 0.50 → 0.52, min_num 3 → 0.

  • Examples & tests
    Adds examples/basic_modules/reranker.py demonstrating both backends; deletes older tree_textual_memory_reranker.py.
    Updates tree searcher test (tests/memories/textual/test_tree_searcher.py) accordingly.

Fix: #(issue)

Docs Issue/PR: (docs-issue-or-pr-link)

Reviewer: @fridayL

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@CaralHsi CaralHsi requested a review from fridayL September 9, 2025 03:50
@CaralHsi CaralHsi marked this pull request as ready for review September 9, 2025 03:50
@CaralHsi CaralHsi merged commit 79ad733 into MemTensor:dev Sep 9, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants