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.
This commit is contained in:
@@ -298,8 +298,8 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
|||||||
separators: ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
separators: ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
||||||
parserEngineRules: undefined as any,
|
parserEngineRules: undefined as any,
|
||||||
enableParentChild: false,
|
enableParentChild: false,
|
||||||
parentChunkSize: 1024,
|
parentChunkSize: 4096,
|
||||||
childChunkSize: 256
|
childChunkSize: 384
|
||||||
},
|
},
|
||||||
storageProvider: 'local' as string,
|
storageProvider: 'local' as string,
|
||||||
multimodalConfig: {
|
multimodalConfig: {
|
||||||
@@ -378,8 +378,8 @@ const loadKBData = async () => {
|
|||||||
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
||||||
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined,
|
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined,
|
||||||
enableParentChild: kb.chunking_config?.enable_parent_child || false,
|
enableParentChild: kb.chunking_config?.enable_parent_child || false,
|
||||||
parentChunkSize: kb.chunking_config?.parent_chunk_size || 1024,
|
parentChunkSize: kb.chunking_config?.parent_chunk_size || 4096,
|
||||||
childChunkSize: kb.chunking_config?.child_chunk_size || 256
|
childChunkSize: kb.chunking_config?.child_chunk_size || 384
|
||||||
},
|
},
|
||||||
storageProvider: (kb.storage_config?.provider || 'local') as string,
|
storageProvider: (kb.storage_config?.provider || 'local') as string,
|
||||||
multimodalConfig: {
|
multimodalConfig: {
|
||||||
@@ -614,8 +614,8 @@ const handleSubmit = async () => {
|
|||||||
separators: data.chunking_config.separators,
|
separators: data.chunking_config.separators,
|
||||||
parserEngineRules: data.chunking_config.parser_engine_rules || undefined,
|
parserEngineRules: data.chunking_config.parser_engine_rules || undefined,
|
||||||
enableParentChild: data.chunking_config.enable_parent_child || false,
|
enableParentChild: data.chunking_config.enable_parent_child || false,
|
||||||
parentChunkSize: data.chunking_config.parent_chunk_size || 1024,
|
parentChunkSize: data.chunking_config.parent_chunk_size || 4096,
|
||||||
childChunkSize: data.chunking_config.child_chunk_size || 256
|
childChunkSize: data.chunking_config.child_chunk_size || 384
|
||||||
},
|
},
|
||||||
multimodal: {
|
multimodal: {
|
||||||
enabled: !!data.vlm_config?.enabled
|
enabled: !!data.vlm_config?.enabled
|
||||||
|
|||||||
@@ -94,10 +94,10 @@
|
|||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
<t-slider
|
<t-slider
|
||||||
v-model="localParentChunkSize"
|
v-model="localParentChunkSize"
|
||||||
:min="256"
|
:min="512"
|
||||||
:max="4096"
|
:max="8192"
|
||||||
:step="64"
|
:step="64"
|
||||||
:marks="{ 256: '256', 1024: '1024', 2048: '2048', 4096: '4096' }"
|
:marks="{ 512: '512', 2048: '2048', 4096: '4096', 8192: '8192' }"
|
||||||
@change="handleParentChunkSizeChange"
|
@change="handleParentChunkSizeChange"
|
||||||
style="width: 200px;"
|
style="width: 200px;"
|
||||||
/>
|
/>
|
||||||
@@ -117,9 +117,9 @@
|
|||||||
<t-slider
|
<t-slider
|
||||||
v-model="localChildChunkSize"
|
v-model="localChildChunkSize"
|
||||||
:min="64"
|
:min="64"
|
||||||
:max="1024"
|
:max="2048"
|
||||||
:step="32"
|
:step="32"
|
||||||
:marks="{ 64: '64', 256: '256', 512: '512', 1024: '1024' }"
|
:marks="{ 64: '64', 384: '384', 1024: '1024', 2048: '2048' }"
|
||||||
@change="handleChildChunkSizeChange"
|
@change="handleChildChunkSizeChange"
|
||||||
style="width: 200px;"
|
style="width: 200px;"
|
||||||
/>
|
/>
|
||||||
@@ -164,8 +164,8 @@ const localChunkSize = ref(props.config.chunkSize)
|
|||||||
const localChunkOverlap = ref(props.config.chunkOverlap)
|
const localChunkOverlap = ref(props.config.chunkOverlap)
|
||||||
const localSeparators = ref([...props.config.separators])
|
const localSeparators = ref([...props.config.separators])
|
||||||
const localEnableParentChild = ref(props.config.enableParentChild ?? false)
|
const localEnableParentChild = ref(props.config.enableParentChild ?? false)
|
||||||
const localParentChunkSize = ref(props.config.parentChunkSize || 1024)
|
const localParentChunkSize = ref(props.config.parentChunkSize || 4096)
|
||||||
const localChildChunkSize = ref(props.config.childChunkSize || 256)
|
const localChildChunkSize = ref(props.config.childChunkSize || 384)
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const separatorOptions = computed(() => [
|
const separatorOptions = computed(() => [
|
||||||
@@ -184,8 +184,8 @@ watch(() => props.config, (newConfig) => {
|
|||||||
localChunkOverlap.value = newConfig.chunkOverlap
|
localChunkOverlap.value = newConfig.chunkOverlap
|
||||||
localSeparators.value = [...newConfig.separators]
|
localSeparators.value = [...newConfig.separators]
|
||||||
localEnableParentChild.value = newConfig.enableParentChild ?? false
|
localEnableParentChild.value = newConfig.enableParentChild ?? false
|
||||||
localParentChunkSize.value = newConfig.parentChunkSize || 1024
|
localParentChunkSize.value = newConfig.parentChunkSize || 4096
|
||||||
localChildChunkSize.value = newConfig.childChunkSize || 256
|
localChildChunkSize.value = newConfig.childChunkSize || 384
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
||||||
const handleChunkSizeChange = () => { emitUpdate() }
|
const handleChunkSizeChange = () => { emitUpdate() }
|
||||||
|
|||||||
@@ -1326,11 +1326,11 @@ type ProcessChunksOptions struct {
|
|||||||
func buildParentChildConfigs(cc types.ChunkingConfig, base chunker.SplitterConfig) (parent, child chunker.SplitterConfig) {
|
func buildParentChildConfigs(cc types.ChunkingConfig, base chunker.SplitterConfig) (parent, child chunker.SplitterConfig) {
|
||||||
parentSize := cc.ParentChunkSize
|
parentSize := cc.ParentChunkSize
|
||||||
if parentSize <= 0 {
|
if parentSize <= 0 {
|
||||||
parentSize = 1024
|
parentSize = 4096
|
||||||
}
|
}
|
||||||
childSize := cc.ChildChunkSize
|
childSize := cc.ChildChunkSize
|
||||||
if childSize <= 0 {
|
if childSize <= 0 {
|
||||||
childSize = 256
|
childSize = 384
|
||||||
}
|
}
|
||||||
parent = chunker.SplitterConfig{
|
parent = chunker.SplitterConfig{
|
||||||
ChunkSize: parentSize,
|
ChunkSize: parentSize,
|
||||||
|
|||||||
@@ -125,10 +125,10 @@ type ChunkingConfig struct {
|
|||||||
// When enabled, large parent chunks provide context while small child chunks
|
// When enabled, large parent chunks provide context while small child chunks
|
||||||
// are used for vector matching. Retrieval matches on child but returns parent content.
|
// 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"`
|
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.
|
// Only used when EnableParentChild is true.
|
||||||
ParentChunkSize int `yaml:"parent_chunk_size,omitempty" json:"parent_chunk_size,omitempty"`
|
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.
|
// Only used when EnableParentChild is true.
|
||||||
ChildChunkSize int `yaml:"child_chunk_size,omitempty" json:"child_chunk_size,omitempty"`
|
ChildChunkSize int `yaml:"child_chunk_size,omitempty" json:"child_chunk_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user