esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Fixed vs Recursive vs Semantic Chunking

Three ways to split documents before AI search, what each gets right and wrong, and which one to pick, explained simply for your AI interview.

In short

Fixed-size chunking cuts by character count and can split a rule from its exception. Recursive chunking tries paragraph breaks first, and LangChain calls it the recommended default for generic text. Semantic chunking cuts where the topic shifts, but costs more, and LangChain says to treat its results as experimental.

12 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Chunking cuts a long document into pieces before it is stored for search. Fixed size cuts every set number of characters. It's simple, but it can split a rule from its exception. Recursive splitting tries paragraph breaks first, then line breaks, then spaces. I'd start there. Semantic chunking cuts where the topic changes. It reads well, but it costs more, and LangChain says to treat its results as experimental. I'd test every choice on real questions before I trust it.

What are fixed, recursive and semantic chunking, in plain words?

Chunking cuts a long document into smaller pieces before it is embedded and stored for search. Embedding turns a piece of text into a list of numbers that stands for its meaning, so the search can find it later.

A retriever (the search step that picks chunks for a question) can only return whole chunks. So where you cut decides what the model can see when it answers. Cut in the wrong place and the answer is split across two chunks, or buried in one that mixes topics.

Think of a records clerk splitting a 300-page claims manual into binders. One clerk counts pages, one follows the chapters, and one starts a new binder whenever the subject changes. In an insurance claims assistant, that same choice decides whether the bot finds a rule and its exception together.

Key words

Chunk
One piece of a document, stored and searched as a single unit.
Chunk size
How big each piece is, counted in characters or tokens (the small word pieces a model counts).
Chunk overlap
Text repeated at the edge of two neighbouring chunks, so a cut doesn't lose a sentence.
Embedding
A list of numbers that stands for the meaning of a piece of text.

How does each method decide where to cut?

The three methods answer one question differently: what tells the splitter where a piece should end?

The same policy, cut three ways

Three ways to cut

Fixed: cut every N chars

ignores sentences and paragraphs

Recursive: split at breaks

falls back to line breaks, then spaces

Semantic: cut on topic

compares nearby sentences by meaning

Rule can split in two

its exception lands in another chunk

Whole paragraphs kept

each chunk reads as one idea

Chunks follow topics

costs an embedding pass first

  1. 1A cut every set length can land in the middle of a rule.
  2. 2Paragraph breaks keep each idea whole, where the text has them.
  3. 3Neighbouring sentences stay together when their meaning is close.
The same policy text, cut three ways, side by side. Fixed size cuts by count and can split a rule from its exception. Recursive splitting follows the text's own breaks. Semantic chunking follows the topic, using embeddings to find where it changes.
  • Fixed size

    Cut every set length

    Simple and fast. It ignores meaning, and it can split a word or a rule in half.

  • Recursive

    Paragraphs, then sentences, then words

    Keeps the biggest natural units whole, and only goes smaller when a piece is still too big.

  • Semantic

    Where the topic shifts

    Keeps one idea together, but it embeds the document while splitting it, so it costs more.

Overlap is a separate dial for the size-based splitters. LangChain's guide gives a common starting point of 10% to 20% of the chunk size. LangChain says overlapping chunks help to mitigate loss of information when context is divided between chunks.

What does a cut look like on real text?

Here is a made-up insurance policy with three paragraphs, cut at 60 characters. The code uses only standard Python, so you can run it yourself.

Python
# A made-up insurance claims policy, cut two ways. Standard library only.
policy = (
    "Claims over $500 need a photo of the damage.\n\n"
    "Photos must be taken within 14 days of the incident. Late photos are not accepted.\n\n"
    "Staff may waive the photo for theft cases, with a police report."
)

def fixed(text, size):
    return [text[i:i + size] for i in range(0, len(text), size)]

def by_words(text, size):
    chunks, line = [], ""
    for word in text.split(" "):
        if line and len(line) + 1 + len(word) > size:
            chunks.append(line)
            line = word
        else:
            line = word if not line else line + " " + word
    return chunks + [line]

def paragraph_first(text, size):
    chunks = []
    for para in text.split("\n\n"):
        chunks += [para] if len(para) <= size else by_words(para, size)
    return chunks

for name, chunks in [("fixed", fixed(policy, 60)), ("paragraph first", paragraph_first(policy, 60))]:
    print(name)
    for c in chunks:
        print("  |" + c.replace("\n", "\\n") + "|")

Output

fixed
  |Claims over $500 need a photo of the damage.\n\nPhotos must be|
  | taken within 14 days of the incident. Late photos are not a|
  |ccepted.\n\nStaff may waive the photo for theft cases, with a |
  |police report.|
paragraph first
  |Claims over $500 need a photo of the damage.|
  |Photos must be taken within 14 days of the incident. Late|
  |photos are not accepted.|
  |Staff may waive the photo for theft cases, with a police|
  |report.|

