Attention Is All You Need: The paper that basically told RNNs to get a life

A research paper that changed how machines understand language, and probably deserves more attention than your 9 AM lecture.

16 min read ·

Let's be honest. Most of us are pursuing a degree in computer science, spending four years learning about things that we will probably forget two weeks after the semester ends, collecting attendance like it's a rare achievement, and preparing for exams with the enthusiasm of someone being sentenced to prison. We have 71 tabs open, three unfinished projects, a GitHub profile that looks more promising than our academic performance, and somehow we still manage to find time to scroll through Instagram for two hours. But ask someone what actually changed the direction of modern artificial intelligence, and suddenly the entire room becomes suspiciously quiet. Apparently, knowing the difference between a primary key and a foreign key is more urgent than understanding the architecture behind the AI tools we're using every single day. Fair enough.
One gets you marks; the other might actually get you somewhere. Anyway, today I want to talk about a research paper that I genuinely think deserves a place on every curious AI student's reading list. A paper with a title that sounds almost too confident: Attention Is All You Need.

Published in 2017 by eight researchers at Google, this paper introduced the Transformer architecture. And if you're studying AI, you've probably heard the word Transformer approximately 300 times by now. GPT, BERT, modern language models, generative AI, ChatGPT — the architecture has become a fundamental part of the story behind modern AI. But what makes this paper interesting isn't simply that it introduced another neural network architecture. It's the problem the researchers were trying to solve, the assumptions they questioned, and the rather bold decision to build an architecture based entirely on attention mechanisms, without recurrence or convolution. To understand why that was such a big deal, we need to go a little backwards.

Before Transformers, machines had a rather exhausting way of reading things.

Imagine reading a 500-page textbook, but you're only allowed to understand one word at a time. You read the first word, remember something about it, move to the second, update your understanding, then move to the third. You cannot jump ahead, revisit everything simultaneously, or process multiple positions in parallel. Sounds like a terrible study strategy? Congratulations, you've just got an idea of how recurrent neural networks process sequences. Before Transformers, RNNs were widely used for sequence modelling, particularly in tasks such as language modelling and machine translation. They processed information sequentially, maintaining a hidden state that carried information from previous time steps. Every new token updated that state, allowing the model to incorporate information from earlier tokens. The problem? As sequences became longer, maintaining useful information from much earlier positions became difficult. Think about a professor mentioning an important concept in the first lecture and asking you about it during the final lecture. Even you, a biological neural network with questionable time-management skills, might struggle. Vanilla RNNs faced similar challenges with long-range dependencies. LSTMs and GRUs improved the situation through gating mechanisms, but they didn't eliminate the fundamental limitation of sequential computation.

Then came attention mechanisms. And here's something worth understanding: attention itself wasn't invented by the 2017 Transformer paper. Researchers had already been exploring attention-based approaches, particularly in neural machine translation. Attention allowed models to focus on relevant parts of an input when generating an output, rather than relying entirely on one compressed representation of the input sequence. It was an important development. But the researchers behind Attention Is All You Need took this idea considerably further. Instead of simply adding attention to an existing recurrent architecture, they asked a much more interesting question: What if we removed recurrence altogether and built the entire architecture around attention? Apparently, eight researchers decided that making machines wait for one word after another was getting a little too old-fashioned. And honestly, I respect the audacity.

Enter the Transformer: The architecture that doesn't believe in waiting.

Let's understand the intuition through something every college student has experienced: a WhatsApp group. Someone sends, "The assignment deadline is tomorrow." Another person replies, "Finally, the professor postponed it." Someone else asks, "What about the lab submission?" And then, naturally, one person sends a completely unrelated meme. Now, if you want to understand what "it" refers to in the second message, you need to connect it with the earlier message. You don't understand the conversation by processing every message independently. You understand it through relationships. This is the basic intuition behind self-attention. Every token can examine other tokens in the sequence and determine how relevant they are when building its own representation. Instead of making information travel through a long chain of sequential steps, the model can directly establish relationships between different positions. Imagine a student who can refer to the entire lecture while answering a question instead of desperately trying to remember what was written on the board 45 minutes ago. That sounds like a student I'd actually like to be.

