00-START-HERE · 01-READING-ROUTES · 12_text_representation · 14_beyond_plain_text_tables_layout_documents This chapter explains how to choose retrieval units, route across granularities, preserve enough context, and measure whether a chunker actually improved retrieval.
TL;DR
- Chunking is an index-time decision. A single-chunk retrieval path may lose a split fact; neighboring-chunk retrieval or parent expansion can repair it if the underlying text remains available.
- Start from the smallest unit that must survive intact. Set overlap from that unit’s length, not from a fixed percentage.
- Use boundaries already present in the document before paying a model to infer them. Meaning-based and model-generated splitting can cost and about as much as fixed splitting.
- Query type determines useful granularity. Do not assume raw sentence, paragraph and section scores are calibrated for one ranking; validate or calibrate them before fusion.
- Fine retrieval helps when pooling hides one exact fact. Index a self-contained proposition, then return its parent passage so the generator still sees qualifiers.
- Evaluate retrieved extent with token recall, precision, and intersection over union (). Recall alone rewards oversized chunks.
- Semantic chunking needs a measured benefit over structural cuts and overlap. In the Gaussian examples, rounded percentile-like thresholds give approximately versus boundary recall; this is a model comparison, not a universal transfer bound.
The story
Imagine a library that receives long policy binders. A cutting clerk prepares searchable cards before patrons arrive. If a fact is split across cards, a desk that retrieves only one card may miss it; a desk that also fetches the neighbor or parent can reconstruct it. Otherwise a new cutting policy requires reindexing affected content. The cheapest clerk counts tokens and cuts on schedule. If a clause crosses the cut, its halves land on different cards. Overlap photocopies the edge of one card onto the next. In the discrete window model, an overlap of tokens protects every span of at most tokens, provided the span fits within a chunk. A more careful clerk follows paragraph breaks. A better clerk reads the binder’s headings, table rows, and clause numbers. Those author-provided marks usually reveal the intended units for almost no extra work. A meaning-aware clerk listens for topic changes. A model-driven clerk reads the whole binder and proposes cuts. Those last two clerks cost more, and they can rediscover boundaries the author already supplied. Some binders contain useful policy text wrapped in repetitive legal boilerplate. A local clerk compares each sentence with its neighbor and cuts when the subject changes. A pseudo-instruction clerk first writes a one-card summary of the binder. The clerk then compares every sentence with that summary and separates runs when usefulness changes. The summary is a proxy for future patron questions. The library also keeps cards at sentence, paragraph, and section sizes. A dosage question wants the sentence card. A broad recommendation question wants the section card. Raw catalog scores from these shelves are not comparable because long, coherent cards can inherit a high background score. The library therefore uses a router, meaning a clerk who reads the question and weights each shelf before ranking. The finest cards hold propositions, meaning one self-contained fact each. A sentence such as “the fee rises to that year” is too dependent on its neighbors. The proposition card rewrites it with the subject, date, and value. The search desk matches that precise card, then follows its parent pointer back to the original passage. The parent passage matters because the answer clerk is a large language model (LLM), and the LLM needs conditions and qualifiers. The proposition is the match unit. The passage is the serve unit. If the library serves only the proposition, a true fragment can still support a wrong answer. The head librarian audits each cutting policy against highlighted gold excerpts. Token recall asks how much highlighted text came back. Token precision asks how much returned text was highlighted. charges for both missing text and padding. Returning the correct whole binder gives perfect extent recall but nearly useless precision; the retriever must still find that binder. Finally, the head librarian tests the meaning-aware clerk on two shelves. One shelf joins unrelated articles. Topic changes are obvious, so the clerk finds almost every seam. The other shelf contains single coherent policies. Adjacent sections share vocabulary and style, so real seams look like ordinary sentence gaps. The same detector now cuts mostly in the wrong places. The library’s rule is practical. Use declared structure first. Buy overlap when it protects a measured answer span. Add fine cards only when pooling truly dilutes exact facts. Add a router only when queries genuinely need different scales. Make every expensive clerk win on real binders before funding a full recataloging.
Decoder table
| Technical term | Plain-English meaning | Why it matters |
|---|---|---|
| Retrieval-Augmented Generation (RAG) | A system that retrieves source text before a model answers | Chunk boundaries decide what evidence the system can retrieve |
| Chunk | One indexed piece of a source document | It is the unit that retrieval ranks and returns |
| Chunker | The procedure that chooses indexed units | Missing candidates can require neighbor recovery, parent expansion or reindexing; failure is not necessarily irreversible |
| Granularity | The scale of a retrieval unit, such as sentence, paragraph, or section | Different questions need different scales |
| Token | The text unit counted by encoders and generators | Chunk size, overlap, cost, and context are priced in tokens |
| Atomic unit | The shortest span that contains everything needed to answer one question | It sets the protection that chunking must provide |
| Fixed-length splitting | Cutting after every fixed number of tokens | It is cheap but ignores content and structure |
| Stride | The distance between consecutive chunk starts | With chunk length and overlap , stride is |
| Overlap | Text repeated in adjacent windows | In this integer-token model, overlap protects fitting spans through tokens |
| Severance rate | The probability that a required span crosses a boundary | It quantifies damage from blind cuts |
| Separator splitting | Cutting at an ordered list of paragraph, line, space, and character boundaries | It preserves known separator-delimited units that fit under the cap |
| Document-specific splitting | Cutting at author-provided structure such as headings, rows, or functions | It often gives faithful units with no model calls |
| Semantic chunking | Inferring boundaries from changes in embedding meaning | It adds compute and only works when boundary gaps are distinguishable |
| Breakpoint chunking | Cutting where adjacent sentence windows become dissimilar | It detects local subject changes |
| Agentic chunking | Asking an LLM to propose boundaries and often titles or summaries | It can judge unstructured text but requires a generation pass |
| Optical character recognition (OCR) | Conversion of scanned pages into text | OCR text may lack reliable document structure |
| Automatic speech recognition (ASR) | Conversion of speech into text | ASR transcripts may need inferred boundaries |
| HyperText Markup Language (HTML) | Structured markup used by web documents | Its tags provide free boundary evidence |
| Embedding | A vector representation used for similarity search | Semantic chunking and retrieval both depend on it |
| Cosine similarity | The angle-based similarity between two vectors | The chapter uses it to score sentences, chunks, and anchors |
| Bi-encoder | An encoder that maps queries and text into separately comparable vectors | Its cosine band and throughput affect chunking choices |
| Anisotropy | The tendency of embedding cosines to occupy a narrow model-specific band | It makes one absolute threshold hard to transfer |
| Pseudo-instruction chunking (PIC) | Splitting sentences by relevance to a generated document summary | It targets usefulness rather than only topic continuity |
| Pseudo-instruction | A generated summary used as a stand-in for future queries | It anchors sentence relevance before real queries exist |
| Anchor | The vector against which every sentence is scored | Its quality determines the useful and boilerplate split |
| Document centroid | The normalized sum of all sentence vectors | It is free but points toward whatever content is most numerous |
| Per-document mean threshold | A cutoff equal to the mean sentence score within one document | It self-normalizes across documents and encoders |
| Score-spread guard | A rule that avoids splitting when maximum and minimum sentence scores are too close | It reduces noise-driven cuts but does not guarantee that a single-topic page stays whole |
| Content hash | A fingerprint of document content | It lets a system reuse summaries for unchanged documents |
| Cold start | A newly ingested document with no query history | It still needs a proxy such as a summary |
| Mixture of Granularity (MoG) | A retriever using query-conditioned granularity weights | It can help calibrate competition across levels; the displayed weights are an illustrative scoring rule |
| Router | A small network that assigns a weight to each granularity for a query | It selects fine or coarse evidence at query time |
| Soft target | A training target distributed across granularity levels | It supervises a router without differentiating through top- selection |
| Mixture of Granularity Graph (MoGG) | A graph extension that treats hop range as granularity | It allows coarse evidence to gather across documents |
| Mean pooling | Averaging or summing unit vectors and normalizing the result | It can dilute an exact fact or create a length-dependent floor |
| Background similarity | Similarity between a query and non-answering sentences on the same topic | It sets the long-chunk score floor |
| Internal coherence | Mean pairwise similarity among sentences or propositions in one unit | It controls dilution and length effects |
| Crossover condition | The limiting toy inequality for | Finite-length crossover has an -dependent threshold; geometric feasibility also matters |
| Small-to-big retrieval | Retrieving a fine unit and expanding it to its parent | It avoids cross-level score mixing and restores context |
| Reciprocal rank fusion (RRF) | Combining ranked lists using rank instead of raw score | It is scale-free when router labels are unavailable |
| Sparse retrieval | Retrieval based on explicit term matches | Its length bias differs from dense mean pooling |
| Term frequency-inverse document frequency (tf-idf) | A sparse weighting scheme for terms and documents | Its cosine score can over-penalize long documents |
| Best Matching 25 (BM25) | A sparse ranking function with tunable length normalization | Its chunk-length intuition does not transfer directly to dense pooling |
| Pivoted length normalization | A correction that adds length back into sparse scoring | It addresses the sparse system’s opposite length pathology |
| Proposition | One rewritten, self-contained, decidable fact | It removes pooling dilution while preserving meaning without neighbors |
| Decontextualization | Rewriting a fragment to restore its missing subject, date, or reference | It makes fine retrieval units searchable on their own |
| Parent map | A mapping from a proposition back to its source passage | It restores source context after fine-grained matching |
| Fan-in | The number of retrieved propositions that collapse onto one parent | It converts proposition top- into returned parent count |
| Multi-hop question | A question that needs evidence from multiple facts or units | Fine units may require several hits instead of one passage |
| Recursive Abstractive Processing for Tree-Organized Retrieval (RAPTOR) | A tree of recursive summaries for broad retrieval | It supplies coarse units and complements propositions |
| Approximate nearest neighbor (ANN) search | Fast vector search that may not inspect every vector exactly | Index size and graph settings affect retrieval cost and recall |
| Hierarchical Navigable Small World (HNSW) | A graph index for ANN search | More vectors add neighbor-list memory and may require retuning |
| Product quantization | Compact codes that replace full vectors | It can shrink a proposition index sharply |
| Floating-point 32-bit (fp32) | Four-byte storage for each vector dimension | It drives the chapter’s index-memory arithmetic |
| Int8 | One-byte integer storage per dimension | It is one cited option for reducing a sentence index |
| Token-offset annotation | A gold answer stored as source token positions | It survives changes to the chunker |
| Recall | The share of gold answer tokens retrieved | It catches missing evidence but rewards large chunks |
| Precision | The share of retrieved tokens that belong to the gold excerpt | It exposes padding and irrelevant extent |
| Intersection over union () | Gold and retrieved overlap divided by their union | It charges for both missed evidence and extra text |
| The harmonic combination of precision and recall | IoU is a per-query monotone transform, not a transform of macro-averaged | |
| A segmentation error rate based on whether window endpoints share a segment | It grades boundaries without running retrieval | |
| WindowDiff | A segmentation error rate that compares boundary counts within a window | It reduces ’s asymmetry around nearby boundaries |
| Fixed retrieved-token budget | Comparing systems that return the same amount of text | It removes the advantage of simply making chunks larger |
| Change-point detector | A method that marks shifts in a sequence | A semantic chunker is this detector over sentence embeddings |
| Within-topic gap | Distance between adjacent sentences inside one topic | Its distribution forms the detector’s negative class |
| Boundary gap | Distance between adjacent sentences across a real topic change | Its separation from within-topic gaps sets the ceiling |
| Separability | The mean boundary-gap difference divided by shared spread | It predicts whether semantic boundaries are detectable |
| Percentile threshold | A cutoff chosen by rank within observed distances | With distinct values it selects approximately a fixed fraction; ties and strict comparisons can change the count |
| False positive rate (FPR) | The share of within-topic gaps incorrectly cut | It reveals spurious boundaries |
| Distribution tail | The rare longest chunks produced by variable-length splitting | It can exceed the encoder limit and create invisible corpus holes |
| Prefill | Processing retrieved context before the model generates | Coarse chunks can dominate query latency and cost |
| Floating-point operations (FLOPs) | Arithmetic operations used to estimate compute | The worked examples compare ingestion and generation cost with them |
| Normalized discounted cumulative gain (nDCG) | A ranking metric that rewards relevant results near the top | A gain can still be invalid if the evaluation corpus manufactures boundaries |
| The fraction of defined gold items found among the top results | With one gold item it reduces to a hit indicator; aggregate grain and chunker-dependent gold definitions must be stated | |
| Rank inversion | A distractor scoring above the true answer | Pooling and cross-level scale differences can cause it |
| Self-containment check | A filter for unresolved pronouns, demonstratives, or missing entities | It blocks malformed propositions from entering the index |
| Corpus | The full collection of source documents | Its formats and query needs determine the right chunker |
| Index | The stored searchable representation of chunks | Boundary changes require rebuilding its vectors |
| Retriever | The component that selects evidence for a query | It can only select units the chunker created |
| Reranker | A second-stage model that reorders retrieved candidates | It cannot recover a fact absent from every candidate |
| Generator | The model that writes the final answer from retrieved context | It often needs broader context than matching does |
| Query | The user’s search or question | Its answer scale determines useful granularity |
| Top- | The first ranked retrieval results | Fine units may need a larger to cover several facts |
| Rerank depth | The number of initial results a second-stage model inspects | A target below that cutoff cannot be rescued |
| Context budget | The maximum retrieved text the generator can accept or afford | Parent expansion and coarse routing consume it quickly |
| Backfill | Reprocessing an existing corpus after a chunker or prompt change | Expensive agentic policies can repeat this cost |
| Re-ingestion | Rebuilding indexed content from its sources | Semantic chunking adds a detection pass to it |
| Ground-truth boundary | A human or structural label for a real topic change | It lets a boundary detector be evaluated directly |
| Held-out set | Labeled data reserved for calibration rather than fitting | It sets spread guards and thresholds without using test queries |
| Gaussian gap model | A bell-shaped model for within-topic and boundary distances | It converts separability into recall and false positives |
| Spread | The shared standard deviation of the two gap populations | It scales their mean difference into |
| Query-conditioned weight | A granularity weight computed from the current query | It avoids one corpus-wide size choice |
| Candidate set | Chunks returned before final ranking or generation | Candidate count can bind reranker cost |
| Relevance shift | A transition between below-anchor and above-anchor sentence runs | PIC uses it as a chunk boundary |
| , , , , , , , and | Corpus token count, chunk length, overlap, required span, document sentence sequence, one sentence, boundary set, and query | These symbols define fixed splitting and the query-dependent ideal boundary |
| , , , , , , , , , , , , and | Encoder, pseudo-instruction, sentence score, mean cutoff, binary label, vector sum, class strengths and directions, residual directions, and score noise | These symbols state the pseudo-instruction method and its worked geometry |
| , , , , , , , , , , and | Unit length, answer and background similarities, coherence, pooled score, router weight and candidate score, corpus size, dimension, graph degree, and result count | These symbols expose cross-granularity score bias and price routing |
| , , , , , and fan-in | Passage, proposition count and vectors, distractor similarity, query, and proposition hits per parent | These quantities define pooling dilution and fine-match to coarse-serve expansion |
| , , , , , , , , , , , , , and | Gold and retrieved token sets, overlap and set sizes, recall, precision, overlap metrics, chunk settings, split fraction, window width, and reference segment length | These symbols measure retrieval extent and segmentation error |
| , , , , , , , , , and | Adjacent gap, threshold, within-topic and boundary means, spread, separability, Gaussian cumulative function, chunk length, answer length, and stride | These symbols turn semantic chunking into a measurable detection problem |
Core mechanics
Mathematical conventions
Token counts and span lengths are integers. For fixed overlapping windows use , , retain the final partial chunk, and stop as soon as the document is covered. Counts and billed unpadded tokens are computed per document, not by pooling unrelated documents into one stream. Long-document overlap multipliers are approximations; finite vector counts and padded compute can differ. A split span can still be recovered by retrieving neighboring chunks or expanding to a parent: failure of a single chunk is not a proof that all RAG systems must fail. Vector-pooling and Gaussian examples are explicitly idealized, not laws of learned encoders. Natural logarithms use nats; storage is decimal. HNSW budgets include vector payload and base-layer neighbor slots only. FLOP estimates use stated sustained throughput and omit attention-length effects, bandwidth, padding unless specified, scheduling, graph work, and I/O. Extent metrics use unique source positions keyed by document, not repeated prompt tokens. Keep full precision until reporting; denotes rounding or a model approximation.
13.1 Five levels of splitting
The index-time retrieval contract
- What: Splitting chooses searchable units before retrieval runs; the text itself need not be compressed or discarded.
- Why: A single-unit match should contain the needed evidence, or the serving path must explicitly recover adjacent or parent context.
- Failure without it: A -token clause cut at can separate obligation from liability cap. A reranker cannot invent a missing candidate, but retrieving both halves can repair the split.
- Cost and complexity: Boundary changes invalidate affected chunk IDs and vectors. Version the chunker and its parent mapping; an entire index rebuild is not always necessary. For a nonempty document with tokens, chunk length and overlap , let stride . Chunk starts are until a chunk first covers the document end. The resulting count is
Set for an empty document. With an unpadded final chunk and no extra windows after coverage, the exact embedded-token count is for . The long-document approximation is ; padding every call to instead processes slots. If span starts are uniform modulo the stride, ignoring document-edge effects, the probability that no one window contains an -token span is for ; it is for . At this becomes for a fitting span. At , , and , modeled severance is . Any span with is contained in at least one window under this discrete coverage convention. Thus is sufficient for every -token span; is a conservative alternative. The long-document multiplier approximates token and vector inflation. Exact token count is , exact vector count is , and graph allocation follows that integer count. These need not share exactly one multiplier on short documents. At , , the asymptotic multiplier is , or about extra. For the finite contract example below, actual token inflation is .
The five splitting levels
| Level | What it does | Why it exists | Failure without the right fit | Stated cost |
|---|---|---|---|---|
| 1. Fixed length | Cuts at a fixed token stride | It gives a simple fallback | It can cross semantic units | Long-document token proxy at ; use exact per-document counts |
| 2. Separators | Tries paragraph, line, space, then character boundaries | It preserves known units when they fit | An oversized unit still needs splitting | One scan plus the token cost of the actual resulting chunks, not necessarily level one’s count |
| 3. Document-specific | Uses headings, HTML tags, functions, rows, slides, or numbered clauses | It takes boundaries the author already declared | Ignoring structure can turn one table into two corrupted fragments | embedded tokens plus one parser per format and zero model calls |
| 4. Semantic | Embeds sentence windows and detects large adjacent distances | It infers structure-free boundaries | Quantile thresholds can force cuts on noise | Approximately tokens in the specified three-sentence-window implementation; about times fixed here |
| 5. Agentic | Asks an LLM to propose boundaries or summaries | It handles units requiring judgment | It may rediscover declared structure | In this price scenario, input tokens plus final embeddings cost about times fixed; output charges are excluded |
With one neighboring sentence on each side, interior sentences appear in three detection windows. Edge sentences appear fewer times. Thus detection is approximately for long documents, and final disjoint chunk embeddings add ; exact cost depends on edges, padding and the implementation. A strict cut above the empirical th percentile selects approximately the largest of distances when values are distinct. Ties, small samples and the quantile convention affect the count; identical distances need not produce any strict-above-threshold cut. A fixed top-fraction rule can nevertheless manufacture boundaries on noise. Level five earns its cost mainly when markup is absent. The source names OCR scans, ASR transcripts, and raw plain text. Doubling halves the no-overlap severance probability for a fixed fitting span under uniform phase. It also roughly doubles retrieved text per full chunk and the linear prefill proxy. An individual final token vector has coefficient in a mean, but that is not its end-to-end influence in a contextual encoder. Cross-length score bias depends on the geometry discussed below.
Worked corpus
The corpus has documents at tokens each. Total is tokens. Embedding costs per million tokens. The generation model costs per million input tokens.
| Configuration | Boundary result | Index result | Cost result |
|---|---|---|---|
| Fixed, , | Spans through tokens fit; a -token clause cannot fit in one window | chunks per document and vectors | unpadded embedded tokens and |
| Recursive separators | Preserves fitting separator-delimited units; oversized ones still split | Actual chunk count depends on separator locations | Same pricing, but recompute counts and overlap rather than assuming the fixed-window bill |
| Numbered clauses | All clauses survive if clauses are kept atomic, even those longer than | million vectors, mean tokens; more vectors | fp32 payload versus ; no overlap gives |
| Semantic | Boundaries depend on encoder and detection settings | Encoder changes may require both recutting and re-encoding | Approximate tokens and , or times the exact fixed-window bill |
| Agentic | A model proposes boundaries | Prompt changes may require a new backfill | input processing plus embeddings gives , or times fixed; output charges omitted |
At weekly turnover, proportional recomputation costs weekly under the same input-plus-embedding model, excluding generation output charges. Dense Passage Retrieval (DPR) used disjoint 100-word English Wikipedia passages. At about tokens per word, is about 133. A 40-token span has modeled severance . A 5-token short answer has modeled severance . The crude splitter fit that task because the required unit was short.
Practical decisions
- Default to level three when markup exists. In the worked corpus it is structurally faithful and costs instead of in the exact finite-window comparison.
- Set from measured required-span length. Protecting every -token span requires under this discrete model.
- Increase only after sampled failures show longer spans. The source proposes 100 sampled failures.
- Index subchunks and return the parent when a structural unit exceeds the encoder’s useful length.
- Cap parent expansion when top- parents overrun the context budget.
- Buy level five for high-traffic documents first. The example applies it to of documents for instead of a full pass.
- For fixed , and index settings, chunk token length does not directly change the arithmetic of one vector comparison. Changing the chunker can still change vector count, geometry, recall and ANN work, as well as generator prefill and its tail.
13.2 Chunking by intent: pseudo-instructions
The conditioning problem
- What: A document is an ordered sentence sequence . A chunker chooses boundary positions from 1 through .
- Why: The ideal would keep every sentence needed by query in one run and exclude everything else.
- Failure without it: The ideal boundary depends on , but the index must commit boundaries before exists.
- Cost and complexity: Every practical chunker must choose a proxy for the unknown query. Fixed splitting uses length and a fixed phase, but no semantic query-intent estimate. Breakpoint chunking compares each sentence with neighbor . It cuts on local subject change. Pseudo-instruction chunking generates a document summary and compares every sentence with that global anchor. For each sentence,
The threshold is the document mean
The binary label is when and 0 otherwise. The boundary set is every i where differs from . This labels runs of above-mean and below-mean similarity to a summary proxy, not verified usefulness for an unknown future query.
Why the summary anchor matters
- What: The generated summary estimates what future queries are likely to seek.
- Why: It is salience-weighted rather than frequency-weighted.
- Failure without it: A local breakpoint can fuse adjacent boilerplate because the boilerplate is internally similar. A centroid can point at boilerplate when boilerplate is most of the document.
- Cost and complexity: The summary requires an LLM pass. Real attributed query logs are better when available. Let be the sum of unit sentence vectors. When , define the normalized centroid . The sum over sentences of equals . The mean centroid score is . It measures document homogeneity, not document intent. The reported ablations replace the true summary with another document’s summary, a random document sentence, or the average embedding. All three degrade retrieval. The claim limit is that the published evaluation is general-domain. A specialist query distribution may emphasize an attribute no summarizer includes. The mean threshold always creates at least one cut when scores are not identical. Since , a single-topic page can split on noise. Guard with . Emit one chunk when the spread is below a threshold calibrated on a held-out set.
Worked policy example
The corpus has policy documents. Each has 40 sentences at 22 tokens each, or 880 tokens. Twelve sentences contain policy. Twenty-eight contain preamble, revision history, and footer material. The toy geometry takes to be mutually orthonormal directions. Each policy sentence has vector ; each boilerplate sentence has . The query is . A unit summary direction gives policy similarity and boilerplate similarity . Assume all policy sentences form one contiguous run. For the mixed-chunk comparison, take a -sentence, -token unit under a -token cap; it is not an exact blind -token window. For the general version, write each policy vector as and each boilerplate vector as , with . Here . A normalized sum of policy and boilerplate vectors, for , has
| Configuration | Composition and score | Ranking or error |
|---|---|---|
| Mixed -token chunk | policy and boilerplate sentences give | Against a local Gaussian distractor approximation , and the expected number above it among distractors is ; expected rank is |
| PIC | One contiguous -policy-sentence run scores | ; modeled Gaussian tail is negligible, not proof of observed rank |
| Summary anchor | Class separation and noiseless mean | With fixed noiseless cutoff and additive Gaussian score noise, boilerplate flips with probability , or expected flips |
| Centroid anchor | Policy score , boilerplate , mean | Under the same fixed-cutoff noise toy, boilerplate flips with probability , or expected flips; an isolated interior flip adds two cuts |
The mixed target’s modeled expected rank is about , beyond a rerank depth of . This is not a measured rank. Gaussian cosine tails are local approximations rather than valid unbounded cosine distributions, and recomputing a threshold from noisy scores changes the flip calculation.
Cost and operating rules
The full corpus contains tokens. A -million-parameter encoder’s sentence pass uses , or at . This one-pass baseline excludes summary-vector encoding and final chunk re-encoding. An -billion-parameter summarizer uses prefill FLOPs and decode FLOPs for output tokens per document. Total work is , or GPU-hours: times the one sentence-embedding pass. Summary-anchor embeddings add FLOPs if all generated tokens are encoded; final chunk embeddings add another pass over their actual token count. These are compute proxies, not latency measurements. Prefill is of this summarization work.
- Cache the pseudo-instruction on a content hash.
- At turnover, summarization uses about times a full-corpus sentence-embedding pass. Relative to a changed-documents-only sentence pass it remains about times; name the baseline.
- Use real queries with document attribution where they exist. Use summaries for cold start.
- Avoid PIC for short single-topic documents with no intent structure.
- Cap each intent run after the relevance cut. Split an overlong run at the nearest paragraph break.
- Score the chunker with against answer spans. alone is confounded by encoder and ANN settings.
13.3 Mixture of Granularity: routing over chunk sizes
Why one tuned size fails
- What: The source sweeps 128, 256, 512, and 1,024-token chunks with overlap on 400 questions.
- Why: Factoid queries need fine evidence. Thematic queries need broad evidence.
- Failure without it: The aggregate winner at 512 serves neither query population optimally.
- Cost and complexity: Multi-level indexes add vectors, searches, a router, and a context-budget decision. Index nested sentence, paragraph, and section units. Let be query similarity to the one answering sentence. Let be similarity to each non-answering neighbor. Let be mean pairwise sentence similarity. For an -sentence chunk:
For and a feasible family of unit-vector geometries, as . Feasibility constrains the parameters; in the limit . The expression is not a law for arbitrary contextual embeddings or for . For , a coarse chunk beats the answer sentence when . The simpler compares the limiting score with , not every finite chunk. With , , and :
| Unit | Score | |
|---|---|---|
| Correct sentence | ||
| Paragraph containing it | ||
| Section containing it | ||
| Different 16-sentence section with no answer | ||
| Long-chunk ceiling | Limit |
A global top-2 list returns the correct section and the wrong section. It drops the exact answer sentence. For a thematic query with , sentence, paragraph, and section scores are , , and . The same coarse bias now makes the correct choice, which helps the bug survive review.
Router and fallback choices
- What: MoG feeds the query embedding to a small network that emits one weight per granularity.
- Why: It rescales each level before candidates compete.
- Failure without it: Raw similarities encode length and relevance together.
- Cost and complexity: The router needs downstream answer-quality supervision and creates a query-conditioned failure surface. Each candidate receives weighted score
Top- selection is not differentiable. The source therefore describes a soft training target over levels, not a gradient through retrieval. Under the displayed multiplicative score rule, factoid weights give approximately for the three answering units. This toy restores the desired order; multiplication alone is not a general calibration method, particularly for negative scores. For a thematic query, weights make the section score . MoGG removes the requirement that levels be nested. It links chunks above a similarity threshold and uses graph hop range as granularity. Small-to-big is a useful first baseline: retrieve fine units and return their parents. It avoids cross-level raw-score comparisons. It can still miss thematic queries when no fine unit carries the broad selection signal; this is a workload risk, not an inevitable failure. When labels are missing, retrieve separately per level and use RRF. It fuses ranks rather than raw scales. Sparse scoring has the opposite length pathology. In tf-idf cosine, only query terms enter the numerator while the document norm grows. Long documents are over-penalized. Pivoted length normalization and BM25 address that sparse problem. Dense pooling has nonzero background contributions in both numerator and denominator, so its ratio flattens.
Worked clinical-reference example
The corpus has documents at tokens each, or tokens. Dimension is 768 in fp32. Sentences average 25 tokens, paragraphs 100, and sections 400.
| Configuration | Vector and graph cost | Query result |
|---|---|---|
| Paragraph only | vectors: payload plus base-layer graph slots | One ANN search |
| Three levels pooled raw | million sentence, paragraph and section vectors: million total, times paragraph count; payload plus base-layer slots at four-byte neighbors | In the toy ranking, the wrong section at about beats the answer sentence at |
| Three levels with router | For an explicit dense network: MACs, approximately FLOPs before bias and activation work | Level choice is learned; no measured router latency follows from the operation count |
Take two extra searches at each as a workload assumption, giving if run serially. Parallelization, routing and candidate merging change wall time. Five -token sections give prompt tokens. At and assumed sustained throughput , the proxy is FLOPs or approximately . Five -token sentences give tokens and approximately under the same proxy. The prefill-proxy difference is . Dividing by the assumed extra search work gives , not a -fold end-to-end speedup. If the route actually replaces sections with sentences, net idealized savings are before router and merge overhead. DPR’s vectors at and four bytes each use GB, matching the reported approximately flat index. Section vectors add payload and base-layer links; sentence vectors add payload and links. These budgets omit upper graph layers, text, IDs and runtime overhead.
Practical routing decisions
- Default to sentence and section levels. They total million vectors in the example, versus million with paragraphs added.
- Add another level only when query logs reveal a distinct answer-length mode.
- Ship small-to-big first. Consider a router when more than roughly one quarter of queries are thematic.
- Estimate from 200 same-document sentence pairs and from 200 query to non-answer sentence pairs.
- Treat the crossover as a check on the toy geometry, not an automatic router decision. Validate finite-level scores and task quality on the actual workload.
- Fail open to the middle granularity when router weights are near-uniform.
- Cap coarse contribution to the context budget because unusual queries can force expensive section prefills.
- Budget granularity against per-query prefill before one-time index memory. The example adds of payload-plus-base-layer capacity over the paragraph baseline and assumes extra search work; level choice moves the prefill proxy by .
13.4 Propositions and fine-grained retrieval
Pooling dilution
- What: A passage contains atomic propositions with mean pairwise similarity .
- Why: One exact fact can contribute only a fraction of a pooled passage vector.
- Failure without it: A broadly topical passage with no answer can outrank the passage that contains the exact answer.
- Cost and complexity: Proposition retrieval removes dilution by creating more vectors and requiring model-written, self-contained units. Assume unit proposition vectors, that the query equals one of them, and that its mean similarity to the other vectors equals the overall mean pairwise similarity . The pooled gold-passage cosine is:
At and , the score is . For a distractor with eight propositions, each at query similarity and the same , the score is . The distractor wins whenever
That threshold is the square of the gold passage score. It is in this example. At proposition granularity, the exact fact scores and the distractor scores .
Why propositions are not sentence splits
- What: A proposition rewrites a fact so it survives without neighboring text.
- Why: A sentence like “the base filing fee rises to that year” lacks the visa class and year.
- Failure without it: Short sentence chunks can be precise but unsearchable because pronouns and references have no anchor.
- Cost and complexity: Rewriting requires a generation pass. Store offsets to the parent because the indexed proposition is model output, not original corpus text. The self-contained rewrite in the source is “The base H-1B filing fee for fiscal year 2026 is .” Chen et al. (2024) compare passage, sentence, and proposition indexing across five open-domain question-answering datasets and six dense retrievers. Proposition indexing beats both alternatives, with the largest margin at small . Sentence retrieval sits between passages and propositions. The claim is comparative, not a guarantee for every corpus. Fine granularity breaks in two directions.
- Coverage falls when a question needs several facts. One passage may bundle them, while several propositions must all reach top .
- Sufficiency falls when a proposition loses conditions such as effective dates or employer-size qualifiers. Entity-relation triples go below the practical floor when they discard conditions. Stop at the smallest unit that is decidable on its own.
Index fine and serve coarse
- What: Search propositions, map hits to parent passages, deduplicate, then send parents to the generator.
- Why: Matching wants precision. Generation wants context.
- Failure without it: Serving only propositions strips qualifiers. Searching only passages restores pooling dilution.
- Cost and complexity: The design needs a parent map, source offsets, more index memory, and a measured fan-in. RAPTOR attacks the broad-query side by building a tree of recursive summaries. It composes with proposition retrieval rather than replacing it.
Worked policy corpus
The corpus has 2 million passages of 100 words. Dimension is 768 in fp32. A passage averages five 20-word sentences and about eight propositions. Rewriting expands total words to about the original.
| Configuration | Ranking | Memory and context |
|---|---|---|
| Passage index | Gold and distractor in the toy | payload plus base-layer graph slots, totaling |
| Proposition index | Gold and distractor in the toy | million vectors: payload plus base-layer slots, totaling ; times the passage count |
| Index fine, serve coarse | Retrieve propositions, map and deduplicate | A planning mean of hits per parent gives about parents; budget parents, or tokens at each. Actual parent counts must be measured |
Using the output tokens per eight-proposition passage budget below gives tokens per proposition on average. Thirty such propositions average about tokens, not exactly , and may omit neighboring qualifiers. The -token parent-text plan fits within tokens only if the remaining instructions, query, formatting and any reserved output fit in the remaining -token budget. Decomposition uses 333 input tokens per passage. That contains 200 instruction and exemplar tokens plus 133 passage tokens. It produces 187 output tokens. Across 2 million passages, that is 666 million input tokens and 374 million output tokens. At per million input tokens and per million output tokens, the bill is once under these assumed prices. The added payload-plus-base-layer capacity is . This is recurring provisioned capacity, not a monthly dollar bill without a specified memory rental price. At per product-quantized code, the proposition payload becomes . Retaining the same base-layer neighbor budget leaves before codebooks, upper layers, metadata, text and any full-precision rerank vectors; it is not a all-in index.
When fine granularity pays
The gain is
At , , the idealized cosine-score headroom is , about cosine points on a – scale. It is not an accuracy gain. At , , the same cosine headroom is , about cosine points, not a measured relative quality gain.
- Favor propositions for mixed reference material such as policies, frequently asked questions, catalogs, and long wiki pages.
- Skip them for tightly coherent prose with little pooling headroom.
- For 800-token parents, fan-in and produce tokens. Serve a sentence window instead.
- Set as target parent count times measured fan-in. In the example, is about 30.
- If fan-in is near , the hits scatter across documents. Treat that as a multi-hop signal rather than merely increasing .
- Reject propositions with unresolved pronouns, bare demonstratives, or missing named entities.
- The source cites contextual retrieval reporting a top-20 failure-rate reduction from to using a generated context prefix. It proposes that cheaper option for heavily anaphoric corpora.
13.5 Evaluating a chunker: and segmentation metrics
Measure token extent, not chunk identity
- What: Annotate each gold answer as raw source token offsets before running any chunker.
- Why: The same annotation remains valid across chunking policies.
- Failure without it: Chunk IDs become stale after every boundary change. End-to-end answer accuracy cannot attribute a change to the chunker.
- Cost and complexity: Human annotators must mark the actual answer excerpt. The example uses 200 queries. For query , let be gold source positions and the union of retrieved source positions, keyed by document and token offset. Require nonempty gold for the recall formulas. If no text is retrieved, define recall and IoU as and declare a precision convention rather than dividing by zero. Duplicate prompt copies count once in but still cost prompt tokens. Recall
Precision
For nonempty gold and retrieved sets with positive intersection, let , , . The reciprocal identity below needs ; the direct identity also extends to zero overlap when .
Per query, IoU is a monotone transform of and adds no ranking information. Averaging this nonlinear transform across queries can change system rankings, so macro-mean IoU is not the transform of macro-mean . gives ; gives . Returning the whole gold-containing document gives token recall conditional on retrieving that document. For source tokens and a -token gold excerpt, precision and IoU are . A one-chunk-per-document index does not by itself guarantee the right document is retrieved. Embedding similarity cannot replace extent accounting. A 60-token answer plus 500 tokens of on-topic padding can remain strongly similar to the gold excerpt.
The three extent errors
For gold tokens 81 through 120 in a 200-token document:
| Error | Retrieved text | Precision | Recall | |
|---|---|---|---|---|
| Too small | Top-1 is tokens 81 through 100 | |||
| Too big | Whole 200-token document | |||
| Misaligned | Top-1 is tokens 61 through 110 |
cannot distinguish the direction of error by itself. Too-small and misaligned both score . Report precision and recall beside it.
Boundary-only metrics
- What: checks whether endpoints at separation agree on same-segment membership in reference and predicted segmentations.
- Why: It evaluates boundaries independently of retrieval and an encoder.
- Failure without it: Retrieval IoU also reflects candidate selection, not only segmentation.
- Cost and complexity: can treat missing and extra nearby boundaries differently; WindowDiff instead checks boundary counts. Both depend on window conventions and reference segment lengths. WindowDiff compares the number of boundaries inside the window rather than a same-segment bit. For uniform reference segments of length , the conventional window is . For long uniform reference segments of even length , gives an approximately no-boundary baseline for both metrics. The all-boundary baseline is approximately for , but approximately for WindowDiff when and every predicted window has more boundaries than the reference. Finite endpoints and rounding affect the values; compute both baselines on the actual reference. The chapter traces element-level precision, recall, and overlap to Extensible Markup Language (XML) retrieval, where systems had to return the correct section, paragraph, or span from a nested document.
Worked chunk-size comparison
The illustrative evaluation has queries with exactly gold tokens each, not merely a mean of . Starts are uniform modulo the chunk length. Assume an oracle returns the one chunk with greatest gold overlap; these are idealized top-one extent metrics, not measured retriever performance. For chunk length and overlap , stride is . Split probability is
For no overlap, a continuously uniform split fraction gives conditional best-piece recall . With an integer -token span, the possible interior cuts give instead. Use integer phases for the table below. For a uniform split fraction , the expectation is
| Configuration | Split and recall | Precision and | Prompt cost at |
|---|---|---|---|
| , | Split ; expected overlap tokens and recall | Expected precision ; mean per-query IoU . Pooled-count IoU | Separately, full chunks cost prompt tokens |
| , | Split ; expected overlap tokens and recall | Expected precision ; mean per-query IoU . Pooled-count IoU | Separately, full chunks cost prompt tokens |
The large chunk wins oracle top-one recall by percentage points. The ratio of mean per-query IoUs is approximately . Neither nor a five-chunk retrieval metric can be inferred by applying IoU to a rounded mean overlap; the prompt column is a separate cost plan. At queries per day and per million input tokens, the prompt costs are and per day. The difference is per day or per year. At , every fitting -token span is intact because . The long-document overlap multiplier is , about extra unpadded tokens; finite vector and graph inflation still depend on document lengths. A 1,000-token chunk with 200-token overlap also protects the 60-token excerpt. A 200-token chunk with 40-token overlap has split probability .
Evaluation decisions
- If source edits make offsets stale, anchor each annotation to a quoted string and relocate it at evaluation time.
- Compare chunkers at a fixed retrieved-token budget, not fixed .
- If the unique-source-position budget is exactly , precision is . A fixed billed prompt-token budget need not fix this denominator when chunks overlap or duplicate; retrieval and encoder effects still influence coverage.
- If the reranker is the binding limit, fix candidate count instead.
- Set overlap from the 95th-percentile annotated excerpt length.
- If index inflation is too high, accept a measured split rate and explicitly retrieve the adjacent chunk or parent. Merely raising to does not guarantee that neighbor is returned.
- Use WindowDiff when reference boundaries cluster.
- A reported rise from to is not enough when mean chunk length also rises from 220 to 610 tokens. That is more text and prompt tokens at for a 60-token answer.
13.6 Does semantic chunking actually pay?
Semantic chunking as detection
- What: Embed sentences through and compute adjacent distance .
- Why: A large may indicate a topic boundary.
- Failure without it: A claimed boundary can look almost identical to an ordinary within-topic transition in one coherent document.
- Cost and complexity: The detector needs a full sentence-embedding pass before the final index pass. As a local approximation, model within-topic cosine gaps as and true-boundary gaps as . Cosine distance actually lies in ; the Gaussian approximation ignores its tails outside that interval. The equal-variance assumption is part of the example. Different variances, prevalence or score calibration change the detector’s precision–recall curve. Separability
The source fixes for its worked model. For stitched text, . Inside one 40-page insurance policy, and . . The ratio of the two standardized mean separations is . This compares model inputs, not an independently measured transfer penalty.
Same threshold, two corpora
Take a 200-sentence article with 8 real boundaries among 199 gaps. Boundaries are of gaps. A strict empirical th-percentile threshold yields roughly cuts among distinct gaps, with details set by quantile and tie conventions. Population-mixture thresholds below approximate this top- rule; a finite document need not realize the expected count. For threshold , boundary recall is
FPR is
| Corpus | Threshold | Boundary result | Final quality |
|---|---|---|---|
| One real document | Recall and FPR ; expected true cuts plus false cuts = | Precision ; these are model expectations | |
| Stitched benchmark | Recall and FPR ; expected true cuts plus false cuts = | Precision ; these are model expectations |
Qu, Tu, and Bao (2024) report no consistent performance gains justifying semantic chunking’s cost in their evaluated tasks and corpora. The Gaussian example illustrates one possible mechanism; it does not establish that the paper’s negative result holds exactly below a particular . Heterogeneous logs or bundles may create clearer boundaries, but validate the benefit on real documents.
Overlap as the cheaper repair
For answer span length , chunk length , and stride , intact probability is
At , intact probability is . Split rate is . At , intact probability is . Split rate is . At , split probability falls from to , a reduction of about percentage points. Long-document token inflation is , or extra; the multiplier itself is not . Semantic output has a length distribution. A coherent run of 90 sentences at about 25 tokens each becomes roughly tokens. A 512-token encoder indexes less than one quarter and silently drops more than three quarters unless the run is capped.
Worked ingestion comparison
The corpus has million articles at tokens each. is tokens. At 25 tokens per sentence, it contains sentences. The encoder has 110 million parameters and costs FLOPs per token. Sustained throughput is . Compute costs per graphics processing unit (GPU) hour.
| Configuration | Compute | Time and money | Boundary quality |
|---|---|---|---|
| Fixed 512 with overlap 50 | Each -token article gives chunks and embedded tokens: corpus tokens, FLOPs | = minutes; | Uniform-phase split rate about for an -token span |
| Breakpoint semantic | padded detection slots plus final-index tokens; this single-sentence implementation differs from the three-sentence windows in Section | minutes; , or more compute than exact fixed splitting | At , modeled recall and precision |
| Agentic or summary-based | input plus output tokens per article on B: generation FLOPs, plus final chunk embeddings | Generation GPU-hours and ; with disjoint final embeddings, hours and | Boundary quality is not assigned by the cost model |
Sentence batches pad from a 25-token mean to 32 token slots. That creates the detection slots. All-pairs dot products for normalized -dimensional sentence vectors require pairs and about FLOPs per pair. Corpus work is FLOPs, a arithmetic proxy. This excludes clustering, storage, kernel launches and orchestration; it is not measured total clustering time. Including final embeddings on both sides, the agentic proxy is about times semantic ingestion compute. Generation alone costs about ; total with final embeddings is about . Bandwidth-bound serial decoding can make actual time substantially larger. A random detector placing 10 cuts among 199 gaps with 8 true boundaries has expected precision . The modeled is six times better than chance and still puts three cuts in four inside a topic.
Shipping rule
- Measure boundary distributions and precision–recall on real held-out documents before building; the source suggests documents and labeled adjacent pairs as a starting audit, not a universal sufficient sample.
- Treat as a cautionary heuristic, not a theorem that recall cannot exceed one third. With , , , the same population top- rule has and approximately recall at precision. Prevalence and threshold matter.
- Prefer headings, HTML sections, PDF outlines, speaker turns and ticket IDs when they match the task’s units.
- On low-separability corpora, benchmark overlap and explicit neighbor recovery against the semantic detector.
- Choose overlap from required span lengths and measured costs; chunk length above alone does not imply overlap must grow proportionally.
- Cap variable chunks at the encoder’s usable length and alert on the tail. For an -token encoder, generator budget and prefill can bind first.
- Do not accept gains established only by concatenating unrelated passages. Validate on naturally occurring documents.
Diagrams
Figure 13.1
| Splitting policy | How boundaries are chosen | Observed placement in the source document | Index-time cost |
|---|---|---|---|
| 1. Fixed length | Every tokens | Four cuts pass through units | tokens |
| 2. Separators | Recursive ordered list | Known separators are preserved, but one cut still crosses code | tokens plus one string scan |
| 3. Document-specific | Headers, cells, and definitions | Cuts align with the declared units | tokens plus a parser |
| 4. Semantic | Sentence embeddings | Most cuts align, one crosses a unit, and one true boundary is missed | About tokens |
| 5. Agentic | An LLM proposes cuts | Cuts align with the declared units | generation tokens, about level one |
Solid boundary means a cut on a real unit boundary. A crossed boundary cuts through a unit. A missed marker means the policy failed to place a boundary. Figure : The five policies have different signals and failure modes. In the finite contract price scenario, semantic ingestion is approximately times and agentic input-plus-embedding cost times the fixed bill. These are setup-specific costs, not guaranteed boundary-quality rankings; output generation charges are omitted.
Figure 13.2
Diagram description and source
flowchart TB
subgraph local["A. Breakpoint chunking: compare each sentence with its neighbor"]
direction LR
s1["s1"] --> s2["s2"] --> s3["s3"] --> s4["s4"]
s4 -. "topic shift" .-> s5["s5"]
s5 --> s6["s6"] --> s7["s7"] --> s8["s8"] --> s9["s9"] --> s10["s10"]
end
subgraph global["B. Pseudo-instruction chunking: compare every sentence with one global anchor"]
g["pseudo-instruction g, LLM summary of D, ri = cos(e(si), e(g))"]
low1["s1 to s3, below mean"]
high["s4 to s7, above mean"]
low2["s8 to s10, below mean"]
g --> low1
g --> high
g --> low2
low1 -. "relevance shift" .-> high
high -. "relevance shift" .-> low2
end
Figure : Breakpoint chunking compares neighbors; PIC compares each sentence with a generated global summary. The latter estimates intent through a proxy rather than knowing future queries. A poor anchor can still split or merge the wrong evidence.
Figure 13.3
Diagram description and source
flowchart TB
subgraph raw["A. Raw pooled scores in this toy"]
a["Rank 1: answering section, 0.696"]
b["Rank 2: no-answer section, 0.686"]
c["Rank 3: answering paragraph, 0.670"]
d["Rank 4: answer sentence, 0.620"]
a --> b
b -. "top k = 2 cutoff" .-> c
c --> d
end
subgraph weighted["B. Example query-conditioned level weights"]
q["Query"] --> gate["Weights: 0.70, 0.20, 0.10"]
gate --> s["Sentence: 0.434"]
gate --> p["Paragraph: about 0.134081"]
gate --> sec["Section: about 0.069628"]
end
For a thematic query, the router emits weights . The section wins at . Raw scores from different levels never compete directly. Figure : In the stated positive-coherence pooling toy, the wrong section scores about above the answer sentence’s . A feasible long-chunk family approaches when . The displayed router weights restore this example’s ordering, not a universal guarantee.
Figure 13.4
Diagram description and source
flowchart TB
subgraph pooling["A. Pooling over m = 8 facts inverts the ranking"]
q["Query: 2026 fee?"] --> gold["Gold passage, one exact fact among eight, cos = sqrt(4.5 / 8) = 0.75"]
q --> distractor["Topical distractor, no fee in eight facts, cos = 4.8 / 6 = 0.80"]
end
subgraph serve["B. Index fine, serve coarse"]
props["16 million propositions"] --> ann["ANN search: top k = 30"]
ann --> parent["Parent map: proposition to passage"]
parent --> dedup["Deduplicate: budget 18 parents from mean fan-in 1.7"]
dedup --> generator["Generator: 2,394 tokens"]
end
The proposition is the self-contained match unit. The full passage is the serve unit that restores dates, conditions, and qualifiers. Figure : Under this toy geometry, passage pooling lowers the exact-match score from to , letting a distractor win. Proposition indexing restores the toy ranking; parent expansion restores surrounding source text. Actual fan-in and context size must be measured, not inferred exactly from a mean.
Figure 13.5
Gold excerpt E: tokens 81-120 of a 200-token document
|========|
A. Too small: top-1 is tokens 81-100
|==== | P = 1.00 R = 0.50 IoU = 0.50
B. Too big: top-1 is tokens 1-200
|==================================================| P = 0.20 R = 1.00 IoU = 0.20
C. Misaligned: top-1 is tokens 61-110
|==========| P = 0.60 R = 0.75 IoU = 0.50
: :
dashed guides mark the gold extent
Figure : The three ways a chunker gets the extent wrong, scored against one gold excerpt (dashed guides). Cases A and C reach the same of from opposite directions. One starves the answer. The other pads and clips it. Report beside precision and recall.
Figure 13.6
A. Stitched benchmark corpus Delta = 8.125
within-topic gaps true-boundary gaps
/\ /\
______/ \__________|______________/ \______ distance di
0 t = 0.435 1.0
95th-percentile cut: recall 100%, precision 80%
B. One real document Delta = 1.25
within-topic gaps true-boundary gaps
/\ /\
______/ \_______|________/ \______________ distance di
0 t = 0.39 1.0
Identical rule: recall 31%, precision 24%
These thresholds are rounded approximations to a population top- rule. Exact mixture quantiles are approximately for stitched and for real text, giving expected cuts. At the displayed rounded thresholds, expected true/false cuts are approximately and , respectively; finite documents fluctuate. Figure : The Gaussian examples show how standardized separation, prevalence and threshold jointly control precision and recall. They are not measured curves and do not establish a universal cutoff or a claim that semantic chunking can never work within a coherent document.
Whiteboard pack
What to draw
- Draw one long document bar and mark the atomic answer span inside it.
- Add fixed chunk boundaries that cut through that span.
- Add overlapping chunks and label the discrete guarantee .
- Add a structural boundary at a heading and label it “free signal.”
- Draw sentence, paragraph, and section shelves beside the document.
- Put a query above a router, then draw one weight arrow to each shelf.
- Draw one proposition hit and an arrow back to its parent passage.
- Draw a gold token span and a retrieved span. Label recall, precision, and .
- Finish with two gap distributions. Show high for stitched text and low for one real document.
Spoken script
Chunking is the index-time choice of what retrieval can ever see. I start with the smallest answer unit that must survive, use document structure when it exists, and set overlap from measured span length. Different questions need different scales, so I do not mix raw sentence, paragraph, and section scores. I route by query or fuse per-level ranks. When passage pooling hides one exact fact, I index a self-contained proposition and return its parent. I evaluate token recall, precision, and . Semantic chunking ships only when real boundary gaps are separable enough to beat overlap and structural cuts.
Interview traps
1. Why not always use 512 tokens with 10% overlap?
The required answer unit, not convention, determines the size. At , overlap is about 51 tokens, so it protects roughly one sentence and does nothing for a 900-token clause.
2. When does semantic chunking not pay?
It may not pay when boundary gaps resemble within-topic gaps. At the example’s rounded threshold, modeled recall is about and precision . The corrected finite-document ingestion comparison is about more compute, not a universal performance or cost rule.
3. When does fine granularity not pay?
It may not pay when passages are coherent, several facts must be jointly retrieved, or parent expansion overruns the budget. At , toy cosine headroom is only about ; the example’s proposition payload-plus-base-layer budget is before other overhead.
4. Why is one global top- across chunk sizes wrong?
Raw cross-length scores can be biased. In the stated feasible unit-vector model with , the limiting pooled cosine is ; the worked no-answer section scores about above the answer sentence’s . This is an example to validate, not a theorem that a pooled index always fails.
5. Did improve because the new chunker is better?
Not necessarily. Recall can be purchased by returning more text, so compare at a fixed token budget and report precision plus . A rise from to with mean chunk length rising from 220 to 610 tokens is confounded by more retrieved text.
Key numbers
| Topic | Value or model estimate | Meaning or limit |
|---|---|---|
| Opening failure | 3 months, about 12 lines of splitter code, 900-token clause, cut at 512 | An old index-time choice can sever a fact permanently |
| Splitting ladder | 5 levels, about cost range, only levels 4 and 5 read meaning | More expensive is not automatically better |
| Chunk count | for ; for | Retain the final partial chunk and stop at first coverage |
| Embedded tokens | exactly for nonempty unpadded documents; asymptotically | Finite token, vector and graph inflation need not match |
| Blind severance | for | Uniform stride phase; an oversized span never fits one chunk |
| Severance example | , , | Fixed boundaries cut the 40-token unit at this rate |
| Overlap guarantee | Discrete token windows protect an extra endpoint token | |
| Overlap example | : asymptotic multiplier, extra | Protects spans through tokens; finite contract token multiplier is |
| Common overlap rule | of 512 gives | It protects about one sentence, not a 900-token clause |
| Semantic splitter | Buffer one: approximately detection plus final embeddings | Edge effects, padding, quantile ties and finite counts matter; cuts are not guaranteed when scores tie |
| Contract corpus | Basis of the five-level cost comparison | |
| Price assumptions | per million embedding tokens, per million generation input tokens | Worked-example prices only |
| Fixed contract index | chunks/document, vectors, unpadded tokens, | Exact finite-document count at |
| Structural contract index | 12 clauses per document, million vectors, mean 333 tokens, more vectors | It uses of embedding and severs no clause |
| Structural memory | GB versus GB at 768 fp32 dimensions | Better boundaries use more vectors but no overlap |
| Semantic contract index | Approximately tokens, , times fixed | Three-sentence detection windows plus final disjoint embeddings |
| Agentic contract index | , approximately times fixed | Input processing and embeddings only; generation output charges excluded |
| Selective agentic refresh | weekly | Proportional turnover under the same incomplete price model |
| DPR split | passages, 100 words, about tokens per word, about 133 | A 40-token span severs , while a 5-token answer severs |
| Overlap calibration | Source suggests sampled failures; protects every -token span | Sample size is a starting audit, not a universal confidence guarantee |
| PIC incident | documents, 12 retrieved chunks, Monday ingest and Wednesday query | The future question was unavailable at index time |
| Centroid warning | boilerplate | Frequency can pull the free anchor toward irrelevant text |
| PIC corpus | tokens | Each 880-token document has 12 policy and 28 boilerplate sentences |
| PIC geometry | Assumption in the worked vector model | |
| Fixed PIC target | , squared norm , cosine , | A -token mixed unit under a cap, not an exact blind window |
| Fixed PIC rank | Gaussian-model tail , expected outranking distractors and rank | Model expectation, not observed rank or a guarantee |
| Isolated policy run | , squared norm , cosine , | Requires a contiguous policy run; Gaussian tail is negligible in the toy |
| Summary anchor | components , , . Class scores and . Mean | Class separation is |
| Centroid anchor | Norm , mean | Policy score , boilerplate |
| PIC noise | Fixed-cutoff toy gives versus boilerplate flips | About versus expected flips; recomputed noisy thresholds differ |
| PIC compute | 110 million encoder parameters, FLOPs, 114 seconds | Uses sustained |
| Summary compute | FLOPs, GPU-hours, times one sentence pass | Prefill ; anchor and final chunk embeddings are extra |
| Cached nightly PIC | turnover gives about times a full-corpus sentence pass in summarization work | It remains about times a changed-only sentence pass |
| Granularity sweep | 128, 256, 512, tokens, overlap, 400 questions | Aggregate 512 hid two query populations |
| Dense length model | , , , ceiling | Scores are , , and across levels |
| Rank inversion | Wrong section beats paragraph and answer sentence | With the gold section first, the paragraph is rank and sentence rank in this four-candidate toy |
| Thematic query | gives , , | Raw pooling appears correct on broad questions |
| Router weights | Factoid , thematic | Weighted factoid scores are , , . Thematic section is |
| Multi-level corpus | tokens, | Sentence, paragraph, section lengths are 25, 100, 400 |
| Multi-level vectors | , or paragraph only | Vector memory is GB versus GB |
| HNSW overhead | , 64 layer-zero neighbor IDs, 4 bytes each, GB | Applies to million vectors |
| Router compute | Explicit : MACs, about FLOPs | MAC and FLOP counts differ; no measured latency follows |
| Retrieval and prefill | Assumed extra serial search work; section/sentence prefill proxies | difference; is avoided-prefill/extra-search work, not system speedup |
| Generator assumption | 7 billion parameters, FLOPs, A100 sustained bfloat16 | Sustained rate is about half the stated peak |
| Multi-level memory choice | extra payload-plus-base-layer capacity over paragraphs | Sentence payload , section payload ; other overhead excluded |
| Router sampling | Source suggests sentence pairs and query–background pairs | is a limiting toy crossover, not a finite-level or workload guarantee |
| Staff routing case | factoid recall points = traffic-weighted recall points under unchanged other strata | Not automatically end-to-end answer-accuracy points; serving and retrieval gains differ |
| Proposition dilution | , , gold , distractor , threshold | Proposition comparison restores versus |
| Proposition evidence | 5 open-domain datasets and 6 dense retrievers | Reported comparison favors propositions, especially at small |
| Proposition corpus | 2 million passages, 100 words, 5 sentences, 1 to 2 propositions each, about 8 | Rewrites expand words about |
| Proposition memory | Passage versus proposition , times | Payload plus base-layer slots only; extra capacity |
| Fine-to-parent serve | , mean fan-in : plan parents, source tokens | Actual parent count is random; raw proposition plan averages tokens using each |
| Proposition generation | million input and million output tokens give | Uses assumed per-million prices and |
| Quantization | codes give payload plus unchanged base-layer graph | before codebooks, upper layers and other storage |
| Fine-grain headroom | : gives ; gives | Absolute toy cosine gaps, not measured accuracy percentages |
| Long parents | Use windows instead of whole parents | |
| Contextual prefix | Top-20 failure rate to | Reported alternative for heavily anaphoric text |
| Extent example | Gold tokens 81-120 in 200 tokens | Too small and misaligned both have . Whole document has |
| transform | ; | Ordering is preserved per query, not necessarily after averaging over queries |
| Degenerate chunker | precision and , recall | Recall alone calls one chunk per document perfect |
| Evaluation corpus | Exact -token spans; gives split , oracle recall , precision , mean IoU | Uniform discrete phase; top-one oracle, not top-five retrieval |
| Large-chunk comparison | gives split , recall , precision , mean IoU | Six recall points versus about times lower mean IoU in the oracle toy |
| Prompt budget | gives versus tokens | At daily queries and per million, cost is versus daily, or yearly difference |
| Overlap alternatives | , gives zero split and storage. gives split | Protect a 60-token excerpt with |
| Semantic opening | million articles, 512-token chunks, 50 overlap, , proposed 2 sprints | A public double-digit lift does not guarantee transfer |
| Separability | , , ratio | Equal-variance Gaussian approximation, not a universal transfer law |
| Percentile detector | boundaries; rounded give expected cuts | Real recall/precision ; stitched approximately |
| Overlap repair | -token chunks and -token spans: split at , at | points less split for asymptotic extra tokens |
| Semantic tail | 90 sentences about tokens versus a 512-token encoder | More than three quarters can disappear |
| Fixed ingestion | chunks/article, tokens, FLOPs, , | Exact per-document windows, no padding of the final chunk |
| Semantic ingestion | detection slots plus final tokens | minutes and , extra compute |
| Clustering add-on | dot products/document; corpus FLOPs | arithmetic proxy, excluding actual clustering and orchestration |
| Agentic ingestion | tokens/article: generation FLOPs | With final embeddings: GPU-hours, , times semantic compute |
| Semantic calibration | documents and adjacent-pair labels are starting-audit heuristics | does not imply recall below one third; prevalence and cutoff jointly determine performance |
| Length caps | Roughly tokens changes overlap economics. An 8,000-token encoder shifts the cap to generator context | Monitor the tail, not only the mean |
00-START-HERE · 01-READING-ROUTES · 12_text_representation · 14_beyond_plain_text_tables_layout_documents