Transformer Model
A specific type of neural network that is the key invention driving modern AI.
More
It's not just for text; it can be adapted for voice, images, and more.
Mar 31, 2024
3Blue1Brown visually explains the Transformer neural network architecture behind the recent AI boom, detailing how it converts text into numerical vectors and uses attention to predict the next word.
A specific type of neural network that is the key invention driving modern AI.
It's not just for text; it can be adapted for voice, images, and more.
The process of converting words (tokens) into high-dimensional vectors.
In this "embedding space," the distance and direction between vectors carry semantic meaning, allowing for analogies like King - Man + Woman โ Queen.
The primary task of a language model like GPT is to predict the most probable next "token" (a word or piece of a word) in a sequence.
By repeatedly doing this, it generates coherent, long-form text.
The video makes a critical distinction between the model's weights (the billions of learned parameters that define the model's "brain") and the data (the input text being processed).
▶ Watch at 12:12The model is Generative (creates new content), Pre-trained on vast amounts of data, and based on the Transformer architecture.
The video outlines the fundamental steps of data processing in a Transformer:
“A transformer is a specific kind of neural network, a machine learning model, and it's the core invention underlying the current boom in AI.”
“The big idea here is that as a model tweaks and tunes its weights... it tends to settle on a set of embeddings where directions in the space have a kind of semantic meaning.”
“You should draw a very sharp distinction in your mind between the weights of the model... and the data being processed... The weights are the actual brains. They are the things learned during training and they determine how it behaves.”
The narrator of this episode points out that a single invention, a specific kind of machine learning model called a Transformer, is the core architecture behind the current boom in artificial intelligence. In this episode, which came out on March 31, 2024, the narrator gives a visual overview of how these models actually process information. By the end, you will understand how a machine turns plain words into numbers to predict what comes next.
Let us start by unlocking the three words hidden inside the letters G, P, and T. G, P, T stands for Generative Pre-trained Transformer. The model is generative because it creates new content, and it is pre-trained because it has already learned from vast amounts of data. Most importantly, it is built on the Transformer architecture.
That brings us to how one neural network architecture powers text, voice, and images alike. As the narrator explains, a Transformer is a specific kind of neural network, which is a machine learning model. While it powers text systems, this same fundamental technology is adapted to build voice to text tools, machine translation, and even text to image generators like DALL E.
So how does this network actually write? A language model like GPT has one primary task: predicting the most probable next token in a sequence. A token is simply a word or a small piece of a word. By repeatedly guessing the next most likely token based on the text that came before it, the model builds long, coherent passages of text one piece at a time.
To make those predictions, the machine has to turn words into geometry, where directions hold actual meaning. A deep learning model cannot process raw text, audio, or images until that information is converted into high-dimensional numerical vectors. This conversion process is called word embedding. Because meaning is mapped like directions on a compass, you can do math with words: taking the vector for King, subtracting Man, and adding Woman gets you approximately to the vector for Queen.
Once words become numbers, they take a four step journey through the Transformer. The data flow begins when input text is broken into tokens and converted into numerical vectors via an embedding matrix. Next, these vectors pass through specialized processing layers called Attention blocks and Multilayer Perceptron blocks, which update the vectors based on the surrounding context. Finally, the updated vector passes through an unembedding matrix and a mathematical tool called a softmax function, turning the numbers back into a list of probabilities for every possible next token.
To understand that journey, you have to separate the machine's permanent brain from the temporary text passing through it. The data is simply the dynamic input text being processed at that moment. The weights, on the other hand, are the billions of learned parameters tuned during training: they are the actual brains of the model, and they determine how it behaves.
If you remember one thing, let it be that the T in GPT, the Transformer, is the single most important component making large language models possible. "A transformer is a specific kind of neural network, a machine learning model, and it's the core invention underlying the current boom in AI."
3Blue1Brown
3Blue1Brown
3Blue1Brown
3Blue1Brown
3Blue1Brown
3Blue1Brown
3Blue1Brown
3Blue1Brown
Grant Sanderson
Eye on AI
The AI Daily Brief: Artificial Intelligence News and Analysis
Steve Eisman
Lenny's Podcast: Product | Career | Growth
Eye on AI
Machine Learning Street Talk
Machine Learning Street Talk