Consider the sentence, "The professor gave the student his notes because he was absent." Understanding who "he" refers to requires looking at the relationship between different words. The meaning of a token depends on its context, and self-attention helps a Transformer build those contextual representations. The word "attention" here doesn't mean consciousness, emotions, or the ability to ignore your roommate playing BGMI during an exam. It is a mathematical mechanism that calculates how much different tokens should influence one another. Simple idea. Slightly less simple mathematics. Naturally, the research paper decided to introduce us to an equation.

The famous formula: The reason your whiteboard is about to suffer.

If you've ever opened a machine learning research paper and wondered whether the authors were paid by the number of Greek symbols they could fit into a page, welcome. Here is the equation that sits at the heart of the Transformer:

$$\text{Attention}(Q,K,V)=\text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V$$

This is called scaled dot-product attention. When I first encountered it, the three letters Q, K, and V looked like another attempt by mathematics to ruin an otherwise peaceful afternoon. But the intuition becomes much easier when you connect it with something familiar. Imagine preparing for a machine learning exam. You have lecture notes, textbooks, slides, and approximately 47 PDFs downloaded from random Telegram groups. You search for "Self-Attention." Your search query behaves like a Query (Q). The Keys (K) represent information used to determine which available content is relevant to that query. The Values (V) represent the actual information that gets combined to produce the result. The model compares queries with keys, calculates similarity scores, converts those scores into attention weights using softmax, and combines the values accordingly. In other words, it doesn't give every token equal importance. It calculates which information deserves more influence. If you're studying Transformers, your DBMS notes probably don't deserve much attention. Unless your professor has discovered a particularly creative way to combine both subjects.

Mathematically, $QK^T$ calculates similarity scores between queries and keys. Dividing by $\sqrt{d_k}$ scales those scores according to the dimensionality of the key vectors, helping prevent the dot products from becoming excessively large. Then comes softmax:

$$\text{softmax}(x_i)=\frac{e^{x_i}}{\sum_j e^{x_j}}$$

This converts the scores into normalized weights, which are then used to combine the Value vectors. That's essentially the mechanism. The model calculates relationships, assigns relevance weights, and produces a weighted representation. And no, understanding this formula doesn't automatically qualify you to call yourself an AI researcher. But it's a pretty good start, which is more than I can say for memorizing ten definitions the night before an exam.

Q, K, V: Three people in every college group project.

Let's take another example. Your professor announces a group project, and you need someone who actually understands machine learning. You ask your classmates, "Who knows neural networks?" That's your Query. Each person has some description of their skills: one knows Python, another knows web development, and one confidently says they know AI because they once used ChatGPT to generate a college assignment. Those descriptions are their Keys. The actual knowledge and contribution they can provide are their Values. Your query gets compared against everyone's keys, and the most relevant information receives higher attention weights. Of course, in real life, the person who says "I'll handle the presentation" and disappears until submission day is a special case that deserves its own research paper.

The interesting part is that Queries, Keys, and Values aren't manually assigned labels. They're generated using learned linear transformations of the input representations. Given an input representation $X$, we can write:

$$Q=XW^Q,\qquad K=XW^K,\qquad V=XW^V$$

Here, $W^Q$, $W^K$, and $W^V$ are trainable matrices learned during training. This means the model learns how to project information into different representations that make attention useful. It isn't following a fixed rule that says a particular word must always be important. Its representations adapt through learning. Which is honestly a more sophisticated way of evaluating relevance than selecting the person with the highest CGPA for every college group project.

Self-attention is interesting. Multi-head attention is where things get even better.

One attention calculation might capture one kind of relationship between tokens, but language is complicated. There are different types of relationships, dependencies, and contextual patterns. So why restrict the model to one attention mechanism? The original Transformer uses multi-head attention, allowing multiple attention heads to learn different relationships in parallel. Think about attending a lecture with eight friends. One pays attention to definitions, another to mathematical formulas, another to examples, and someone else is busy identifying the questions the professor might ask in the exam. Each person notices something different. Multi-head attention follows a somewhat similar intuition. Each head has its own learned projections, and their outputs are concatenated and transformed:

