Find answers from the community

Updated 3 months ago

For each query, I'd like to perform

For each query, I'd like to perform several custom vector retrievals...and control which nodes are selected for the prompt. Would it be best to sublcass VectorIndexRetriever to achieve this?
B
d
L
15 comments
Depends on what you define as custom. You can already customize the nodes retrieved using response_mode=no_text and then filter through them. You can also perform multiple vector retrieval and merge the selected nodes together.
Is this the use case you are looking for?
Yes, I just want to parse the sub topics within a query on my own and perform multiple vector retrievals.
I do not wish to use SubQuestionQueryEngine.
I'm not sure that response_mode=no_text would suffice here.
Or perhaps I should bypass the query altogether and do something more fine grained?
You can use the retriever directly for this use case, and then use a response synthesizer on its own once you have your nodes
Plain Text
retriever = index.as_retriever(similarity_top_k=2)
nodes = retriever.retrieve("query")

from llama_index.core import get_response_synthesizer

synth = get_response_synthesizer(response_mode="compact", llm=;;m)

response = synth.synthesize("query", nodes)
To add to this @doughboy you should consider a pre-processing step where you use a language model to extract out the topics in the query and then retrieve them for each topic. Then you can synthesize the response using Logan's example.
Also if these topics are keywords, I recommend BM25 or a hybrid retriever.
I already have a sure-fire way to parse the topics without a language model that might hallucinate.
So I should just do nodes = retriever.retrieve(topic) multiple times, and then it's business as usual?
yeah you also need to merge them and then synthesize
Will do. Thanks, guys!
@Logan M @BioHacker If I'm not using a query engine, how do I incorporate a node postprocessor, such as MetadataReplacementPostProcessor?
Do I simply do this?
Plain Text
nodes = postprocessor.postprocess_nodes(nodes) response = synthesizer.synthesize(prompt, nodes)
Add a reply
Sign up and join the conversation on Discord