HtmlRAG: HTML is Better Than Plain Text for Modeling Retrieved Knowledge in RAG Systems
该论文提出了HtmlRAG,一种将HTML作为检索知识格式的RAG系统,以保留HTML文档中的丰富语义和结构信息。
更新于 2024-11-09。作者:Jiejun Tan、Zhicheng Dou、Wen Wang、Mang Wang、Weipeng Chen、Ji-Rong Wen。
中文摘要
检索增强生成(Retrieval-Augmented Generation,RAG)已被证明可以提升知识能力并减轻大型语言模型(LLMs)的幻觉问题。网络是RAG系统中使用的主要外部知识来源,许多商业系统如ChatGPT和Perplexity都将其作为主要检索系统的网络搜索引擎。通常,这类RAG系统会检索搜索结果,下载结果页面的HTML源代码,然后从中提取纯文本。纯文本文档或片段被输入到LLMs中,以增强生成。然而,在这个过程中,HTML中固有的许多结构和语义信息,如标题和表格结构,会在基于纯文本的RAG过程中丢失。为了缓解这个问题,我们提出了HtmlRAG,它使用HTML而不是纯文本作为RAG中检索到的知识格式。我们相信,HTML在对外部文档中的知识建模方面优于纯文本,并且大多数LLMs都具备理解HTML的强大能力。然而,利用HTML也带来了新的挑战。HTML包含标签、JavaScript和CSS规范等额外内容,这些内容为RAG系统带来了额外的输入标记和噪音。为了解决这个问题,我们提出了HTML清洗、压缩和修剪策略,以缩短HTML文档的同时最大限度地减少信息损失。具体来说,我们设计了一种基于两步块树修剪的方法,修剪掉无用的HTML块,仅保留HTML的相关部分。在六个问答数据集上的实验证实了在RAG系统中使用HTML的优越性。
英文摘要
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.
解读
一句话总结
该论文提出了HtmlRAG,一种将HTML作为检索知识格式的RAG系统,以保留HTML文档中的丰富语义和结构信息。
问题1:这篇论文想要解决什么具体问题?
• 问题背景:现有的RAG系统通常将HTML文档转换为纯文本,导致结构化和语义信息的丢失。 • 现有方案不足:纯文本格式的RAG过程无法保留HTML文档中的结构化和语义信息,如标题和表格结构。 • 研究目标:提出HtmlRAG,使用HTML作为RAG系统中检索知识的格式,以保留HTML文档中的信息。
问题2:论文的核心创新点是什么?
• 技术创新:提出HtmlRAG,使用HTML作为检索知识格式。 • 方法改进:设计HTML清理、压缩和修剪策略,以缩短HTML文档的长度同时最小化信息损失。 • 优势:与纯文本相比,HtmlRAG能够更好地保留HTML文档中的结构化和语义信息。
问题3:实验结果如何验证了方法的有效性?
• 关键实验:在六个QA数据集上进行实验,包括模糊QA、自然QA、多跳QA和长格式QA。 • 性能提升:HtmlRAG在所有数据集上均优于基线方法,验证了其有效性。 • 对比结果:与基于纯文本的RAG系统相比,HtmlRAG在保留结构化和语义信息方面具有显著优势。
问题4:这个研究的实际应用价值是什么?
• 应用场景:适用于需要利用外部知识库的RAG系统,如问答系统、知识图谱等。 • 实施建议:在实际部署中,建议使用HtmlRAG来提高RAG系统的性能。 • 局限与展望:HtmlRAG目前主要针对HTML文档,未来可以扩展到其他类型的结构化数据。