RoPE 小迷思

RoPE 小迷思

题意

RoPE 的核心思想在于:存在一族线性映射 $M_i:\mathbb R^d\to\mathbb R^d (i\in\mathbb Z)$,使得对于任意的 $\mathbf q,\mathbf k\in\mathbb R^d$,

只与 $t-s$ 有关,于是可以在 Transformer 中用它记录相对位置信息。标准的 RoPE 中,上述线性映射由 $d/2$ 个旋转矩阵 $\begin{bmatrix}\cos(\theta) & -\sin(\theta)\ \sin(\theta) & \cos(\theta)\end{bmatrix}$ 组成。


现在我们稍微放宽条件,不再要求 $\mathbf q,\mathbf k$ 的任意性。

  • 给定整数 $d\ge 2$。求所有函数 $f:\mathbb Z\to\mathbb R$,使得存在 $\mathbf q,\mathbf k\in\mathbb R^d$,以及一族线性映射 $M_i:\mathbb R^d\to\mathbb R^d (i\in\mathbb Z)$,满足