arXiv(opens in a new tab)cs.CLJun 2024Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2406.17526

LumberChunker: Long-Form Narrative Document Segmentation

André V. Duarte, João Marques, Miguel Graça, Miguel Freire, Lei Li, Arlindo L. Oliveira

Abstract

Modern NLP tasks increasingly rely on dense retrieval methods to access up-to-date and relevant contextual information. We are motivated by the premise that retrieval benefits from segments that can vary in size such that a content's semantic independence is better captured. We propose LumberChunker, a method leveraging an LLM to dynamically segment documents, which iteratively prompts the LLM to identify the point within a group of sequential passages where the content begins to shift. To evaluate our method, we introduce GutenQA, a benchmark with 3000 "needle in a haystack" type of question-answer pairs derived from 100 public domain narrative books available on Project Gutenberg 1^{1}. Our experiments show that LumberChunker not only outperforms the most competitive baseline by 7.37% in retrieval performance (DCG@20) but also that, when integrated into a RAG pipeline, LumberChunker proves to be more effective than other chunking methods and competitive baselines, such as the Gemini 1.5M Pro.

1 Introduction

The rapid expansion of Large Language Models (LLMs) has paved the way for tackling a wide range of tasks, including translation (Alves et al., 2024), summarization (Kedia et al., 2021), and question answering (Huang et al., 2022), among others (Zhao et al., 2023). However, a significant issue arises when these models are tasked with generating responses based on information they lack, often resulting in "hallucinations" - responses that, while seemingly plausible, are factually incorrect (Zhang et al., 2023). Given the broad accessibility of these models, less informed users may accept all generated content as accurate, potentially causing severe misinterpretations and adverse consequences, like the recent incident where a lawyer cited fictitious cases produced by ChatGPT (OpenAI, 2022) in court, resulting in sanctions for the lawyer and highlighting the severe risks of unverified AI-generated information (Bohannon, 2023).

In the field of question answering, where precision and accuracy of information are paramount, Retrieval Augmented Generation (RAG) systems present a viable solution to hallucinations by grounding the model's generation on contextually relevant documents (Lewis et al., 2020).

One often overlooked part of the RAG pipeline is how textual content is segmented into ‘chunks’, which can significantly impact the dense retrieval quality (Shi et al., 2023). Real-world applications tend to simplify this step and consider sentences, paragraphs, or propositions as the usual granularity level (Tiedemann and Mur, 2008; Chen et al., 2023).

In this paper, we propose LumberChunker, a novel text segmentation method based on the principle that retrieval efficiency improves when content chunks are as independent as possible from one another. This independence is best achieved by allowing chunks to be of dynamic sizes. Given that language models excel at analyzing text, we leverage their capabilities to identify optimal segmentation points. Specifically, we repeatedly instruct a language model to receive a series of continuous paragraphs and determine the precise paragraph within the sequence where the content starts diverging. This approach ensures that each segment is contextually coherent yet distinct from adjacent segments, thereby enhancing the effectiveness of information retrieval.

We introduce a new benchmark: GutenQA, which consists of 100 public domain narrative books manually extracted from Project Gutenberg 2^{2}. We create 3000 high-quality question-answer pairs

1^{1}Code and Data available at: https://github.com/joaodsmarques/LumberChunker

2^{2}https://www.gutenberg.org/

Figure

Figure 1: LumberChunker follows a three-step process. First, we segment a document paragraph-wise. Secondly, a group (Gi)(G_i) is created by appending sequential chunks until exceeding a predefined token count θ\theta. Finally, GiG_i is fed as context to Gemini, which determines the ID where a significant content shift starts to appear, thus defining the start of Gi+1G_{i+1} and the end of the current chunk. This process is cyclically repeated for the entire document.

from these books to evaluate the impact of Lumber-Chunker on retrieval. Finally, we integrate LumberChunker into a RAG pipeline for a downstream QA task to assess its effect on the accuracy of the generated outputs.

References (54)