$$\text{MultiHead}(Q,K,V)=\text{Concat}(\text{head}_1,\ldots,\text{head}_h)W^O$$

The important idea is that the model can attend to information through multiple learned representation subspaces. I'm not suggesting that one head literally handles grammar while another handles sarcasm. Although, if someone manages to train a model that understands college sarcasm perfectly, please send me the GitHub repository.

But wait, if every word can look at every other word, how does the model know which word came first?

This was one of the things I found particularly interesting when exploring the paper. Consider the sentences "I punched the wall" and "The wall punched me." Same words, very different situations. Word order matters. But if the Transformer doesn't use recurrence to process tokens in sequence, how does it receive information about their positions? Enter positional encoding. The original Transformer uses sinusoidal positional encodings, which are added to the token embeddings to introduce information about where each token appears in the sequence. The equations are:

$$PE(pos,2i)=\sin\left(\frac{pos}{10000^{2i/d_{\text{model}}}}\right)$$

$$PE(pos,2i+1)=\cos\left(\frac{pos}{10000^{2i/d_{\text{model}}}}\right)$$

Don't close the tab just yet. The intuition is more important than memorizing these equations immediately. Each position receives a pattern of values that helps the model distinguish where a token occurs. Think about your college attendance register. Knowing that Rahul is present isn't necessarily enough; you might also need to know his roll number. Positional encoding provides a positional signal. Without it, the model would know which tokens are present but wouldn't have an explicit representation of their order. And considering how important roll numbers are during university examinations, I think we can all appreciate the importance of positional information.

The Transformer isn't just an attention formula. It's an entire architecture.

This is where the paper gets even more interesting. The original Transformer uses an encoder-decoder architecture. The encoder processes the input sequence and builds contextual representations. The decoder uses those representations along with previously generated output tokens to generate the next token. The encoder consists of repeated layers containing multi-head self-attention and position-wise feed-forward networks, supported by residual connections and layer normalization. The decoder includes masked self-attention, encoder-decoder attention, and feed-forward networks. Masked self-attention prevents a position from looking at future output tokens during training. Basically, the model isn't allowed to peek at the answer key while writing the exam. A rule that some students still seem to be negotiating with.

The feed-forward network processes each position independently after attention has mixed contextual information across tokens. Residual connections provide shortcuts for information and gradients, while layer normalization helps stabilize the training process. Looking at the complete architecture made me realize something: the Transformer isn't simply a clever formula that researchers discovered one afternoon. It is a collection of carefully designed decisions, each addressing a particular challenge. And that's exactly why reading research papers is interesting. You start seeing not just what someone built, but why they built it that way.

Why was this such a big deal? Because apparently, waiting is overrated.

One of the biggest advantages of Transformers was parallelization. Remember our RNN student, who has to process every word sequentially? Transformers allow all input positions to participate in attention computations together during training. This removes the sequential dependency that limits recurrent architectures. Imagine two students preparing for an exam. Student A completes Chapter 1, then Chapter 2, then Chapter 3. Student B organizes the work and studies multiple independent sections simultaneously. Student B has a better chance of finishing earlier. That's the intuition behind parallel computation. Of course, the student who starts studying two hours before the exam is a completely different research problem.

The paper demonstrated its effectiveness through machine translation experiments. On the WMT 2014 English-to-German benchmark, the Transformer achieved a BLEU score of 28.4, outperforming previously reported results, including ensemble models. The authors also reported strong results on English-to-French translation. The important achievement wasn't just a better benchmark score. It demonstrated that an architecture relying entirely on attention mechanisms could outperform established recurrent and convolutional approaches on these tasks. This wasn't merely an improvement to an existing architecture. It was a different way of thinking about sequence modelling.

And what about the limitations? Apparently, even attention has commitment issues.

