Back to Generative AI Notes
Topic #110

Chunking Strategies

Beyond naive fixed-size splitting, several chunking strategies exist, each better suited to different content structures — choosing the right one is a real, measurable lever on retrieval quality.

Fixed-Size Chunking

Split text every N characters/tokens, with some overlap.
Simple, predictable, but ignores document structure entirely —
can split mid-sentence or mid-thought.

Sentence/Paragraph-Based Chunking

Split at natural sentence or paragraph boundaries, grouping
them until reaching roughly the target chunk size.
→ Respects natural language structure, avoiding awkward
  mid-sentence splits.

Recursive/Hierarchical Chunking

Try splitting by larger structural units first (sections,
then paragraphs, then sentences), falling back to smaller
units only if a piece is still too large.
→ Better preserves document structure (headings, sections)
  than naive fixed-size splitting.

Semantic Chunking

Use embeddings to detect where the TOPIC actually shifts
within the text, and split there — rather than at a fixed
size or a purely structural boundary.
→ Chunks align with actual topic boundaries, but this
  approach is more computationally expensive (requires
  embedding calls during chunking itself) and adds complexity.

Document-Structure-Aware Chunking

Use the document's own structure — headings, sections, table
boundaries, code blocks — as natural chunk boundaries.
→ Particularly effective for structured content like technical
  documentation, Markdown files, or well-formatted reports.

Choosing a Strategy

Content TypeReasonable Starting Point
Well-structured docs (Markdown, technical docs)Structure-aware chunking
Prose-heavy content (articles, reports)Sentence/paragraph-based or recursive chunking
Highly variable, mixed contentSemantic chunking, if the added complexity/cost is justified by measured quality gains
Quick prototype / unclear requirements yetFixed-size with reasonable overlap — simple, works as a baseline

Practical Use Case

Technical documentation with headings and code examples benefits significantly from structure-aware chunking (keeping a code example with its explanation, not splitting them apart) — a chunking strategy mismatched to content type is a common, fixable source of mediocre RAG performance.

Common Mistakes

  • Defaulting to fixed-size chunking for structured content where a structure-aware approach would clearly perform better
  • Adopting semantic chunking's added complexity and cost without first measuring whether simpler approaches are actually insufficient
  • Never comparing chunking strategies empirically against real queries — assuming one approach is "obviously" better without testing

Interview Relevance

"How would you chunk a technical documentation site with headings, code blocks, and prose?" — structure-aware chunking that respects headings and keeps code examples intact with their explanations is the expected strong answer.

Practice Question

Recommend a chunking strategy for a knowledge base of legal contracts with numbered clauses, and justify the choice.

Want to go beyond the notes?

Join Coding Now Tech Institute's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Chunking Strategies – FAQs

Quick answers about learning Chunking Strategies in Generative AI.

This free note from Coding Now Tech Institute explains Chunking Strategies in Generative AI — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Generative AI topic on Coding Now Tech Institute, including Chunking Strategies, is 100% free with no signup required.
With focused practice, most students grasp Chunking Strategies in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now