概述
深度学习理论在2025-2026年取得了显著进展。本文档综合分析了这一领域的最新研究成果,涵盖注意力机制理论、LLM泛化界、表示学习等核心方向。
一、最优传输与注意力机制
核心发现
Self-Attention矩阵可以严格解释为半松弛熵最优传输问题的解:
这一发现提供了注意力的几何理解,并为设计新的注意力变体提供了理论基础。
关键进展
| 研究 | 主要贡献 |
|---|---|
| Mensch & Blondel (2018) | 首次建立注意力与OT的联系 |
| Geshkovski et al. (2025) | Particle System模型,AMS Bulletin |
| OpenReview 2025 | 半松弛EOT的完整理论 |
Sinkhorn Attention
def sinkhorn_attention(Q, K, V, epsilon=0.1, num_iters=10):
"""
Sinkhorn Attention: Full iterative OT solution
Standard attention uses one Sinkhorn iteration.
Sinkhorn attention runs multiple iterations.
"""
C = -torch.matmul(Q, K.transpose(-2, -1)) / (Q.shape[-1] ** 0.5)
K_mat = torch.exp(-C / epsilon)
a = torch.ones(Q.shape[0], Q.shape[1]) / Q.shape[1]
b = torch.ones(K.shape[0], K.shape[1]) / K.shape[1]
for _ in range(num_iters):
u = 1.0 / (torch.matmul(K_mat, b.unsqueeze(-1)).squeeze(-1) + 1e-8)
v = 1.0 / (torch.matmul(K_mat.transpose(-2, -1), u.unsqueeze(-1)).squeeze(-1) + 1e-8)
a, b = a * u, b * v
gamma = u.unsqueeze(-1) * K_mat * v.unsqueeze(-2)
return torch.matmul(gamma, V)温度参数的影响
| Attention行为 | |
|---|---|
| 近似one-hot(hard attention) | |
| 标准softmax | |
| 均匀分布 |
二、Transformer的Particle System模型
核心思想
Geshkovski等人将Transformer建模为交互粒子系统:
- Token = 球面上的粒子
- 层 = 时间演化步骤
- 注意力 = 粒子间相互作用
Mean-Field动态
在连续极限下,粒子系统由McKean-Vlasov方程描述:
聚类定理
经过足够深的Transformer后,Token会聚类到有限吸引子:
def compute_clustering_metrics(x):
"""
Compute clustering metrics for token representations
"""
x_norm = F.normalize(x, dim=-1)
S = torch.matmul(x_norm, x_norm.transpose(-2, -1))
# Effective number of clusters
mean_sim = S.mean(-1)
effective_clusters = (1 / (1 - mean_sim + 1e-8)).mean()
return effective_clusters.item()与Kuramoto模型的联系
| Kuramoto模型 | Transformer |
|---|---|
| 相位 | Token方向 |
| 耦合强度 | 温度 |
| 同步/失同步 | Token聚类/分散 |
三、LLM压缩泛化界
传统界的困境
传统PAC-Bayes界对GPT-4级模型是平凡的(vacuous):
Token-as-Data-Points框架
核心创新:使用计算量而非参数量度量复杂度:
非平凡界示例
def compute_token_pac_bayes_bound(compute, num_samples, empirical_risk):
"""
Compute non-vacuous bound using compute as complexity measure
"""
C_m_ratio = compute / num_samples
complexity = np.sqrt((C_m_ratio + np.log(2 * np.sqrt(compute))) / num_samples)
return min(empirical_risk + complexity, 1.0)
# 比较
traditional_bound(1.7e12 params, 1e12 samples) # ~1.0 (vacuous)
token_bound(1e25 FLOPs, 1e12 samples) # ~0.2 (non-vacuous)Compute-Optimal Scaling
在Chinchilla最优设置下(),泛化误差:
四、Contexture理论与表示学习
Contexture假设
核心思想:FM学习的是输入与上下文之间的关联表示:
六条对齐关系
| 关系 | 描述 |
|---|---|
| 输入-输入 | 同上下文的相似输入有相似表示 |
| 上下文-上下文 | 同输入的相似上下文有相似表示 |
| 跨任务 | 表示可跨任务迁移 |
| 组合性 |
Contexture与注意力
注意力机制正是实现Contexture的核心操作:
def contexture_attention(x, context):
"""
Contexture operation: query input against context
"""
q = W_q(x) # What to understand
k, v = W_k(context), W_v(context) # What to use
# Compute input-context association
scores = torch.matmul(q, k.T) / np.sqrt(d)
weights = F.softmax(scores, dim=-1)
return torch.matmul(weights, v)五、长度外推理论
问题定义
在长度为 上训练,能否泛化到 ?
任务复杂度分类
| 任务 | 电路复杂度 | 能否外推 |
|---|---|---|
| Copy | ✅ 能 | |
| 检索 | ✅ 能 | |
| Parity | ❌ 不能 | |
| 加法 | ⚠️ 部分 |
位置编码的影响
| 编码类型 | 内插质量 | 外推质量 |
|---|---|---|
| Absolute | 差 | 无 |
| Relative | 好 | 部分 |
| ALiBi | 好 | 好 |
| RoPE | 好 | 部分 |
六、对比学习泛化界
InfoNCE的信息论分析
对InfoNCE目标的泛化分析(Hieu et al., 2024):
其中 是表示维度, 是负样本数。
非平凡界条件
def check_non_vacuity(num_samples, repr_dim, neg_samples):
"""
Check if contrastive learning bound is non-vacuous
"""
bound = np.sqrt(repr_dim / (num_samples * np.log(neg_samples)))
return bound < 0.5七、开放问题与未来方向
理论-实践差距
| 理论预测 | 实际观察 | 差距原因 |
|---|---|---|
| 泛化界 | 实际泛化更好 | 隐式正则化 |
| 需要大量数据 | 小样本也能学 | 预训练迁移 |
未来研究方向
- 更紧的泛化界:如何进一步收紧理论界限?
- 任务依赖泛化:不同任务为何泛化行为差异巨大?
- 架构影响:为什么某些架构泛化更好?
- 动态系统视角:Mean-Field理论的更深入应用
八、实践建议
基于理论的实践指南
| 理论发现 | 实践建议 |
|---|---|
| 温度 影响注意力稀疏性 | 任务相关调参 |
| 计算量决定泛化 | 投资更多计算训练 |
| 位置编码影响外推 | 选择合适编码(ALiBi) |
| Contexture学习 | 关注上下文质量 |
调参建议
class TheoryBasedHyperparameters:
"""
Hyperparameter suggestions based on theory
"""
@staticmethod
def suggest_attention_temperature(task_type):
"""
Suggest attention temperature based on task
"""
if task_type == 'retrieval':
return 0.1 # Low temp for sharp attention
elif task_type == 'reasoning':
return 0.5 # Medium temp for balanced
else:
return 1.0 # Standard temperature
@staticmethod
def suggest_positional_encoding(seq_len, test_len):
"""
Suggest positional encoding based on sequence lengths
"""
if test_len > seq_len:
return 'alibi' # Best for extrapolation
else:
return 'roformer' # Good for in-distribution参考资料
最优传输与注意力
- Mensch & Blondel (2018). Differentiable dynamic programming
- Geshkovski et al. (2025). A mathematical perspective on transformers. AMS Bulletin
LLM泛化界
- Lotfi et al. (ICML 2024). Non-vacuous generalization bounds for LLMs
- Finzi et al. (ICLR 2025). Compute-optimal LLMs provably generalize better
Contexture理论
- Zhai et al. (2024). Contexture: A theory of representation learning in foundation models
长度外推
- Huang et al. (ICLR 2025). A formal framework for length generalization