GraphRAG-R1: 图检索增强生成与过程约束强化学习

GraphRAG-R1: 图检索增强生成与过程约束强化学习

ArXiv ID: 2507.23581
作者: Chuanyue Yu, Kuo Zhao, Yuhan Li 等
机构: Tsinghua University
发表: The Web Conference 2026 (WWW’26)
发布日期: 2025-07-31


摘要

现有的 GraphRAG 方法在处理复杂多跳推理任务时存在局限性。GraphRAG-R1 提出了一种自适应 GraphRAG 框架,通过过程约束的基于结果的强化学习来训练 LLM,增强其多跳推理能力。框架设计了两个关键奖励机制:渐进式检索衰减 (PRA) 解决浅层检索问题,成本感知 F1(CAF) 平衡性能与开销。在域内和域外数据集上均超越 SOTA 方法。


问题背景

传统 GraphRAG 的局限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
传统 GraphRAG 流程:

问题 → 检索相关子图 → 生成答案

└─ 问题:
• 浅层检索 (只获取直接相连的实体)
• 无法处理多跳推理
• 过度检索导致成本浪费
• 检索和推理分离

示例:
问题:"张三的导师的学生有哪些?"

传统 GraphRAG:
- 检索:"张三" → "导师李四"
- 缺失:"李四的学生" (第二跳)
- 答案不完整

理想流程:
- 检索:"张三" → "导师李四" → "李四的学生王五、赵六"
- 完整答案

核心挑战

挑战 描述 影响
浅层检索 只获取表面信息 无法多跳推理
过度检索 检索无关信息 成本浪费
检索 - 推理分离 两阶段独立优化 次优性能
固定检索策略 无法动态调整 适应性差

GraphRAG-R1 方法

整体架构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
┌─────────────────────────────────────────────────────────┐
│ GraphRAG-R1 Architecture │
│ │
│ 问题输入 │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Rollout with │ │
│ │ Thinking │ ← 思维过程可干预 │
│ └─────────────────┘ │
│ │ │
│ ├─ 决定检索 ──→ [图检索模块] ──┐ │
│ │ │ │
│ ├─ 决定推理 ──→ [推理模块] ────┤ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ 过程约束强化学习 (GRPO) │ │
│ │ │ │
│ │ 奖励 1: 渐进式检索衰减 (PRA) │ │
│ │ 奖励 2: 成本感知 F1 (CAF) │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 答案生成 │
└─────────────────────────────────────────────────────────┘

组件 1:过程约束强化学习

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import torch
import torch.nn as nn

class ProcessConstrainedGRPO:
"""
过程约束的 GRPO

基于 Group Relative Policy Optimization
支持 rollout-with-thinking 机制
"""

def __init__(self, model, group_size=8):
self.model = model
self.group_size = group_size

def compute_rewards(self, trajectories, answers,
retrieval_actions):
"""
计算奖励

Args:
trajectories: 推理轨迹
answers: 最终答案
retrieval_actions: 检索动作序列
"""
rewards = []

for i, (traj, answer, actions) in enumerate(
zip(trajectories, answers, retrieval_actions)
):
# 奖励 1: PRA (渐进式检索衰减)
pra_reward = self._compute_pra_reward(actions)

# 奖励 2: CAF (成本感知 F1)
caf_reward = self._compute_caf_reward(answer, actions)

# 综合奖励
total_reward = 0.6 * pra_reward + 0.4 * caf_reward
rewards.append(total_reward)

return rewards

def _compute_pra_reward(self, retrieval_actions):
"""
渐进式检索衰减奖励

鼓励深层检索,惩罚浅层检索

计算方式:
- 统计检索深度分布
- 深度越大,奖励越高
- 随训练进程提高深度要求
"""
depths = [action['depth'] for action in retrieval_actions]

if not depths:
return 0.0

avg_depth = sum(depths) / len(depths)

# 渐进式奖励函数
# 早期:浅层检索也有一定奖励
# 后期:只有深层检索才有高奖励
reward = min(1.0, avg_depth / 3.0) # 目标深度 3

return reward

def _compute_caf_reward(self, answer, actions):
"""
成本感知 F1 奖励

平衡准确性和成本

计算方式:
CAF = F1 / (1 + α * retrieval_cost)
"""
# 计算 F1
f1_score = self._compute_f1(answer)

# 计算检索成本
retrieval_cost = len(actions) * 0.1 # 每次检索成本 0.1

# CAF 公式
alpha = 0.5
caf = f1_score / (1 + alpha * retrieval_cost)

return caf

def update_policy(self, trajectories, rewards):
"""
更新策略

GRPO 更新公式:
L = E[log(π_new / π_old) * A]
其中 A 是优势函数
"""
# 计算优势
advantages = self._compute_advantages(rewards)

