VectorDB Retrieval
VectorDBRetrieval Class Documentation
Last updated
VectorDBRetrieval Class Documentation
Last updated
The VectorDBRetrieval
class is a retrieval class that uses VectorDB as a backend. You can use Dense Retrieval with this class easily.
It first embeds the passage content using an embedding model, then stores the embedded vector in VectorDB. When retrieving, it embeds the query and searches for the most similar vectors in VectorDB. Lastly, it returns the passages that have the most similar vectors.
First, prepare the VectorDB instance you want to use and set up your database. In this example, we are using Chroma
and as our VectorDB. is VectorStore that stores only passage ID and embedding vectors, which optimizes for RAGchain. The Chroma client requires a path to save the database and an embedding function.
Using Langchain Chroma VectorStore
Using RAGchain SlimVectorStore
Ingest a list of passages into your retrieval system.
Retrieve top-k passages for a given query.
You can also filter the retrieved passages. Use the retrieve_with_filter
method and provide the query, top-k value, and a list of content, filepath, or metadata values to filter by.
Here's an example:
In this method uses DB.search
method. Please refer for further information.