TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

249 点作者 johnjwang12 个月前

24 条评论

pamelafox12 个月前
If you&#x27;re looking for an example of RRF + Hybrid Search with PostgreSQL, I&#x27;ve put together a FastAPI app here that uses RAG with those options:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Azure-Samples&#x2F;rag-postgres-openai-python&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;Azure-Samples&#x2F;rag-postgres-openai-python&#x2F;</a><p>Here&#x27;s the RRF+Hybrid part: <a href="https:&#x2F;&#x2F;github.com&#x2F;Azure-Samples&#x2F;rag-postgres-openai-python&#x2F;blob&#x2F;e30ea96ca11ca6578ca38d3428594bd98d704900&#x2F;src&#x2F;fastapi_app&#x2F;postgres_searcher.py#L38">https:&#x2F;&#x2F;github.com&#x2F;Azure-Samples&#x2F;rag-postgres-openai-python&#x2F;...</a><p>That&#x27;s largely based off a sample from the pgvector repo, with a few tweaks.<p>Agreed that Hybrid is the way to go, it&#x27;s what the Azure AI Search team also recommends, based off their research:<p><a href="https:&#x2F;&#x2F;techcommunity.microsoft.com&#x2F;t5&#x2F;ai-azure-ai-services-blog&#x2F;azure-ai-search-outperforming-vector-search-with-hybrid&#x2F;ba-p&#x2F;3929167" rel="nofollow">https:&#x2F;&#x2F;techcommunity.microsoft.com&#x2F;t5&#x2F;ai-azure-ai-services-...</a>
评论 #40538286 未加载
thefourthchime12 个月前
I also found pure RAG with vector search to not work. I was creating a bot that could find answers to questions about things by looking at Slack discussions.<p>At first, I downloaded entire channels, loaded them into a vector DB, and did RAG. The results sucked. Vector searches don&#x27;t understand things very well, and in this world, specific keywords and error messages are very searchable.<p>Instead, I take the user&#x27;s query, ask an LLM (Claude &#x2F; Bedrock) to find keywords, then search Slack using the API, get results, and use an LLM to filter for discussions that are relevant, then summarize them all in a response.<p>This is slow, of course, so it&#x27;s very multi-threaded. A typical response will be within 30 seconds.
评论 #40533618 未加载
评论 #40529308 未加载
评论 #40532639 未加载
评论 #40530710 未加载
edude0312 个月前
Thanks for sharing, I like the approach and it makes a lot of sense for the problem space. Especially using existing products vs building&#x2F;hosting your own.<p>I was however tripped up by this sentence close to the beginning:<p>&gt; we encountered a significant challenge with RAG: relying solely on vector search (even using both dense and sparse vectors) doesn’t always deliver satisfactory results for certain queries.<p>Not to be overly pedantic, but that&#x27;s a problem with vector similarity, not RAG as a concept.<p>Although the author is clearly aware of that - I have had numerous conversations in the past few months alone of people essentially saying &quot;RAG doesn&#x27;t work because I use pg_vector (or whatever) and it never finds what I&#x27;m looking for&quot; not realizing 1) it&#x27;s not the only way to do RAG, and 2) there is often a fair difference between the embeddings and the vectorized query, and with awareness of why that is you can figure out how to fix it.<p><a href="https:&#x2F;&#x2F;medium.com&#x2F;@cdg2718&#x2F;why-your-rag-doesnt-work-9755726dd1e9" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;@cdg2718&#x2F;why-your-rag-doesnt-work-9755726...</a> basically says everything I often say to people with RAG&#x2F;vector search problems but again, seems like the assembled team has it handled :)
评论 #40525374 未加载
评论 #40531282 未加载
eskibars12 个月前
Having worked building out a RAG SaaS platform for the past year and having worked on the vendor side of several keyword-based search systems in the past 10 years, I can say it&#x27;s absolutely necessary to have some kind of hybrid search for most use cases I&#x27;ve seen.<p>The problem is that most people don&#x27;t have experience optimizing even 1 of the retrieval systems (vector or keyword), so a lot of users that try to DIY build end up with an awful time trying to get to prod. People are talking about things like RRF (which are needed) but then missing other big-picture things like the mistakes everyone makes when building out a keyword search (not getting the right language rules in place) and <i>also</i> not getting the right vector side (finding the right embedding models, chunking strategies, etc).<p>I recognize I have a bit of a conflict of interest since I&#x27;m at a RAG vendor, but I&#x27;ll abstain from the name&#x2F;self-promotion and say: I&#x27;ve seen so many cases where people get this wrong, if you&#x27;re thinking RAG you really should be hiring a consultant or looking at a complete platform from people that have done it more. Or be prepared to spend a <i>lot</i> of cycles learning and iterating
评论 #40536325 未加载
评论 #40534825 未加载
pmc0012 个月前
For another set of measurements that support RRF + Hybrid &gt; vectors, we (Azure AI Search team) did a bunch of evaluations a few months ago: <a href="https:&#x2F;&#x2F;techcommunity.microsoft.com&#x2F;t5&#x2F;ai-azure-ai-services-blog&#x2F;azure-ai-search-outperforming-vector-search-with-hybrid&#x2F;ba-p&#x2F;3929167" rel="nofollow">https:&#x2F;&#x2F;techcommunity.microsoft.com&#x2F;t5&#x2F;ai-azure-ai-services-...</a><p>We also included supporting data in that write up showing you can improve significantly on top of Hybrid&#x2F;RRF using a reranking stage (assuming you have a good reranker model), so we shipped one as an optional step as part of our search engine.
cheesyFish12 个月前
RRF is alright, but I&#x27;ve had better results with relative score, or distribution-based scoring.<p>LlamaIndex has a module for exactly this<p><a href="https:&#x2F;&#x2F;docs.llamaindex.ai&#x2F;en&#x2F;stable&#x2F;examples&#x2F;retrievers&#x2F;relative_score_dist_fusion&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.llamaindex.ai&#x2F;en&#x2F;stable&#x2F;examples&#x2F;retrievers&#x2F;rel...</a>
yingfeng12 个月前
RRF is a simple and effective means of fused ranking for multiple recall. Within our open source RAG product RAGFlow(<a href="https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;ragflow">https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;ragflow</a>), Elasticsearch is currently used instead of other general vector databases, because it can provide hybrid search right now. Under the default cases, embedding based reranker is not required, just RRF is enough, while even if reranker is used, keywords based retrieval is also a MUST to be hybridized with embedding based retrieval, that&#x27;s just what RAGFlow&#x27;s latest 0.7 release has provided.<p>On the other hand let me introduce another database we developed, Infinity(<a href="https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;infinity">https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;infinity</a>), which can provide the hybrid search, you can see the performance here(<a href="https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;infinity&#x2F;blob&#x2F;main&#x2F;docs&#x2F;references&#x2F;benchmark.md">https:&#x2F;&#x2F;github.com&#x2F;infiniflow&#x2F;infinity&#x2F;blob&#x2F;main&#x2F;docs&#x2F;refere...</a>), both vector search and full-text search could perform much faster than other open source alternatives.<p>From the next version(weeks later), Infinity will also provide more comprehensive hybrid search capabilities, what you have mentioned the 3-way recalls(dense vector, sparse vector, keyword search) could be provided within single request.
评论 #40532447 未加载
retakeming12 个月前
pg_search (full text search Postgres extension) can be used with pgvector for hybrid search over Postgres tables. It comes with a helpful hybrid search function that uses relative score fusion. Whereas rank fusion considers just the order of the results, relative score fusion uses the actual metrics outputted by text&#x2F;vector search.
throwaway11512 个月前
I&#x27;ve implemented a very similar RAG hybrid solution, and it has improved LLM responses enormously. There are other things you can do too that have huge improvements, like destructuring your data and placing it into a graph structure, with queryable edge relationships. I think we&#x27;re just scratching the surface.
评论 #40527846 未加载
janalsncm12 个月前
Reciprocal rank scoring is just one way of forcing scores into a fixed distribution: in this case, decaying with the reciprocal of its rank. But it also assumes fixed weight from all components, i.e. the top ranked keyword match has equal relevance to the top ranked semantic match.<p>There are a couple ways around this. Either learning the relative importance based on the query, and&#x2F;or using a separate reranking function (usually a DNN) that also takes user behavior into account.
ko_pivot12 个月前
Meilisearch has a really clean implementation of this. Can easily adjust keyword vs vector weighting per query.
gregnr12 个月前
In case you just want a single Postgres function that does RRF (pgvector+fts): <a href="https:&#x2F;&#x2F;supabase.com&#x2F;docs&#x2F;guides&#x2F;ai&#x2F;hybrid-search">https:&#x2F;&#x2F;supabase.com&#x2F;docs&#x2F;guides&#x2F;ai&#x2F;hybrid-search</a><p>(disclaimer: supabase dev who went down the rabbit hole with hybrid search)
SomewhatLikely12 个月前
Both of your references use RRF=1&#x2F;(60+Rank)<p>So I&#x27;m not sure why the article uses 1&#x2F;Rank alone. Did you test both and find that the smoothing didn&#x27;t help? My understanding is that it has been pretty important for the best results.
评论 #40526867 未加载
评论 #40526876 未加载
owen-elliott12 个月前
The composability of RRF is definitely one of its most appealing characteristics. It doesn&#x27;t matter what algorithm or vendor you have, you can just fuse with ranks alone. I&#x27;ve seen it shine when fusing lexical and vector search results where semantic attributes like styles and exact attributes like quantities are mixed together in queries, e.g., &quot;modern formal watch with 40mm face&quot;.<p>While it&#x27;s not such a problem in RAG, one downside is that it complicates pagination for results (there are a few different ways to tackle this).
cricketlover12 个月前
Pardon my ignorance but I was hung up on this line.<p>&gt; Out-of-sync document stores could lead to subtle bugs, such as a document being present in one store but not another.<p>But then the article suggests to upload synchronously in S3&#x2F;DDB and then sync asynchronously to actual document stores. How does this solve out of sync issue? It doesn&#x27;t. It can&#x27;t be solved is what I&#x27;m thinking.<p>&gt; Data, numbers<p>How much data are we talking about?
marcyb5st12 个月前
As soon as the indexed documents contain lingo of any kind you need hybrid search IMHO.<p>Additionally, if you can add conditional fuzzy matching into the mix so fat fingering something still yields a workable result is even better for UX (something along the lines of &quot;the results from the tf-idf search are garbage, let&#x27;s redo the search with fuzzy matching this time).
_pdp_12 个月前
I have no doubt this probably produces better results than a simple vector search, but you cannot escape the fact that you are converting a query to a set of results, and so the quality and intent of the query matter. In fact, it matters more than the search mechanics. Anyone who has ever used a search engine or some other search mechanism knows that intuitively.
treprinum12 个月前
Hybrid might work for English but where are you going to get sparse embeddings like SPLADE or ELSERv2 for most other languages? Vector search with ada-002 or text-003-large capped to the first 500-1000 dimensions will give you a support for 100+ languages for free. If you are using BM25, then you need to train BM25 on every single separate knowledge base which is annoying and expensive.
mtbarta312 个月前
Great article. Hybrid search works well for a lot of scenarios.<p>The tradeoffs of using existing systems vs building your own resonate with me. What we eventually experienced, however, is that periods of bad search performance often correlated to out-of-date search indices.<p>I&#x27;d be interested in another article detailing how you monitor search. It can be tricky to keep an entire search system moving.
esafak12 个月前
1. Does anyone know a postgres reranking extension, to go beyond RRF through ML models or at least custom code?<p>2. If anyone is observing significant gains from incorporating knowledge graphs into the retrieval step, what kind of a knowledge graph are you working with, what is your retrieval algorithm, and what technology are you using to store it?
评论 #40529063 未加载
ndricca12 个月前
May I ask you if you tried hybrid search directly on Pinecone, using Bm25 or splade?
cpursley12 个月前
Any tips on accomplishing this in Postgres with pg_vector?
评论 #40529056 未加载
评论 #40527209 未加载
评论 #40527580 未加载
armind12 个月前
how does this compare to differentiable search index (DSI) and it&#x27;s updated version (DSI++)?
yding12 个月前
Absolutely makes sense!