arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2407.15360cs.CL
收藏

剖析Transformer中的乘法:对大型语言模型的洞察

Dissecting Multiplication in Transformers: Insights into LLMs

Hong Kong University of Science and Technology(香港科技大学);Hong Kong Polytechnic University(香港理工大学)

Luyu Qiu, Jianing Li, Chi Su, Chen Jason Zhang, Lei Chen

AI总结:

本文通过分析标准Transformer在整数乘法中的分解机制,指出其缺陷源于连续进位计算与中间结果缓存的困难,并提出改进方案,以微型模型在5位乘法上达到99.9%以上准确率,超越GPT-4,增强可解释性。

摘要:

基于Transformer的大型语言模型在各种自然语言处理任务中取得了显著性能。然而,尽管它们拥有强大的能力,却常常在看似简单的算术任务上表现不佳。这种鲜明反差引发了人们对其安全性和伦理使用的担忧,并阻碍了它们的广泛采用。在本文中,我们聚焦于一个典型的算术任务——整数乘法,以探索并解释Transformer在该领域的不足。我们对一个经过训练可执行n位整数乘法的标准Transformer进行了全面分析。我们的观察表明,该模型将乘法任务分解为多个并行的子任务,针对每一位数字依次优化每个子任务,以完成最终的乘法运算。基于观察与分析,我们推断Transformer在乘法任务中表现不佳的原因在于其难以计算连续进位和缓存中间结果,并通过实验证实了这一推断。在这些发现的指导下,我们提出了改进方案以提升Transformer在乘法任务上的性能。这些改进经过严格测试和数学建模验证,不仅增强了Transformer的可解释性,还提升了其性能,例如,我们使用一个微型Transformer在5位整数乘法上实现了超过99.9%的准确率,超越了大型语言模型GPT-4。我们的方法有助于模型理解和可解释性这一更广泛领域的发展,为分析更复杂的任务和Transformer模型铺平了道路。这项工作强调了可解释人工智能的重要性,有助于建立对大型语言模型的信任,并促进其在关键应用中的采用。

英文摘要:

Transformer-based large language models have achieved remarkable performance across various natural language processing tasks. However, they often struggle with seemingly easy tasks like arithmetic despite their vast capabilities. This stark disparity raise human's concerns about their safe and ethical use, hinder their widespread adoption.In this paper, we focus on a typical arithmetic task, integer multiplication, to explore and explain the imperfection of transformers in this domain. We provide comprehensive analysis of a vanilla transformer trained to perform n-digit integer multiplication. Our observations indicate that the model decomposes multiplication task into multiple parallel subtasks, sequentially optimizing each subtask for each digit to complete the final multiplication. Based on observation and analysis, we infer the reasons of transformers deficiencies in multiplication tasks lies in their difficulty in calculating successive carryovers and caching intermediate results, and confirmed this inference through experiments. Guided by these findings, we propose improvements to enhance transformers performance on multiplication tasks. These enhancements are validated through rigorous testing and mathematical modeling, not only enhance transformer's interpretability, but also improve its performance, e.g., we achieve over 99.9% accuracy on 5-digit integer multiplication with a tiny transformer, outperform LLMs GPT-4. Our method contributes to the broader fields of model understanding and interpretability, paving the way for analyzing more complex tasks and Transformer models. This work underscores the importance of explainable AI, helping to build trust in large language models and promoting their adoption in critical applications.

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

↑