fix(splitter): 传递数据集级二阶段分片配置#286
Draft
ottercoconut wants to merge 1 commit into
Draft
Conversation
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.
变更概述
修复数据集级分片配置没有完整传递到 splitter 装配的问题。关联 issue:#285。
本次改动后,
create_chunking_engine(config=...)会使用数据集级ChunkingConfig中的:stage_two_algorithmprotected_neighbor_overlap此前工厂虽然已经消费了
overlap_tokens、min_candidate_chunk_tokens、max_chunk_tokens、hard_max_tokens、heading_break_level,但StageTwoRouter仍读取全局settings.CHUNKING_STAGE_TWO_ALGORITHM,导致前端/数据集开启semantic_depth_window后,只要服务端全局默认仍是noop,实际分片仍走candidate_boundary + noop。根因
StageServices.run_chunking()已经按数据集级stage_two_algorithm判断是否需要加载用户 EMBEDDING,但src/core/splitter/factory.py真正构造StageTwoRouter时又回到了全局 settings:这造成“配置读取到了,但执行路由没用上配置”。
具体改动
src/core/splitter/factory.pyChunkingConfig解析stage_two_algorithm,并传给StageTwoRouter。ChunkingConfig解析protected_neighbor_overlap,并传给StructuredSemanticChunker。config is None时继续回退系统级CHUNKING_*配置。tests/unit/core/splitter/test_factory.pysemantic_depth_window覆盖全局noop。noop覆盖全局semantic_depth_window。noop时,只要数据集级为semantic_depth_window,最终split_strategy应为candidate_boundary + semantic_depth_window。heading_break_level、min_candidate_chunk_tokens、overlap_tokens、max_chunk_tokens、hard_max_tokens、stage_two_algorithm、protected_neighbor_overlap。验证
结果:
tests/unit/core/splitter:69 passedgit diff --check:通过风险与说明