feat: persist RAPTOR layer metadata on summary chunks#13286
Open
yuch85 wants to merge 1 commit intoinfiniflow:mainfrom
Open
feat: persist RAPTOR layer metadata on summary chunks#13286yuch85 wants to merge 1 commit intoinfiniflow:mainfrom
yuch85 wants to merge 1 commit intoinfiniflow:mainfrom
Conversation
RAPTOR's recursive clustering builds a `layers` list tracking `(start_idx, end_idx)` boundaries per level, but currently discards this information — only the flat `chunks` list is returned. This makes it impossible to distinguish leaf-level summaries from top-level ones, which downstream features need (e.g. retrieving only the highest-level document summary for entity extraction or search result snippets). Changes: - `rag/raptor.py`: Return `(chunks, layers)` tuple from `__call__` - `rag/svr/task_executor.py`: Compute `raptor_layer_int` per summary chunk using the layer boundaries. Layer 1 = first summary level, layer 2 = summary-of-summaries, etc. - `conf/infinity_mapping.json`: Add `raptor_layer_int` integer field (Elasticsearch handles this via existing `*_int` dynamic template) Fixes infiniflow#7488 Related: infiniflow#4104, infiniflow#11191, infiniflow#10951
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
RAPTOR's recursive clustering builds a
layerslist tracking(start_idx, end_idx)boundaries per level, but currently discards this information — only the flatchunkslist is returned. This makes it impossible to distinguish leaf-level summaries from top-level ones.This PR:
(chunks, layers)tuple fromraptor.py's__call__raptor_layer_int(1 = first summary level, 2 = summary-of-summaries, etc.)raptor_layer_inttoinfinity_mapping.json(Elasticsearch handles it via existing*_intdynamic template)Why this matters
Downstream features need to know which RAPTOR layer a summary belongs to:
Changes
rag/raptor.py(chunks, layers)tuplerag/svr/task_executor.pychunk_layermapping, setraptor_layer_intconf/infinity_mapping.jsonraptor_layer_intinteger fieldBackward compatibility
raptor_layer_int = 0by default)Test plan
raptor_layer_intis set on indexed chunksraptor_layer_intvalues increase with abstraction level (layer 1 < layer 2 < ...)delete by raptor_kwd) still worksFixes #7488
Related: #4104, #11191, #10951
🤖 Generated with Claude Code