Encoder
- टेक्स्ट को vector में बदलने की प्रक्रिया और उससे प्राप्त embedding में positional information जोड़ने की प्रक्रिया समझाई गई है.
- लक्ष्य ऐसा embedding बनाना है जो input text की semantic information को कैप्चर करे.
1. टेक्स्ट embedding
- "Hello World" को vector में बदलकर embedding बनाया जाता है.
- हर token के लिए मनमाने मान देकर vector बनाया जाता है.
2. Positional encoding
- embedding में शब्दों की position information जोड़ने के लिए positional encoding जोड़ा जाता है.
- fixed vectors का उपयोग करके हर position को एक unique और consistent numeric pattern दिया जाता है.
3. Positional encoding और embedding का संयोजन
- positional encoding और embedding को जोड़कर encoder के input के रूप में इस्तेमाल होने वाला नया matrix बनाया जाता है.
Self-attention
- attention को ऐसे mechanism के रूप में समझाया गया है जो model को input के किसी खास हिस्से पर focus करने देता है.
- multi-head attention का उपयोग करके अलग-अलग representation spaces में जानकारी पर एक साथ ध्यान दिया जा सकता है.
4.1 Matrix की परिभाषा
- हर attention head के लिए K, V, Q matrices परिभाषित किए जाते हैं.
4.2 Key, Query, Value की गणना
- input embedding और weight matrices को गुणा करके key, query, value matrices की गणना की जाती है.
4.3 Attention की गणना
- query और हर key vector का dot product निकाला जाता है, और परिणाम को key vector के dimension के square root से विभाजित किया जाता है.
- softmax function लागू करके attention weights प्राप्त किए जाते हैं.
- हर value vector पर attention weights गुणा किए जाते हैं.
Feed-forward layer
- encoder में self-attention layer के बाद feed-forward neural network होता है.
- यह neural network दो linear transformations और ReLU activation function का उपयोग करता है.
5.1 बुनियादी feed-forward layer
- पहला linear layer input के dimension को बढ़ाता है, ReLU activation function लागू करता है, और फिर दूसरा linear layer dimension को वापस मूल आकार में घटा देता है.
5.2 Encoder की पूरी प्रक्रिया का संयोजन
- multi-head attention और feed-forward layer को शामिल करने वाला encoder block कोड में लिखा गया है.
5.3 Residual connection और layer normalization
- residual connection में layer के input को output में जोड़ा जाता है, और layer normalization layer के input को normalize करने की तकनीक है.
GN⁺ की राय
- यह लेख Transformer model की गणितीय समझ में मदद करने के लिए जटिल गणित को सरल बनाकर समझाता है.
- खास तौर पर, यह self-attention mechanism और feed-forward neural network के काम करने के तरीके को समझने में मदद करता है.
- residual connection और layer normalization जैसी तकनीकों से neural network की stability और performance में कैसे योगदान मिलता है, यह दिखाकर लेख deep neural networks की training problems को हल करने के तरीकों पर insight देता है.
1 टिप्पणियां
Hacker News राय
ट्रांसफॉर्मर की "रहस्यपूर्ण" बात यह है कि हर layer में static weights और values की linear sequence के बजाय, उसी input पर सीखे गए weights के गुणन से प्राप्त 3 अलग-अलग matrices का उपयोग किया जाता है, और फिर इन matrices को आपस में गुणा किया जाता है। इससे अधिक parallel processing संभव होती है, लेकिन attention formula static होने के कारण यह बहुत सीमित है।
अगर कोई अधिक सूखा, औपचारिक और संक्षिप्त approach चाहता है, तो John Thickstun का "The Transformer Model in Equations" देख सकता है। पूरा विषय standard mathematical notation का उपयोग करते हुए सिर्फ एक पेज में समा जाता है।
यह लेख पढ़ते समय कुछ सवाल उठते हैं।
मैं ऐसे papers या articles ढूंढना चाहूँगा जो यह समझाएँ कि ट्रांसफॉर्मर केवल "next token predictor" की तरह काम करते हुए भी training dataset में मौजूद नहीं रहे शब्दों या subword/token को कैसे संभाल सकता है।
ट्रांसफॉर्मर tutorials शायद नए monad tutorials बन गए हैं। यह समझने में कठिन concept है, लेकिन computer science की कई चीज़ों की तरह इसे समझने के लिए जूझना और examples का अभ्यास करना पड़ता है।
मुझे कुछ शब्द पता हैं।
TensorFlow का उपयोग किए बिना scratch से ANN लिख चुके व्यक्ति के रूप में भी, यह व्याख्या अब भी उलझाने वाली लगती है।
मुझे Quarto website पसंद आई। मैं ज़्यादा Python users को publishing के लिए Quarto इस्तेमाल करते देख रहा हूँ।
मुझे यह जिज्ञासा है कि decoder के step 7 में
Z_encoder_decoder = layer_norm(Z_encoder_decoder + Z)की जगहZ_encoder_decoder = layer_norm(Z_encoder_decoder + Z_self_attention)होना चाहिए या नहीं, और क्या decoder के step 8 में layer_norm छूट गया है।मैं यह जानना चाहता हूँ कि क्या LLM neural network का उपयोग करते हैं, और "neuron" को बनाने वाली चीज़ वास्तव में क्या है। यानी, क्या neuron के पीछे कोई code structure होता है, या यह "सिर्फ" जटिल गणित ही है।