LLM & Transformer Fundamentals·Question 74 of 109Quick-fire

At a high level, how does a transformer work, and what is self-attention doing?

Quick-fire answer from the Awesome Generative AI Guide (MIT)

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

A transformer processes a sequence of token embeddings through stacked layers of self-attention and feed-forward networks. Self-attention lets every token weigh how much to draw from every other token, so the model builds context-dependent representations (the meaning of "bank" shifts based on surrounding words). Multiple attention heads capture different relationships in parallel. For decoder-only LLMs, attention is causal (a token only attends to earlier tokens), which is what makes next-token prediction possible.

Full worked answer

A transformer processes a sequence of token embeddings through stacked layers of self-attention and feed-forward networks. Self-attention lets every token weigh how much to draw from every other token, so the model builds context-dependent representations (the meaning of "bank" shifts based on surrounding words). Multiple attention heads capture different relationships in parallel. For decoder-only LLMs, attention is causal (a token only attends to earlier tokens), which is what makes next-token prediction possible.

Learn more: Foundations topic

What a good answer covers

  • A transformer processes a sequence of token embeddings through stacked layers of self-attention and…
  • Self-attention lets every token weigh how much to draw from every other token, so the model builds…
  • Multiple attention heads capture different relationships in parallel
  • For decoder-only LLMs, attention is causal (a token only attends to earlier tokens), which is what makes…

Key terms: Learn more

Quick-fire answer from the Awesome Generative AI Guide (MIT) · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep