Skip to content
AI for Everyone

Transformer

Concept

A three-step diagram. Step 1 shows the sentence “The animal didn’t cross the street because it was too tired,” with the word “it” highlighted. Step 2 shows weight bars: the longest one for “animal” and shorter ones for “street,” “tired,” and “cross.” Step 3 gives the result: “it” refers to “animal.”
The attention mechanism lets the model work out which words in a sentence matter for understanding a given word. Bar lengths are illustrative only. The example comes from Google’s Machine Learning Glossary.Diagram: AI for Everyone

Ashish Vaswani and his coauthors introduced the transformer in 2017, in a paper titled “Attention Is All You Need.” They dropped the approaches that machine translation models had relied on until then (recurrent and convolutional networks) and built the whole network on the attention mechanism. They tested the new architecture on English-to-German and English-to-French translation.

An example from Google’s Machine Learning Glossary shows how attention works. In the sentence “The animal didn’t cross the street because it was too tired,” a model processing the word “it” gives the most weight to the word “animal.” That weighting is how the model figures out what “it” refers to. A transformer stacks many layers that each use this kind of attention. Large language models, including GPT and Gemini, are built on this architecture.

In my articles

In my February 2025 article on generative AI, I compare transformers to a very attentive reader who remembers not just the last sentence but also earlier plot threads and can connect them. That comparison captures the attention mechanism well, because the model can reach back to distant words, not just neighboring ones. In the article, I name transformers alongside GANs as a foundation of generative AI.

Sources

Related articles

Related entries

Last checked:

All entries