Find answers from the community

Updated 3 months ago

How to use Auto merging retriever alongside vectordb

How to use Auto merging retriever alongside vectordb
k
2 comments
Please stand by @bidda7287 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To use the Auto Merging Retriever alongside a vector database in LlamaIndex, you would need to follow these steps:

  1. Define the Schema: Define the vector db schema (e.g., the metadata fields). This will be put into the LLM input prompt when it's deciding what metadata filters to infer.
  1. Instantiate the VectorIndexAutoRetriever class: This creates a retriever on top of your summarized metadata index and takes in the defined schema as input.
  1. Define a wrapper retriever: This allows you to postprocess each node into an IndexNode, with an index id linking back to the source document. This will allow you to do recursive retrieval in the next section (which depends on IndexNode objects linking to downstream retrievers/query engines/other Nodes).
Here is a code snippet that shows how to use the Auto Merging Retriever:

Plain Text
from llama_index.core.retrievers import AutoMergingRetriever

base_retriever = base_index.as_retriever(similarity_top_k=6)
retriever = AutoMergingRetriever(base_retriever, storage_context, verbose=True)

query_str = (
    "What could be the potential outcomes of adjusting the amount of safety"
    " data used in the RLHF stage?"
)

nodes = retriever.retrieve(query_str)
base_nodes = base_retriever.retrieve(query_str)

This code snippet is from this source ().

For more detailed information, you can refer to the LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord