After a RAG team added overlap and a whole-document summary prefix to every chunk, why does a one-line edit now re-embed whole documents, and how do you fix it?
answer
- what reaches the embedding input
- a prefix every chunk shares
- regenerated summaries drift
- overlap costs about one neighbour
- scope the prefix to the section
basics
~20 sThe summary prefix is part of every chunk's embedding input, so any edit that changes the summary changes every fingerprint; overlap only adds a neighbour. Cache or scope the prefix and keep volatile fields out of the input.
solid answer
~50 sSeparate the two causes. **Overlap** copies part of one chunk into the next, so an edit near a boundary touches two chunks instead of one; at 50% overlap roughly every passage sits in two chunks. That widens an edit by about one neighbour; it does not reach the whole document. The **whole-document prefix** does: it is written from the full text, so any edit can change it, a model-written summary can change on a rerun even when the text did not, and because it is folded into every chunk's embedding input, every fingerprint changes at once. Fix it by caching the summary against a document fingerprint and regenerating only on a material change, by scoping the prefix to the section (title plus heading path), and by keeping modified times, version numbers and owners out of the embedding input as filterable metadata.
go deeper
Recall that a vector is computed from everything in its input, so a prefix shared by every chunk makes every chunk change whenever the prefix does.
Explain the overlap arithmetic, stride S minus O and about S over that stride chunks per passage, and contrast it with a whole-document prefix that reaches every chunk.
Diagnose by diffing one chunk's old and new embedding input, then fix with a cached, threshold-refreshed summary, section-scoped prefixes and volatile fields moved to metadata.
Set the rule for what may enter the embedding input and when a summary is refreshed, trading retrieval context against the corpus-wide re-embedding each change triggers.
## Two ways an edit spreads, of very different size With stable chunk boundaries and a chunk-level fingerprint check, a one-line edit should cost one embedding call. Two common additions to a chunker widen that, and they are easy to blame on each other: - **chunk overlap**, where each chunk repeats part of its neighbour; - a **contextual prefix**, text placed in front of every chunk before it is embedded, here a summary of the whole document. The scenario: a forty-page design document chunked by paragraph into 40 chunks, with overlap and a model-written document summary prefixed to each chunk. After the change, a one-line typo fix re-embeds all 40. ## Overlap widens an edit by about one neighbour With chunk size `S` and overlap `O`, consecutive windows advance by a stride of `S - O`, so each passage sits in about `S / (S - O)` chunks. With 500-token chunks: - overlap 100: stride 400, each passage in 1.25 chunks on average; - overlap 250: stride 250, each passage in 2 chunks. So an edit lands in one chunk, or two when it falls in a shared stretch. With anchored boundaries, where the overlap is a copy of the previous chunk's tail, an edit in the tail of chunk 7 also changes the copied head of chunk 8: two embedding calls instead of one. That is real, but it is bounded and local. Overlap is not what re-embeds the whole document. With fixed-size windows, everything after an insert changes anyway, with or without overlap. ## The prefix touches every chunk at once A vector is computed from its whole input, prefix included, so a pipeline that fingerprints embedding inputs sees every chunk change whenever the shared prefix does. A whole-document prefix changes far more often than teams expect: - **any edit can change the summary**, because it is written from the full text; - **a model-written summary often comes back worded differently on a rerun**, even when the text did not change, unless it is cached; a nightly regeneration then re-embeds the document every night; - **volatile fields** placed in the prefix, such as a last-modified time, a version number, a view count or the owner's name, change every chunk's input on events that have nothing to do with the text. In the scenario, the typo fix changed one sentence of the regenerated summary, and that sentence reached all 40 chunks. ## Diagnosing which it is 1. Pick one chunk that was re-embedded but whose own text did not change. 2. Compare its stored embedding input with the new one. 3. If the difference sits inside the prefix, the prefix is the cause; if it sits in the copied head or tail of the chunk text, overlap is. 4. Check the re-embed fraction per edit across documents: prefix churn shows fractions near 1.0 whatever the edit size, while overlap shows about two chunks per edit. ## Fixes and their costs | fix | what it limits | what it costs | |---|---|---| | cache the summary, regenerate on material change | churn from reruns and small edits | the summary lags the text slightly | | scope the prefix to the section | an edit's reach, to its own section | less whole-document context per chunk | | keep volatile fields out of the input | churn from metadata events | those fields filter results but no longer shape the vector | | reduce overlap | the second chunk per edit | less shared context across a cut | The usual combination is a summary cached against a fingerprint of the document and regenerated when the change passes a threshold the team chooses, such as a changed heading or a share of edited chunks; section-scoped prefixes built from the title and heading path, which change only when those do; and volatile fields stored as filterable metadata. Whether a prefix improves retrieval at all, and how to write a good one, belongs with structure-aware chunking; this question is only about how far its changes reach. ## Watch the blast radius Record on each chunk the summary version it was embedded with, so a stale prefix is visible instead of silent, and chart the re-embed fraction per edit. A jump in that fraction right after a chunker or prefix change is the earliest sign that something new has reached the embedding input.
- A document did not change, yet a nightly run re-embedded all of its chunks. What is the likely cause?Something in the embedding input changed without the text changing. The usual suspects are a summary prefix regenerated by a model, which often comes back worded differently, and a volatile field such as a last-synced time or view count folded into the input. Compare two runs' embedding inputs for one chunk; the changed span names the culprit.
- Is it acceptable to let a cached summary go stale after small edits?Often yes, if it is a deliberate rule: regenerate when the document has changed past a threshold, such as a changed heading or a share of edited chunks, or on a schedule, and record the summary's version on each chunk so you know what it was written against. The cost is retrieval context that lags the text slightly.
- Does removing overlap fix the re-embedding problem with fixed-size windows?No. With fixed windows, the shift after an insert re-embeds every later chunk with or without overlap; overlap only changes how many chunks each passage sits in. Removing it matters once boundaries are anchored, where it trims an edit near a boundary from two chunks to one.
- Overlap is why the whole document re-embeds after one edit.
- If a chunk's text is unchanged, its vector is unchanged whatever the prefix.
- A model-written summary comes out the same every time, so caching it is pointless.
- Putting the last-modified time in every chunk's input helps freshness.
- Dropping the prefix entirely is the only fix.