0Pricing
AI Engineering Academy · Aula

Transformadores e atenção em linguagem simples

Desmistifique a arquitetura de transformadores explorando como os mecanismos de atenção permitem que os modelos se concentrem no contexto relevante sem exigir que você compreenda a matemática.

Transformadores e atenção em linguagem simples é uma aula grátis de AI Engineering Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de AI Engineering Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de AI Engineering Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

The Core Problem: Long-Range Dependencies

In "the trophy didn't fit in the bag because it was too big," what is "it"? Old models lost track over long sentences. This is the long-range dependency problem.

Attention as Weighted Focus

Attention is how a model decides which words matter most for each word — like highlighting the key parts of a passage instead of treating every word the same.

Queries, Keys, and Values

Attention works like a search: each word sends a Query, matches it against every Key, and pulls in the most relevant Values. The code below shows the core idea.

# Simplified self-attention in pseudocode
import numpy as np

def scaled_dot_product_attention(Q, K, V):
    d_k = Q.shape[-1]  # dimension of keys
    scores = Q @ K.T / np.sqrt(d_k)  # scale to prevent vanishing gradients
    weights = np.exp(scores) / np.sum(np.exp(scores), axis=-1, keepdims=True)  # softmax
    output = weights @ V  # weighted sum of values
    return output

Multi-Head Attention: Multiple Perspectives

One attention head catches one kind of link. Multi-head attention runs many in parallel, so the model sees words through several lenses at once.

Positional Encodings: Adding Word Order

Attention alone ignores word order — "dog bites man" looks like "man bites dog." Positional encodings add a sense of position so order isn't lost.

Feed-Forward Layers After Attention

After attention shares context, a feed-forward network processes each word on its own. Interestingly, much of the model's factual knowledge seems to live here.

Encoder-Only vs Decoder-Only Models

BERT-style encoder-only models read all the text at once to understand it. GPT-style decoder-only models read left-to-right to generate it — which is what ChatGPT does.

Layer Stacking and Depth

Modern LLMs stack dozens of Transformer blocks. Each layer refines the last — early ones catch grammar, deeper ones handle reasoning. More depth, more thinking.

Residual Connections and Layer Normalization

Stacking many layers is tricky. Residual connections and layer normalization keep the signal stable, so deep models can train reliably at 100+ layers.

Why Attention Scales So Well

Attention is easy to run in parallel, so more GPUs mean faster training. That's how researchers trained on huge data and uncovered the famous scaling laws.

Flash Attention and Modern Optimizations

Long inputs make standard attention very memory-hungry. FlashAttention computes the same result far more efficiently, making big context windows practical.

Quick Check

Test your understanding of AI Engineering concepts from this lesson.

Lesson Recap

Recap: self-attention links every word to every other, multi-head attention captures many relationships at once, and residuals plus normalization let models go deep. Next: how LLMs are trained.

Perguntas Frequentes

A aula “Transformadores e atenção em linguagem simples” é grátis?

Sim — o texto completo de “Transformadores e atenção em linguagem simples” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de AI Engineering Academy, atualize para CoddyKit PRO. O curso de AI Engineering Academy inclui 4 aulas no total.

O que vou aprender em “Transformadores e atenção em linguagem simples”?

Desmistifique a arquitetura de transformadores explorando como os mecanismos de atenção permitem que os modelos se concentrem no contexto relevante sem exigir que você compreenda a matemática. Você pratica AI Engineering Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar AI Engineering Academy?

Nenhuma experiência prévia é necessária. AI Engineering Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Transformadores e atenção em linguagem simples”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de AI Engineering Academy?

Sim. Cada aula de AI Engineering Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Do preenchimento automático ao ChatGPT
  2. Transformadores e atenção em linguagem simples
  3. Como os LLMs são treinados
  4. Capacidades e limitações dos LLMs
← Voltar para AI Engineering Academy