What Is Chunking? RAG Boundaries, Context, and Evaluation

What Is Chunking?

Scrapeless Web Unlocker retrieves web content that your application can normalize and split into passages for retrieval.

Chunking is the process of dividing source material into units that a retrieval system can index and return. In retrieval-augmented generation, those units become candidate evidence for an answer. The goal is to preserve enough context for a passage to be useful while keeping the retrieved material focused on the question.

A chunk is a design choice, not a universal document format. A paragraph, a complete section, a table with its labels, or a structured code unit can each be appropriate. Chunk size alone does not tell you whether the unit contains a complete answer. Inspect its boundaries, attached context, and relationship to the original source.

Why Split Documents Before Retrieval?

Documents often contain several topics, while a user asks about one specific issue. Splitting can let retrieval select the relevant part without supplying the entire source to the answer model. It also gives the index a more focused representation. A whole manual embedded as one record may blur distinctions between unrelated sections.

The retrieval-augmented generation architecture uses retrieved external information to support generation. Chunking helps determine what that external information looks like in a practical corpus. It does not create missing evidence. If the original page never contained the answer or extraction discarded it, changing the splitter cannot restore the absent content.

How Do Fixed and Structure-Aware Splits Differ?

A fixed-size splitter divides text according to a configured length. A structure-aware splitter uses boundaries such as headings, paragraphs, lists, tables, or code blocks, usually with a size limit. A recursive strategy can prefer larger structural boundaries and fall back to smaller ones when a section exceeds the allowed input size.

For a hypothetical return policy, keep the eligibility statement with the exception that follows it. Separating those sentences can make a retrieved passage appear to authorize something that the full policy excludes. For a table, preserve the row and column labels that explain each value. The right unit follows the evidence a reader needs, rather than treating every sequence of tokens as equally self-contained.

StrategyBoundary basisWhat to inspect
Fixed sizeConfigured text lengthSplit sentences and missing qualifications
Structure awareHeadings and document elementsSections too large or too dependent
SemanticRepresented topic changesExtra processing and unstable boundaries
Parent expansionRetrieved child plus related contextIrrelevant additions and version conflicts

What Does Semantic Chunking Add?

Semantic chunking uses a representation of content to choose boundaries based on changes in topic or meaning. A common design compares neighboring sentence representations and starts a new group when their relationship changes enough. Its behavior depends on the embedding model, segmentation method, and boundary rule.

Semantic splitting adds processing and can create boundaries that differ from the author's document structure. Compare it against a simpler baseline before adopting it. A page with clear headings may need only structural splitting, while a long unstructured transcript may benefit from a different method. Do not assume that the word “semantic” guarantees coherent passages or better answers. The retrieved evidence must demonstrate the improvement for your questions and corpus.

How Should You Choose Chunk Size and Overlap?

Chunk size should fit the input constraints and the amount of evidence needed to answer the target questions. Overlap repeats some material across adjacent units so information near a boundary can remain available. Larger overlap can also return repeated passages and consume answer context without adding new evidence.

Choose candidates, then evaluate them with representative questions. Include a question answered by one short paragraph, another requiring a neighboring exception, and another requiring several sections. There is no single token count that fits every source type and model. Research on RAG configuration practices reinforces the need to consider the pipeline as a set of interacting choices rather than treating one parameter as universally optimal.

What Must Happen Before Chunking Web Content?

Web content should be acquired and normalized before it is split. Remove unrelated navigation and duplicated page chrome, while preserving headings, lists, table relationships, and other meaning-bearing structure. Retain the raw source when permitted so a reviewer can locate where information was lost or altered.

The Web Unlocker content acquisition step supplies material for downstream processing. Your application still owns extraction and splitting. The semantic chunking pipeline develops that separation. A successful response can contain an unexpected document, so inspect the page identity and main content before treating it as valid input. Otherwise the splitter can produce perfectly formed chunks of an error page.

Which Metadata Should Travel With a Chunk?

A chunk should retain a link to its source version and its location within that version. Useful metadata includes the source identifier, heading path, passage position, content version, collection context, and access scope. The text can carry a concise heading prefix when that is needed to interpret the passage outside the original page.

