Files
myWiki/concepts/output-aware-metric.md

51 lines
2.2 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: "Output-Aware Metric (OAM)"
created: 2026-06-05
updated: 2026-06-05
type: concept
tags: [sparse-attention, value, token-selection, metric]
sources: [[niu-stem-causal-sparse-attention]]
---
# Output-Aware Metric (OAM)
**Output-Aware Metric** 是 [[stem-sparse-attention|Stem]] 框架的第二个核心组件,解决传统稀疏注意力**仅靠注意力分数选 token** 的盲区。
## 传统方法的局限
现有稀疏注意力(如 [[sparse-attention-patterns|各类稀疏模式]])的标准流程:
1. 计算注意力概率矩阵 P ∈ R^(N×N)
2. 对每行取 top-k按 P_{i,j} 的分数)
3. 仅保留 top-k 对应的 KV 对
问题P_{i,j} 只反映了 query i 对 key j 的**相关性**"我想关注这个 token"),但不反映 token j 的 Value 向量 V_j 对最终输出的**实际贡献度**"这个 token 的信息是否重要")。
## OAM 的核心思想
OAM 在 token 选择时引入 **Value 信息**
```
score(j) = f(P_{i,j}, ||V_j||)
```
不仅看 query-key 匹配度(注意力分数),还看 Value 向量的近似输出幅度(||V_j||)。高注意力分数 + 低 Value 幅度的 token 可能不如中等注意力 + 高 Value 幅度的 token 重要。
## 实现方式
1. **近似输出幅度**:基于 ||V_j|| 或其低秩近似估计 token 对最终输出的影响
2. **两信号融合**P 分数(相关性信号)和 V 幅度(重要性信号)的加权组合
3. **高效计算**:使用 V 向量的 norm 作为近似(无需完整计算 O = PV
## 与 TPD 的协同
| 组件 | 解决的问题 | 决策粒度 |
|------|-----------|---------|
| [[token-position-decay|TPD]] | **全局结构**:茎 vs 叶的预算分配 | 位置级 |
| OAM | **局部选择**:在每个位置选哪些 token | Token 级 |
TPD 决定"这个位置可以保留多少个 token"How manyOAM 决定"保留哪几个 token"Which ones。二者协同覆盖了稀疏化的结构层面和信息层面。
## 效果
在 LongBench 上OAM 使 Stem 在相同稀疏率下比纯注意力分数选 token 的方案提升 2-5% 的准确率,特别是在需要精确信息检索的长上下文任务(如 KV 检索)中优势最明显。