Skip to content

search function within GraphRAG class does not validate empty answers. #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CrisBMoya opened this issue Mar 28, 2025 · 0 comments
Open

Comments

@CrisBMoya
Copy link

In the search function of GraphRAG class, theres a step to retrieve data:

retriever_result: RetrieverResult = self.retriever.search(

If the result comes empty, then the value for retriever_result.items is an empty list ([]). This is fine.

Problem is the function later does not validate for this scenario, finally passing the input, message_history and system_instruction to the function:

Which could lead to potential problems, hallucinations and undesired answers.

A simple solution could be to just validate the items:

if not retriever_result.items:
    result: dict[str, Any] = {"answer": ""}

A more robust solution would be to return either a predefined message or user defined message (as an argument to the function) before the invoke of the llm (as to not invoke an llm over an empty answer) in scenarios where the result is an empty list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant