Repository navigation
fix: Stop TextChunker once a chunk reaches the end of the text - #7078
Open
patelchaitany wants to merge 1 commit into
Open
patelchaitany wants to merge 1 commit into
patelchaitany wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7078 +/- ##
=======================================
Coverage 50.97% 50.98%
=======================================
Files 455 455
Lines 56994 56996 +2
Branches 8321 8322 +1
=======================================
+ Hits 29055 29057 +2
Misses 25954 25954
Partials 1985 1985
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
The sliding window kept advancing after the last word was covered, so a leftover window with at least min_chunk_size words was emitted as an extra chunk whose words were all in the previous chunk. Break out of the loop right after the chunk that reaches the end of the text. Fixes feast-dev#7063 Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
patelchaitany
force-pushed
the
fix/text-chunker-trailing-chunk
branch
from
October 27, 2026 17:47
de2ea2c to
febedd3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
TextChunker._chunk_by_wordskept advancing its sliding window after a chunk had already reached the end of the text. If the leftover window still had at leastmin_chunk_sizewords, it was emitted as another chunk whose words were all in the previous chunk. With the defaultChunkingConfig, a 100-word document produced a redundantw80–w99chunk, andDocEmbedderwould embed and store it as its own row.This PR breaks out of the loop right after the chunk that reaches the end of the text. Texts that do not reach the end produce the same output as before.
Which issue(s) this PR fixes:
Fixes #7063
Checks
git commit -s)Testing Strategy
Misc
Added
test_no_trailing_chunk_contained_in_previous, which fails before this change and passes after it. The existingTestTextChunkertests pass, and ruff check and format are clean.🤖 Generated with Claude Code