arXiv:2502.12462cs.CL2025-02被引 12

用提示工程模拟检索增强生成,让大模型更好理解长文本。

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

  • 用提示词标记长文本关键段落,再分步推理整合信息。
  • 在BABILong数据集上,多跳问答准确率显著优于基线和传统RAG。
  • 无需外部检索器,适合资源受限场景下的长文本理解。

本文针对大语言模型(LLMs)处理超长上下文的挑战,提出一种通过特定提示工程和思维链(CoT)推理模拟检索增强生成(RAG)的方法。尽管现代LLMs支持单个提示超过10万 token,但仅扩大上下文窗口并未保证在关键信息分散于海量文本时实现稳健的多跳推理。本方法将模型自身视为检索器与推理器:先标记长文本中的相关段落,再通过逐步的CoT流程整合证据。该单次遍历方法降低了对外部检索器的依赖,同时保持对关键信息的关注。我们在BABILong任务上评估该方法,该任务将标准bAbI QA问题与大量干扰文本交错。相比无检索基线和朴素RAG管道,本方法在对象位置追踪、计数及不确定知识等多事实问题上表现更优。此外,我们分析了提示结构(如问题顺序、相关文本标记位置、整体指令)对性能的显著影响。结果表明,优化的提示工程结合引导式推理,可有效提升大模型的长上下文理解能力,为传统检索流水线提供轻量替代方案。

原文摘要 · Abstract (English)

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.

长文本理解提示工程思维链RAG

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。