Add hybrid ranking and recency scoring - #322
Open
dhruvi-16-me wants to merge 5 commits into
Open
dhruvi-16-me wants to merge 5 commits into
dhruvi-16-me wants to merge 5 commits into
Conversation
added 5 commits
July 19, 2026 01:07
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the RAG retrieval ranking in Ell-ena by introducing hybrid ranking based on semantic similarity, recency, and entity-specific urgency.
Previously, retrieved tasks, tickets, and meetings were primarily ranked using vector similarity. This PR adds a hybrid ranking layer while keeping semantic relevance as the dominant signal.
What Changed
1. Hybrid RAG Ranking
Retrieved candidates are now ranked using:
Semantic similarity remains the strongest ranking signal to ensure that urgent but unrelated items cannot outrank strongly relevant results.
2. Similarity Threshold
A minimum similarity threshold of
0.30is applied before recency and urgency scoring.Updated retrieval flow:
This ensures that recency and urgency only influence results that are already semantically relevant.
3. Recency Scoring
A decay-based recency score has been added:
Newer items receive a higher score, while older items gradually lose influence.
The dates used depend on the entity:
meeting_date, with fallback timestamps where availableupdated_at/created_atupdated_at/created_atFuture dates are handled safely by preventing negative age values.
4. Task Urgency
Tasks do not have a dedicated priority column, so urgency is derived from existing fields:
due_datestatusHigher urgency is given to:
Completed tasks receive no urgency boost.
No new task priority column was introduced.
5. Ticket Priority
Ticket urgency uses the existing priority and status fields:
Resolved tickets receive no urgency boost.
6. Meeting Ranking
Meetings are ranked using:
No artificial priority or urgency field was introduced for meetings.
7. Candidate Retrieval and Reranking
The existing HNSW cosine similarity search is preserved.
The updated pipeline:
Candidate and match counts are bounded to prevent unnecessarily large retrieval operations.
8. Ranking Metadata
Additional ranking metadata is returned where applicable:
recency_scoreurgency_scorefinal_scoreRelevant entity metadata such as dates, status, and priority is also preserved where supported.
Existing return fields remain available for compatibility.
9. Flutter RAG Updates
Updated the RAG result and retrieval layers to support the new ranking system.
Changes include:
RagResultThe implementation includes coverage for:
A key validation ensures that an unrelated but urgent item cannot outrank a strongly semantically relevant result.
✅ Checklist