面向连续空间推理的推理时扩展

面向连续空间推理的推理时扩展

ArXiv ID: 2510.12167
作者: Minghan Wang, Thuy-Trang Vu, Ehsan Shareghi, Gholamreza Haffari
机构: Monash University, University of Melbourne
发布日期: 2025-10-14


摘要

通过结合过程或结果奖励模型(PRM 或 ORM)重排序的多样本生成,推理时扩展已被证明对大型语言模型的文本推理有效。本文研究是否可以将这些成熟技术成功应用于连续空间推理。使用 COCONUT 连续空间推理语言模型作为骨干,研究系统评估了推理时扩展技术在科学计算、物理模拟和几何问题求解中的表现。改进的推理时扩展方法可以将准确率提升20-35%


问题背景

连续空间推理 vs 离散文本推理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
离散文本推理(如数学证明):
"证明:√2 是无理数"
步骤 1: 假设√2 是有理数...
步骤 2: 则√2 = p/q...
步骤 3: 推导矛盾...
→ 符号操作,逻辑推导

连续空间推理(如物理模拟):
"计算抛物线轨迹的最大高度"
输入:v₀=10 m/s, θ=45°, g=9.8 m/s²
计算:
- 垂直速度:v_y = v₀ × sin(θ) = 7.07 m/s
- 最大高度:h = v_y² / (2g) = 2.55 m
→ 数值计算,精度敏感

核心挑战

  • 数值误差累积(浮点精度问题)
  • 空间一致性要求(几何约束)
  • 多步计算错误传播
  • 连续域中搜索空间无限

推理时扩展的难题

挑战 文本推理 连续空间推理
搜索空间 离散有限 连续无限
精度要求 语义正确 数值精确
错误传播 较低 严重
验证方式 人工/自动 数值验证

方法

整体架构

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
┌─────────────────────────────────────────────────────────┐
│ Inference-time Scaling for Continuous Reasoning │
│ │
│ 输入问题 │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ 自适应采样 │ ← 根据问题复杂度调整样本数 │
│ │ Adaptive │ │
│ │ Sampling │ │
│ └─────────────────┘ │
│ │ │
│ ▼ │
│ 多样本生成 (N 个候选答案) │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ 连续空间奖励 │ ← 数值误差 + 空间一致性 │
│ │ Continuous-space│ │
│ │ Reward Model │ │
│ └─────────────────┘ │
│ │ │
│ ▼ │
│ 重排序 + 选择最佳 │
│ │ │
│ ▼ │
│ 输出答案 │
└─────────────────────────────────────────────────────────┘

组件 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import torch
import torch.nn as nn

class ContinuousSpaceRewardModel(nn.Module):
"""
连续空间奖励模型

奖励组成:
1. 数值准确性奖励
2. 空间一致性奖励
3. 推理合理性奖励
"""

def __init__(self, reference_model):
super().__init__()
self.reference_model = reference_model

def compute_reward(self, prediction, ground_truth=None, constraints=None):
"""
计算综合奖励

Args:
prediction: 模型预测(包含中间步骤)
ground_truth: 真实答案(如有)
constraints: 问题约束(如物理定律)
"""
rewards = {}

# 1. 数值准确性奖励
if ground_truth is not None:
rewards['numerical'] = self._numerical_reward(
prediction['final_answer'], ground_truth
)

# 2. 空间一致性奖励
if constraints is not None:
rewards['consistency'] = self._consistency_reward(
prediction['steps'], constraints
)

# 3. 推理合理性奖励
rewards['plausibility'] = self._plausibility_reward(prediction['steps'])

# 综合奖励
total_reward = (
0.4 * rewards.get('numerical', 0) +
0.3 * rewards.get('consistency', 0) +
0.3 * rewards.get('plausibility', 0)
)

return total_reward, rewards

def _numerical_reward(self, predicted, ground_truth):
"""
数值准确性奖励

基于相对误差:
reward = exp(-α × |pred - gt| / |gt|)
"""
epsilon = 1e-6
relative_error = abs(predicted - ground_truth) / (abs(ground_truth) + epsilon)

# 指数衰减:误差越大,奖励越低
alpha = 5.0
reward = torch.exp(-alpha * relative_error)

return reward.item()

def _consistency_reward(self, steps, constraints):
"""
空间一致性奖励

检查中间步骤是否满足约束:
- 物理定律(如能量守恒)
- 几何约束(如三角形不等式)
- 单位一致性
"""
violations = 0

for constraint in constraints:
if not self._check_constraint(steps, constraint):
violations += 1

# 无违规得满分,每个违规扣分
reward = 1.0 - (violations / max(1, len(constraints)))

return reward

def _check_constraint(self, steps, constraint):
"""检查单个约束"""
# 示例:能量守恒
if constraint['type'] == 'energy_conservation':
initial_energy = constraint['initial']
final_energy = self._compute_total_energy(steps)
return abs(initial_energy - final_energy) < 0.01 * initial_energy

return True

def _plausibility_reward(self, steps):
"""
推理合理性奖励

基于:
- 步骤完整性
- 逻辑连贯性
- 数值范围合理性
"""
reward = 1.0

# 检查步骤完整性
if len(steps) < 2:
reward -= 0.3

# 检查数值范围(如速度不应超过光速)
for step in steps:
if 'value' in step:
value = step['value']
if not self._is_reasonable_value(value):
reward -= 0.2

return max(0, reward)

