Files
myWiki/concepts/long-range-dependency.md

40 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Long-Range Dependency"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: ["sequence-modeling", "memory", "architecture"]
sources: ["https://arxiv.org/abs/2312.00752"]
---
# Long-Range Dependency
## 定义
Long-Range Dependency长距离依赖是序列建模的核心挑战模型需要在相距很远的 token 之间建立有效的语义连接。Transformer 通过注意力实现了理论上的无限上下文窗口(受内存限制),而 SSM 通过 [[hippo]] 等数学工具在固定维度的隐状态中压缩长距离信息。
## 不同架构的处理方式
| 架构 | 机制 | 复杂度 | 限制 |
|------|------|--------|------|
| Transformer | 全对全注意力 | O(n²) 训练O(n) 推理内存 | KV cache 随序列线性增长 |
| LSTM/RNN | 隐状态 + 门控 | O(n) 训练O(1) 推理 | 梯度消失,容量有限 |
| S4 (LTI SSM) | HiPPO 隐状态 | O(n log n) 训练O(1) 推理 | 无内容感知 |
| Mamba (S6) | 选择性隐状态 | O(n) 训练O(1) 推理 | 选择性但无注意力式交互 |
## HiPPO 的作用
[[hippo|HiPPO]]High-order Polynomial Projection Operators为 SSM 提供了**数学上最优的在线压缩**——在给定隐状态维度下最大化对历史信息的保留能力。HiPPO-LegS 矩阵对输入的时间尺度变化具有鲁棒性,使 SSM 天然适合处理变化长度的长序列。
## 相关概念
- [[hippo]] — SSM 处理长距离依赖的数学基础
- [[structured-state-space-models]] — 基于 HiPPO 的 S4
- [[selective-state-space]] — Mamba 在此基础上增加选择性
- [[attention-mechanism]] — 注意力的长距离依赖方案
## 参考
- HiPPO (Gu et al., 2020)
- [[gu-mamba|Mamba]] (Gu & Dao, 2024)