What is a transformer? The brain behind modern AI, intuitively explained

Estimated reading time: 6 minutes | Level: Beginner

If you use advanced artificial intelligence today, such as language models, chatbots, or automatic translators, you are using a transformer. Since the introduction of this architecture in 2017, it has sparked a revolution in the tech world. But what exactly does a transformer do under the hood, and why does it work so well?

In this module, we explain it without complex formulas or heavy math.

The problem with old AI

Before the transformer existed, computers looked at language like an assembly line in a factory: word by word, from left to right. This had a major drawback: if a sentence became long, the computer 'forgot' the beginning of the sentence. Furthermore, a computer could not properly determine the meaning of a word with multiple meanings (such as the word 'bank') without seeing the context of the entire sentence.

A transformer solves this by looking at all words in a sentence simultaneously and analyzing how they relate to each other.

The analogy: A group of editors

Imagine reading a complex book. Instead of one person reading the book word by word, you set up a large table with dozens of editors. Each editorial member is assigned one specific word.

As soon as the starting signal sounds, all editors shout across the room which other words in the text are important for their word. This way, the editor assigned to the word "bank" immediately knows whether it refers to money or sitting down, because they look at the relationship with words like "borrow" or "cushion" further down the text.

The secret weapon: This interconnected network of relationships is called Self-Attention. It enables the AI to instantly determine which words in a sentence deserve the most 'attention' to understand the true meaning.

Why does this work so well?

Thanks to the attention mechanism, a transformer can:

Practical Exercise

Look at the following sentence: "The cat claws gave the plant no water because they were too dry."

Question: What does 'they' mean in this sentence? Does it refer to the cat claws, the plant, or something else? How would a transformer solve this?

Hint: A transformer calculates the 'attention score' between 'they' and all possible nouns in the sentence to see which score is the highest. Share your findings with other creators in our community!