The fixed cut splits the word accepted in two, so a question about late photos may find half a rule. The paragraph version keeps the first paragraph whole. The other two paragraphs are longer than 60 characters, so they are cut at spaces, and no word is split. The real recursive splitter does the same kind of thing and only cuts inside a word as a last resort.

Which one should you pick, and why?

For generic text, start with recursive splitting. It needs no extra model calls and keeps natural units whole. LangChain names it the recommended default for generic text. Move to another method only when your own tests show a problem.

How recursive splitting works

Long policy

a made-up claims manual

Split at paragraphs

keeps each idea whole

Still too big?

checked for each piece

Two outcomes

Small enough: keep

the piece stays as one chunk

Too big: split again

by line breaks, then spaces

Chunks ready

each under the size limit

  1. 1The long document goes in, and the splitter looks for paragraph breaks.
  2. 2Each paragraph is checked against the size limit.
  3. 3A piece that fits stays as one chunk.
  4. 4A piece that is still too big is split again, by line breaks, then spaces.
  5. 5Pieces that fit go on to the search index.
  6. 6Pieces that were split again go on to the search index too.
  7. 7A piece that is still too big after a split goes back for a check.
A long policy is first split at its paragraph breaks. Each piece is checked against the size limit: pieces that fit stay whole, and pieces still too big are split again, by line breaks, then spaces, and checked again.
  1. 1

    Start with recursive

    It keeps paragraphs and sentences whole, and only cuts smaller when it has to.

  2. 2

    Use the structure when there is one

    Markdown headings, HTML tags and source code are natural cut points, and they can be kept as metadata for filtering.

  3. 3

    Try semantic only when cuts still fail

    Use it when size-based cuts break up ideas and structure doesn't help. Treat the result as experimental.

  4. 4

    Test with real questions

    Check that the right chunk comes back for real questions, and change one setting at a time.

  • “Chunk boundaries decide what a retriever can return: a chunk that mixes several topics dilutes its embedding, and a chunk that splits one idea across two pieces hides context from the model.”

    LangChain, chunking guide

  • “Prefer recursive or structure-aware splitting for new work.”

    LangChain, chunking guide

  • “The choice of chunk size, chunk boundary, and chunk overlap can affect retrieval performance”

    Anthropic, contextual retrieval (Sep 2024)

Tip

Asked which to use, don't name one and stop. Say recursive by default, what would make you switch, and how you would measure the result.

How would you chunk 40,000 legal contracts?

A legal team wants to search 40,000 contracts. Many are scanned PDFs with numbered clauses, and a few hold tables of fees. A size-only cut would break clauses in odd places and separate each fee from its heading.

  1. 1

    Turn scans into text first

    A scanned PDF has no text to split until OCR (optical character recognition, which reads the page image as text) has run. Check a sample of the output before you split it.

  2. 2

    Split on the clause headings first

    Each numbered clause stays whole. Keep the contract name and date with every chunk, so a result can say where it came from.

  3. 3

    Cut long clauses by size, with overlap

    A clause that runs past the size limit is cut with some overlap, so no sentence is lost at a cut.

  4. 4

    Keep each fee table as one chunk

    A table with its heading is more useful whole than cut into rows.

  5. 5

    Test with questions lawyers ask

    Use questions whose answer is one clause, and check that the right clause comes back.

Semantic chunking is the wrong first tool here. The headings already mark the topics, and embedding 40,000 contracts just to find them again would cost more for less.

What does the interviewer want to hear?

A strong answer covers

  • Chunking happens before search, and the cut decides what the model sees.
  • Fixed size, recursive and semantic, with what each gets right and wrong.
  • Recursive as the default, with the reason: it keeps natural units whole.
  • Semantic costs more, and LangChain says to treat its results as experimental, so it is a later choice.
  • Overlap for cuts that fall in the middle of an idea.
  • A test on real questions, not a feeling about the output.

Common traps

  • Trap"Semantic chunking is always the best."

    BetterIt keeps topics together, but it embeds the document while splitting it, and LangChain says to treat its results as experimental.

  • Trap"Bigger chunks always give better answers."

    BetterBig chunks mix topics and dilute the embedding. Small ones can leave out the context around the answer.

  • Trap"Splitting every 500 characters is good enough."

    BetterIt's a fast start, but it can cut a rule from its exception. Check it against real questions.

Can you spot the bad cut?

Spot the bad cut

A fixed-size splitter cut this claims policy at 60 characters. Which chunk is most likely to give a wrong answer?

Quick check

The team's docs are Markdown with headings, and users ask about one section at a time. Which splitter fits best?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q115What is chunk overlap?10 min
  2. Q116How do you choose an embedding model?12 min
  3. Q130How do you handle tables, PDFs and images?12 min
  4. Q131Retrieval metrics: recall@k, MRR, nDCG?12 min
  5. Q112Walk through a RAG pipeline end to end.12 min

Learn it in depth

Last updated on 26 November 2026

Building a search over your own documents?

I design and build AI products and agents, including the UI and the system behind them. Book a short call and tell me what your documents look like and what questions people ask of them.