You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add automatic text chunking with aggregate embeddings
Add automatic text chunking for documents exceeding embedding model token limits:
- Create chunker package with configurable chunking strategies
- FixedOverlapChunker: splits text with configurable size and overlap
- Uses tiktoken for accurate token counting (cl100k_base encoding)
- Default: 512 token chunks with 50 token overlap, 8191 max tokens
- Implement batch embedding support
- Add BatchEmbeddingProvider interface for efficient multi-text embedding
- Implement EmbedBatch in OpenAI provider (up to 2048 texts per request)
- Automatic fallback to individual embeddings if batch not supported
- Aggregate embedding approach
- Chunk text when exceeding token limits
- Embed all chunks using batch API for performance
- Average chunk embeddings into single aggregate embedding
- Store as single entry (no derived keys needed)
- Convert entire codebase from float32 to float64
- Use OpenAI's native float64 format (eliminates conversions)
- Update all similarity functions and backends
- Better precision for similarity calculations
- Configuration options
- Chunking enabled by default with sensible defaults
- WithChunking() to customize chunk size/overlap/strategy
- WithoutChunking() to disable if not needed
- Zero-config works out of the box
- Add comprehensive tests
- Chunker package tests (validation, chunking logic, token counting)
- Cache integration tests (aggregate embeddings, enable/disable)
- All existing tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments