{
  "source_file": "0930",
  "source_platform": "个人博客",
  "author": "苏剑林",
  "title_listed": "Transformer升级之路：12、无限外推的ReRoPE?",
  "keywords": "ReRoPE,长度外推,RoPE",
  "domain": "大模型算法",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://spaces.ac.cn/archives/9708",
  "publish_date": "2023-08",
  "corpus_stage": "预训练/SFT",
  "notes": "ReRoPE 方法提出",
  "id": "d23dc90f53b8",
  "collected_at": "2026-10-02T15:14:46",
  "title": "Transformer升级之路：12、无限外推的ReRoPE？ - 科学空间|Scientific Spaces",
  "body_markdown": "SEARCH\nMENU\n打赏\n公式\n天象\n链接\n时光\n博览\n归档\nCATEGORIES\n千奇百怪\n天文探索\n数学研究\n物理化学\n信息时代\n生物自然\n图片摄影\n问题百科\n生活/情感\n资源共享\nNEWPOSTS\n如何让GDN2更稳定一些？\n通过微扰分析求解等式约束优化问题\n慢即是快：1. Shampoo的尽...\n排序不等式及其推广\n让炼丹更科学一些（十）：单调性假设...\n让炼丹更科学一些（九）：经典自适应...\n让炼丹更科学一些（八）：多阶段训练...\n动量的新理解：逼近特征层面的梯度下降\n流形上的最速下降：7. Stief...\n除了交叉熵，LM Loss还有什么选择？\nCOMMENTS\ncarl_lei\n: 苏神，之前我一直有一个直觉是：MoE通过不同系数加权得到的FF...\nAli Hatamizadeh\n: Thank you for looking into this...\n苏剑林\n: 对于线性层，取max能得到谱范数，然后可以推出Muon，Muo...\n苏剑林\n: Thanks for sharing! I looked in...\nPurshow\n: 苏老师，请问下取max会不会影响控制下界太宽松了呢\nbookworm\n: 天下苦秦久矣，期待苏老师的教材！\nAli Hatamizadeh\n: Hi ! I am the lead GDN-2 author...\nyixiao chen\n: 谢谢苏神！代码在https://github.com/Chyx...\n苏剑林\n: 欢迎作者！我仔细读了一下，感觉写作还是很清晰的，至少比 htt...\n苏剑林\n: 免训练估计够呛，从实用的角度看，其实也不应该相信任何免训练的可能\nUSERLOGIN\n登录\n科学空间|Scientific Spaces\n登录\n打赏\n公式\n天象\n链接\n时光\n博览\n归档\n渴望成为一个小飞侠\n欢迎订阅\n个性邮箱\n天象信息\n观测ISS\nLaTeX\n关于博主\n欢迎访问“科学空间”，这里将与您共同探讨自然科学，回味人生百态；也期待大家的分享～\n千奇百怪\nEverything\n天文探索\nAstronomy\n数学研究\nMathematics\n物理化学\nPhy-chem\n信息时代\nBig-Data\n生物自然\nBiology\n图片摄影\nPhotograph\n问题百科\nQuestions\n生活/情感\nLife-Feeling\n资源共享\nResources\n千奇百怪\n天文探索\n数学研究\n物理化学\n信息时代\n生物自然\n图片摄影\n问题百科\n生活/情感\n资源共享\n首页\n信息时代\nTransformer升级之路：12、无限外推的ReRoPE？\n7\nAug\nTransformer升级之路：12、无限外推的ReRoPE？\nBy\n苏剑林\n|\n2023-08-07\n|\n137957位读者\n|\n:\n自从在\n《Transformer升级之路：11、将β进制位置进行到底》\n中引入混合进制的思路进一步推广了NTK-aware Scaled RoPE后，笔者感觉类似思路的效果已经达到了上限，想要更大幅度的提升就必须另辟蹊径了。这时候笔者想起了此前构思过的一个思路，该思路由于复杂度较高所以被搁置下了，既然现在已经遇到了瓶颈，那么“唯一的办法就是最好的办法”，于是便将它重拾起来。\n万万没想到的是，尽管该方法增加了一些推理复杂度，但它的实验效果却惊人地好——甚至隐约有无限的长度外推能力！因此，笔者迫不及待地撰写了本文来分享该方法。由于形式上跟ReLU激活函数的相似性，所以笔者将该方法命名为“\nReRoPE (Rectified Rotary Position Embeddings)\n”。\n重温\n#\n我们知道，\nRoPE\n形式上是一种绝对位置编码，但实际上给Attention带来的是相对位置信息，即如下的\nToeplitz矩阵\n：\n\\begin{equation}\\begin{pmatrix}0 & \\\\\n1 & 0 & \\\\\n2 & 1 & 0 &\\\\\n3 & 2 & 1 & 0 & \\\\\n\\ddots & 3 & 2 & 1 & 0 & \\\\\n\\ddots & \\ddots & 3 & 2 & 1 & 0 & \\\\\n\\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots \\\\\n\\small{L - 2} & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots \\\\\n\\small{L - 1} & \\small{L - 2} & \\ddots & \\ddots & \\ddots & 3 & 2 & 1 & 0 & \\\\\n\\end{pmatrix}\\label{eq:rope}\\end{equation}\n这里的$L$是当前样本长度。当$L$明显超出了训练长度时，多出来的位置由于没有被训练过，所以无法保证效果，这就是直接外推（Length Extrapolation）表现通常比较差的原因。\n后来，研究人员提出了位置内插（Position Interpolation），它相当于将相对位置矩阵改为：\n\\begin{equation}\\begin{pmatrix}0 & \\\\\n\\frac{1}{k} & 0 & \\\\\n\\frac{2}{k} & \\frac{1}{k} & 0 &\\\\\n\\frac{3}{k} & \\frac{2}{k} & \\frac{1}{k} & 0 & \\\\\n\\ddots & \\frac{3}{k} & \\frac{2}{k} & \\frac{1}{k} & 0 & \\\\\n\\ddots & \\ddots & \\frac{3}{k} & \\frac{2}{k} & \\frac{1}{k} & 0 & \\\\\n\\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots \\\\\n\\small{\\frac{L-2}{k}} & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots & \\ddots \\\\\n\\small{\\frac{L-1}{k}} & \\small{\\frac{L-1}{k}} & \\ddots & \\ddots & \\ddots & \\frac{3}{k} & \\frac{2}{k} & \\frac{1}{k} & 0 & \\\\\n\\end{pmatrix}\\end{equation}\n这样一来，只要调整$k$，就可以保证最大的相对位置也不超过训练长度，因此避免了外推。然而，它使得位置信息更加“拥挤”了，所以还需要进行一定步数的微调才能让模型重新工作。而也正因为避免了外推，所以它所需要的微调步数相比直接外推要少得多（神经网络往往更擅长内插而不是外推）。\n至于后面提出的NTK-aware Scaled RoPE，则是“剑走偏锋”，巧妙地将外推压力平摊到每一个维度上，所以它不微调也能有不错的效果，但它终究还是依赖外推，这是神经网络不擅长的事情，所以效果存在上限，在笔者的实验中，它的Long Context表现还无法很接近训练效果。\n融合\n#\n我们也可以从语言模型的局域性来考察这些方法。所谓局域性，是指语言模型在推断下一个token时，明显更依赖于邻近的token。直接外推保持了局域性（0附近位置编码不变），效果差是因为引入了超出训练长度的位置编码；位置内插虽然没有外推位置编码，但扰乱了局域性（0附近位置编码被压缩为$1/k$），所以不微调效果也不好；而NTK-aware Scaled RoPE通过“高频外推、低频内插”隐含了两者优点，保证了局域性，又没有明显外推位置编码，所以不微调也有不错的效果。\n有没有能更直接地结合外推和内插的方法呢？有，我们可以设定一个窗口大小$w$，在窗口内我们使用大小为$1$的位置间隔，在窗口外我们使用大小为$1/k$的位置间隔，整个相对位置矩阵如下：\n\\begin{equation}\\begin{pmatrix}\n\\color{red}{0} & \\\\\n\\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\small{w + \\frac{1}{k}}} & \\color{green}{w} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\small{w + \\frac{2}{k}}} & \\color{green}{\\small{w + \\frac{1}{k}}} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\ddots} & \\color{green}{\\small{w + \\frac{2}{k}}} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\\\\n\\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\small{w + \\frac{2}{k}}} & \\color{green}{\\small{w + \\frac{1}{k}}} & \\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\small{w + \\frac{L-1-w}{k}}} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\small{w + \\frac{2}{k}}} & \\color{green}{\\small{w + \\frac{1}{k}}} & \\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\end{pmatrix}\\label{eq:leaky-rerope}\\end{equation}\n只要$w$小于训练长度，那么通过控制$k$，我们就可以在精确保持了局域性的前提下，使得所有位置编码不超过训练长度，简单直接地结合了直接外推和位置内插。\n特别地，矩阵$\\eqref{eq:leaky-rerope}$还有一个特别的case：当$k\\to\\infty$时，它简化为\n\\begin{equation}\\begin{pmatrix}\n\\color{red}{0} & \\\\\n\\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{w} & \\color{green}{w} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{w} & \\color{green}{w} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\ddots} & \\color{green}{w} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\color{red}{\\ddots} & \\\\\n\\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{w} & \\color{green}{w} & \\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\color{green}{w} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{\\ddots} & \\color{green}{w} & \\color{green}{w} & \\color{green}{w} & \\color{red}{\\small{w - 1}} & \\color{red}{\\ddots} & \\color{red}{2} & \\color{red}{1} & \\color{red}{0} & \\\\\n\\end{pmatrix}\\label{eq:rerope}\\end{equation}\n在这个case下，不管输入长度是多少，它的位置编码范围都不超过$w$，所以这是一种有可能支持任意长度的Context的方案！\n形式上，矩阵$\\eqref{eq:rerope}$、$\\eqref{eq:leaky-rerope}$与标准RoPE矩阵$\\eqref{eq:rope}$的关系，就相当于ReLU、Leaky ReLU与Linear的关系，所以笔者将$\\eqref{eq:rerope}$称为“\nReRoPE（Rectified RoPE）\n”，将$\\eqref{eq:leaky-rerope}$称为“\nLeaky ReRoPE\n”。\n计算\n#\n其实，类似的思路并不难想到，以往基于Attention Bias的相对位置编码（比如\n经典相对位置编码\n、\nT5位置编码\n）经常会出现这样的分块运算。然而跟这些相对位置编码不同，在RoPE中实现这样的分块运算会明显增加计算量，这也是该思路会被笔者搁置的主要原因。\n怎么理解增加计算量呢？我们知道RoPE是“通过绝对位置实现相对位置”，这样只能得到线性的相对位置，而矩阵$\\eqref{eq:leaky-rerope}$、$\\eqref{eq:rerope}$是非线性的（或者说分段线性的），要实现它只能算两次Attention矩阵，然后组合起来。具体来说，首先用标准的RoPE计算一次Attention矩阵（Softmax之前）\n\\begin{equation}a_{i,j}^{(1)} = \\left(\\boldsymbol{\\mathcal{R}}^i\\boldsymbol{q}_i\\right)^{\\top}\\left(\\boldsymbol{\\mathcal{R}}^j\\boldsymbol{k}_j\\right) = \\boldsymbol{q}_i^{\\top}\\boldsymbol{\\mathcal{R}}^{j-i}\\boldsymbol{k}_j\\end{equation}\n这里第一个等号是实现方式，第二个等号是等效结果，其中$\\boldsymbol{\\mathcal{R}}$就是RoPE的旋转矩阵，简单起见我们省略了Attention的scale因子。接着，我们需要计算间隔为$1/k$的RoPE的Attention矩阵（Leaky ReRoPE）：\n\\begin{equation}a_{i,j}^{(2)} = \\left(\\boldsymbol{\\mathcal{R}}^{(i-w)/k+w}\\boldsymbol{q}_i\\right)^{\\top}\\left(\\boldsymbol{\\mathcal{R}}^{j/k}\\boldsymbol{k}_j\\right) = \\boldsymbol{q}_i^{\\top}\\boldsymbol{\\mathcal{R}}^{(j-i+w)/k-w}\\boldsymbol{k}_j\\end{equation}\n如果是ReRoPE，那么简单一些：\n\\begin{equation}a_{i,j}^{(2)} = \\left(\\boldsymbol{\\mathcal{R}}^w\\boldsymbol{q}_i\\right)^{\\top}\\boldsymbol{k}_j = \\boldsymbol{q}_i^{\\top}\\boldsymbol{\\mathcal{R}}^w\\boldsymbol{k}_j\\end{equation}\n最后，根据$i - j < w$这个条件，将它们合并起来：\n\\begin{equation}a_{i,j} = \\left\\{\\begin{aligned}\n&a_{i,j}^{(1)},\\quad (i - j < w) \\\\[8pt] &a_{i,j}^{(2)}, \\quad (i - j \\geq w)\n\\end{aligned}\\right.\\end{equation}\n不管是ReRoPE还是Leaky ReRoPE，都不可避免地计算两次Attention矩阵（如果有更高效的实现方法，请赐教），这便是增加的计算量之一。此外，需要自定义计算Attention矩阵也导致了不能直接套用现成的flash attention实现，因此相对之下又增加了计算成本。\n另一方面，同样是由于非线性的相对位置，所以在自回归解码时，Key序列的cache只能存RoPE之前的，然后在每步解码时给整个Key序列补上对应的RoPE，这样的改动也会增加推理计算量。唯一的好消息是，在token by token解码时，从第二步开始Query序列的长度就为1，此时只需要为Key序列定制RoPE，那么可以只算一次Attention矩阵：\n\\begin{equation}a_{i,j} = \\left\\{\\begin{aligned}\n&\\boldsymbol{q}_i^{\\top}\\left(\\boldsymbol{\\mathcal{R}}^{\\max(j-i,-w)}\\boldsymbol{k}_j\\right), \\quad(\\text{ReRoPE})\\\\[8pt]\n&\\boldsymbol{q}_i^{\\top}\\left(\\boldsymbol{\\mathcal{R}}^{\\max(j-i,(j-i+w)/k-w)}\\boldsymbol{k}_j\\right), \\quad(\\text{Leaky ReRoPE})\n\\end{aligned}\\right.\\end{equation}\n实验\n#\n继续沿着\n《Transformer升级之路：11、将β进制位置进行到底》\n的设置，我们对ReRoPE进行了实验，效果如下表：\n\\begin{array}{c|cc}\n\\hline\n\\text{测试长度} & 512(\\text{训练}) & 4096(\\text{重复}) & 4096(\\text{不重复})\\\\\n\\hline\n\\text{Baseline} & 49.41\\% & 24.17\\% & 23.16\\% \\\\\n\\text{Baseline-}\\log n & 49.40\\% & 24.60\\% & 24.02\\% \\\\\n\\hline\n\\text{PI-RoPE} & 49.41\\% & 15.04\\% & 13.54\\% \\\\\n\\text{PI-RoPE-}\\log n & 49.40\\% & 14.99\\% & 16.51\\% \\\\\n\\hline\n\\text{NTK-RoPE-old} & 49.41\\% & 51.28\\% & 39.27\\% \\\\\n\\text{NTK-RoPE-}\\log n\\text{-old} & 49.40\\% & 61.71\\% & 43.75\\% \\\\\n\\hline\n\\text{NTK-RoPE-fixed} & 49.41\\% & 51.86\\% & 39.61\\% \\\\\n\\text{NTK-RoPE-}\\log n^{\\color{red}{\\dagger}}\\text{-fixed} & 49.41\\% & 55.94\\% & 41.11\\% \\\\\n\\text{NTK-RoPE-}\\log n\\text{-fixed} & 49.40\\% & 62.85\\% & 44.14\\% \\\\\n\\text{NTK-RoPE-mixed} & 49.41\\% & 53.09\\% & 40.12\\% \\\\\n\\text{NTK-RoPE-}\\log n^{\\color{red}{\\dagger}}\\text{-mixed} & 49.41\\% & 59.11\\% & 42.38\\% \\\\\n\\text{NTK-RoPE-}\\log n\\text{-mixed} & 49.40\\% & 68.91\\% & 45.41\\% \\\\\n\\hline\n\\text{ReRoPE-w256} & 49.41\\% & 77.90\\% & 48.48\\% \\\\\n\\text{ReRoPE-w256-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 82.40\\% & 48.85\\% \\\\\n\\text{ReRoPE-w256-}\\log n & 49.40\\% & \\boldsymbol{85.12\\%} & \\boldsymbol{49.07\\%} \\\\\n\\hline\n\\text{HFWA} & 48.70\\% & 80.84\\% & 48.15\\% \\\\\n\\hline\n\\end{array}\n正如文章开头所说，ReRoPE不微调外推的效果可谓出奇地好，不仅明显超越了此前最优的NTK-RoPE-mixed，还明显超过了从零预训练的\nHFWA\n！这里的$\\text{w256}$指的$w=256$，$\\log n^{\\color{red}{\\dagger}}$是指预训练没有加入$\\log n$缩放（比如LLAMA），测试阶段每个$\\boldsymbol{q}_n$都乘上$\\max(1, \\log_{\\text{maxlen}} n)$，$\\log n$则是指预训练就加入了$\\log n$缩放因子。\n以下是一些消融实验，显示出ReRoPE关于$w$还是很鲁棒的，最优值大致是训练长度的$1/4\\sim 1/2$左右：\n\\begin{array}{c|cc}\n\\hline\n\\text{测试长度} & 512(\\text{训练}) & 4096(\\text{重复}) & 4096(\\text{不重复})\\\\\n\\hline\n\\text{ReRoPE-w64} & 49.41\\% & 69.39\\% & 45.19\\% \\\\\n\\text{ReRoPE-w64-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 78.58\\% & 47.42\\% \\\\\n\\text{ReRoPE-w64-}\\log n & 49.40\\% & 84.38\\% & 48.14\\% \\\\\n\\hline\n\\text{ReRoPE-w128} & 49.41\\% & 76.11\\% & 47.82\\% \\\\\n\\text{ReRoPE-w128-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 82.28\\% & 48.78\\% \\\\\n\\text{ReRoPE-w128-}\\log n & 49.40\\% & \\boldsymbol{85.47\\%} & 48.87\\% \\\\\n\\hline\n\\text{ReRoPE-w256} & 49.41\\% & 77.90\\% & 48.48\\% \\\\\n\\text{ReRoPE-w256-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 82.40\\% & 48.85\\% \\\\\n\\text{ReRoPE-w256-}\\log n & 49.40\\% & 85.12\\% & \\boldsymbol{49.07\\%} \\\\\n\\hline\n\\text{ReRoPE-w384} & 49.41\\% & 70.72\\% & 48.15\\% \\\\\n\\text{ReRoPE-w384-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 76.42\\% & 48.31\\% \\\\\n\\text{ReRoPE-w384-}\\log n & 49.40\\% & 83.24\\% & 48.62\\% \\\\\n\\hline\n\\text{ReRoPE-w512} & 49.41\\% & 7.09\\% & 8.25\\% \\\\\n\\text{ReRoPE-w512-}\\log n^{\\color{red}{\\dagger}} & 49.41\\% & 7.08\\% & 8.25\\% \\\\\n\\text{ReRoPE-w512-}\\log n & 49.40\\% & 15.84\\% & 10.83\\% \\\\\n\\hline\n\\end{array}\n下表则对比了ReRoPE和Leaky ReRoPE：\n\\begin{array}{c|cc}\n\\hline\n\\text{测试长度} & 512(\\text{训练}) & 4096(\\text{重复}) & 4096(\\text{不重复})\\\\\n\\hline\n\\text{ReRoPE-w128-}\\log n & 49.40\\% & \\boldsymbol{85.47\\%} & 48.87\\% \\\\\n\\text{Leaky ReRoPE-w128-k64-}\\log n & 49.40\\% & 85.29\\% & 48.96\\% \\\\\n\\text{Leaky ReRoPE-w128-k32-}\\log n & 49.40\\% & 85.31\\% & 49.03\\% \\\\\n\\text{Leaky ReRoPE-w128-k16-}\\log n & 49.40\\% & 85.15\\% & \\boldsymbol{49.10\\%} \\\\\n\\text{Leaky ReRoPE-w128-k8-}\\log n & 49.40\\% & 80.00\\% & 48.11\\% \\\\\n\\hline\n\\text{ReRoPE-w256-}\\log n & 49.40\\% & 85.12\\% & 49.07\\% \\\\\n\\text{Leaky ReRoPE-w256-k64-}\\log n & 49.40\\% & 84.60\\% & 49.03\\% \\\\\n\\text{Leaky ReRoPE-w256-k32-}\\log n & 49.40\\% & 84.30\\% & 48.97\\% \\\\\n\\text{Leaky ReRoPE-w256-k16-}\\log n & 49.40\\% & 83.59\\% & 48.87\\% \\\\\n\\text{Leaky ReRoPE-w256-k8-}\\log n & 49.40\\% & 69.80\\% & 45.72\\% \\\\\n\\hline\n\\end{array}\n作为ReRoPE的一般化，经过精调的Leaky ReRoPE是有机会超过ReRoPE的，但提升很微弱。此外，当$k$取有限值时，能处理的最大长度也是有限的，因为我们不能提前知道要生成的总长度，所以只能预设一个足够大的$k$，但设定为有限值之后，当输入足够长时，就会因为位置编码超出训练长度而效果大幅下降，相比之下ReRoPE则不会有这个风险。总的来说，精调Leaky ReRoPE相比ReRoPE的价值似乎不大。\n以上实验结果都只是在1亿参数的GAU模型上测试的，下面给出基于llama2-13b的测试结果（指标是loss，越小越好），它代表了在真正的LLM表现：\n\\begin{array}{c|cc}\n\\hline\n\\text{测试长度} & 4096(\\text{训练}) & 8192 & 16384\\\\\n\\hline\n\\text{RoPE} & 1.4967 & 8.8615 & \\text{-} \\\\\n\\text{NTK-RoPE} & 1.6081 & 1.5417 & 1.5163 \\\\\n\\text{ReRoPE} & 1.4996 & 1.4267 & 1.4001 \\\\\n\\hline\n\\end{array}\n可以看到，ReRoPE真正做到了几乎不损训练效果（RoPE-4096代表训练效果），并且满足“longer context, lower loss”的理想特点（更多的context应该更加有助于预测）。此外，笔者也在OpenBuddy开源的LLAMA2-13b微调模型上测试了chat的效果，自我感觉还不错（最多测试过20k tokens的Context）。\n最后，分享笔者在transformers的LLAMA模型基础上实现ReRoPE和Leaky ReRoPE的代码，读者也可以自行加载LLAMA系列模型进行测试：\nGithub：\nhttps://github.com/bojone/rerope\n小结\n#\n在这篇文章中，笔者提出了ReRoPE (Rectified RoPE)，它同样是一种RoPE的后处理方案，实验结果显示它的不微调长度外推能力不仅明显超过了此前的NTK-aware Scaled RoPE，甚至还超过了之前专门设计的需要从零训练的HFWA。此外，不同于NTK-aware Scaled RoPE在超过某个长度后能力会大幅下降，ReRoPE似乎在任意长度下都表现良好。除了对比实验外，文章还给出了基于transformers-llama的参考实现，有兴趣的读者可以自行测试。\n转载到请包括本文地址：\nhttps://spaces.ac.cn/archives/9708\n更详细的转载事宜请参考：\n《科学空间FAQ》\n如果您还有什么疑惑或建议，欢迎在下方评论区继续讨论。\n如果您觉得本文还不错，欢迎\n分享\n/\n打赏\n本文。打赏并非要从中获得收益，而是希望知道科学空间获得了多少读者的真心关注。当然，如果你无视它，也不会影响你的阅读。再次表示欢迎和感谢！\n打赏\n微信打赏\n支付宝打赏\n因为网站后台对打赏并无记录，因此欢迎在打赏时候备注留言。\n你还可以\n点击这里\n或在下方评论区留言来告知你的建议或需求。\n如果您需要引用本文，请参考：\n苏剑林. (Aug. 07, 2023). 《Transformer升级之路：12、无限外推的ReRoPE？ 》[Blog post]. Retrieved from\nhttps://spaces.ac.cn/archives/9708\n@online{kexuefm-9708,\ntitle={Transformer升级之路：12、无限外推的ReRoPE？},\nauthor={苏剑林},\nyear={2023},\nmonth={Aug},\nurl={\\url{https://spaces.ac.cn/archives/9708}},\n}\n分类：\n信息时代\n标签：\nattention\n,\n位置编码\n,\n泛化\n,\n外推\n,\nrope\n48 评论\n<\nTransformer升级之路：11、将β进制位置进行到底\n|\nTransformer升级之路：13、逆用Leaky ReRoPE\n>\n你也许还对下面的内容感兴趣\n如何让GDN2更稳定一些？\n简单谈谈K3的MoE和Attention\n将Softmax Attention线性化为Gated DeltaNet\nLogSumExp和Softmax的泰勒展开\nAttention Residuals 回忆录\nDeltaNet的核心逆矩阵的元素总是在[-1, 1]内\n为什么DeltaNet要加L2 Normalize？\n低精度Attention可能存在有偏的舍入误差\n为什么线性注意力要加Short Conv？\nQK-Clip：让Muon在Scaleup之路上更进一步\n发表你的看法\n«\n1\n2\n3\nTransformer升级之路：15、Key归一化助力长度外推 R11; AI 資訊\nNovember 20th, 2023\n[...]大体上，我们可以将目前Transformer的长度外推技术分为两类：一类是事后修改，比如NTK-RoPE、YaRN、ReRoPE等，这类方法的特点是直接修改推理模型，无需微调就能达到一定的长度外推效果，但缺点是它们都无法保持模型在训练长度内的恒等性；另一类自然是事前修改，如ALIBI、KERPLE、XPOS以及HWFA等，它们可以不加改动地实现一定的长度外推，但相应的改动需要在训练之前就引入，因此[...]\n回复评论\nltekills3g\nJanuary 3rd, 2024\n挺好奇为什么ReRope会比NTK-RoPE-mixed还要好？看起来ReRope损失了很多>w时候相对位置的信息啊？\n难道单纯是因为mixed分摊仍然很难合理化（距离越远训练越少），而ReRope这里可以充分训练所有的>w的远距离吗？\n回复评论\n苏剑林\n发表于\n                January 5th, 2024\n因为ReRoPE局部保持得更好，说明局部也是相当重要的。\n回复评论\nstan\nOctober 16th, 2024\n苏老师看了这篇新的对RoPE的解释的文章吗？https://arxiv.org/pdf/2410.06205\n回复评论\n苏剑林\n发表于\n                October 21st, 2024\n刷到了，有一些结论跟以前所构思的相符，但论文细节还没有认真阅读。\n回复评论\n探秘Transformer系列之（23）R12; 长度外推 | 呱唧呱唧网\nApril 6th, 2025\n[...]Transformer升级之路：12、无限外推的ReRoPE？[...]\n回复评论\n«\n1\n2\n3\n取消回复\n你的大名\n电子邮箱\n个人网站（选填）\n1. 可以使用LaTeX代码，点击“预览效果”可查看效果；\n2. 可以通过点击评论楼层编号来引用该楼层；\n3. 网站可能会有点卡，如非确认评论失败，请\n不要重复点击提交\n。\n内容速览\n重温\n融合\n计算\n实验\n小结\n智能搜索\n支持整句搜索！网站自动使用\n结巴分词\n进行分词，并结合ngrams排序算法给出合理的搜索结果。\n热门标签\nattention\n生成模型\n优化\n模型\n语言模型\n梯度\n优化器\n矩阵\n概率\n网站\n转载\n微分方程\n分析\n天象\n深度学习\n积分\npython\n几何\n扩散\n力学\n无监督\n损失函数\n节日\n线性\n生活\n随机文章\n三味Capsule：矩阵Capsule与EM路由\n《量子力学与路径积分》习题解答V0.2\nOCR技术浅探：3. 特征提取(1)\n基于量子化假设推导模型的尺度定律（Scaling Law）\n几个有关集合势的“简单”证明\n今天你食了吗？（广东云浮观测日偏食之旅）\nGlobalPointer下的“KL散度”应该是怎样的？\n三百年之谜——费马大定理(历史+证明)\n路径积分系列：2.随机游走模型\n貌离神合的RNN与ODE：花式RNN简介\n最近评论\ncarl_lei\n: 苏神，之前我一直有一个直觉是：MoE通过不同系数加权得到的FFN相比原始的大FFN（也就是直接...\nAli Hatamizadeh\n: Thank you for looking into this and featuring i...\n苏剑林\n: 对于线性层，取max能得到谱范数，然后可以推出Muon，Muon比Adam、SGD等要好，所以...\n苏剑林\n: Thanks for sharing! I looked into this improvem...\nPurshow\n: 苏老师，请问下取max会不会影响控制下界太宽松了呢\nbookworm\n: 天下苦秦久矣，期待苏老师的教材！\nAli Hatamizadeh\n: Hi ! I am the lead GDN-2 author.We've addressed...\nyixiao chen\n: 谢谢苏神！代码在https://github.com/Chyxx/CyclicFlowAtte...\n苏剑林\n: 欢迎作者！我仔细读了一下，感觉写作还是很清晰的，至少比 https://papers.cool...\n苏剑林\n: 免训练估计够呛，从实用的角度看，其实也不应该相信任何免训练的可能\n友情链接\nCool Papers\n数学研发\nSeatop\nXiaoxia\n积分表-网络版\n丝路博傲\n数学之家\n有趣天文奇观\nTwistedW\ngodweiyang\nAI柠檬\n王登科-DK博客\nESON\n枫之羽\ncoding-zuo\n博科园\n孔皮皮的博客\n运鹏的博客\njiming.site\nOmegaXYZ\nEAI猩球\n文举的博客\n汇尘轩\n申请链接\n本站采用创作共用版权协议，要求署名、非商业用途和保持一致。转载本站内容必须也遵循“\n署名-非商业用途-保持一致\n”的创作共用协议。\n© 2009-2026 Scientific Spaces. All rights reserved. Theme by\nlaogui\n. Powered by\nTypecho\n. 备案号:\n粤ICP备09093259号-1/2\n。",
  "metadata": {
    "title": "Transformer升级之路：12、无限外推的ReRoPE？ - 科学空间|Scientific Spaces",
    "description": "自从在《Transformer升级之路：11、将β进制位置进行到底》中引入混合进制的思路进一步推广了NTK-aware Scaled RoPE后，笔者感觉类似思路的效果已经达到了上限，想要更大幅...",
    "keywords": "attention,位置编码,泛化,外推,rope",
    "author": null
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/slide-button.png",
      "bytes": 4328,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-fcd8b7d1212b1f5eab2b.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/slide-button.png",
      "alt": "MobileSideBar",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/rss.png",
      "bytes": 19283,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-043e6308dc873ff9fa67.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/rss.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/mail.png",
      "bytes": 16811,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-942ff5c7b650f4d3d31f.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/mail.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/Saturn.png",
      "bytes": 2524,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-53b9d00850633d612de3.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/Saturn.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/iss.png",
      "bytes": 3301,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-896b482bdde5ec1df88a.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/iss.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/pi.png",
      "bytes": 939,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-3f7f2f2318249e4eac9a.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/pi.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/images/mlogo.png",
      "bytes": 18685,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-cbbace78f2cd4551d156.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/images/mlogo.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/payment/wx.png",
      "bytes": 36540,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-c5d79f289db1f5d431bc.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/payment/wx.png",
      "alt": "科学空间",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://spaces.ac.cn/usr/themes/geekg/payment/zfb.png",
      "bytes": 31565,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-4345e58697a529a3d3a5.png",
      "src": "https://spaces.ac.cn/usr/themes/geekg/payment/zfb.png",
      "alt": "科学空间",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://kexue.fm/usr/themes/geekg/images/cc.gif",
      "bytes": 2031,
      "reused": false,
      "local_path": "attachments/d23dc90f53b8/images/body-b2904ced8e4508d61bed.gif",
      "src": "https://kexue.fm/usr/themes/geekg/images/cc.gif",
      "alt": "署名-非商业用途-保持一致",
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://spaces.ac.cn/reward.html",
      "label": "打赏",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/latex.html",
      "label": "公式",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/ac.html",
      "label": "天象",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/links.html",
      "label": "链接",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/me.html",
      "label": "时光",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/science.html",
      "label": "博览",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/content.html",
      "label": "归档",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Everything",
      "label": "千奇百怪",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Astronomy",
      "label": "天文探索",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Mathematics",
      "label": "数学研究",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Phy-chem",
      "label": "物理化学",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Big-Data",
      "label": "信息时代",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Biology",
      "label": "生物自然",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Photograph",
      "label": "图片摄影",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Questions",
      "label": "问题百科",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Life-Feeling",
      "label": "生活/情感",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/category/Resources",
      "label": "资源共享",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11945",
      "label": "如何让GDN2更稳定一些？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11928",
      "label": "通过微扰分析求解等式约束优化问题",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11917",
      "label": "慢即是快：1. Shampoo的尽...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11910",
      "label": "排序不等式及其推广",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11885",
      "label": "让炼丹更科学一些（十）：单调性假设...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11882",
      "label": "让炼丹更科学一些（九）：经典自适应...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11879",
      "label": "让炼丹更科学一些（八）：多阶段训练...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11875",
      "label": "动量的新理解：逼近特征层面的梯度下降",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11864",
      "label": "流形上的最速下降：7. Stief...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11854",
      "label": "除了交叉熵，LM Loss还有什么选择？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/10699/comment-page-3",
      "label": "carl_lei : 苏神，之前我一直有一个直觉是：MoE通过不同系数加权得到的FF...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11945/comment-page-1",
      "label": "Ali Hatamizadeh : Thank you for looking into this...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11340/comment-page-1",
      "label": "苏剑林 : 对于线性层，取max能得到谱范数，然后可以推出Muon，Muo...",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/1328/comment-page-1",
      "label": "bookworm : 天下苦秦久矣，期待苏老师的教材！",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11848/comment-page-2",
      "label": "苏剑林 : 免训练估计够呛，从实用的角度看，其实也不应该相信任何免训练的可能",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/admin/login.php",
      "label": "登录",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/",
      "label": "科学空间|Scientific Spaces",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/feed",
      "label": "欢迎订阅",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/119",
      "label": "个性邮箱",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/41",
      "label": "观测ISS",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708",
      "label": "Transformer升级之路：12、无限外推的ReRoPE？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9706",
      "label": "《Transformer升级之路：11、将β进制位置进行到底》",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/8265",
      "label": "RoPE",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Toeplitz_matrix",
      "label": "Toeplitz矩阵",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/8130",
      "label": "经典相对位置编码",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9603",
      "label": "HFWA",
      "type": "a"
    },
    {
      "href": "https://github.com/bojone/rerope",
      "label": "https://github.com/bojone/rerope",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/6508",
      "label": "《科学空间FAQ》",
      "type": "a"
    },
    {
      "href": "http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=tN7d1drY3drrx8H0xcWa19vZ",
      "label": "点击这里",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/attention/",
      "label": "attention",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E4%BD%8D%E7%BD%AE%E7%BC%96%E7%A0%81/",
      "label": "位置编码",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%B3%9B%E5%8C%96/",
      "label": "泛化",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%A4%96%E6%8E%A8/",
      "label": "外推",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/rope/",
      "label": "rope",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9728",
      "label": "Transformer升级之路：13、逆用Leaky ReRoPE",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11848",
      "label": "简单谈谈K3的MoE和Attention",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11823",
      "label": "将Softmax Attention线性化为Gated DeltaNet",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11814",
      "label": "LogSumExp和Softmax的泰勒展开",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11664",
      "label": "Attention Residuals 回忆录",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11563",
      "label": "DeltaNet的核心逆矩阵的元素总是在[-1, 1]内",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11486",
      "label": "为什么DeltaNet要加L2 Normalize？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11371",
      "label": "低精度Attention可能存在有偏的舍入误差",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11320",
      "label": "为什么线性注意力要加Short Conv？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/11126",
      "label": "QK-Clip：让Muon在Scaleup之路上更进一步",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-2",
      "label": "«",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-1",
      "label": "1",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3",
      "label": "3",
      "type": "a"
    },
    {
      "href": "https://news.aitime.space/2023/11/69309/",
      "label": "Transformer升级之路：15、Key归一化助力长度外推 R11; AI 資訊",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=23103",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=23436",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "https://kexue.fm/",
      "label": "苏剑林",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=23457",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=25522",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=25541",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "http://www.itfaba.com/jishufenxian/211006.html",
      "label": "探秘Transformer系列之（23）R12; 长度外推 | 呱唧呱唧网",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9708/comment-page-3?replyTo=27326",
      "label": "回复评论",
      "type": "a"
    },
    {
      "href": "https://github.com/fxsjy/jieba",
      "label": "结巴分词",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%94%9F%E6%88%90%E6%A8%A1%E5%9E%8B/",
      "label": "生成模型",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E4%BC%98%E5%8C%96/",
      "label": "优化",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%A8%A1%E5%9E%8B/",
      "label": "模型",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E8%AF%AD%E8%A8%80%E6%A8%A1%E5%9E%8B/",
      "label": "语言模型",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%A2%AF%E5%BA%A6/",
      "label": "梯度",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E4%BC%98%E5%8C%96%E5%99%A8/",
      "label": "优化器",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%9F%A9%E9%98%B5/",
      "label": "矩阵",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%A6%82%E7%8E%87/",
      "label": "概率",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%BD%91%E7%AB%99/",
      "label": "网站",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E8%BD%AC%E8%BD%BD/",
      "label": "转载",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%BE%AE%E5%88%86%E6%96%B9%E7%A8%8B/",
      "label": "微分方程",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%88%86%E6%9E%90/",
      "label": "分析",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%A4%A9%E8%B1%A1/",
      "label": "天象",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/",
      "label": "深度学习",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%A7%AF%E5%88%86/",
      "label": "积分",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/python/",
      "label": "python",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%87%A0%E4%BD%95/",
      "label": "几何",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%89%A9%E6%95%A3/",
      "label": "扩散",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E5%8A%9B%E5%AD%A6/",
      "label": "力学",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%97%A0%E7%9B%91%E7%9D%A3/",
      "label": "无监督",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/",
      "label": "损失函数",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E8%8A%82%E6%97%A5/",
      "label": "节日",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%BA%BF%E6%80%A7/",
      "label": "线性",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/tag/%E7%94%9F%E6%B4%BB/",
      "label": "生活",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/5155",
      "label": "三味Capsule：矩阵Capsule与EM路由",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/3476",
      "label": "《量子力学与路径积分》习题解答V0.2",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/3785",
      "label": "OCR技术浅探：3. 特征提取(1)",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9607",
      "label": "基于量子化假设推导模型的尺度定律（Scaling Law）",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/2964",
      "label": "几个有关集合势的“简单”证明",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/30",
      "label": "今天你食了吗？（广东云浮观测日偏食之旅）",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/9039",
      "label": "GlobalPointer下的“KL散度”应该是怎样的？",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/38",
      "label": "三百年之谜——费马大定理(历史+证明)",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/3750",
      "label": "路径积分系列：2.随机游走模型",
      "type": "a"
    },
    {
      "href": "https://spaces.ac.cn/archives/5643",
      "label": "貌离神合的RNN与ODE：花式RNN简介",
      "type": "a"
    },
    {
      "href": "https://papers.cool/",
      "label": "Cool Papers",
      "type": "a"
    },
    {
      "href": "https://bbs.emath.ac.cn/",
      "label": "数学研发",
      "type": "a"
    },
    {
      "href": "http://www.seatop.com.cn/",
      "label": "Seatop",
      "type": "a"
    },
    {
      "href": "https://xiaoxia.org/",
      "label": "Xiaoxia",
      "type": "a"
    },
    {
      "href": "https://kexue.fm/sci/integral/index.html",
      "label": "积分表-网络版",
      "type": "a"
    },
    {
      "href": "http://blog.dvxj.com/",
      "label": "丝路博傲",
      "type": "a"
    },
    {
      "href": "http://www.2math.cn/",
      "label": "数学之家",
      "type": "a"
    },
    {
      "href": "http://interesting-sky.china-vo.org/",
      "label": "有趣天文奇观",
      "type": "a"
    },
    {
      "href": "http://www.twistedwg.com/",
      "label": "TwistedW",
      "type": "a"
    },
    {
      "href": "https://godweiyang.com/",
      "label": "godweiyang",
      "type": "a"
    },
    {
      "href": "https://blog.ailemon.net/",
      "label": "AI柠檬",
      "type": "a"
    },
    {
      "href": "https://greatdk.com/",
      "label": "王登科-DK博客",
      "type": "a"
    },
    {
      "href": "https://blog.eson.org/",
      "label": "ESON",
      "type": "a"
    },
    {
      "href": "https://fzhiy.net/",
      "label": "枫之羽",
      "type": "a"
    },
    {
      "href": "https://coding-zuo.github.io/",
      "label": "coding-zuo",
      "type": "a"
    },
    {
      "href": "https://www.bokeyuan.net/",
      "label": "博科园",
      "type": "a"
    },
    {
      "href": "https://www.kppkkp.top/",
      "label": "孔皮皮的博客",
      "type": "a"
    },
    {
      "href": "https://yunpengtai.top/",
      "label": "运鹏的博客",
      "type": "a"
    },
    {
      "href": "https://jiming.site/",
      "label": "jiming.site",
      "type": "a"
    },
    {
      "href": "https://www.omegaxyz.com/",
      "label": "OmegaXYZ",
      "type": "a"
    },
    {
      "href": "https://www.robotech.ink/",
      "label": "EAI猩球",
      "type": "a"
    },
    {
      "href": "https://liwenju0.com/",
      "label": "文举的博客",
      "type": "a"
    },
    {
      "href": "https://kirigaya.cn/",
      "label": "汇尘轩",
      "type": "a"
    },
    {
      "href": "https://kexue.fm/links.html",
      "label": "申请链接",
      "type": "a"
    },
    {
      "href": "http://creativecommons.org/licenses/by-nc-nd/2.5/cn/",
      "label": "",
      "type": "a"
    },
    {
      "href": "http://www.laogui.com/",
      "label": "laogui",
      "type": "a"
    },
    {
      "href": "http://typecho.org/",
      "label": "Typecho",
      "type": "a"
    },
    {
      "href": "https://beian.miit.gov.cn/",
      "label": "粤ICP备09093259号-1/2",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:53:05Z",
  "source_url": "https://spaces.ac.cn/archives/9708",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 17127,
  "expected_body_images": 10,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/d23dc90f53b8/pages/source.html",
  "local_html": "attachments/d23dc90f53b8/pages/article.html",
  "body_base_path": "attachments/d23dc90f53b8/pages/",
  "body_markdown_path": "attachments/d23dc90f53b8/pages/article.md"
}