ChatPaper.aiChatPaper

HtmlRAG:HTML比纯文本更适合在RAG系统中建模检索到的知识

HtmlRAG: HTML is Better Than Plain Text for Modeling Retrieved Knowledge in RAG Systems

November 5, 2024
作者: Jiejun Tan, Zhicheng Dou, Wen Wang, Mang Wang, Weipeng Chen, Ji-Rong Wen
cs.AI

摘要

检索增强生成(RAG)已被证明可以提高知识能力并缓解LLM的幻觉问题。网络是RAG系统中使用的主要外部知识来源,许多商业系统如ChatGPT和Perplexity都使用网络搜索引擎作为它们的主要检索系统。通常,这类RAG系统检索搜索结果,下载结果的HTML源代码,然后从HTML源代码中提取纯文本。纯文本文档或片段被输入LLM以增强生成。然而,在这种基于纯文本的RAG过程中,HTML中固有的许多结构和语义信息,如标题和表结构,都会丢失。为了缓解这一问题,我们提出了HtmlRAG,它在RAG中使用HTML而不是纯文本作为检索到的知识的格式。我们认为HTML在建模外部文档中的知识方面优于纯文本,并且大多数LLM具有理解HTML的强大能力。然而,利用HTML也带来了新的挑战。HTML包含额外的内容,如标签、JavaScript和CSS规范,这些内容会给RAG系统带来额外的输入标记和噪音。为了解决这个问题,我们提出了HTML清理、压缩和修剪策略,以缩短HTML的长度同时最大限度地减少信息丢失。具体来说,我们设计了一个基于两步块树的修剪方法,用于修剪无用的HTML块,并仅保留HTML的相关部分。对六个问答数据集的实验证实了在RAG系统中使用HTML的优越性。
English
Retrieval-Augmented Generation (RAG) has been shown to improve knowledge capabilities and alleviate the hallucination problem of LLMs. The Web is a major source of external knowledge used in RAG systems, and many commercial systems such as ChatGPT and Perplexity have used Web search engines as their major retrieval systems. Typically, such RAG systems retrieve search results, download HTML sources of the results, and then extract plain texts from the HTML sources. Plain text documents or chunks are fed into the LLMs to augment the generation. However, much of the structural and semantic information inherent in HTML, such as headings and table structures, is lost during this plain-text-based RAG process. To alleviate this problem, we propose HtmlRAG, which uses HTML instead of plain text as the format of retrieved knowledge in RAG. We believe HTML is better than plain text in modeling knowledge in external documents, and most LLMs possess robust capacities to understand HTML. However, utilizing HTML presents new challenges. HTML contains additional content such as tags, JavaScript, and CSS specifications, which bring extra input tokens and noise to the RAG system. To address this issue, we propose HTML cleaning, compression, and pruning strategies, to shorten the HTML while minimizing the loss of information. Specifically, we design a two-step block-tree-based pruning method that prunes useless HTML blocks and keeps only the relevant part of the HTML. Experiments on six QA datasets confirm the superiority of using HTML in RAG systems.

Summary

AI-Generated Summary

PDF7122November 13, 2024