Repository navigation
feat(rag): rank RAG results by reference material priority - #787
Conversation
Closes askimo-ai#345 Signed-off-by: Recep Eken <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@haiphucnguyen this is ready for review, and CI is green. A few things worth a look:
Happy to adjust anything. |
|
Thank you @rcpeken for this great PR. I pulled the PR and test it first. The output looks good with the high quality response from the AI RAG. I am using model qwen2.5-coder:14b
I will look into the code and provide the feedback when I have time today. In the mean time, since you are interested to RAG, we also use the metadata to instruct the AI response in the format we want, see https://github.com/askimo-ai/askimo/blob/main/shared-jvm/src/main/kotlin/io/askimo/core/rag/MetadataAwareContentInjector.kt. If you are interested in RAG, I can create a follow up ticket relates to Web Search, and another one how to control the metadata content instruction that we allow users can decide the format they want. If you're interested and have time, please let me know and I leave them for you :) |
haiphucnguyen
left a comment
There was a problem hiding this comment.
Thank you @rcpeken ! It is a great PR, I left some minor comment about the enum.
| import java.nio.file.Path | ||
| import kotlin.test.assertEquals | ||
|
|
||
| class HybridContentRetrieverTest { |
There was a problem hiding this comment.
I love these tests :).
Signed-off-by: Recep Eken <[email protected]>
|
Thanks for testing it with qwen2.5-coder @haiphucnguyen, great to see it working end to end! I've pushed the enum change from your review. And yes, I'm interested in both follow-ups: web search configuration per collection, and letting users control the metadata instruction format in |
haiphucnguyen
left a comment
There was a problem hiding this comment.
Thank you @rcpeken ! LGTM
|
Hİ @haiphucnguyen. I've already looked into the web search side. Today the web search chip only shows in project sessions, so chats using a resource collection can't turn it on at all, and the toggle resets when the app restarts. I have a short proposal ready (a per-collection "Use web search" default that the session chip can override, as you suggested). Would you like me to open the issue with it, or would you prefer to create it yourself? Either way, I'd be glad to work on it. |
Thank you @rcpeken!. Feel free to create a ticket by yourself. Your proposal is good. The minor logic is the search is the toogle enable option (let user option they do want the privacy with the AI response). We should warn user must enable search option before using RAG web search |
|
Thanks! I've opened the ticket with your privacy point included: the global web search setting stays the master switch, with a warning when it's off. #810 |

Closes #345
Summary
Adds a priority to each reference material (Low / Normal / High / Always prioritize) in Projects and Resource Collections. Hybrid RAG ranking multiplies each result's RRF score by the priority of the source it came from, as discussed in #345.
Related Issue(s)
Closes #345
Type of Change
What Changed & Why
KnowledgeSourceConfig.priority(a plainDouble, default1.0) plusKnowledgeSourcePrioritywith the weights we agreed on:LOW=0.5,NORMAL=1.0,HIGH=2.0,ALWAYS_PRIORITIZE=100.0. Sources are stored as JSON with defaults andignoreUnknownKeys, so there's no migration and existing sources decode as Normal.HybridContentRetrieversorts byrrfScore * priority, as you suggested. The samepriority / (k + rank)weighting is also applied when only one retriever returns results; otherwise priority would be silently ignored whenever, for example, keyword search comes back empty. With every source at Normal, the ranking is identical to today.KnowledgeSourcePriorityResolvermaps each chunk back to its reference material: longest folder prefix on a path boundary, exact file path, exact URL. Live web results and unmatched chunks stay at 1.0. No re-index is needed.knowledgeSourcePrioritySelector). It persists the same way the watch toggle does. Strings added to all 10 locales.RagIndexer.handleRemoveIndexEventlooked up the live coordinator by full config equality. After a priority (or watch) change, the stored config no longer equals the coordinator's copy, so deleting that source fell back to persisted cleanup and left its folder watcher running. It now matches byresourceIdentifier, like the other lookups in that file.How to Test