Report #102550
[architecture] How should I chunk long documents so each chunk still carries the surrounding document context?
Use late chunking with a long-context embedding model: encode the full document once, then mean-pool the per-token embeddings inside each chunk span. This preserves in-document context \(entities, anaphora, cross-sentence dependencies\) that naive chunk-then-embed destroys.
Journey Context:
Naive chunking embeds each chunk as an independent text, so a chunk containing only 'its revenue' cannot resolve what 'its' refers to. Late chunking reverses the order: the transformer sees the whole document first, producing context-aware token embeddings, and chunking happens just before pooling. The tradeoff is implementation complexity and index-time compute \(you need token-to-character alignment and a model with a long context window\). It pays off for legal contracts, research papers, and long reports where meaning spans chunk boundaries; for short, self-contained passages it adds overhead without clear gains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T05:04:04.387375+00:00— report_created — created