arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2402.17709cs.AIcs.CL
收藏

基于案例还是基于规则:Transformer 如何做数学?

Case-Based or Rule-Based: How Do Transformers Do the Math?

Institute for Artificial Intelligence, Peking University(北京大学人工智能研究院);National Key Laboratory of General Artificial Intelligence, BIGAI(北京智源人工智能研究院通用人工智能国家重点实验室)

Yi Hu, Xiaojuan Tang, Haotong Yang, Muhan Zhang

AI总结:

本研究通过干预实验证实Transformer在数学任务中采用基于案例的推理,并提出规则遵循微调(RFFT)技术,使其在加法任务上实现从1-5位到12位的长度泛化,准确率超95%。

摘要:

尽管现代大型语言模型(LLMs)在各种复杂任务中表现出色,但它们仍然难以处理一些对人类来说简单直观的数学问题,例如加法。虽然我们可以轻松学习加法的基本规则并将其应用于任意长度的新问题,但 LLMs 却难以做到这一点。相反,它们可能依赖训练语料库中见过的相似案例来寻求帮助。我们将这两种不同的推理机制定义为“基于规则的推理”和“基于案例的推理”。由于基于规则的推理对于获得系统性泛化能力至关重要,我们旨在探究 Transformer 在处理数学问题时究竟是使用基于规则的推理还是基于案例的推理。通过在五个数学任务上精心设计的干预实验,我们确认 Transformer 执行的是基于案例的推理,无论是否使用草稿本(scratchpad),这与先前观察到的 Transformer 使用子图匹配/捷径学习进行推理的结论一致。为了缓解此类问题,我们提出了一种规则遵循微调(RFFT)技术,以教导 Transformer 执行基于规则的推理。具体来说,我们在输入中提供明确的规则,然后指示 Transformer 逐步背诵并遵循这些规则。通过 RFFT,我们成功使在 1-5 位加法上微调的 LLMs 泛化到最多 12 位加法,准确率超过 95%,比使用草稿本(scratchpad)高出 40% 以上。这一显著改进表明,明确教导 LLMs 使用规则有助于它们学习基于规则的推理,并在长度上实现更好的泛化。

英文摘要:

Despite the impressive performance in a variety of complex tasks, modern large language models (LLMs) still have trouble dealing with some math problems that are simple and intuitive for humans, such as addition. While we can easily learn basic rules of addition and apply them to new problems of any length, LLMs struggle to do the same. Instead, they may rely on similar cases seen in the training corpus for help. We define these two different reasoning mechanisms as "rule-based reasoning" and "case-based reasoning". Since rule-based reasoning is essential for acquiring systematic generalization ability, we aim to explore exactly whether transformers use rule-based or case-based reasoning for math problems. Through carefully designed intervention experiments on five math tasks, we confirm that transformers are performing case-based reasoning, no matter whether scratchpad is used, which aligns with the previous observations that transformers use subgraph matching/shortcut learning to reason. To mitigate such problems, we propose a Rule-Following Fine-Tuning (RFFT) technique to teach transformers to perform rule-based reasoning. Specifically, we provide explicit rules in the input and then instruct transformers to recite and follow the rules step by step. Through RFFT, we successfully enable LLMs fine-tuned on 1-5 digit addition to generalize to up to 12-digit addition with over 95% accuracy, which is over 40% higher than scratchpad. The significant improvement demonstrates that teaching LLMs to use rules explicitly helps them learn rule-based reasoning and generalize better in length.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