parthsarthi03 / raptor

The official implementation of RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval
https://arxiv.org/abs/2401.18059
MIT License
688 stars 98 forks source link

Inquiring about Vector DB implementation #31

Open daniyal214 opened 2 months ago

daniyal214 commented 2 months ago

Hi, thanks for the code. I want to understand why any vector database is not implemented for storing the embeddings for fast retrieval as we do in conventional RAG. I read in the paper that 'yes' the collapsed tree approach calculates the cosine similarity against all nodes, better approach is to use some fast k-nearest neighbor libraries such as FAISS. So my question is: 1- What were the considerations behind not integrating a vector database? Was there any benefit? 2- When recommending the adoption of k-nearest neighbor libraries, is the intention solely to substitute the existing cosine similarity search methodology? So that you don't need to run the search over all the nodes? 3- And how can I integrate this recommended library for retrieval with my answer_question method?

Your insights on these matters would be greatly appreciated.

Thanks!

parthsarthi03 commented 2 months ago

Hi there! In our experiment, we didn't find vector search to be a bottleneck, so we didn't feel the need to integrate a vector database to speed up retrieval. However, we did implement support for using Faiss. You can find the code we wrote for the Faiss integration at https://github.com/parthsarthi03/raptor/blob/master/raptor/FaissRetriever.py. To use it, you can create a tree normally using the RA.add_documents() method, and then pass RA.tree.leaf_nodes to FaissRetreiver.build_from_leaf_nodes(). This will build a Faiss index from the leaf nodes of the tree, allowing for fast vector similarity search.

daniyal214 commented 2 months ago

Thanks for the response, got it.