Skip to content

Fix MMR zero threshold handling#22157

Open
adityat210 wants to merge 3 commits into
run-llama:mainfrom
adityat210:fix-mmr-zero-threshold
Open

Fix MMR zero threshold handling#22157
adityat210 wants to merge 3 commits into
run-llama:mainfrom
adityat210:fix-mmr-zero-threshold

Conversation

@adityat210

Copy link
Copy Markdown

Summary

Fixes an MMR retrieval edge case where mmr_threshold=0 was treated the same as an omitted threshold.

get_top_k_mmr_embeddings() documents that a threshold of 0 should strongly avoid similarity to previous results, but the implementation used mmr_threshold or 0.5, causing explicit 0 to fall back to the default 0.5.

Changes

  • Preserve explicit mmr_threshold=0
  • Continue using 0.5 only when mmr_threshold is None
  • Add a focused unit test for the zero-threshold behavior

Testing

UV_CACHE_DIR=/private/tmp/uv-cache UV_PYTHON_INSTALL_DIR=/private/tmp/uv-python uv run --python /Users/aditya/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 -- pytest tests/indices/query/test_embedding_utils.py

Result: 2 passed

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant