Attention Is All You Need (2017): Attention से Transformer तक

Class 8+ के विद्यार्थियों के लिए Feynman Technique से विस्तृत Explanation

मूल शोधपत्र: Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser और Illia Polosukhin, "Attention Is All You Need" (2017).
arXiv: https://arxiv.org/abs/1706.03762\ NeurIPS paper: https://papers.neurips.cc/paper/7181-attention-isall-you-need


1. इस लेख में क्या सीखेंगे?

इस explanation के बाद आप समझ पाएँगे:

2. शुरुआत एक आसान उदाहरण से

यह वाक्य पढ़िए:

"रीना ने मीना को किताब दी क्योंकि वह परीक्षा की तैयारी कर रही थी।"

यहाँ "वह" किसके लिए है---रीना या मीना? सही उत्तर आसपास के शब्दों और पूरे वाक्य के अर्थ पर निर्भर करता है। भाषा समझने के लिए केवल एक शब्द को अलग से देखना पर्याप्त नहीं; हमें यह देखना होता है कि दूसरे शब्द उससे कैसे जुड़े हैं।

अब एक और वाक्य:

"बैंक के पास नाव खड़ी थी।"

यहाँ "बैंक" का अर्थ नदी का किनारा है, न कि पैसे रखने वाली संस्था। आसपास के शब्द अर्थ तय करने में मदद करते हैं।

मानव पाठक यह काम ध्यान देकर करता है। Transformer में attention mechanism प्रत्येक token को sequence के अन्य tokens से जानकारी लेने का एक सीखा हुआ तरीका देता है। वह हर बार केवल पिछले शब्द से आगे नहीं बढ़ता; attention के माध्यम से वह कई positions के बीच संबंध बना सकता है।

यह मनुष्य जैसी चेतना या समझ का प्रमाण नहीं है। यह एक गणितीय प्रक्रिया है, जो training के दौरान उपयोगी संबंधों के लिए parameters सीखती है।

3. 2017 से पहले sequence modeling की चुनौती

भाषा, अनुवाद और speech जैसे कार्यों में data अक्सर sequence के रूप में आता है। उदाहरण के लिए:

I | am | learning | mathematics

Sequence में दो बातें महत्वपूर्ण हैं:

  1. Content: कौन-से tokens मौजूद हैं?
  2. Order: वे किस क्रम में आए हैं?

Transformer से पहले sequence-to-sequence कार्यों में Recurrent Neural Networks (RNNs), LSTMs/GRUs और Convolutional Neural Networks (CNNs) का व्यापक उपयोग होता था। Encoder-decoder models में attention को पहले से सहायक mechanism के रूप में भी जोड़ा जाता था।

RNN का मूल विचार

RNN sequence को क्रम से process करता है। हर step पर वह वर्तमान token और पिछले step की hidden state का उपयोग करके नई hidden state बनाता है।

सरल रूप में:

ht=f(xt,ht−1)h_t = f(x_t, h_{t-1})ht​=f(xt​,ht−1​)

यह तरीका क्रम को स्वाभाविक रूप से संभालता है, लेकिन सामान्य RNN computation में अगले step को पिछले step के परिणाम की प्रतीक्षा करनी पड़ती है। इसलिए एक ही sequence के positions को training के दौरान पूरी तरह parallel process करना कठिन होता है।

CNN का मूल विचार

CNN स्थानीय आसपास के हिस्सों पर filters लगाकर features निकालता है। Sequence में दूर-दूर के tokens के बीच संबंध पकड़ने के लिए कई layers या विशेष व्यवस्था की जरूरत पड़ सकती है।

Paper का प्रश्न

Vaswani और सहलेखकों ने पूछा: क्या sequence modeling के लिए recurrence और convolution को हटाकर, मुख्यतः attention पर आधारित architecture बनाया जा सकता है?

उनका उत्तर Transformer था: encoder-decoder architecture, जिसमें attention और position-wise feed-forward layers को stack किया जाता है। मूल paper ने machine translation पर इसका परीक्षण किया और training parallelization के लाभों को रेखांकित किया।

4. Token से Vector तक: Embedding

Computer शब्दों को सीधे मानव की तरह नहीं पढ़ता। पहले text को tokens में बाँटा जाता है। Token पूरा शब्द, शब्द का हिस्सा, punctuation या कोई अन्य token unit हो सकता है।

उदाहरण के लिए:

Transformers are useful

किसी tokenizer में यह tokens बन सकता है:

