Find answers from the community

Updated 5 months ago

Hello everyone, I am working on bot

At a glance
Hello everyone, I am working on bot which will respond to user entered queries. The bot will use a list of PDFs and content from various blogs stored in VectorIndex. Below is the code that I am using:
Plain Text
chat_engine = index.as_chat_engine(
        streaming=True,
        similarity_top_k=3,
        chat_mode="condense_plus_context",
        llm=llm,
        verbose=True,
    )
response = chat_engine.stream_chat(query)
sources = []
for node in response.source_nodes:
    sources.append(node.node.metadata["file_name"])

The issue that I am facing is that, the sources I get in response are not always relevant. So if I ask a question to this bot and it does not have information related to the question, it should ideally return empty list of sources but the sources returned are never empty and they contain at least one source every time
W
K
2 comments
You can use node postprocessors for this case IMO.
They help in trimming down the nodes based on conditions that you have set.

For example one postprocessor is: SimilarityPostprocessor This allows you to set a threshold similarity value below which all the nodes will be removed from the final nodes list.

https://docs.llamaindex.ai/en/stable/module_guides/querying/node_postprocessors/
Is there a way to improve the accuracy of these scores that get attached with nodes? Because even for a node which does not have relevant content related to user query, the score being returned is approximately around 0.8 which seems very inaccurate?
Add a reply
Sign up and join the conversation on Discord