Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RRF algorithm to match AI Search algo #25

Merged
merged 1 commit into from
Mar 18, 2025
Merged

Fix RRF algorithm to match AI Search algo #25

merged 1 commit into from
Mar 18, 2025

Conversation

pamelafox
Copy link
Owner

This algorithm matches what AI Search describes. I stepped through the results with the debugger and they seemed reasonable.

@pamelafox pamelafox requested a review from Copilot March 18, 2025 05:16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the reciprocal rank fusion implementation to align with the AI Search algorithm. The changes include:

  • Replacing the previous weighted fusion (using alpha) with an RRF scoring approach using a k offset.
  • Updating the hybrid_search function to use the new fusion mechanism.
  • Modifying sample user query strings in both the Spanish and English versions.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
spanish/rag_documents_hybrid.py Updates the reciprocal_rank_fusion function and sample query string.
rag_documents_hybrid.py Updates the reciprocal_rank_fusion function and sample query string.
Comments suppressed due to low confidence (2)

spanish/rag_documents_hybrid.py:85

  • [nitpick] Consider using (i+1+k) instead of (i+k) to properly reflect 1-indexed ranks for RRF scoring, ensuring no off-by-one error.
scores[doc["id"]] += 1 / (i + k)

rag_documents_hybrid.py:85

  • [nitpick] Consider using (i+1+k) instead of (i+k) so that the ranking starts at 1 as expected by standard RRF implementations, which may avoid off-by-one issues.
scores[doc["id"]] += 1 / (i + k)
@pamelafox pamelafox merged commit c1408e1 into main Mar 18, 2025
1 check 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