-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Do you need to file an issue?
- I have searched the existing issues and this bug is not already filed.
- My model is hosted on OpenAI or Azure. If not, please look at the "model providers" issue and don't file a new one here.
- I believe this is a legitimate bug, not just a question. If this is a question, please use the Discussions area.
Describe the bug
In graphrag/query/context_builder/dynamic_community_selection.py, lines 131-132 read:
for child in self.communities[community].children: # child is int
if child in self.reports: # self.reports keys are str
Because children holds integers and self.reports is keyed by strings, the membership test always fails.
As a result, IDs that should be selected as child communities are missed, and the exploration of the next community level is never executed.
Steps to reproduce
Execute global_search
with dynamic_community_selection=True
using a knowledge graph where the highest community_level
is 1 or higher.
Expected Behavior
Expected Behavior
Child community IDs should match the type used in self.reports
, allowing them to be evaluated and, if relevant, included in the result.
Actual Behavior
if child in self.reports
is always False
; all child communities are skipped, so the algorithm never descends to the next level.
GraphRAG Config Used
# Paste your config here
Logs and screenshots
This is the current behavior when a query is issued:
The message cannot find community is displayed, and only 10 out of 5,586 communities are referenced.
This is the behavior after a simple fix was applied:
309 out of 5,586 communities are now referenced when a query is issued.
Note: The threshold
is set to 2.
Fixed Code:
for child in self.communities[community].children:
if str(child) in self.reports:
communities_to_rate.append(str(child))
Additional Information
- GraphRAG Version: v2.4.0
- Operating System: Windows 11
- Python Version: 3.12.11
- Related Issues: Nothing