arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.12462cs.CL
收藏

通过提示工程模拟检索增强生成以增强大型语言模型的长上下文理解

Emulating Retrieval Augmented Generation via Prompt Engineering for Enhanced Long Context Comprehension in LLMs

Kyoto University(京都大学)

Joon Park, Kyohei Atarashi, Koh Takeuchi, Hisashi Kashima

AI总结:

提出用提示工程和CoT在LLM内部模拟RAG,通过标记相关片段并逐步整合证据,提升长上下文多跳问答性能。

摘要:

本文解决大型语言模型(LLM)理解极长上下文的挑战,提出一种通过专门的提示工程和思维链(CoT)推理来模拟检索增强生成(RAG)的方法。尽管近期的LLM在单个提示中支持超过100,000个token,但当关键细节分散在海量输入中时,单纯扩大上下文窗口并不能保证稳健的多跳推理。我们的方法将模型同时视为检索器和推理器:它首先标记长段落中的相关片段,然后采用逐步CoT工作流整合这些证据。因此,这种单遍方法减少了对外部检索器的依赖,同时保持对关键片段的关注。我们在BABILong的选定任务上评估该方法,这些任务将标准bAbI问答问题与大量干扰文本交织在一起。与基线(无检索)和朴素RAG流水线相比,我们的方法能更准确地处理多事实问题,例如物体位置追踪、计数和不定知识。此外,我们分析了提示结构(包括问题顺序、相关文本标记和总体指令)如何显著影响性能。这些发现强调,优化的提示工程与引导式推理相结合,可以增强LLM的长上下文理解,并作为传统检索流水线的轻量级替代方案。

英文摘要:

This paper addresses the challenge of comprehending very long contexts in Large Language Models (LLMs) by proposing a method that emulates Retrieval Augmented Generation (RAG) through specialized prompt engineering and chain-of-thought (CoT) reasoning. While recent LLMs support over 100,000 tokens in a single prompt, simply enlarging context windows has not guaranteed robust multi-hop reasoning when key details are scattered across massive input. Our approach treats the model as both the retriever and the reasoner: it first tags relevant segments within a long passage, then employs a stepwise CoT workflow to integrate these pieces of evidence. This single-pass method thereby reduces reliance on an external retriever, yet maintains focus on crucial segments. We evaluate our approach on selected tasks from BABILong, which interleaves standard bAbI QA problems with large amounts of distractor text. Compared to baseline (no retrieval) and naive RAG pipelines, our approach more accurately handles multi-fact questions such as object location tracking, counting, and indefinite knowledge. Furthermore, we analyze how prompt structure, including the order of question, relevant-text tags, and overall instructions, significantly affects performance. These findings underscore that optimized prompt engineering, combined with guided reasoning, can enhance LLMs' long-context comprehension and serve as a lightweight alternative to traditional retrieval pipelines.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