O que é Transformer

Um Transformer é um modelo de deep learning que emprega mecanismos de autoatenção para ponderar a importância de diferentes partes dos dados de entrada ao processá-los, destacando-se em tarefas como processamento de linguagem natural.

Transformers, introduzidos no artigo "Attention is All You Need", revolucionaram o campo da IA, particularmente no processamento de linguagem natural (NLP). Ao contrário das redes neurais recorrentes (RNNs) que processam dados sequencialmente, os Transformers usam autoatenção para analisar todos os dados de entrada simultaneamente, permitindo a paralelização e um treinamento mais rápido. Essa arquitetura permite que o modelo entenda as relações entre diferentes partes da entrada, levando a um desempenho aprimorado em tarefas como tradução automática, resumo de texto e resposta a perguntas. O mecanismo de autoatenção permite que o modelo se concentre nas partes mais relevantes da sequência de entrada, independentemente de sua posição, capturando dependências de longo alcance de forma eficaz.

        graph LR
  Center["O que é Transformer"]:::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;

      

🧠 Teste de conhecimento

1 / 3

🧒 Explique como se eu tivesse 5 anos

It's like a super-smart reader that can look at all the words in a sentence at once and figure out which words are most important to understand the meaning of each individual word.

🤓 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.

🔗 Termos relacionados

📚 Fontes