This document is a follow-up to our previous paper dedicated to a vectorized derivation of backpropagation in CNNs. Following the same principles and notations already put in place there, we now focus on transformer-based next-token-prediction architectures. To this end, we apply our lightweight index-free methodology to new types of layers such as embedding, multi-headed self-attention and layer normalization. In addition, we also provide gradient expressions for LoRA layers to illustrate parameter-efficient fine-tuning. Why bother doing manual backpropagation when there are so many tools that do this automatically? Any gap in understanding of how values propagate forward will become evident when attempting to differentiate the loss function. By working through the backward pass manually, we gain a deeper intuition for how each operation influences the final output. A complete PyTorch implementation of a minimalistic GPT-like network is also provided along with analytical expressions for of all of its gradient updates.


翻译:本文是我们先前致力于卷积神经网络反向传播向量化推导论文的后续研究。沿用先前建立的相同原理与符号体系,我们现聚焦于基于Transformer的下一词元预测架构。为此,我们将轻量级无索引方法应用于新型层结构,例如嵌入层、多头自注意力机制与层归一化。此外,我们还提供了LoRA层的梯度表达式以阐释参数高效微调过程。既然存在众多可实现自动反向传播的工具,为何仍需进行手动推导?当尝试对损失函数进行微分时,任何关于数值前向传播机制的理解空白都将显现。通过手动推演反向传播过程,我们能更深入地理解每个运算如何影响最终输出。本文同时提供了完整的最小化类GPT网络的PyTorch实现及其所有梯度更新的解析表达式。

0
下载
关闭预览

相关内容

反向传播一词严格来说仅指用于计算梯度的算法,而不是指如何使用梯度。但是该术语通常被宽松地指整个学习算法,包括如何使用梯度,例如通过随机梯度下降。反向传播将增量计算概括为增量规则中的增量规则,该规则是反向传播的单层版本,然后通过自动微分进行广义化,其中反向传播是反向累积(或“反向模式”)的特例。 在机器学习中,反向传播(backprop)是一种广泛用于训练前馈神经网络以进行监督学习的算法。对于其他人工神经网络(ANN)都存在反向传播的一般化–一类算法,通常称为“反向传播”。反向传播算法的工作原理是,通过链规则计算损失函数相对于每个权重的梯度,一次计算一层,从最后一层开始向后迭代,以避免链规则中中间项的冗余计算。
【NeurIPS2025】迈向开放世界的三维“物体性”学习
专知会员服务
12+阅读 · 2025年10月21日
【阿姆斯特丹博士论文】表示学习中的信息理论
专知会员服务
23+阅读 · 2025年7月18日
UCL& UC Berkeley | 深度强化学习中的泛化研究综述
专知会员服务
61+阅读 · 2021年11月22日
从HPO到NAS: 自动深度学习
专知会员服务
39+阅读 · 2020年6月15日
【ACL2020-密歇根州立大学】语言和视觉推理的跨模态关联
R语言机器学习:xgboost的使用及其模型解释
R语言中文社区
11+阅读 · 2019年5月6日
使用CNN生成图像先验实现场景的盲图像去模糊
统计学习与视觉计算组
10+阅读 · 2018年6月14日
国家自然科学基金
39+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
14+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
16+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
39+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
14+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
16+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员