Refactor: Enhance KG Editing with Chunk Tracking #2265
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.
Refactor: Enhance KG Editing with Chunk Tracking
Overview
Currently, knowledge graph editing does not synchronously update the chunk tracking storage, resulting in inconsistencies that disrupt entity and relation reconstruction after document deletion. This PR significantly improves the knowledge graph editing functionality by adding comprehensive chunk tracking synchronization.
Key Changes
1. Chunk Tracking Synchronization (Commits: 3fbd704, a3370b0)
2. Graph Consistency Improvements (Commits: bf1897a, a3370b0)
3. Code Refactoring (Commit: 6015e8b)
_persist_graph_updates()function to eliminate code duplicationTechnical Details
Modified Files:
lightrag/utils_graph.py- Core graph utility functions with chunk trackinglightrag/utils.py- Added utility functions for chunk trackinglightrag/lightrag.py- Integration with chunk storagelightrag/api/routers/graph_routes.py- API endpoint updatesStatistics:
Impact
Testing Recommendations
Outstanding issue
Entity merging operations still fail to update the corresponding text chunk tracking information.