<aside> ๐Ÿ“…

Date: Monday, October 5, 2026 ยท Week 2, Day 8 ยท Type: Build Day

</aside>

Learning Manual

8.1 The Chunking Dilemma โ€” why sending entire 50-page PDFs directly to an LLM is slow, expensive, and leads to missed facts.

8.2 Chunking Strategies โ€” fixed character splitting, sliding windows with overlap, and paragraph/sentence splitting.

8.3 Token Budgeting โ€” packing the most relevant context chunks into a prompt without overflowing context limits.

The Daily Build

Build a text-chunking utility script that ingests any .txt or .md file and outputs chunks based on two selectable strategies: fixed-size with 20% overlap, and paragraph-boundary splitting.

Architecture Diagram

+--------------+     +-------------------+     +-------------------------+
| Raw Document | --> | Text Splitter     | --> | Chunk Array with Overlap|
+--------------+     +-------------------+     +-------------------------+

Interview Questions

  1. Why is sliding-window overlap (e.g., 50 tokens) necessary between consecutive text chunks in a RAG system?
  2. What happens to retrieval accuracy if your chunk size is too small (e.g., 20 words) vs. too large (e.g., 2,000 words)?
  3. How do you chunk markdown documents containing headers, code blocks, and bullet points without breaking structure?

Problem Statement

Problem 08. Write a Python function chunk_text_with_overlap(text: str, chunk_size: int, overlap: int) -> list[str] that splits text into character chunks of size chunk_size while maintaining an overlap of overlap characters between consecutive chunks.

AI-DSA Primitive

Algorithm: Sliding Window Splitting.

Mechanics: Maintaining two pointers (start, end) moving across a string by step size (chunk_size โˆ’ overlap).

Real-World Production Use: Deployed inside document pre-processing engines (LlamaIndex, Unstructured.io, LangChain).

Software Design Pattern