# 策略梯度更新
for traj, adv in zip(trajectories, advantages):
for state, action in traj:
log_prob = self.model.get_log_prob(state, action)
loss = -log_prob * adv
loss.backward()

组件 2:混合检索策略

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class HybridGraphRetriever:
"""
混合图检索器

结合图结构和文本语义
"""

def __init__(self, graph_db, text_encoder):
self.graph_db = graph_db
self.text_encoder = text_encoder

def retrieve(self, query, current_context,
max_hops=3, beam_size=5):
"""
多跳检索

Args:
query: 用户问题
current_context: 当前上下文
max_hops: 最大跳数
beam_size: 束搜索大小
"""
# 步骤 1: 实体链接
entities = self._link_entities(query)

# 步骤 2: 束搜索多跳遍历
beam = [(entity, 0, [entity]) for entity in entities]
retrieved_subgraph = []

for hop in range(max_hops):
next_beam = []

for entity, depth, path in beam:
# 获取邻居
neighbors = self.graph_db.get_neighbors(entity)

for neighbor, relation in neighbors:
new_path = path + [(relation, neighbor)]
score = self._score_path(query, new_path)

next_beam.append((neighbor, depth + 1, new_path))
retrieved_subgraph.append((entity, relation, neighbor))

# 保留 top-k
next_beam.sort(key=lambda x: x[0][1], reverse=True)
beam = next_beam[:beam_size]

return retrieved_subgraph

def _score_path(self, query, path):
"""评估路径相关性"""
# 文本相似度
path_text = ' '.join(str(p) for p in path)
query_embedding = self.text_encoder.encode(query)
path_embedding = self.text_encoder.encode(path_text)

similarity = cosine_similarity(
query_embedding, path_embedding
)

return similarity

三阶段渐进训练策略

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
训练阶段:

阶段 1: 基础检索能力 (1000 steps)
┌─────────────────────────────────────┐
│ 目标:学会基本检索操作 │
│ │
│ 奖励配置: │
│ • PRA: 宽松 (深度≥1 即有奖励) │
│ • CAF: 低成本权重 │
│ │
│ 任务:单跳检索问答 │
└─────────────────────────────────────┘

阶段 2: 多跳推理能力 (2000 steps)
┌─────────────────────────────────────┐
│ 目标:掌握多跳推理 │
│ │
│ 奖励配置: │
│ • PRA: 中等 (深度≥2 才有高奖励) │
│ • CAF: 平衡权重 │
│ │
│ 任务:2-3 跳推理问答 │
└─────────────────────────────────────┘

阶段 3: 复杂推理优化 (3000 steps)
┌─────────────────────────────────────┐
│ 目标:优化复杂推理性能 │
│ │
│ 奖励配置: │
│ • PRA: 严格 (深度≥3 才有高奖励) │
│ • CAF: 高质量权重 │
│ │
│ 任务:复杂多跳推理 │
└─────────────────────────────────────┘

实验结果

主实验结果

方法 HotpotQA 2Wiki MuSiQue 平均
Standard RAG 52.3% 48.5% 35.2% 45.3%
GraphRAG 58.5% 55.2% 42.1% 51.9%
Iter-RetGen 62.1% 58.3% 45.8% 55.4%
GraphRAG-R1 68.5% 65.2% 52.3% 62.0%

消融实验

奖励组件贡献

配置 HotpotQA 2Wiki MuSiQue
完整模型 68.5% 65.2% 52.3%
- PRA 奖励 62.1% 58.5% 45.2%
- CAF 奖励 65.2% 61.8% 48.5%
- 两阶段训练 64.5% 60.2% 47.1%

训练阶段影响

配置 性能 收敛速度
单阶段 58.5%
两阶段 64.2%
三阶段 68.5% 稳定

检索深度分析

1
2
3
4
5
6
7
8
9
检索深度分布:

深度 | 传统 GraphRAG | GraphRAG-R1
-----|--------------|-------------
1 | 65% | 15%
2 | 25% | 35%
3+ | 10% | 50%

GraphRAG-R1 显著增加了深层检索比例

总结

GraphRAG-R1 通过过程约束强化学习实现了自适应图检索增强:

核心贡献

  1. 过程约束 GRPO 支持 rollout-with-thinking
  2. PRA 奖励解决浅层检索问题
  3. CAF 奖励平衡性能与成本
  4. 三阶段渐进训练策略

实际价值

  • 多跳推理任务 SOTA
  • 域外泛化能力强
  • 可集成多种检索方法

评分: 4.3/5.0 ⭐⭐⭐⭐

推荐度: 推荐。复杂推理任务的优秀解决方案。

© 2026 Generative AI Discovery All Rights Reserved.
Theme by hiero