Skip to content

fix(search): rank episode_mentions_reranker by descending mention count (#1342)#1640

Open
Kayvan-Zahiri wants to merge 1 commit into
getzep:mainfrom
Kayvan-Zahiri:fix/mentions-reranker
Open

fix(search): rank episode_mentions_reranker by descending mention count (#1342)#1640
Kayvan-Zahiri wants to merge 1 commit into
getzep:mainfrom
Kayvan-Zahiri:fix/mentions-reranker

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

episode_mentions_reranker scores nodes by how many episodes mention them (higher = more relevant) but sorts ascending, so the least-mentioned nodes rank highest — the opposite of the reranker's intent. Unmentioned nodes also defaulted to float('inf'), which would rank them first once the ordering is corrected.

Fix

  • Sort descending (reverse=True) to match rrf and the MMR reranker, where a higher score means more relevant. (node_distance_reranker sorts ascending correctly because there lower distance is better — this function had copied that pattern, including the misleading # shortest path / # shortest distance comments, now corrected.)
  • Default unmentioned nodes to 0 instead of inf, so they rank last.

Tests

Two regression tests added in tests/utils/search/search_utils_test.py. On main the first fails (['few', 'many'] != ['many', 'few']); with the fix both pass.

Fixes #1342.

@zep-cla-assistant

zep-cla-assistant Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Kayvan-Zahiri

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: kzahiri@dons.usfca.edu

…nt (getzep#1342)

episode_mentions_reranker scored nodes by mention count (higher = more
relevant) but sorted ascending, so the least-mentioned nodes ranked highest.
Unmentioned nodes also defaulted to inf, which would rank them first once the
order is corrected. Sort descending to match rrf/mmr (higher score = better)
and default unmentioned nodes to 0 so they rank last. Adds regression tests.

Fixes getzep#1342.
@Kayvan-Zahiri
Kayvan-Zahiri force-pushed the fix/mentions-reranker branch from ae98702 to 2fb7ec8 Compare July 9, 2026 00:25
zep-cla-assistant Bot added a commit that referenced this pull request Jul 9, 2026
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.

[BUG] episode_mentions_reranker sorts nodes ascending (fewest mentions first)

1 participant