Why documents are split at all
A search that returns a whole thirty-page policy document has not really found anything: the model still has to find the one sentence that answers the question, and the document may not even fit. Splitting it into passages lets the search return the paragraph about international delivery rather than the entire terms of sale.
The trade-off
- Chunks that are too large mix several topics. A passage about both delivery times and return windows matches questions about either, and scores only moderately for both, so the right answer can lose to a worse but more focused passage.
- Chunks that are too small lose their context. "Within 7 days" means nothing without the heading that says it is about returns, and a passage that has lost its heading can be retrieved for the wrong question.
Splitting on structure
The better approach is to split where the document itself changes subject: at headings, list items and table rows, rather than every so many characters. A heading stays attached to the paragraph it introduces, and a table row about one product does not bleed into the next.
Products are their own chunks
In a shopping assistant, each product should be exactly one chunk, carrying its name, price, stock, options, image and link together. A product split across two chunks can be recommended with the wrong price, and two products merged into one chunk can be confused with each other.
How to tell chunking went wrong
In a trace, a chunking problem looks like the right information retrieved under the wrong context: a passage that contains the answer but also contains three other things, or one that contains the answer without the heading that makes it make sense. The fix is to restructure the page, not to change the model.
A quick test
Pick a page and read one passage from it out of context. If you cannot tell what it is about, the assistant cannot either.
How ChatWidget does it: documents are split on their structure, each product is one passage, and you can preview exactly what every passage contains before the assistant uses it.