How to combine Parent Document Retriever with Self Query Retriever with Lang Chain framework

169 Views Asked by At

I have implemented a Self Query retriever (https://python.langchain.com/docs/modules/data_connection/retrievers/self_query) for my RAG model, and it works fine. I can retrieve specific chunks of documents based on metadata information.

However, instead of retrieving the small chunks (400 tokens), I would like to retrieve its parent bigger chunk (let’s say 2000 tokens).

The Parent Document Retriever (https://python.langchain.com/docs/modules/data_connection/retrievers/parent_document_retriever) allows you to do that, but the research of the first small chunks in the vector DB is assessed with the basic semantic technique. Instead, I would like to search the first small chunks using the Self Query technique.

I don’t want to just increase the chunk size in my Self Query retrieval, because I want to keep the research of the chunks more accurated.

Does anyone know how to combine these two retrievers?

0

There are 0 best solutions below