["Transform", "ers", "are", "useful"]

यह केवल illustrative example है; वास्तविक tokenization vocabulary और tokenizer पर निर्भर करती है।

फिर प्रत्येक token को एक numeric vector यानी embedding में बदला जाता है:

token→embedding vector\text{token} \rightarrow \text{embedding vector}token→embedding vector

Vector को संख्याओं की सूची समझें, जैसे:

0.12,;−0.31,;0.84,;…0.12,; -0.31,; 0.84,; \ldots0.12,;−0.31,;0.84,;…

ये संख्याएँ सीधे शब्दकोश की परिभाषाएँ नहीं हैं। Training के दौरान embeddings ऐसी representations सीखती हैं जो model के कार्य में उपयोगी हों।

मूल Transformer में model dimension (d_{model\text{model}model}=512) था। यानी हर token की embedding 512-dimensional vector थी।

5. Attention क्या है?

Attention एक तरीका है जिसमें किसी position की representation, sequence की अन्य positions से मिली जानकारी का weighted combination बनती है।

एक classroom उदाहरण लें। कक्षा में शिक्षक एक प्रश्न पूछते हैं: "वह किसकी किताब थी?" जवाब देने के लिए आप वाक्य में उन शब्दों पर अधिक ध्यान देंगे जो "वह" और "किताब" के संबंध को स्पष्ट करते हैं। आप हर शब्द को समान महत्व नहीं देंगे।

Transformer में attention weights यह तय करते हैं कि किसी token की नई representation बनाते समय किन अन्य tokens की Value कितनी मात्रा में शामिल होगी।

महत्वपूर्ण: Attention weight को "मॉडल ने मनुष्य की तरह सचमुच ध्यान दिया" का सीधा प्रमाण नहीं मानना चाहिए। यह गणना में इस्तेमाल होने वाला learned weighting mechanism है।

6. Query, Key और Value (Q, K, V)

Attention को समझाने के लिए तीन नाम उपयोग किए जाते हैं:

ये नाम समझने के लिए analogy हैं। तकनीकी रूप से Q, K और V input representations पर learned linear projections लगाने से बनते हैं।

मान लें sequence में token representations की matrix (X) है:

Q=XWQ,K=XWK,V=XWVˆQ=XW^Q,\qquad K=XW^K,\qquad V=XW\^VQ=XWQ,K=XWK,V=XWVˆ

यहाँ (W^Q), (W^K), (W^V) learned weight matrices हैं। अलग-अलग projections एक ही input को matching और information-transfer के लिए अलग representation spaces में बदलती हैं।

7. Scaled Dot-Product Attention

मूल paper का मुख्य attention operation है:

Attention⁡(Q,K,V)=softmax⁡(QKTdk)V\operatorname{Attention}(Q,K,V) = \operatorname{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)VAttention(Q,K,V)=softmax(dk​​QKT​)V

इसे चरणों में समझें।

चरण 1: Query और Keys की matching

QKTˆQK\^TQKTˆ

यह dot products के माध्यम से हर query और keys के बीच compatibility scores निकालता है। Score अधिक होने का अर्थ है कि उस query-key pair को इस learned matching space में अधिक compatibility मिली।

चरण 2: Scaling

QKTdk\frac{QK^T}{\sqrt{d_k}}dk​​QKT​

(d_k) key vector की dimension है। Dimensions बड़ी होने पर unscaled dot products का magnitude बढ़ सकता है। इससे softmax बहुत तीखे probabilities दे सकता है और gradients छोटे हो सकते हैं। (dk\sqrt{d_k}dk​​) से divide करना scores को अधिक उपयोगी scale में रखने का तरीका है।

चरण 3: Softmax

Softmax scores को ऐसे weights में बदलता है जिनका योग प्रत्येक query के लिए 1 होता है:

αi=esi∑jesj\alpha_i = \frac{e^{s_i}}{\sum_j e^{s_j}}αi​=∑j​esj​esi​​

इससे हर key-position को एक normalized weight मिलता है।

चरण 4: Values का weighted sum

∑iαiVi\sum_i \alpha_i V_i∑i​αi​Vi​

अब Values को उनके attention weights के अनुसार मिलाया जाता है। अधिक weight वाली Value output में अधिक योगदान देती है।

छोटा संख्यात्मक उदाहरण

मान लें किसी query को तीन positions से weights मिले:

Position Attention weight


(V_1) 0.70 (V_2) 0.20 (V_3) 0.10 कुल 1.00

