Repository navigation
fix(chunking): don't repeat a very large split element in every chunk - #4565
Merged
cragwolfe merged 1 commit intoOct 21, 2026
Merged
Conversation
When one element is split into several chunks, each chunk carries the whole element in metadata.orig_elements and serializes its own copy. For the spreadsheet in Unstructured-IO#3872 that is 12,555 copies of a 4.3 MB encoded table, about 54 GB of JSON. Above 1,000,000 characters of text, HTML and image data, split chunks now omit orig_elements and a warning is logged. Smaller elements and elements that are not split keep today's behaviour.
cragwolfe
approved these changes
Oct 21, 2026
cragwolfe
left a comment
Contributor
There was a problem hiding this comment.
Reviewed cd686ea against main at 07d978b with GPT Pro. No actionable production defects found.
The split guards preserve originals for single-output cases, and omitted originals remain compatible with serialization and table reconstruction. This approval accepts the documented loss of original-only metadata for qualifying large split elements; the threshold does not impose a total memory or output-size bound.
All 51 check runs on the reviewed head succeeded, including the required unit-test, lint, Docker, ingest, changelog, and Socket checks. No local tests were run; the author’s performance claims were not independently reproduced.
(authored by codex)
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.
Fixes #3872.
Each chunk split from one element gets the whole element in metadata.orig_elements and serializes its own copy. The spreadsheet in the issue becomes one Table with 9.6 MB of text_as_html, chunk_by_title cuts it into 12,555 chunks, and the JSON ends up around 54 GB.
This adds SPLIT_ORIG_ELEMENTS_MAX_CHARS = 1,000,000 (text + HTML + image data). If a single element over that limit really gets split into more than one chunk, those chunks skip orig_elements and a warning is logged. Everything else works as before, including large elements that fit in one chunk and pre-chunks with several elements.
With default by_title options the issue's file now gives 24 MB of JSON in 0.5 s.
Keeping orig_elements on the first chunk only would also work, if you prefer that.