Is there an example notebook showcasing the use of approximate. meta data filtering ? For example, I am using
workflows
for RAG and I'd like to include. approximate metadata filtering for better retrieval accuracy.
custom_index = VectorStoreIndex.from_documents(
documents,
storage_context=storage_context
)
class RAGWorkflow(Workflow):
@step
async def ingest(self, ctx: Context, ev: StartEvent) -> StopEvent | None:
"""Entry point - ingest documents"""
index = custom_index
return StopEvent(result=index)
@step
async def retrieve(self, ctx: Context, ev: StartEvent) -> RetrieverEvent | None:
"Entry point for RAG, triggered by a StartEvent with `query`."
query = ev.get("query")
index = ev.get("index")
if not query:
return None
# store the query in the global context
await ctx.set("query", query)
await ctx.set("index", index)
# get the index from the global context
if index is None:
print("Index is empty, load some documents before querying!")
return None
retriever = index.as_retriever(similarity_top_k=10)
nodes = await retriever.aretrieve(query)
return RetrieverEvent(nodes=nodes)