Before we start treating Transformers as the answer to every problem in computer science, let's discuss their limitations. Standard self-attention has computational and memory costs that grow quadratically with sequence length. If your input contains $n$ tokens, the attention matrix contains $n\times n$ interactions. So, as the sequence becomes longer, the cost can increase rapidly. Imagine your college WhatsApp group going from 50 students to 50,000 students, with everyone trying to examine everyone's messages. Even your GPU would start reconsidering its life choices. Transformers also require significant data and computational resources for large-scale training. The original paper itself reported training experiments using eight GPUs. And while Transformers are incredibly powerful, they don't automatically possess common sense or guarantee correct answers. They learn patterns from data. Sometimes those patterns are useful, sometimes misleading, and sometimes the model confidently produces an answer that sounds exactly like a student explaining a topic they learned five minutes before the viva.

From a 2017 research paper to the AI we use today.

Now comes the reason I think this paper deserves more attention from students interested in AI. The Transformer architecture became the foundation for many influential developments in modern AI. GPT-style models use decoder-only Transformer architectures. BERT uses an encoder-only Transformer architecture. The original paper introduced an encoder-decoder architecture for sequence-to-sequence tasks. These models aren't identical, but they share important Transformer ideas. Think about ChatGPT, modern language models, machine translation, and all those AI applications that suddenly appeared in everyone's college project presentations. Their development is connected to the ideas explored in this paper. The next time you ask an AI tool to explain your DBMS assignment, generate JavaScript code, summarize a research paper, or debug your C++ linked list, remember that you're interacting with technology whose history is deeply connected to these architectural ideas. Your linked list might still be broken, but at least the machine knows which words deserve attention.

Why am I asking you to care about a paper instead of your lectures?

I'm not saying you should stop attending lectures. Please don't send this blog to your HOD as evidence. But there's a difference between studying something because it is in your syllabus and understanding something because you're genuinely curious about how the technology around you works. College teaches us concepts, formulas, and definitions. Research papers show us how people question existing ideas, identify limitations, experiment with alternatives, and sometimes change an entire field. And if you're genuinely interested in AI, I think you should occasionally step outside the cycle of tutorials, assignments, and semester examinations. You don't need to understand every line of a research paper on your first attempt. You don't even need to understand every equation. Start with the problem the researchers were trying to solve. Ask why existing approaches weren't enough. Understand the intuition behind their solution. Then slowly work your way through the mathematics. That's how curiosity turns into actual understanding.

If you haven't read Attention Is All You Need yet, I'd genuinely recommend giving it a shot. It's around 11 pages, which is considerably shorter than the answer PDFs of your Question Bank. Start with the Introduction, understand the motivation behind removing recurrence, explore scaled dot-product attention and multi-head attention, and then study positional encoding and the overall architecture. Pay particular attention to Figure 1. And if you want to take it one step further, try implementing a tiny self-attention mechanism using Python and NumPy. Create a few token embeddings, calculate Q, K, and V, apply softmax, and observe what happens. Please don't immediately download a GitHub repository with 37 files and a README saying "just run the script." At least give yourself the opportunity to understand what's happening underneath.

One last thing before you go back to your end sem prep.

What I found most interesting about this paper wasn't simply the attention formula or the Transformer architecture. It was the mindset behind it. The researchers questioned something that had become normal. They looked at recurrent architectures, understood their limitations, explored attention mechanisms, and asked a question that helped change the direction of modern AI: What if we didn't need recurrence at all?

And I think that's the part worth remembering. You don't necessarily need to invent something completely new to contribute to research. Sometimes you just need to look at something everyone has accepted for years and ask, "Wait, why are we doing it this way?"
So, the next time someone asks why you're reading a 2017 research paper instead of preparing for tomorrow's semester exam, tell them you're studying the architecture behind modern AI. If they still don't care, that's fine. Their attendance is probably better than yours anyway.

This was all about "Attention Is All You Need." But somehow, nobody has figured out how to make my college timetable attend to my mental health.

In the margin

Enter to leave a note.

More from Utkarsh

22 min ·

The Foundations of Deep Learning

From artificial neurons to CNNs, RNNs, and Transformers , understanding how machines learn patterns, recognise the world, remember sequences, and somehow manage to make mistakes with incredible confidence.