[论文解读] Mastering Chess with a Transformer Model
本文提出 ChessFormer,一种基于 Transformer 的国际象棋架构,采用 Shaw 等人提出的多功能位置编码方案,在计算成本仅为原有方法几分之一的情况下,实现了最先进的对弈水平与解谜性能。其在 8 倍更少的 FLOPS 下超越 AlphaZero,在 30 倍更少的 FLOPS 下达到特级大师水平代理的性能,表明位置编码中的领域特定归纳偏置对国际象棋中自注意力机制的高效运行至关重要。
Transformer models have demonstrated impressive capabilities when trained at scale, excelling at difficult cognitive tasks requiring complex reasoning and rational decision-making. In this paper, we explore the application of transformers to chess, focusing on the critical role of the position representation within the attention mechanism. We show that transformers endowed with a sufficiently expressive position representation can match existing chess-playing models at a fraction of the computational cost. Our architecture, which we call the Chessformer, significantly outperforms AlphaZero in both playing strength and puzzle solving ability with 8x less computation and matches prior grandmaster-level transformer-based agents in those metrics with 30x less computation. Our models also display an understanding of chess dissimilar and orthogonal to that of top traditional engines, detecting high-level positional features like trapped pieces and fortresses that those engines struggle with. This work demonstrates that domain-specific enhancements can in large part replace the need for model scale, while also highlighting that deep learning can make strides even in areas dominated by search-based methods.
研究动机与目标
- 研究 Transformer 模型是否能在显著降低计算成本的前提下,实现与现有方法相比更高的国际象棋性能。
- 评估不同位置编码方案(绝对编码、相对编码与可学习相对编码)对 Transformer 在国际象棋中性能的影响。
- 证明精心设计的位置编码可使 Transformer 达到甚至超越 AlphaZero 等专用架构及特级大师水平代理的性能。
- 提供一个可扩展的开源训练框架,用于通过自监督自我对弈训练高效且高性能的国际象棋智能体。
提出的方法
- 采用带有缩放点积注意力的自注意力机制,其中查询、键和值投影从输入标记计算得出。
- 集成来自 Shaw 等人的可学习相对位置编码,引入可学习向量 $a_{ij}^Q$、$a_{ij}^K$ 和 $a_{ij}^V$,以建模国际象棋棋盘方格之间的位置关系。
- 通过蒙特卡洛树搜索(MCTS)进行自我对弈训练,其中策略头预测走法概率,价值头预测对局结果。
- 采用双头架构:一个用于策略(走法选择),一个用于价值(局面评估),两者均通过自监督自我对弈进行训练。
- 应用将国际象棋局面表示为 64 个方格特征序列的输入表示,包括棋子类型和颜色,并加入可学习的位置嵌入。
- 通过结合策略损失与价值损失进行模型优化,辅以温度缩放和标签平滑以提升训练稳定性。

实验结果
研究问题
- RQ1基于 Transformer 的架构是否能在显著减少 FLOPS 的前提下,实现与 AlphaZero 及其他特级大师水平代理相竞争的国际象棋对弈强度?
- RQ2位置编码的选择(绝对编码、相对偏差编码或可学习相对编码)如何影响 Transformer 在国际象棋中的性能表现?
- RQ3一种能够捕捉非欧几里得关系(如斜线)的多功能位置编码,在多大程度上能提升注意力效率与模型准确性?
- RQ4通过自我对弈训练的轻量化 Transformer 模型是否能在对局与解谜两方面达到甚至超越更大、更复杂的模型性能?
- RQ5架构选择(如输入表示与辅助头)对收敛速度与最终性能有何影响?
主要发现
- 采用 Shaw 等人位置编码的 ChessFormer 模型在 8 倍更少的 FLOPS 下,其国际象棋等级分(Elo)与解谜准确率均超越 AlphaZero。
- 在 30 倍更少的 FLOPS 下,CF-240M-policy 模型在解谜准确率上与特级大师水平的 GC-270M 代理持平,并在 Elo 表现上实现超越。
- 消融实验表明,来自 Shaw 等人的可学习相对位置编码在价值损失与策略准确率方面均显著优于绝对编码与相对偏差编码。
- 将模型参数量从 600 万增至 1200 万,策略准确率提升了约 1.5%,表明具有良好的可扩展性。
- 尽管仅使用 AlphaZero-policy 所需 FLOPS 的 1/8,CF-6M-policy 智能体在解谜与 Elo 表现上均优于 AlphaZero-policy。
- 开源训练代码已发布于 https://github.com/Ergodice/lczero-training,支持可复现性,并推动高效国际象棋人工智能的进一步研究。
![Figure 2 : Puzzle-solving ability on puzzles rated 1000-3000 of our CF-240M-policy and CF-240M-value agents against the GC-136M and GC-270M agents of Ruoss et al. [ 9 ] .](https://ar5iv.labs.arxiv.org/html/2409.12272/assets/figures/graphs/puzzles.png)
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。