20260706:新增一些文章
This commit is contained in:
43
concepts/markov-draft-head.md
Normal file
43
concepts/markov-draft-head.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: "Markov Draft Head"
|
||||
created: 2026-06-28
|
||||
updated: 2026-06-28
|
||||
type: concept
|
||||
tags: [speculative-decoding, draft-architecture, low-rank-factorization]
|
||||
sources: [DSpark]
|
||||
---
|
||||
# Markov Draft Head
|
||||
|
||||
马尔可夫草稿头是 [[DSpark]] 的[[semi-autoregressive-generation|半自回归生成(Semi-Autoregressive Generation)]]中最简单的顺序块实例化,将转移偏置 $B_k$ 限制为仅依赖**紧前一个 token**,简化为一个一阶转移矩阵 $B(x_{k-1}, x_k)$。
|
||||
|
||||
## 低秩分解
|
||||
|
||||
直接存储 $|\mathcal{V}| \times |\mathcal{V}|$ 的转移矩阵不现实(典型 $10^5 \times 10^5$)。采用低秩近似:
|
||||
|
||||
$$B = W_1 W_2^\top$$
|
||||
|
||||
- $W_1 \in \mathbb{R}^{|\mathcal{V}| \times r}$:充当嵌入查找表
|
||||
- $W_2 \in \mathbb{R}^{|\mathcal{V}| \times r}$:充当 logit 投影
|
||||
- 默认 rank $r = 256$
|
||||
|
||||
给定前一 token $x_{k-1}$,位置 $k$ 的转移偏置:
|
||||
|
||||
$$B(x_{k-1}, \cdot) = W_1[x_{k-1}] W_2^\top \in \mathbb{R}^{|\mathcal{V}|}$$
|
||||
|
||||
低秩分解使得存储和每步计算量都保持较小,即使对于大词汇表也能高效运行。
|
||||
|
||||
## 直觉
|
||||
|
||||
例如,当上下文允许多种延续 "of course" 和 "no problem" 时:
|
||||
- 若位置 1 采样了 "of",马尔可夫头在位置 2 提升 "course" 并抑制 "problem"
|
||||
- 有效缓解[[cross-mode-collision|跨模态碰撞(Cross-Mode Collision)]]
|
||||
|
||||
## 局限性
|
||||
|
||||
马尔可夫头是无记忆的——位置 $k$ 无法访问 $x_{k-2}$ 之前的 token。对于需要更长依赖的后缀连贯性,[[rnn-draft-head|RNN 草稿头]]通过循环状态累积完整前缀历史。
|
||||
|
||||
## 参考
|
||||
|
||||
- [[DSpark]]
|
||||
- [[semi-autoregressive-generation|半自回归生成(Semi-Autoregressive Generation)]]
|
||||
- [[rnn-draft-head|RNN 草稿头]]
|
||||
Reference in New Issue
Block a user