Output होगा:

0.70V1+0.20V2+0.10V30.70V_1+0.20V_2+0.10V_30.70V1​+0.20V2​+0.10V3​

इसका अर्थ है कि इस query की output representation में (V_1) का योगदान सबसे अधिक है। यह केवल समझाने के लिए चुने गए weights हैं; किसी वास्तविक model के weights input और learned parameters से निकलते हैं।

8. Self-Attention और Cross-Attention

Self-Attention

जब Q, K और V एक ही sequence की representations से बनते हैं, तो इसे self-attention कहते हैं। इससे sequence का हर token उसी sequence के अन्य tokens से जानकारी ले सकता है---उपलब्ध mask के अधीन।

उदाहरण: "The animal didn't cross the street because it was tired."

Self-attention model को "it" और "animal" के बीच संबंध सीखने का अवसर देता है। यह उदाहरण संभावित संबंध दिखाता है; model का वास्तविक निर्णय context और training पर निर्भर करेगा।

Cross-Attention

Cross-attention में Query एक sequence से आती है और Keys/Values दूसरी sequence से।

मूल encoder-decoder Transformer में decoder की Query, encoder के output से बनी Keys और Values को देखती है। Translation में decoder इस तरह source sentence की जानकारी का उपयोग कर सकता है, जब वह target sentence के अगले token की prediction करता है।

9. Multi-Head Attention: एक दृष्टिकोण नहीं, कई learned projections

यदि एक attention operation पूरे representation space में संबंध निकाले, तो वह कुछ प्रकार की जानकारी को एक ही मिश्रण में समेट सकता है। Multi-Head Attention कई अलग learned projections पर attention parallel चलाता है।

head⁡i=Attention⁡(QWiQ,KWiK,VWiVˆ)\operatorname{head}_i = \operatorname{Attention}(QW_i^Q,KW_i^K,VW_i\^V)headi​=Attention(QWiQ​,KWiK​,VWi​Vˆ)

फिर heads के outputs concatenate करके एक और learned projection लगाई जाती है:

MultiHead⁡(Q,K,V)=Concat⁡(head⁡1,…,head⁡h)WOˆ\operatorname{MultiHead}(Q,K,V) = \operatorname{Concat}(\operatorname{head}_1,\ldots,\operatorname{head}_h)W\^OMultiHead(Q,K,V)=Concat(head1​,…,headh​)WOˆ

मूल paper के base Transformer में:

क्योंकि (8 ×64\times 64×64=512), heads के outputs concatenate होकर model dimension के अनुरूप बनते हैं।

इसे कई अलग "देखने के तरीकों" की analogy से समझ सकते हैं। लेकिन यह निश्चित नहीं कि हर head एक साफ़-सुथरा मानवीय grammatical role ही सीखता है। Heads के व्यवहार को interpret करना अलग research question है।

10. Positional Encoding: क्रम की जानकारी कहाँ से आती है?

RNN में sequence order computation में स्वाभाविक रूप से शामिल होता है। लेकिन self-attention अपने आप token order नहीं बताता। यदि tokens की representations में position की जानकारी न दी जाए, तो attention अकेले sequence के permutation को पहचानने में सक्षम नहीं होगा।

मूल Transformer ने token embeddings में positional encodings जोड़े:

Input representation=Token Embedding+Positional Encoding\text{Input representation} = \text{Token Embedding} + \text{Positional Encoding}Input representation=Token Embedding+Positional Encoding

Paper ने अलग-अलग frequencies वाले sine और cosine functions इस्तेमाल किए:

PE(pos,2i)=sin⁡(pos100002i/dmodel)PE_{(pos,2i)} = \sin\left(\frac{pos}{10000^{2i/d_{\text{model}}}}\right)PE(pos,2i)​=sin(100002i/dmodel​pos​) PE(pos,2i+1)=cos⁡(pos100002i/dmodel)PE_{(pos,2i+1)} = \cos\left(\frac{pos}{10000^{2i/d_{\text{model}}}}\right)PE(pos,2i+1)​=cos(100002i/dmodel​pos​)

जहाँ:

सरल analogy: token embedding बताती है "कौन-सा token है", और positional encoding model को "यह token sequence में कहाँ है" की अतिरिक्त सूचना देती है।

