----------------------
To use the Auto Merging Retriever alongside a vector database in LlamaIndex, you would need to follow these steps:
- 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.
- Instantiate the VectorIndexAutoRetriever class: This creates a retriever on top of your summarized metadata index and takes in the defined schema as input.
- 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:
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:
----------------------