
Chris CoutinhoandClaude
cb39b3fca4
feat(vector): Add configurable chunk size and overlap for document embedding
Enable users to tune document chunking parameters to match their embedding
model and content type by adding DOCUMENT_CHUNK_SIZE and DOCUMENT_CHUNK_OVERLAP
environment variables.
- **config.py**: Added `document_chunk_size` (default: 512) and
`document_chunk_overlap` (default: 50) configuration fields with validation:
- Ensures overlap < chunk_size
- Warns if chunk_size < 100 words
- Prevents negative overlap values
- **processor.py**: Updated DocumentChunker instantiation to use config
settings instead of hardcoded values (line 174-177)
- **tests/unit/test_config.py**: Added TestChunkConfigValidation class with
9 tests covering:
- Default values
- Valid configurations
- Validation errors (overlap >= chunk_size, negative overlap)
- Warning for small chunk sizes
- Environment variable loading
- **docs/configuration.md**: Added comprehensive "Document Chunking
Configuration" section with:
- Chunk size selection guidance (256-384 vs 512 vs 768-1024 words)
- Overlap recommendations (10-20% of chunk size)
- Configuration examples for different use cases
- Added env vars to reference table
- **docs/semantic-search-architecture.md**: Added "Document Chunking Strategy"
section with:
- Chunking process explanation
- Example showing sliding window behavior
- Search behavior with chunks
- Tuning recommendations
- **env.sample**: Added complete "Semantic Search & Vector Sync Configuration"
section with:
- Vector sync settings
- Qdrant configuration (3 modes)
- Ollama embedding service
- Document chunking configuration
- **docker-compose.yml**: Added commented examples for DOCUMENT_CHUNK_SIZE and
DOCUMENT_CHUNK_OVERLAP with usage notes
\`\`\`bash
DOCUMENT_CHUNK_SIZE=512
DOCUMENT_CHUNK_OVERLAP=50
\`\`\`
1. \`overlap\` must be less than \`chunk_size\`
2. \`overlap\` cannot be negative
3. Warning issued if \`chunk_size\` < 100 words
**Precise matching** (small notes, specific queries):
\`\`\`bash
DOCUMENT_CHUNK_SIZE=256
DOCUMENT_CHUNK_OVERLAP=25
\`\`\`
**Balanced** (default, general purpose):
\`\`\`bash
DOCUMENT_CHUNK_SIZE=512
DOCUMENT_CHUNK_OVERLAP=50
\`\`\`
**Contextual** (long documents, broader topics):
\`\`\`bash
DOCUMENT_CHUNK_SIZE=1024
DOCUMENT_CHUNK_OVERLAP=100
\`\`\`
✅ **User control** - Tune chunking to match embedding model capabilities
✅ **Experimentation** - Test different chunk sizes for optimal results
✅ **Model alignment** - Match chunk size to embedding context window
✅ **Backward compatible** - Defaults maintain existing behavior
✅ **Well validated** - Comprehensive tests prevent misconfiguration
All 22 config validation tests pass (9 new tests for chunking):
- Default values work correctly
- Validation prevents invalid configurations
- Environment variables load properly
- Warning system works as expected
With configurable chunk sizes, users can now experiment with different Ollama
embedding models and tune chunk parameters for optimal semantic search quality.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 02:47:57 +01:00
..
2025-05-07 23:06:22 +02:00
2025-11-02 23:31:39 +01:00
2025-11-08 20:32:49 +01:00
2025-11-04 00:03:24 +01:00
2025-11-03 20:33:56 +01:00
2025-11-05 23:19:03 +01:00
2025-11-07 21:08:55 +01:00
2025-11-09 05:11:56 +01:00
2025-11-09 04:47:20 +01:00
2025-11-09 04:47:20 +01:00
2025-11-02 22:03:22 +01:00
2025-10-14 01:23:49 +02:00
2025-09-11 17:31:00 +02:00
2025-10-15 14:47:43 +02:00
2025-11-10 02:47:57 +01:00
2025-09-11 17:28:13 +02:00
2025-10-17 03:08:16 +02:00
2025-11-03 20:33:56 +01:00
2025-09-11 17:28:13 +02:00
2025-10-14 01:23:38 +02:00
2025-11-02 22:03:21 +01:00
2025-11-02 22:03:19 +01:00
2025-05-06 02:52:51 +02:00
2025-11-09 01:00:18 +01:00
2025-11-02 23:58:15 +01:00
2025-11-09 04:47:20 +01:00
2025-11-02 22:03:22 +01:00
2025-11-02 22:03:21 +01:00
2025-11-02 22:03:21 +01:00
2025-11-02 22:03:21 +01:00
2025-11-09 08:54:04 +01:00
2025-10-15 16:27:22 +02:00
2025-10-14 01:23:38 +02:00
2025-11-10 02:47:57 +01:00
2025-09-11 17:28:13 +02:00
2025-10-23 11:20:49 +02:00
2025-10-24 04:38:49 +02:00
2025-11-02 22:03:21 +01:00
2025-09-11 17:28:13 +02:00