Paper ने learned positional embeddings का भी परीक्षण किया और अपने प्रयोगों में sinusoidal तथा learned versions के परिणाम लगभग समान पाए। Sinusoidal encoding चुनने का एक कारण यह hypothesis था कि यह training में देखी गई लंबाई से आगे sequence lengths पर generalization में मदद कर सकती है। इसे हर आधुनिक model के लिए guaranteed property न समझें।

11. मूल Transformer का Encoder--Decoder Architecture

2017 के मूल Transformer में दो मुख्य हिस्से थे:

मूल base configuration में encoder की 6 layers और decoder की 6 layers थीं।

Encoder layer का सरल flow`Input representations` → `Multi-Head Self-Attention` → `Add & Norm` → `Feed-Forward Network` → `Add & Norm`

Decoder layer का सरल flow`Previous output tokens` → `Masked Self-Attention` → `Add & Norm` → `Encoder–Decoder Cross-Attention` → `Add & Norm` → `Feed-Forward Network` → `Add & Norm`

Encoder में क्या होता है?

हर encoder layer में दो sub-layers होते हैं:

  1. Multi-Head Self-Attention;
  2. Position-wise Feed-Forward Network।

हर sub-layer के आसपास residual connection और layer normalization रखे गए थे।

Decoder में क्या अतिरिक्त है?

हर decoder layer में तीन sub-layers होते हैं:

  1. Masked Multi-Head Self-Attention;
  2. Encoder--Decoder Cross-Attention;
  3. Position-wise Feed-Forward Network।

इससे decoder पहले target sequence के उपलब्ध हिस्से को देखता है और फिर source sequence की encoded जानकारी से संबंध बनाता है।

12. Masking: भविष्य के उत्तर को पहले से न देखना

Autoregressive generation में model को अगला token predict करना होता है। Training के दौरान decoder को यह अनुमति नहीं होनी चाहिए कि position (i), उससे आगे के सही target tokens को देख ले।

इसलिए decoder self-attention में causal mask लगाया जाता है। Future positions के attention scores को softmax से पहले निषिद्ध कर दिया जाता है।

तीन target positions का illustrative mask:

Query position Position 1 Position 2 Position 3


1 देख सकता है छिपा छिपा 2 देख सकता है देख सकता है छिपा 3 देख सकता है देख सकता है देख सकता है

यह mask सुनिश्चित करता है कि position 1 भविष्य के token 2 और 3 का उपयोग न करे, position 2 token 3 को न देखे, इत्यादि।

Encoder self-attention में यही causal restriction आवश्यक नहीं होती, क्योंकि encoder input sequence के सभी tokens को एक साथ देख सकता है। Decoder की cross-attention encoder के पूरे source representation को देख सकती है।

13. Feed-Forward Network: Attention के बाद transformation

Attention दूसरे tokens से जानकारी मिलाने का तरीका देता है। उसके बाद प्रत्येक position पर एक Feed-Forward Network (FFN) लागू होता है:

FFN⁡(x)=max⁡(0,xW1+b1)W2+b2\operatorname{FFN}(x) = \max(0,xW_1+b_1)W_2+b_2FFN(x)=max(0,xW1​+b1​)W2​+b2​

मूल paper में यह दो linear transformations और बीच में ReLU activation से बना था। यह हर position पर अलग-अलग लागू होता है, लेकिन एक ही layer के सभी positions के लिए parameters साझा होते हैं।

Base Transformer में:

आसान भाषा में: Attention sequence में दूसरी positions से relevant information मिलाता है; FFN उस position की representation को आगे transform करता है।

14. Residual Connection और Layer Normalization

गहरी neural networks को train करना कठिन हो सकता है। Transformer में sub-layer के output को उसके input के साथ जोड़ने के लिए residual connection इस्तेमाल किया गया:

LayerNorm⁡(x+Sublayer⁡(x)) \operatorname{LayerNorm}(x+\operatorname{Sublayer}(x))LayerNorm(x+Sublayer(x))

Residual connection information और gradient के लिए एक अतिरिक्त रास्ता देता है। Layer normalization activations को व्यवस्थित करने में मदद करती है। इन्हें अकेले training की सफलता की गारंटी नहीं मानना चाहिए; ये पूरे architecture और optimization recipe के हिस्से हैं।

15. Transformer में training कैसे हुई?

मूल paper ने machine translation के लिए encoder-decoder Transformer को train किया। Model target sequence के अगले token की probability predict करता था। Training के दौरान predicted distribution और सही target token के बीच loss निकाला जाता है, और backpropagation/optimizer के माध्यम से parameters update किए जाते हैं।

