让大模型学会按图结构推理,提升长文档理解与问答能力
Graph-KV: Breaking Sequence via Injecting Structural Biases into Large Language Models
- 用图结构掩码替代串行注意力,只关注相关段落
- 在7个RAG任务和学术论文问答中显著超越基线
- 适合需要结构化推理的科研、知识检索场景
现代大语言模型本质上是自回归的,必须将输入序列化为扁平序列,忽略其结构依赖关系。这限制了模型利用结构归纳偏置的能力,尤其在检索增强生成(RAG)和具有天然图结构的数据推理任务中。本文提出Graph-KV,将文本段落的键值缓存(KV-cache)作为压缩表示,并通过结构归纳偏置控制其交互。目标段落仅关注指定源段落的KV缓存,而非所有前序段落,形成图结构块掩码,稀疏化注意力并实现类消息传递机制。此外,对源与目标段落进行策略性位置编码分配,降低位置偏差和上下文窗口消耗。我们在三个场景评估:(1) 七个跨直接推理、多跳推理与长文档理解的RAG基准;(2) Arxiv-QA,一个基于引用引子图的学术论文问答任务;(3) 引用网络中的论文主题分类。结果表明,通过有效减少位置偏差并利用结构归纳偏置,Graph-KV在多种设置下显著优于基线,包括代价高昂的序列编码。代码与数据已公开。
原文摘要 · Abstract (English)
Modern large language models (LLMs) are inherently auto-regressive, requiring input to be serialized into flat sequences regardless of their structural dependencies. This serialization hinders the model's ability to leverage structural inductive biases, especially in tasks such as retrieval-augmented generation (RAG) and reasoning on data with native graph structures, where inter-segment dependencies are crucial. We introduce Graph-KV with the potential to overcome this limitation. Graph-KV leverages the KV-cache of text segments as condensed representations and governs their interaction through structural inductive biases. In this framework, 'target' segments selectively attend only to the KV-caches of their designated 'source' segments, rather than all preceding segments in a serialized sequence. This approach induces a graph-structured block mask, sparsifying attention and enabling a message-passing-like step within the LLM. Furthermore, strategically allocated positional encodings for source and target segments reduce positional bias and context window consumption. We evaluate Graph-KV across three scenarios: (1) seven RAG benchmarks spanning direct inference, multi-hop reasoning, and long-document understanding; (2) Arxiv-QA, a novel academic paper QA task with full-text scientific papers structured as citation ego-graphs; and (3) paper topic classification within a citation network. By effectively reducing positional bias and harnessing structural inductive biases, Graph-KV substantially outperforms baselines, including standard costly sequential encoding, across various settings. Code and the Graph-KV data are publicly available.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。