Repository navigation
Spring AI chunking with overlapping #2113
Replies: 3 comments
|
That's a good question, me too I would like to have updates about chunking with overlapping, I have found nothing interesting in official documentation, thanks |
|
this might be interesting to you: |
|
An update to the linked feature request: built-in token overlap is now available in Spring AI 2.1.0-RC1. The implementation was completed in #2123; the builder method is import java.util.List;
import org.springframework.ai.document.Document;
import org.springframework.ai.transformer.splitter.TokenTextSplitter;
var splitter = TokenTextSplitter.builder()
.withChunkSize(4)
.withChunkOverlap(1)
.withMinChunkSizeChars(0)
.withMinChunkLengthToEmbed(0)
.build();
var chunks = splitter.apply(List.of(new Document("A B C D E F G H I J K L")))
.stream().map(Document::getText).toList();
System.out.println(chunks);
// [A B C D, D E F G, G H I J, J K L]The tiny sizes and zero minimum lengths above are only to make the behavior visible. For a real document you could use Verification: JDK 17, Maven 3.9.11, the published Version caveat: this is a release-candidate version. The published Sources: completed implementation issue, implementation commit, Central artifact listing. Prepared with AI assistance; the example and boundary tests were executed locally. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, is there any built-in functionality in Spring AI that supports chunking with overlapping? If not, is there any recommended approach or library for achieving this?
All reactions