Paper की training recipe में Adam optimizer, learning-rate schedule, dropout और label smoothing जैसी तकनीकें शामिल थीं। Base model के लिए authors ने (d_{model\text{model}model}=512), (d_{ff}=2048), 8 heads और 6 encoder/decoder layers का उपयोग किया।

यहाँ "attention" का अर्थ यह नहीं कि model बिना training के संबंध जानता है। Q/K/V projections, embeddings और FFN के parameters data से optimize किए जाते हैं।

16. Transformer अधिक parallelizable क्यों था?

RNN में सामान्यतः sequence की position (t) की hidden state, position (t-1) की state पर निर्भर करती है। इससे positions के बीच sequential dependency बनती है।

Transformer का self-attention एक layer में सभी positions के pairwise scores matrix operations के माध्यम से निकाल सकता है। इसलिए training के दौरान sequence positions का बड़ा हिस्सा parallel process किया जा सकता है, जो accelerator hardware पर उपयोगी है।

लेकिन इसका अर्थ यह नहीं कि Transformer की हर computation सस्ती है। Standard self-attention में sequence length (n) के साथ attention-score matrix का आकार (n ×\times ×n) होता है। इसलिए लंबे sequences पर memory और computation की लागत बढ़ सकती है।

17. Paper के प्रमुख प्रयोग और परिणाम

मूल paper ने मुख्य रूप से WMT 2014 English-to-German और English-to-French machine translation benchmarks पर Transformer का मूल्यांकन किया।

Paper के abstract में authors ने रिपोर्ट किया:

BLEU machine translation के outputs की reference translations से तुलना करने वाला एक automatic evaluation metric है। यह उपयोगी है, लेकिन अकेले translation quality, factual correctness या भाषा की सभी विशेषताओं को नहीं मापता।

इन परिणामों को paper के समय और उन्हीं benchmarks/configurations के संदर्भ में पढ़ना चाहिए। इन्हें आज के हर model या हर language task पर लागू नहीं किया जा सकता।

18. "Attention Is All You Need" शीर्षक का सही अर्थ

शीर्षक का आशय यह था कि sequence transduction के लिए प्रस्तावित architecture में recurrence और convolution की जगह attention को केंद्रीय computation बनाया जा सकता है।

इसका अर्थ यह नहीं है कि Transformer में attention के अलावा कोई operation नहीं होता। मूल architecture में embeddings, positional encoding, feed-forward networks, residual connections, normalization और output projection/softmax भी शामिल हैं।

अधिक सटीक रूप में कहें तो: Transformer ने sequence modeling की मुख्य inter-token interaction mechanism के रूप में attention का उपयोग किया और recurrent/convolutional sequence processing को हटाया।

19. 2017 का मूल Transformer और आज के LLMs

आज के कई बड़े भाषा मॉडल Transformer से प्रेरित हैं, लेकिन वे मूल 2017 encoder-decoder architecture की हूबहू प्रतियाँ नहीं हैं।


विषय मूल Transformer (2017) कई आधुनिक decoder-only LLMs


मुख्य उद्देश्य Machine translation अगला token predict करके सहित text generation और अन्य sequence-to-sequence tasks tasks

Architecture Encoder + Decoder अक्सर decoder-only

Attention Encoder self-attention, आम तौर पर causal masked decoder self-attention self-attention, cross-attention

Position information Sinusoidal positional अलग-अलग learned या अन्य encoding positional methods संभव

Scale Base model में 6+6 कई आकारों और layers, configurations में (d_{model}=512)

Training Paper की बड़े और विविध datasets, translation-focused अलग objectives/recipes recipe

Output Source sequence के आधार अक्सर autoregressive पर target sequence token generation

यह table broad architectural distinction दिखाती है; हर आधुनिक LLM एक ही design का उपयोग नहीं करता।

20. मॉडल की सीमाएँ और सावधानियाँ

Transformer ने sequence modeling में महत्वपूर्ण बदलाव किया, लेकिन इसकी सीमाएँ भी हैं।

21. Feynman Technique: किसी मित्र को दो मिनट में समझाएँ