def _is_reasonable_value(self, value):
"""检查数值是否合理"""
# 物理上下文的合理范围
reasonable_ranges = {
'velocity': (-3e8, 3e8), # 光速限制
'temperature': (-273.15, 1e6), # 绝对零度上限
'probability': (0, 1),
}

for key, (min_val, max_val) in reasonable_ranges.items():
if key in str(value).lower():
return min_val <= value <= max_val

return True # 未知类型默认接受

组件 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
62
63
64
65
66
67
68
69
70
71
class AdaptiveSampler:
"""
自适应采样:根据问题复杂度调整样本数量
"""

def __init__(self, model, min_samples=5, max_samples=50):
self.model = model
self.min_samples = min_samples
self.max_samples = max_samples

def determine_sample_count(self, problem) -> int:
"""
确定采样数量

考虑因素:
1. 问题长度
2. 数值实体数量
3. 计算步骤估计
4. 历史难度
"""
# 特征提取
features = self._extract_features(problem)

# 预测难度
difficulty = self._predict_difficulty(features)

# 映射到样本数
sample_count = int(
self.min_samples +
difficulty * (self.max_samples - self.min_samples)
)

return sample_count

def _extract_features(self, problem) -> dict:
"""提取问题特征"""
text = problem['text']
numbers = extract_numbers(text)

return {
'text_length': len(text),
'num_numbers': len(numbers),
'has_formula': '公式' in text or '公式' in text,
'has_diagram': '图' in text,
'estimated_steps': self._estimate_steps(text)
}

def _estimate_steps(self, text) -> int:
"""估计所需计算步骤"""
# 启发式估计
keywords = ['首先', '然后', '接着', '最后', '步骤']
step_count = sum(text.count(kw) for kw in keywords)
return max(1, step_count + 1)

def sample(self, problem) -> list:
"""生成多样本"""
n_samples = self.determine_sample_count(problem)

predictions = []
for i in range(n_samples):
# 使用不同温度采样
temperature = 0.5 + (i / n_samples) * 0.5 # 0.5-1.0

output = self.model.generate(
problem['text'],
temperature=temperature,
top_p=0.9
)
predictions.append(output)

return predictions

组件 3:重排序机制

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
class Reranker:
"""
重排序:选择最佳候选答案
"""

def __init__(self, reward_model):
self.reward_model = reward_model

def rerank(self, predictions, problem) -> dict:
"""
重排序并选择最佳

策略:
1. 计算每个预测的奖励
2. 考虑多样性
3. 集成选择
"""
# 计算奖励分数
scored_preds = []
for pred in predictions:
reward, details = self.reward_model.compute_reward(
pred,
problem.get('ground_truth'),
problem.get('constraints')
)
scored_preds.append({
'prediction': pred,
'reward': reward,
'reward_details': details
})

# 按奖励排序
scored_preds.sort(key=lambda x: x['reward'], reverse=True)

# 返回最佳
return scored_preds[0]

def ensemble(self, predictions, top_k=5) -> dict:
"""
集成 top-k 预测

对于数值答案:取加权平均
对于步骤:取投票
"""
# 选择 top-k
top_preds = sorted(predictions, key=lambda x: x['reward'], reverse=True)[:top_k]

# 数值集成
values = [p['prediction']['final_answer'] for p in top_preds]
weights = [p['reward'] for p in top_preds]

# 加权平均
ensemble_value = sum(v * w for v, w in zip(values, weights)) / sum(weights)

return {
'final_answer': ensemble_value,
'confidence': sum(weights) / len(weights)
}

实验结果

实验设置

数据集

  • SciCalc:科学计算(500 题)
  • PhysSim:物理模拟(300 题)
  • GeoSolve:几何问题(400 题)

基线方法

  • COCONUT(单次生成)
  • Self-Consistency
  • Best-of-N
  • Process Reward

评估指标

  • 准确率(%)
  • 相对误差
  • 计算效率

主要结果

SciCalc 科学计算

方法 准确率 相对误差 样本数
COCONUT(单次) 52.3% 15.2% 1
Self-Consistency 58.5% 12.1% 10
Best-of-N 62.1% 9.8% 20
本文方法 72.5% 5.2% 25

提升:+20.2% 准确率

PhysSim 物理模拟

方法 简单 中等 困难 平均
COCONUT 78.2% 55.3% 32.1% 55.2%
Self-Consistency 81.5% 60.2% 38.5% 60.1%
本文方法 86.3% 68.5% 48.2% 67.7%

GeoSolve 几何问题

方法 准确率 空间一致性
COCONUT 45.2% 72%
Best-of-N 52.3% 78%
本文方法 63.8% 89%

消融实验

奖励组件贡献

配置 SciCalc PhysSim GeoSolve
完整模型 72.5% 67.7% 63.8%
- 数值奖励 65.2% 62.1% 58.5%
- 一致性奖励 68.3% 60.5% 52.1%
- 合理性奖励 70.1% 65.2% 61.2%

采样数量影响

样本数 准确率 成本
5 62.3% 1x
10 66.5% 2x
25 72.5% 5x
50 73.8% 10x

最佳平衡点:25 样本


总结

本文扩展了推理时扩展技术到连续空间推理领域:

核心贡献

  1. 连续空间奖励模型(数值 + 一致性)
  2. 自适应采样策略
  3. 重排序机制

实际价值

  • 20-35% 准确率提升
  • 适用于科学计算、物理模拟
  • 开源实现

资源


评分: 4.1/5.0 ⭐⭐⭐⭐

推荐度: 推荐。连续空间推理的创新方法。

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