fix: 修改了local search中的relation_counts计数规则 #318
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
您好,看到您的项目对我很有启发。但我在使用 local search 时,发现源码中
/LightRAG/lightrag/operate.py
在召回实体最相关文本单元_find_most_related_text_unit_from_entities
函数的时候,为了对文本单元重要性进行排序所使用到了relation_counts。但在现有的逻辑中,如果一个文本单元c_id与多个实体节点相关联,且这些实体节点的一跳相邻节点数量不同,那么先遍历到一跳相邻节点少的实体节点时,relation_counts可能会被低估。
所以我修改为:在每次遍历时更新relation_counts,而不是跳过已经存在的文本单元。