# 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.

AI and LLM interview question Q114, Retrieval-augmented generation (RAG). Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/fixed-vs-recursive-vs-semantic-chunking

## Say it in 30 seconds

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.

## Say it in 2 minutes

Chunking happens before search. The search can only return whole chunks, so where I cut decides what the model can see. Cut too big and a chunk mixes topics. Cut too small and it loses the words around the answer. There are three common ways to choose the cut, and they differ in what they look at.

Fixed size is the simplest. I cut every set number of characters or tokens, with some overlap so a cut doesn't lose a sentence. It's fast and predictable, but it ignores meaning. A rule can land in one chunk and its exception in the next. Recursive splitting looks at the text's own breaks. It tries paragraphs first, then line breaks, then spaces, and only goes smaller when a piece is still too big. LangChain calls it the recommended default for generic text.

Semantic chunking compares the meaning of neighbouring sentences and cuts where the topic shifts. It reads well on prose, but it embeds the document while splitting it, so it costs more. LangChain also says its version lives in an unmaintained package, and that its results should be treated as experimental. For a claims policy, I would start with recursive, check the questions that fail, and only try semantic if the cuts still land in the wrong place.

I'd say chunking is one of the biggest factors in quality, and the real test is a set of questions with known answers. Overlap helps when a cut falls in the middle of an idea, but it doesn't fix a bad split on its own.

## 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.

- **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?

*Diagram, The same policy, cut three ways: 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.*
1. A cut every set length can land in the middle of a rule.
2. Paragraph breaks keep each idea whole, where the text has them.
3. Neighbouring sentences stay together when their meaning is close.

- **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:

```text
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.

*Diagram, How recursive splitting works: 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. The long document goes in, and the splitter looks for paragraph breaks.
2. Each paragraph is checked against the size limit.
3. A piece that fits stays as one chunk.
4. A piece that is still too big is split again, by line breaks, then spaces.
5. Pieces that fit go on to the search index.
6. Pieces that were split again go on to the search index too.
7. A piece that is still too big after a split goes back for a check.

1. **Start with recursive:** It keeps paragraphs and sentences whole, and only cuts smaller when it has to.
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. **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. **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. **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. **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. **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. **Keep each fee table as one chunk:** A table with its heading is more useful whole than cut into rows.
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." Better: It 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." Better: Big 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." Better: It'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?

A. Claims over $500 need a photo of the damage.
B. taken within 14 days of the incident. Late photos are not a
C. Staff may waive the photo for theft cases, with a police report.
D. Photos must be taken within 14 days of the incident.

**Answer:** B. The chunk ends in the middle of the late-photo rule, so a question about late photos finds half of it. The other three options are whole sentences. A split that follows the sentences keeps each rule whole.

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

A. Semantic chunking, because it is the newest
B. Structure-aware splitting along the headings
C. Fixed size at 1,000 characters
D. One chunk per document

**Answer:** B. When a document has structure, split along it. The headings keep each section whole, and they can be stored as metadata for filtering. Semantic chunking costs more, and LangChain says to treat its results as experimental.

## Can you answer these from memory?

**Flash cards**

- **What does fixed-size chunking cut by?** A set number of characters or tokens. Simple, but blind to meaning.
- **What does recursive splitting try first?** Paragraph breaks, then line breaks, then spaces, only when pieces are too big.
- **Where does semantic chunking cut?** Where the topic shifts, found by comparing the meaning of nearby sentences.
- **Why is semantic chunking costly?** It embeds the document while splitting it. LangChain says to treat its results as experimental.
- **What is chunk overlap for?** Repeating text at chunk edges, so a cut doesn't lose a sentence.
- **Which one should you start with?** Recursive, for generic text. Change it only when your tests show the cuts fail.

## Likely follow-up questions

- Q115 What is chunk overlap? https://designervenkat.online/interview/ai/what-is-chunk-overlap
- Q116 How do you choose an embedding model? https://designervenkat.online/interview/ai/how-do-you-choose-an-embedding-model
- Q130 How do you handle tables, PDFs and images? https://designervenkat.online/interview/ai/how-do-you-handle-tables-pdfs-and-images
- Q131 Retrieval metrics: recall@k, MRR, nDCG? https://designervenkat.online/interview/ai/retrieval-metrics-recall-at-k-mrr-ndcg
- Q112 Walk through a RAG pipeline end to end. https://designervenkat.online/interview/ai/rag-pipeline-end-to-end

## Learn it in depth

- [Chunking](https://designervenkat.online/learn/ai-engineering/chunking)
