Трансформер (Архитектура)

Transformer — это модель глубокого обучения, использующая механизмы самовнимания для оценки важности различных частей входных данных при их обработке, преуспевающая в таких задачах, как обработка естественного языка.

Transformers, представленные в статье «Attention is All You Need», произвели революцию в области искусственного интеллекта, особенно в обработке естественного языка (NLP). В отличие от рекуррентных нейронных сетей (RNN), которые обрабатывают данные последовательно, Transformers используют самовнимание для одновременного анализа всех входных данных, что позволяет выполнять параллелизацию и ускорять обучение. Эта архитектура позволяет модели понимать взаимосвязи между различными частями входных данных, что приводит к повышению производительности в таких задачах, как машинный перевод, суммаризация текста и ответы на вопросы. Механизм самовнимания позволяет модели фокусироваться на наиболее релевантных частях входной последовательности, независимо от их положения, эффективно улавливая долгосрочные зависимости.

        graph LR
  Center["Трансформер (Архитектура)"]:::main
  Pre_neural_network["neural-network"]:::pre --> Center
  click Pre_neural_network "/terms/neural-network"
  Pre_linear_algebra["linear-algebra"]:::pre --> Center
  click Pre_linear_algebra "/terms/linear-algebra"
  Pre_deep_learning["deep-learning"]:::pre --> Center
  click Pre_deep_learning "/terms/deep-learning"
  Rel_transformer_architecture["transformer-architecture"]:::related -.-> Center
  click Rel_transformer_architecture "/terms/transformer-architecture"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Проверка знаний

1 / 3

🧒 Простыми словами

📖 Представьте, что вы читаете длинное предложение. Вместо того чтобы читать по одному слову слева направо, Трансформер видит все предложение целиком и сразу. Он использует 'маркер' (внимание), чтобы выделить самые важные слова, которые помогают понять смысл каждого отдельного слова.

🤓 Expert Deep Dive

The Transformer model's success stems from its ability to model dependencies without regard to their distance in the input or output sequences. The self-attention mechanism computes a weighted sum of value vectors, where the weight assigned to each value is determined by the compatibility (dot product) of its corresponding key vector with a query vector. This allows for direct modeling of relationships between any two positions in the sequence. Multi-head attention further enhances this by allowing the model to jointly attend to information from different representation subspaces at different positions. The encoder uses stacked self-attention and point-wise feed-forward layers, while the decoder adds masked self-attention (to prevent attending to future tokens) and encoder-decoder attention. The absence of recurrence makes it highly parallelizable, leading to faster training times on modern hardware compared to RNNs. However, the quadratic complexity of self-attention with respect to sequence length ($O(n^2)$) remains a bottleneck for very long sequences, prompting research into more efficient variants.

🔗 Связанные термины

Предварительные знания:

📚 Источники