Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Text Chunking with Overlap in TokenTextSplitter #2123

Open
alfredogangemi opened this issue Jan 27, 2025 · 0 comments
Open

Support for Text Chunking with Overlap in TokenTextSplitter #2123

alfredogangemi opened this issue Jan 27, 2025 · 0 comments

Comments

@alfredogangemi
Copy link

Expected Behavior

The TokenTextSplitter class should support splitting text into chunks with an optional overlap between them. This would enable better context preservation when processing long texts that are chunked for downstream tasks such as embeddings or text analysis.

TokenTextSplitter splitter = TokenTextSplitter.builder().withChunkSize(800).withOverlapSize(50).build();

Current Behavior

Currently, the TokenTextSplitter class splits text into chunks without any overlap. While this works for cases where chunks are fully independent, it may result in loss of context between adjacent chunks, particularly in tasks like embeddings where continuity can improve results.

Context

Why it's needed
Chunking with overlap is critical for use cases where preserving context across chunks is necessary. For example:

  • Embedding generation, where continuity between chunks improves semantic representations.
  • Language models that benefit from adjacent context during token predictions.

Alternatives considered
The functionality can be implemented by extending TokenTextSplitter locally. However, a native implementation would ensure consistency and reusability across projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant