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