"मान लो computer को एक वाक्य का अनुवाद करना है। पुराने recurrent model में वह अक्सर शब्दों को क्रम से process करता था। Transformer ने एक अलग तरीका दिया: हर token को दूसरे tokens से सीधे जानकारी लेने का अवसर मिलता है। इसे attention कहते हैं। Attention में Query और Key से matching score बनता है, Softmax उन scores को weights में बदलता है, और Values का weighted sum नया representation बनाता है। कई attention heads अलग learned projections पर यह काम करते हैं। क्योंकि attention अपने आप word order नहीं जानता, positional encoding जोड़ी जाती है। मूल Transformer में Encoder input को represent करता है और Decoder output sequence बनाता है। Decoder mask के कारण भविष्य के target tokens नहीं देख सकता। इस architecture ने translation training को अधिक parallelizable बनाया, लेकिन इसका मतलब यह नहीं कि model मानव की तरह सोचता है या attention ही उसके अंदर की हर प्रक्रिया है।"

22. स्वयं को जाँचें

  1. Sequence model में token order क्यों महत्वपूर्ण है?
  2. RNN की sequential dependency training को किस तरह प्रभावित कर सकती है?
  3. Attention output में Values का weighted sum क्यों लिया जाता है?
  4. Query, Key और Value में conceptual अंतर क्या है?
  5. Scaled dot-product attention में (dk\sqrt{d_k}dk​​) से divide क्यों करते हैं?
  6. Multi-Head Attention में कई heads का उद्देश्य क्या है?
  7. Positional Encoding की जरूरत क्यों पड़ी?
  8. Encoder और Decoder में मुख्य अंतर क्या है?
  9. Causal mask किस प्रकार information leakage रोकता है?
  10. मूल Transformer को आज के decoder-only LLM के बराबर क्यों नहीं मानना चाहिए?

उत्तर-संकेत

  1. समान tokens अलग क्रम में अलग अर्थ दे सकते हैं।
  2. अगला recurrent step पिछले step की hidden state पर निर्भर रहता है, इसलिए sequence positions को पूरी तरह parallel करना कठिन होता है।
  3. इससे relevant positions का योगदान अधिक और कम relevant positions का योगदान कम हो सकता है।
  4. Q matching request/representation, K matching feature, और V आगे मिलाई जाने वाली information का representation है।
  5. बड़े dot-product scores से softmax अत्यधिक तीखा हो सकता है; scaling score magnitude को नियंत्रित करने में मदद करती है।
  6. अलग learned projection spaces में अनेक attention computations करने के लिए।
  7. Self-attention को token order की जानकारी देने के लिए।
  8. Encoder source sequence की contextual representation बनाता है; Decoder target sequence generate करता है।
  9. हर position को केवल वर्तमान और पहले के target tokens देखने देता है, भविष्य के tokens नहीं।
  10. मूल model encoder-decoder था; कई आधुनिक LLM decoder-only हैं और training, positional methods तथा scale में भी अलग हो सकते हैं।

23. निष्कर्ष

Attention Is All You Need ने 2017 में Transformer architecture प्रस्तुत किया, जिसने sequence modeling के लिए attention को केंद्रीय भूमिका दी और recurrent/convolutional sequence processing के बिना encoder-decoder model बनाया। इसकी प्रमुख तकनीकी अवधारणाएँ scaled dot-product attention, multi-head attention, positional encoding, masking, feed-forward layers और residual connections हैं।

इस paper की मुख्य सीख यह है कि sequence के हर token की representation बनाते समय दूसरे tokens से संबंधों को सीधे और parallel तरीके से model किया जा सकता है। साथ ही, Transformer केवल attention का एक सूत्र नहीं है---यह कई components, training choices और architectural assumptions का संयोजन है।

एक पंक्ति में: Transformer ऐसा neural network architecture है जो sequence के tokens के बीच learned attention संबंधों का उपयोग करके contextual representations बनाता है और मूल paper में इन्हीं सिद्धांतों से machine translation किया गया।


मूल स्रोत और आगे पढ़ें

  1. Vaswani, A. et al. (2017). Attention Is All You Need. arXiv:1706.03762. https://arxiv.org/abs/1706.03762
  2. NeurIPS 2017 paper PDF: https://papers.neurips.cc/paper/7181-attention-isall-you-need
  3. Google Research publication page: https://research.google/pubs/attention-is-all-you-need/

लेखन-संबंधी नोट: Q/K/V की "प्रश्न--मिलान--जानकारी" वाली व्याख्या और classroom examples intuition के लिए हैं। Equations तथा architecture मूल paper पर आधारित हैं; आधुनिक LLMs के बारे में कथन व्यापक प्रवृत्तियों का सार हैं, हर model पर लागू होने वाले नियम नहीं।