MICROMATH turns important research into structured, approachable explanations—without losing the ideas, evidence, or nuance that make the science valuable.
Browse the library
Explore by subject
Find clear explanations across mathematics, physics, artificial intelligence, and computer science.
MICROMATH turns important research into structured, approachable explanations—without losing the ideas, evidence, or nuance that make the science valuable.
Our approach
We explain the problem a paper addresses, the key idea behind its method, the evidence supporting its claims, and the limitations readers should understand. Technical terms and equations are introduced in context.
Editorial team
MICROMATH editorial content is developed to help students and curious readers build understanding while keeping links to original research available.
Legal
Privacy Policy
Replace this demo copy with MICROMATH's reviewed privacy policy before publishing.
Legal
Terms of Service
Replace this placeholder with the final terms applicable to MICROMATH.
Contact
Get in touch
Add the official MICROMATH contact address here before publishing.
Conceptual illustration: machine learning connects information by learning which relationships matter.
Original paper abstract
The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. The authors propose the Transformer, a network architecture based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.
Experiments on machine translation show improved quality, greater parallelizability, and reduced training time. The paper reports 28.4 BLEU on WMT 2014 English-to-German and 41.8 BLEU on WMT 2014 English-to-French, and also evaluates the architecture on English constituency parsing.
Abstract summary based on the original arXiv record. See the linked source for the full abstract and version history.
मूल शोध-पत्र का सारांश
उस समय प्रचलित प्रमुख sequence-transduction मॉडल encoder–decoder संरचना में जटिल recurrent या convolutional neural networks पर आधारित थे। बेहतर प्रदर्शन करने वाले मॉडल encoder और decoder को attention mechanism से जोड़ते थे। लेखकों ने Transformer नामक ऐसी network architecture प्रस्तुत की जो केवल attention mechanisms पर आधारित है और जिसमें recurrent तथा convolutional layers की आवश्यकता नहीं होती।
मशीन अनुवाद के प्रयोगों में बेहतर गुणवत्ता, अधिक parallel computation और कम training time देखा गया। शोध-पत्र में WMT 2014 English-to-German कार्य पर 28.4 BLEU और English-to-French कार्य पर 41.8 BLEU का परिणाम दिया गया। लेखकों ने English constituency parsing पर भी इस architecture का मूल्यांकन किया।
यह सारांश मूल arXiv रिकॉर्ड पर आधारित है। पूरा abstract और version history मूल स्रोत पर देखें।
Imagine translating a sentence while keeping every word in context. A word can mean different things depending on the words around it. The word “bank,” for example, may refer to a financial institution or the side of a river. A useful language model must learn which surrounding words matter for the current meaning.
Before Transformers, many sequence models processed text step by step. The paper Attention Is All You Need, published by researchers at Google in 2017, proposed a different design: the Transformer. Its central mechanism, called attention, lets each token weigh information from other tokens directly.
The central idea is simple: instead of processing a sentence only one step at a time, let its parts compare and exchange information with one another.
1. The problem with processing words sequentially
Consider the sentence: “The animal didn’t cross the road because it was tired.” To interpret “it,” a model needs information from earlier in the sentence. If a model handles tokens sequentially, information must travel through a chain of processing steps. Long chains can make training harder and limit parallel computation.
Recurrent neural networks (RNNs) process one token after another. Convolutional models can process multiple positions together, but relating distant words may require several layers. The Transformer was designed to make relationships between any two positions easier to learn.
2. What does attention mean?
Think of attention as a context-aware highlighting system. When processing one word, the model assigns different weights to other words. A relevant word can receive a larger weight; a less relevant word can receive a smaller one. The weighted information is then combined into a representation of the current word.
Attention is a learned way to select context—not a human-like conscious act.
Queries, keys, and values
The paper describes attention using three vectors: a Query (Q), a Key (K), and a Value (V). A query represents what a token is looking for. Keys describe the information available from tokens. Values carry the information that will be combined.
Query: what this token is looking for.
Key: what each token can be matched on.
Value: the information contributed by each token.
The model compares queries with keys to calculate attention scores, converts those scores into weights, and uses the weights to combine values. These are learned numerical operations; the model is not manually given a dictionary of word relationships.
3. The key equation
The paper’s scaled dot-product attention is written as:
Here, \(QK^{\mathsf T}\) measures compatibility between queries and keys. Dividing by \(\sqrt{d_k}\) controls the scale of the scores, where \(d_k\) is the key-vector dimension. The softmax function turns scores into weights, and multiplying by \(V\) combines the corresponding information.
Reading note: this page uses a plain-text formula for a dependency-free demo. A production implementation can render LaTeX with a math renderer.
4. Why use multi-head attention?
A sentence can contain several kinds of relationships at once: grammar, references between pronouns and nouns, and links between distant concepts. Multi-head attention runs several attention operations in parallel. Each head can learn a different pattern, and their outputs are combined.
Conceptual visual for parallel attention heads. Replace this stock image with an original, labeled architecture diagram in a published article.
5. The Transformer architecture
The original Transformer uses an encoder–decoder structure. The encoder builds contextual representations of the input sequence. The decoder generates the output sequence while attending to encoder representations and previously generated tokens.
Core components
Component
Purpose
Self-attention
Connects information across token positions.
Multi-head attention
Learns multiple relationship patterns in parallel.
Feed-forward network
Transforms each position’s representation.
Positional information
Provides information about token order.
Residual connections and normalization
Support stable and effective training.
6. Why did this design matter?
Attention can connect distant tokens without requiring information to pass through a long recurrent chain. During training, the model can also process many token positions in parallel. This made the architecture well suited to large-scale training on modern accelerators.
However, standard full self-attention compares each token with every other token. Its attention computation and memory use grow approximately quadratically with sequence length. That is an important limitation for very long inputs.
7. What followed from the paper?
The Transformer became a foundation for many later language and multimodal systems. Encoder-focused models, decoder-focused language models, and encoder–decoder systems use related ideas in different ways. Their training objectives and designs vary, so not every modern model is identical to the original architecture.
Key takeaways
Attention lets tokens use context from other tokens directly.
Queries, keys, and values provide a mechanism for scoring and combining information.
Multi-head attention can learn different types of relationships in parallel.
The original Transformer combines attention with feed-forward layers, positional information, residual connections, and normalization.
Parallel computation is a major advantage, while quadratic attention cost is a key limitation.
Original paper and references
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). Attention Is All You Need. Advances in Neural Information Processing Systems 30, 5998–6008.
arXiv:1706.03762. First submitted 12 June 2017; latest revision v7 posted 2 August 2023.
Artificial IntelligenceDeep LearningNatural Language Processing
कल्पना कीजिए कि आप किसी वाक्य का अनुवाद करते समय उसके हर शब्द का संदर्भ भी समझ रहे हैं। किसी शब्द का अर्थ उसके आसपास के शब्दों से बदल सकता है। उदाहरण के लिए, “bank” का अर्थ वित्तीय संस्था भी हो सकता है और नदी का किनारा भी। भाषा को अच्छी तरह समझने वाले मॉडल को सीखना होता है कि मौजूदा अर्थ के लिए आसपास के कौन-से शब्द महत्वपूर्ण हैं।
Transformer से पहले कई sequence models पाठ को एक-एक कदम करके संसाधित करते थे। Google के शोधकर्ताओं ने 2017 में प्रकाशित Attention Is All You Need शोध-पत्र में एक अलग तरीका प्रस्तुत किया: Transformer। इसका मुख्य तंत्र attention है, जो हर token को दूसरे tokens से सीधे जानकारी लेने और उनके महत्व के अनुसार वजन देने देता है।
मुख्य विचार सरल है: वाक्य को केवल एक-एक कदम करके संसाधित करने के बजाय, उसके अलग-अलग हिस्सों को एक-दूसरे से तुलना करके जानकारी साझा करने दें।
1. शब्दों को क्रम से संसाधित करने की समस्या
इस वाक्य पर विचार करें: “जानवर सड़क पार नहीं कर पाया, क्योंकि वह थका हुआ था।” “वह” किसके लिए कहा गया है, यह समझने के लिए मॉडल को वाक्य के पहले हिस्से की जानकारी चाहिए। यदि मॉडल tokens को क्रम से संसाधित करता है, तो जानकारी को कई processing steps की श्रृंखला से गुजरना पड़ता है। लंबी श्रृंखला training को कठिन बना सकती है और एक साथ गणना करने की क्षमता सीमित कर सकती है।
Recurrent neural networks (RNNs) एक token के बाद दूसरा token संसाधित करते हैं। Convolutional models कई positions को साथ संसाधित कर सकते हैं, लेकिन दूर स्थित शब्दों के संबंध समझने के लिए कई layers की जरूरत पड़ सकती है। Transformer को इस तरह बनाया गया कि किसी भी दो positions के बीच संबंध सीखना आसान हो।
2. Attention का अर्थ क्या है?
Attention को संदर्भ के अनुसार महत्वपूर्ण शब्दों को highlight करने वाली प्रणाली की तरह समझें। किसी एक शब्द को संसाधित करते समय मॉडल दूसरे शब्दों को अलग-अलग weights देता है। उपयोगी शब्द को अधिक weight और कम उपयोगी शब्द को कम weight मिल सकता है। इसके बाद इन weights के अनुसार जानकारी को मिलाकर मौजूदा शब्द की representation बनाई जाती है।
Attention संदर्भ के आधार पर सीखी गई चयन-प्रक्रिया है—यह मनुष्य जैसी चेतन क्रिया नहीं है।
Queries, Keys और Values
शोध-पत्र attention को तीन vectors से समझाता है: Query (Q), Key (K) और Value (V)। Query बताता है कि token किस तरह की जानकारी खोज रहा है। Keys tokens में उपलब्ध जानकारी की तुलना करने में मदद करते हैं। Values वह जानकारी रखते हैं जिसे मिलाकर अंतिम representation बनाई जाएगी।
Query: यह token क्या खोज रहा है।
Key: हर token की जानकारी का मिलान किन आधारों पर किया जा सकता है।
Value: हर token कौन-सी जानकारी योगदान देता है।
मॉडल queries और keys की तुलना करके attention scores निकालता है, उन scores को weights में बदलता है और उन weights से values को मिलाता है। ये सीखी गई गणितीय प्रक्रियाएँ हैं; मॉडल को शब्दों के संबंधों की कोई तैयार सूची हाथ से नहीं दी जाती।
3. मुख्य समीकरण
शोध-पत्र में scaled dot-product attention को इस प्रकार लिखा गया है:
यहाँ \(QK^{\mathsf T}\) queries और keys के बीच मेल को मापता है। \(\sqrt{d_k}\) से भाग देने पर scores का scale नियंत्रित रहता है; यहाँ \(d_k\) key vector का dimension है। Softmax function scores को weights में बदलता है और फिर \(V\) से गुणा करके संबंधित जानकारी को मिलाया जाता है।
पठन-सूचना: इस पृष्ठ पर LaTeX सूत्र KaTeX के माध्यम से प्रदर्शित होते हैं।
4. Multi-head attention क्यों उपयोगी है?
एक वाक्य में एक ही समय पर कई तरह के संबंध हो सकते हैं—व्याकरण, सर्वनाम और संज्ञा के बीच संबंध, तथा दूर स्थित विचारों के बीच संबंध। Multi-head attention कई attention प्रक्रियाएँ समानांतर रूप से चलाता है। हर head अलग pattern सीख सकता है और अंत में उनके outputs को जोड़ा जाता है।
यह चित्र समानांतर attention heads का वैचारिक संकेत है। प्रकाशित लेख में इसे मूल, लेबलयुक्त architecture diagram से बदलना बेहतर होगा।
5. Transformer की संरचना
मूल Transformer में encoder–decoder संरचना होती है। Encoder input sequence की संदर्भयुक्त representations बनाता है। Decoder, encoder की representations और पहले से बनाए गए tokens पर ध्यान देते हुए output sequence तैयार करता है।
मुख्य घटक
घटक
काम
Self-attention
अलग-अलग token positions की जानकारी को जोड़ता है।
Multi-head attention
एक साथ कई तरह के संबंध सीखता है।
Feed-forward network
हर position की representation को रूपांतरित करता है।
Positional information
Tokens के क्रम की जानकारी देता है।
Residual connections और normalization
Training को स्थिर और प्रभावी बनाने में मदद करते हैं।
6. इस design का महत्व क्या था?
Attention दूर स्थित tokens को जोड़ सकता है, बिना जानकारी को लंबे recurrent chain से गुजारे। Training के दौरान कई token positions पर समानांतर गणना भी की जा सकती है। इससे यह architecture आधुनिक accelerators पर बड़े पैमाने की training के लिए उपयोगी बना।
हालाँकि, सामान्य full self-attention में हर token की तुलना हर दूसरे token से की जाती है। इसलिए attention की गणना और memory का उपयोग sequence की लंबाई के साथ लगभग quadratic दर से बढ़ता है। बहुत लंबे inputs के लिए यह एक महत्वपूर्ण सीमा है।
7. इस शोध-पत्र के बाद क्या बदला?
Transformer बाद के अनेक language और multimodal systems की बुनियाद बना। Encoder-केंद्रित models, decoder-केंद्रित language models और encoder–decoder systems अलग-अलग तरीकों से संबंधित विचारों का उपयोग करते हैं। उनके training objectives और designs अलग हो सकते हैं; इसलिए हर आधुनिक मॉडल मूल Transformer जैसा नहीं होता।
मुख्य बातें
Attention tokens को दूसरे tokens से सीधे संदर्भ लेने देता है।
Queries, keys और values जानकारी का महत्व आँकने और उसे मिलाने का तरीका देते हैं।
Multi-head attention एक साथ कई प्रकार के संबंध सीख सकता है।
मूल Transformer में attention के साथ feed-forward layers, positional information, residual connections और normalization शामिल हैं।
समानांतर गणना इसका बड़ा लाभ है, जबकि quadratic attention cost इसकी प्रमुख सीमाओं में से एक है।
मूल शोध-पत्र और संदर्भ
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., और Polosukhin, I. (2017). Attention Is All You Need. Advances in Neural Information Processing Systems 30, 5998–6008.
arXiv:1706.03762। पहली बार 12 जून 2017 को जमा; नवीनतम संशोधन v7, 2 अगस्त 2023।
कृत्रिम बुद्धिमत्ताडीप लर्निंगप्राकृतिक भाषा संसाधन