Abstract
Effective document segmentation is critical for Retrieval-Augmented Generation (RAG) systems, yet traditional fixed-size or rule-based methods often fragment semantic units. We present LumberChunker, a novel segmentation pipeline that leverages Large Language Models (LLMs) to dynamically identify "content shifts" in narrative text. By creating semantically independent and contextually coherent chunks, LumberChunker improves retrieval performance by over 7% and achieves QA accuracy nearly matching human-curated gold standards.
Introduction
In RAG architectures, the granularity and coherence of document "chunks" significantly impact the quality of retrieved context. Naive chunking—splitting text by fixed character counts or paragraph breaks—frequently bisects critical ideas or introduces irrelevant noise. While semantic chunking using embedding distances offers some improvement, it often fails to capture the subtle narrative flow of long-form documents. We argue that optimal retrieval requires chunks to be semantically independent: containing one complete idea with minimal extraneous information.
Methodology: The LumberChunker Pipeline
LumberChunker employs an iterative, LLM-driven approach to document segmentation. The process begins by decomposing a document into its constituent paragraphs, each uniquely identified. These paragraphs are then sequentially grouped into a candidate segment ($G_i$) until a predefined token threshold ($\theta$) is reached.
As shown in Figure 1, the candidate group is passed to an LLM (Gemini 1.0 Pro) with a prompt to identify the specific paragraph ID where the content clearly diverges from the preceding context. This identified paragraph serves as the starting point for the subsequent chunk. This method utilizes the reasoning capabilities of LLMs to understand semantic boundaries rather than relying on surface-level heuristics.
Experimental Evaluation
To evaluate performance, we introduced GutenQA, a benchmark comprising 3,000 high-quality question-answer pairs derived from 100 public domain narrative books. Each question is linked to a verbatim ground-truth text span.
Key Insights
- Optimal Context Window: Ablation studies identified a threshold ($\theta$) of 550 tokens as the "Goldilocks" zone. Smaller windows lack sufficient context for the LLM to detect shifts, while larger windows suffer from "lost in the middle" effects.
- Human-Centric Logic: LumberChunker’s segments demonstrated a high Rouge-L overlap (0.709) with manually created gold-standard chunks, indicating that the LLM successfully mimics human editorial judgment.
Results
LumberChunker significantly outperformed traditional baselines. In retrieval tasks, it achieved a Recall@20 of 77.92%, surpassing Semantic Chunking (64.51%) and Recursive Chunking (74.35%). Furthermore, it improved Discounted Cumulative Gain (DCG@20) by 7.37% over the best baseline.
In a full RAG pipeline (Figure 2), LumberChunker reached 88.89% accuracy, nearly matching the 90.53% achieved by human-segmented "gold" chunks. Notably, this RAG approach far exceeded the performance of "Open-Book" long-context models (37.76%), suggesting that precise retrieval remains superior to processing massive context windows directly.
Discussion and Limitations
While highly effective, LumberChunker introduces trade-offs in cost and latency. Processing long documents requires multiple sequential LLM calls; for instance, segmenting The Count of Monte Cristo took approximately 27 minutes. The iterative nature of the algorithm also presents a bottleneck for parallelization. Future research will focus on optimizing the pipeline through asynchronous processing and the use of smaller, specialized models to reduce the computational overhead of semantic segmentation.
Summary updated