“I would also recommend checking out the phenomenal research by OfirPress on ALiBi which laid the foundation for many of these scaling techniques: Train Short, Test Long”
Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
ALiBi:用与距离成正比的注意力惩罚让 Transformer 外推到更长序列
论文研究 Transformer 如何在推理时处理比训练时更长的序列,先证明只需改变位置表示就能实现外推,但现有方法并不高效。作者提出 ALiBi:不给词嵌入加位置嵌入,而是用与距离成正比的惩罚去偏置查询与键之间的注意力分数。以 1024 长度训练的 13 亿参数模型可外推到 2048,困惑度与在 2048 长度上训练的正弦位置嵌入模型相同,训练还快 11%、省 11% 内存,并在 WikiText-103 上优于多种强位置方法。
讨论长上下文和位置编码时,评论者把 ALiBi 当作许多长度扩展技术的奠基工作,常拿它与 RoPE 对比,也用来指认某些模型采用的位置编码方式。
学习路径
读这篇之前,按顺序读书架上的 3 篇 · 参考文献来自 OpenAlex,顺序和要点由 Claude Code 排出这条路径帮你建立 Transformer 注意力、不同位置表示方式以及长上下文建模的前置知识,再看 ALiBi 如何用线性偏置做长度外推。
- 1
- 2
BERT 使用可学习的绝对位置嵌入,是长度外推受限的典型例子。
读抓输入表示里的位置嵌入部分,注意其最大长度固定为 512。
- 3
Transformer-XL 的相对位置编码和段级循环是解决长上下文的前一代方案,ALiBi 与之对比。
读读相对位置编码的设计和评估时使用更长上下文的做法。
- 4Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
不加位置嵌入,而是按距离给注意力分数加线性惩罚,实现短训长测。
读重点读 ALiBi 的偏置公式与各头的斜率设置,以及外推到更长序列的困惑度实验。
HN 书评
推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及“You can read the paper here Train Short, Test Long”
“They are using ALiBi (Attention with Linear Biases): Train Short, Test Long.”
“Also, have you guys experimented with ALiBi[1] which claims better extrapolative results than rotary positional encoding?”
“AliBi Attention: Train Short, Test Long”
“I believe it's ALiBi ("Attention with Linear Biases Enables Input Length Extrapolation"), a method of positional encoding”
看全部 7 条 →
“It would be easy to test by running this experiment against a baseline where both use alibi attention”
- Attention with Linear Biases (ALiBi) ↗pmoriarty · 2023-05-14 · 3 分