Files
myWiki/concepts/sparse-attention-patterns.md

32 lines
1.1 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: 稀疏注意力模式 (Sparse Attention Patterns)
created: 2025-04-15
updated: 2026-05-01
type: concept
tags: []
sources: []
---
# 稀疏注意力模式 (Sparse Attention Patterns)
**稀疏注意力**限制每个 Token 只关注序列的子集,将复杂度从 O(n²) 降至 O(n·k) 或 O(n·log n)。
## 主要类型
1. **局部窗口**: 每个 Token 只看固定窗口内的邻居 → O(n·w)
2. **全局+局部**: 少数全局 Token + 局部窗口Longformer, BigBird
3. **跨步注意力**: 固定步长的稀疏模式Sparse Transformer
4. **可学习稀疏**: 动态学习注意力模式([[seer-attention|SeerAttention]], [[native-sparse-attention|NSA]]
## 优势与局限
**优势**: 内存和计算线性缩放,支持极长序列。
**局限**: 稀疏模式可能遗漏关键的长距离依赖;硬件利用率低(不规则访问模式)。
## 相关概念
- [[linear-attention-methods]] — 另一种线性化路径
- [[seer-attention]] — 可学习稀疏
- [[native-sparse-attention]] — NSA (DeepSeek)
- [[llm-attention-survey-2026]] — 综述参考