arXiv:2410.08633cs.LGstat.ML2024-10ICLR被引 55

Transformer通过思维链可高效解决奇偶性问题,理论证明其推理机制有效。

Transformers Provably Solve Parity Efficiently with Chain of Thought

  • 用思维链分解任务,通过中间步骤监督训练
  • 教师强制下一次梯度更新即可学会奇偶性判断
  • 无需教师强制时,增广数据能实现高效推理

本文首次对Transformer通过递归生成中间状态来求解复杂问题进行理论分析,类比于思维链(CoT)微调。研究训练单层Transformer求解基础的k-奇偶性问题,扩展了Wies等(2023)对RNN的工作。得出三个关键结论:(1) 任何有限精度的基于梯度的算法,在无中间监督的情况下,需大量迭代才能在有限样本下解决奇偶性问题;(2) 当将中间奇偶性纳入损失函数时,模型在教师强制(teacher forcing)下,仅需一次梯度更新即可学会奇偶性判断;(3) 即使无教师强制,模型需端到端生成思维链,但若引入增广数据以内部验证中间步骤的正确性,仍可高效学习奇偶性。数值实验支持这些发现,表明任务分解与分步推理自然源于优化带有思维链的Transformer;此外,自洽性检查可提升多步推理能力,与思维链的实证研究一致。

原文摘要 · Abstract (English)

This work provides the first theoretical analysis of training transformers to solve complex problems by recursively generating intermediate states, analogous to fine-tuning for chain-of-thought (CoT) reasoning. We consider training a one-layer transformer to solve the fundamental $k$-parity problem, extending the work on RNNs by Wies et al. (2023). We establish three key results: (1) any finite-precision gradient-based algorithm, without intermediate supervision, requires substantial iterations to solve parity with finite samples. (2) In contrast, when intermediate parities are incorporated into the loss function, our model can learn parity in one gradient update when aided by \emph{teacher forcing}, where ground-truth labels of the reasoning chain are provided at each generation step. (3) Even without teacher forcing, where the model must generate CoT chains end-to-end, parity can be learned efficiently if augmented data is employed to internally verify the soundness of intermediate steps. Our findings, supported by numerical experiments, show that task decomposition and stepwise reasoning naturally arise from optimizing transformers with CoT; moreover, self-consistency checking can improve multi-step reasoning ability, aligning with empirical studies of CoT.

Transformer思维链奇偶性理论分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。