Live data from Hacker News

Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

assembled.com

11–20 of 59 posts

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#11
I'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're just scratching the surface.

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#12
1. Does anyone know a postgres reranking extension, to go beyond RRF through ML models or at least custom code?

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?

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#13
post #10
post #9

Any tips on accomplishing this in Postgres with pg_vector?

Supabase has some good examples on their website, search for hybrid search. I needed to tune the function they have there but it should show you how to approach it.

I'm actually doing something like that already, I'm mostly referring to the Reciprocal Rank Fusion (RRF) part of this to squeeze more out.

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#15
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/vector search.

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#16

I'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're just scratching the surface.

This is really interesting, do you have other recommendations for improvements (gladly with sources I you have any)? I have to build a RAG solution for my job and right now I am collecting information to determine the best way to go ahead.

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#17
If you're looking for an example of RRF + Hybrid Search with PostgreSQL, I've put together a FastAPI app here that uses RAG with those options:

https://github.com/Azure-Samples/rag-postgres-openai-python/

Here's the RRF+Hybrid part: https://github.com/Azure-Samples/rag-postgres-openai-python/...

That's largely based off a sample from the pgvector repo, with a few tweaks.

Agreed that Hybrid is the way to go, it's what the Azure AI Search team also recommends, based off their research:

https://techcommunity.microsoft.com/t5/ai-azure-ai-services-...

Re: Better RAG Results with Reciprocal Rank Fusion and Hybrid Search

#19
For another set of measurements that support RRF + Hybrid > vectors, we (Azure AI Search team) did a bunch of evaluations a few months ago: https://techcommunity.microsoft.com/t5/ai-azure-ai-services-...

We also included supporting data in that write up showing you can improve significantly on top of Hybrid/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.

Post reply on HN