Attention Mechanism and Transformers
摘要
This chapter explores the attentionAttention mechanism in machine learningLearningmachine learning, a concept inspired by the way human visual and cognitive systems selectively focus on the most informative parts of a scene or text. AttentionAttention enables models to assign varying levels of importance to different parts of the input data, making it a crucial component of modern Natural Language ProcessingNatural language processing (NLP) systems. The chapter begins by introducing the attentionAttention mechanism as a data-weighting strategy and explains its role in enhancing the performance of deepLearningdeep learning learningDeepdeep learning models, particularly in sequence modeling. A major breakthrough in this area was the introduction ofTransformer Transformers—models built from attentionAttention modules without any recurrence. This architectureArchitecture revolutionized NLP by replacing traditional recurrent networks such as Recurrent Neural NetworksRecurrent neural network (RNN) (RNNs) and Long Short-Term Memory (LSTM)Long short-term memory network (LSTM) networks, enabling more efficient training and parallelization. The chapter covers the encoderEncoder–decoderDecoder structure of TransformersTransformer and explains how they serve both as sequence-to-sequence autoencoders and as tools for transfer learning. Additionally, the chapter introduces TransformerTransformer alternatives, offering a broader perspective on the evolving landscape of attentionAttention-based architecturesArchitecture. Key variants of the TransformerTransformer model are presented, with a particular focus on the PerformerPerformer, which improves computational complexityComplexity through efficient approximationsApproximation of attentionAttention.