Skip to content

Transformer

Overview

Transformer is the foundational architecture of all modern LLM, based on the attention mechanism. It was introduced in 2017 and has since revolutionized everything.

Why Transformer Won

Before 2017, text was processed by recurrent networks (RNN, LSTM), which read words strictly in order—slowly and with loss of distant connections. Transformer broke this order: it looks at the entire text at once and decides for itself which words to pay attention to.

Attention Mechanism

The key idea is Self-Attention. For each word, the model calculates how it is related to all other words in the sentence. In the phrase “the cat drinks milk because he is hungry,” attention connects “he” specifically to “cat,” not to “milk.”

This allows:

  • capturing context across hundreds of words;
  • processing text in parallel (quickly);
  • scaling up to billions of parameters.

Architecture

Transformer consists of two types of blocks stacked together:

  • Encoder — understands the input (used in embedders, BERT).
  • Decoder — generates the output (used in GPT-like LLM).

Modern LLM (GPT, DeepSeek, Llama) are decoder-only transformers.

What is Built on Transformer

  • All modern LLMs
  • Multimodal models (partially)
  • Embedders for RAG

See Also