Files
myWiki/concepts/selective-state-space.md

57 lines
2.0 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: "Selective State Space (S6)"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: ["ssm", "mamba", "selection-mechanism", "architecture"]
sources: ["https://arxiv.org/abs/2312.00752"]
---
# Selective State Space (S6)
## 定义
Selective State SpaceS6是 Mamba 提出的核心机制,将 [[state-space-models|SSM]] 从线性时间不变LTI升级为输入依赖的参数化。S6 让 SSM 的 B、C、Δ 参数成为输入 x_t 的函数,使模型能够在序列维度上**选择性传播或遗忘信息**。
## 从 S4 到 S6
```
S4 (LTI): B, C, Δ — 所有时间步固定 → 卷积 OR 循环
S6: B_t = s_B(x_t), C_t = s_C(x_t), Δ_t = τ(Δ + s_Δ(x_t))
→ 仅循环scan但获得了选择性
```
| 维度 | S4 | S6 |
|------|-----|-----|
| 参数 | Parameter (D, N) | x 的函数 (B, L, N/D) |
| Δ | 标量参数 | 输入依赖步长 → 控制"关注多久" |
| 选择性 | 无(所有 token 同等对待) | 有(根据内容过滤/保留) |
| 计算 | 卷积 (训练) + 循环 (推理) | 仅循环 (需 scan) |
## 具体参数化
```python
B_t = Linear_N(x_t) # (B, L, N)
C_t = Linear_N(x_t) # (B, L, N)
Δ_t = softplus(Δ + Linear_1(x_t)) # (B, L, D)
A_bar, B_bar = discretize(Δ_t, A, B_t) # ZOH 离散化
```
Δ 的选择:`s_Δ = Broadcast_D(Linear_1(x))``τ_Δ = softplus`——与 RNN 门控机制GRU/LSTM有深层联系。
## 选择性 Δ 的门控解释
当 Δ_t 大 → 状态"重置",模型更关注当前输入而遗忘过去;当 Δ_t 小 → 状态"保持",模型忽略当前输入而保留历史。这与 LSTM 的遗忘门和 GRU 的更新门功能类似。
## 相关概念
- [[hardware-aware-algorithm]] — 选择性消除卷积后的高效计算方案
- [[content-based-reasoning]] — 选择性实现的根本能力
- [[structured-state-space-models]] — S4 前身LTI
- [[mamba-ssm]] — 使用 S6 的完整架构
- [[gu-mamba|Mamba 论文]]
## 参考
- [[gu-mamba|Mamba]] (Gu & Dao, 2024)