<aside> ๐
Date: Monday, October 5, 2026 ยท Week 2, Day 8 ยท Type: Build Day
</aside>
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.
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.
+--------------+ +-------------------+ +-------------------------+
| Raw Document | --> | Text Splitter | --> | Chunk Array with Overlap|
+--------------+ +-------------------+ +-------------------------+
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.
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).