The provenance data model provides a vocabulary for derived information and its source activities. In a practical index, the same principle means that a citation should resolve to the material that actually produced the retrieved passage. Do not reuse a passage identifier for unrelated text without a version boundary. Changed or deleted documents must update their derived chunks as well.

How Can You Test Whether Boundaries Are Working?

Test chunking with questions whose supporting passages have been reviewed. Inspect whether retrieval returns complete evidence, whether important qualifications remain attached, and whether duplicate overlap crowds out distinct information. Then evaluate whether the answer accurately uses the retrieved text. A visually neat chunk is not enough.

The RAG evaluation framework research distinguishes retrieval and generation concerns. Apply that separation in your review. If the correct chunk is absent, investigate splitting and retrieval. If the correct evidence is present but the answer ignores a limitation, investigate context assembly or generation. Keep the corpus and question set fixed while comparing splitter candidates so the result measures the boundary change.

When Should You Retrieve More Than One Chunk?

Retrieve related material when a question requires context beyond a single indexed unit. A system can search smaller passages and expand to a parent section, recover adjacent passages, or combine several distinct sources. Expansion should add relevant evidence and respect the answer model's context budget.

For a hypothetical integration question, one passage may define authentication while another explains the operation's prerequisites. The answer needs both, but it does not need every unrelated endpoint description. Retain document relationships so expansion can be deliberate. Also check contradictions across versions before merging text. An answer assembled from individually relevant chunks can still be wrong if one passage describes an old configuration and another describes the current one.

What Should a Chunking Change Record Include?

A chunking change record should identify the source corpus, splitter configuration, resulting passage versions, and the evaluation used to compare them. Keep the earlier configuration available long enough to explain a regression. A change in boundaries can alter identifiers, overlap, and retrieval ranking even when the source document itself has not changed.

For a hypothetical manual with tables, an improved splitter may keep column labels with each relevant row. The acceptance check should ask whether table questions now retrieve interpretable evidence. A total chunk count cannot answer that question. It can help explain processing cost, but the review still needs the returned passages and the resulting answers.

Plan the transition so old and new units are distinguishable. If both versions are searchable at once, duplicate evidence may dominate the result set or create misleading citations. Build the replacement collection separately or use an explicit version filter, then compare the same judged questions. Once the replacement is accepted, remove superseded units through the defined lifecycle. The purpose is a cleaner evidence boundary and a measurable retrieval change, not simply a different distribution of passage lengths.

Conclusion

Chunking determines the evidence units your retrieval system can return. Preserve source meaning before tuning size, compare strategies on the same questions, and inspect both complete support and duplicate context. Keep every passage connected to its source version so future updates and citations remain trustworthy.

Acquire pages with Scrapeless Web Unlocker, compare splitter candidates on your own corpus, and use Scrapeless pricing to budget the source collection stage.

Collect Content for Useful Chunks

Acquire source pages, preserve their structure, and evaluate your own passage boundaries.

Sign up today and get $5 in free credit — no credit card required.

Claim Your $5 Credit →

FAQ

Is chunking the same as tokenization?

Chunking creates retrievable content units, while tokenization converts text into the units a model processes. A chunk can contain many tokens. Token counts help enforce size limits, but they do not establish whether a passage contains complete evidence.

What is the best chunk size for RAG?

The best chunk size depends on the corpus, question types, embedding model, and answer context limits. Compare candidate configurations using reviewed questions and supporting passages. A default size is a starting hypothesis rather than an evidence-based optimum.

Does overlap always improve retrieval?

Overlap does not always improve retrieval. It can preserve boundary context, but excessive repetition can displace distinct evidence. Evaluate both the completeness of retrieved passages and the amount of duplicate material sent to the answer model.

Does changing chunks require updating embeddings?

Changing the text represented by a chunk requires a matching representation under the chosen embedding workflow. Keep the passage, vector, and metadata aligned, and remove superseded records so retrieval does not mix conflicting source versions.

References