Files
myWiki/concepts/token-shift.md

47 lines
1.6 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: "Token Shift"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: ["rwkv", "time-mixing", "sequence-modeling"]
sources: ["https://arxiv.org/abs/2503.14456"]
---
# Token Shift
## 定义
Token ShiftToken 偏移)是 RWKV 系列架构独有的时间混合技巧:通过将当前 token 与前一个 token 的表示做线性混合,让模型以极低成本获取**局部时序信息**,而不依赖显式位置编码或卷积。
## 机制
```
x_shifted = α ⊙ x_t + (1 - α) ⊙ x_{t-1}
```
其中 α 是可学习的逐通道混合系数。这个操作在 RWKV 每一层的时间混合Time Mixing模块中执行。
## 设计哲学
RWKV 不显式使用位置编码Transformer或卷积核Hyena/H3而是通过 token shift 这种**最小侵入**的时序注入方式:
- 仅需保存前一 token 的表示O(d) 而非 O(n)
- 不引入额外参数层
- 提供局部上下文感知,全局依赖由 WKV/Delta 循环状态完成
## 在 RWKV-7 中
RWKV-7 继承了 token shift 机制,但将其与 [[generalized-delta-rule]] 配合使用——shift 提供局部时序Delta 状态提供全局记忆。两者互补shift 负责"相邻 token 之间的平滑"Delta 负责"远距离的联想和状态追踪"。
## 相关概念
- [[wkv-time-mixing]] — Token shift 所在的时间混合模块
- [[rwkv]] — 使用 token shift 的全系列架构
- [[generalized-delta-rule]] — RWKV-7 的全局记忆机制
- [[peng-rwkv7|RWKV-7 论文]]
## 参考
- RWKV-4 (Peng et al., 2023) — 首次引入 token shift
- [[peng-rwkv7|RWKV-7 "Goose"]] (Peng et al., 2025)