RAG: Hybrid Search Primarily based on Two Indexes | by Jérôme DIAZ

The proposition I will probably be speaking about on this article is one thing I have already got applied and I’m at present testing in a private challenge.

Hybrid search within the context of RAG and vector database means looking out chunks of paperwork that may assist reply a query utilizing each a semantic search primarily based on embeddings and a full textual content search on the content material of these chunks.

The restrictions

Whereas hybrid search ought to give higher outcomes than a pure semantic method because it ought to offers extra related chunks of textual content by highlighting those who incorporates some key phrases current within the analysis, there’s nonetheless room for enchancment.

As key phrases are search in the identical textual content that was used to calculate the embedding, what occur when a chunk A of a doc incorporates the key phrases whereas one other chunk B of the identical doc is semantically near the question and so ought to assist to reply it?

We wish to have chunk B to be a part of the paperwork returned by the retriever, however with an ordinary hybrid search which may not be the case.

Self-querying retriever

This sort of retriever is predicated on metadata filtering. Key data which may assist to filter the vector…