From b697d4945eb661798719d041a02ef66a5b7cd93e Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 5 Mar 2026 15:04:08 +0800 Subject: [PATCH] feat: update chunk size configurations for knowledge base processing - Increased default sizes for parent and child chunks in the knowledge base editor and settings, enhancing data processing capabilities. - Adjusted slider settings in the UI to reflect new minimum and maximum values for chunk sizes, improving user control over configurations. - Updated backend logic to ensure consistent handling of chunk sizes across the application. These changes optimize the chunking process, allowing for more efficient data handling and improved performance in knowledge base operations. --- .../knowledge/KnowledgeBaseEditorModal.vue | 12 ++++++------ .../knowledge/settings/KBChunkingSettings.vue | 18 +++++++++--------- internal/application/service/knowledge.go | 4 ++-- internal/types/knowledgebase.go | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue index 9cd6e36b..c098d2ec 100644 --- a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue +++ b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue @@ -298,8 +298,8 @@ const initFormData = (type: 'document' | 'faq' = 'document') => { separators: ['\n\n', '\n', '。', '!', '?', ';', ';'], parserEngineRules: undefined as any, enableParentChild: false, - parentChunkSize: 1024, - childChunkSize: 256 + parentChunkSize: 4096, + childChunkSize: 384 }, storageProvider: 'local' as string, multimodalConfig: { @@ -378,8 +378,8 @@ const loadKBData = async () => { separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'], parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined, enableParentChild: kb.chunking_config?.enable_parent_child || false, - parentChunkSize: kb.chunking_config?.parent_chunk_size || 1024, - childChunkSize: kb.chunking_config?.child_chunk_size || 256 + parentChunkSize: kb.chunking_config?.parent_chunk_size || 4096, + childChunkSize: kb.chunking_config?.child_chunk_size || 384 }, storageProvider: (kb.storage_config?.provider || 'local') as string, multimodalConfig: { @@ -614,8 +614,8 @@ const handleSubmit = async () => { separators: data.chunking_config.separators, parserEngineRules: data.chunking_config.parser_engine_rules || undefined, enableParentChild: data.chunking_config.enable_parent_child || false, - parentChunkSize: data.chunking_config.parent_chunk_size || 1024, - childChunkSize: data.chunking_config.child_chunk_size || 256 + parentChunkSize: data.chunking_config.parent_chunk_size || 4096, + childChunkSize: data.chunking_config.child_chunk_size || 384 }, multimodal: { enabled: !!data.vlm_config?.enabled diff --git a/frontend/src/views/knowledge/settings/KBChunkingSettings.vue b/frontend/src/views/knowledge/settings/KBChunkingSettings.vue index c8a2f61e..528ec4fa 100644 --- a/frontend/src/views/knowledge/settings/KBChunkingSettings.vue +++ b/frontend/src/views/knowledge/settings/KBChunkingSettings.vue @@ -94,10 +94,10 @@
@@ -117,9 +117,9 @@ @@ -164,8 +164,8 @@ const localChunkSize = ref(props.config.chunkSize) const localChunkOverlap = ref(props.config.chunkOverlap) const localSeparators = ref([...props.config.separators]) const localEnableParentChild = ref(props.config.enableParentChild ?? false) -const localParentChunkSize = ref(props.config.parentChunkSize || 1024) -const localChildChunkSize = ref(props.config.childChunkSize || 256) +const localParentChunkSize = ref(props.config.parentChunkSize || 4096) +const localChildChunkSize = ref(props.config.childChunkSize || 384) const { t } = useI18n() const separatorOptions = computed(() => [ @@ -184,8 +184,8 @@ watch(() => props.config, (newConfig) => { localChunkOverlap.value = newConfig.chunkOverlap localSeparators.value = [...newConfig.separators] localEnableParentChild.value = newConfig.enableParentChild ?? false - localParentChunkSize.value = newConfig.parentChunkSize || 1024 - localChildChunkSize.value = newConfig.childChunkSize || 256 + localParentChunkSize.value = newConfig.parentChunkSize || 4096 + localChildChunkSize.value = newConfig.childChunkSize || 384 }, { deep: true }) const handleChunkSizeChange = () => { emitUpdate() } diff --git a/internal/application/service/knowledge.go b/internal/application/service/knowledge.go index 1171b9c6..c4c9bd83 100644 --- a/internal/application/service/knowledge.go +++ b/internal/application/service/knowledge.go @@ -1326,11 +1326,11 @@ type ProcessChunksOptions struct { func buildParentChildConfigs(cc types.ChunkingConfig, base chunker.SplitterConfig) (parent, child chunker.SplitterConfig) { parentSize := cc.ParentChunkSize if parentSize <= 0 { - parentSize = 1024 + parentSize = 4096 } childSize := cc.ChildChunkSize if childSize <= 0 { - childSize = 256 + childSize = 384 } parent = chunker.SplitterConfig{ ChunkSize: parentSize, diff --git a/internal/types/knowledgebase.go b/internal/types/knowledgebase.go index a96392aa..f5099e46 100644 --- a/internal/types/knowledgebase.go +++ b/internal/types/knowledgebase.go @@ -125,10 +125,10 @@ type ChunkingConfig struct { // When enabled, large parent chunks provide context while small child chunks // are used for vector matching. Retrieval matches on child but returns parent content. EnableParentChild bool `yaml:"enable_parent_child,omitempty" json:"enable_parent_child,omitempty"` - // ParentChunkSize is the size of parent chunks (default: 1024). + // ParentChunkSize is the size of parent chunks (default: 4096). // Only used when EnableParentChild is true. ParentChunkSize int `yaml:"parent_chunk_size,omitempty" json:"parent_chunk_size,omitempty"` - // ChildChunkSize is the size of child chunks used for embedding (default: 256). + // ChildChunkSize is the size of child chunks used for embedding (default: 384). // Only used when EnableParentChild is true. ChildChunkSize int `yaml:"child_chunk_size,omitempty" json:"child_chunk_size,omitempty"` }