What is Chunking?
Splitting documents into smaller passages before embedding, so retrieval can return the precise section that answers a question rather than a whole page.
Embedding an entire 5,000-word page produces a vector that is an average of many topics — good at matching nothing in particular. Chunking splits documents into retrieval-sized passages so each vector represents one coherent idea.
How you split matters. Naive fixed-size chunks cut sentences in half and orphan content from its heading. Structure-aware chunking follows the document's headings and sections, keeping each chunk self-contained and attributable — which also makes citations point somewhere sensible.
Chunk size is a tradeoff: too small and chunks lack context to be understood; too large and retrieval precision drops. Heading-aware strategies adapt the boundaries to the document instead of forcing one size.
How BeforeQuery uses this
BeforeQuery normalizes every source to markdown (stripping navigation and boilerplate, preserving code blocks), then chunks heading-aware before embedding. Each chunk keeps its document, heading, and URL context — so a citation lands the reader at the right section.
Related terms
Embeddings
Numeric vector representations of text in which semantically similar passages end up close together, enabling search by meaning rather than exact words.
RAG (Retrieval-Augmented Generation)
An AI architecture that retrieves relevant documents from a trusted knowledge source and passes them to a language model, so answers are grounded in real content instead of the model's training data.
Knowledge Base
A curated, indexed collection of an organization's knowledge — docs, wikis, tickets, repos — that an AI assistant retrieves from when answering questions.
From definition to deployment
Connect a knowledge source and see cited AI answers on your own content in minutes — free, no credit card required.
Get Started Free