Transformers have emerged as the cornerstone of state-of-the-art natural language processing models, showcasing exceptional performance across a wide range of AI applications. However, the memory demands posed by the self-attention mechanism and the large feedforward network in Transformers limit their ability to handle long sequences, thereby creating challenges for tasks involving multiple long sequences or long-term dependencies. We present a distinct approach, Blockwise Parallel Transformer (BPT), that leverages blockwise computation of self-attention and feedforward network fusion to minimize memory costs. By processing longer input sequences while maintaining memory efficiency, BPT enables training sequences 32 times longer than vanilla Transformers and up to 4 times longer than previous memory-efficient methods. Extensive experiments on language modeling and reinforcement learning tasks demonstrate the effectiveness of BPT in reducing memory requirements and improving performance.
翻译:Transformer已成为最先进自然语言处理模型的基石,在各类人工智能应用中展现出卓越性能。然而,自注意力机制和大型前馈网络带来的内存需求限制了其处理长序列的能力,从而为涉及多长序列或长期依赖性的任务带来挑战。我们提出一种独特方法——块并行Transformer(BPT),通过利用自注意力机制的块计算与前馈网络融合来最小化内存开销。在保持内存效率的同时处理更长的输入序列,BPT能够实现训练序列长度是原始Transformer的32倍,且比此前内存高效方法长4倍。在语言建模和强化学习任务上的大量实验证明,BPT在降低内存需求及提升性能方面具有有效性。