Find answers from the community

Updated 3 months ago

subquery metadata

Hello everyone,

I'm fallowing this implementation to get subquery QA and metadata node.text citations used for each subquery.

Plain Text
# iterate through sub_question items captured in SUB_QUESTION event
from llama_index.core.callbacks import CBEventType, EventPayload

for i, (start_event, end_event) in enumerate(
    llama_debug.get_event_pairs(CBEventType.SUB_QUESTION)
):
    qa_pair = end_event.payload[EventPayload.SUB_QUESTION]
    print("Sub Question " + str(i) + ": " + qa_pair.sub_q.sub_question.strip())
    print("Answer: " + qa_pair.answer.strip())
    print("====================================")


How I can access for each subquestion source_nodes to extract node.metadata, node.text, score used ?

Thank you
A
L
5 comments
@Logan M @WhiteFang_Jr any sugestion here ? I can loop throw for elem in llm_response.source_nodes but if I have more subquestions I don't know if we sent same chunks each time or for each question are different chunks retrived from query engine ? if we have different chunks then how I can get what is used for each subquestion ? Thanks
Hi @Logan M @WhiteFang_Jr any recomandation how to get node.text used for each subquestion generated in SubQuerEngine ?
I think they are already in response.source_nodes
Either that, or you can write a custom callback handler to pick into the sub-questions as they happen
Add a reply
Sign up and join the conversation on Discord