
Motivator ☮️ Positive quotes 😉 Stupendous Engineer in education Vibrant Entrepreneur in business Super Dad by family Quality husband for my wife #Cricketer
Coimbatore
Joined March 2011
- Tweets970
- Following3.5K
- Followers361
- Likes2.2K
callmeDJ 😜 alter ego #businessman #csengineer retweeted
Self attention clearly explained!
With LLMs (Language Models) taking the world by storm, it's important to understand what makes them so powerful.
Today, we will focus on understanding the three key ingredients of self-attention:
- Keys
- Queries
- Values
Background:
Neural networks are good with number❗️
In NLP we convert the sequence of words into token & then token to embeddings.
Token:
Picture a sentence: "The cat sat on the mat." You can think of each word in this sentence as a token.
Embeddings:
Each token is then transformed into a numerical representation called an embedding. Think of this as assigning unique characteristics to each word/token, helping us identify and relate them.
Crafting Keys, Queries, and Values:
For each token, we derive three elements: a key (K), a query (Q), and a value (V).
Let’s relate this to a library analogy:
🔹 Keys (K): Imagine each book in a library has a unique identifier. This identifier, or key, helps us locate the book on the shelf.
🔸 Query (Q): Suppose you’re looking for a specific book. The information you have about this book acts as the query, which is used to search through the library.
🔹 Value (V): Once you find your book, the content inside it is the value. It holds the actual information you’re looking for.
So as we derive K, Q & V for each token, we know what a token contains, what else it is looking for & what it will provide to other tokens.
Check this out👇
Building a context aware embedding: A 3-Step process!
With our keys, queries, and values in place, it’s time for the tokens to start interacting!
(refer the image below as you read ahead)
🔹 Step 1: Attention score calculation:
Each token’s query (Q) interacts with all the keys (K) in the sentence, including its own.
This interaction is a dot product, followed by scaling.
The result? An attention score, representing the relationship between our token and every other token in the sentence.
Example:
Consider the sentence "I love tennis".
Let's say our token is "I". The query for "I" interacts with the key for every word, revealing how closely "I" should attend to "love" & "tennis".
🔸 Step 2: Softmax and Weighting
With attention scores in hand, the next step is normalization.
We apply the softmax function to these scores, ensuring that they sum up to 1.
This gives us the weights – indicating the level of attention each token should pay to every other token.
For example, "I" might pay most of its attention to "love" and less to "tennis".
🔹 Step 3: Constructing the Context
Now that we have the weights, we use them to compute a weighted sum of the values (V).
This sum is the context representation of the token, including information from other tokens based on the calculated attention weights.
So, the context of "I" would be a combination of the information from "love" and "tennis", with more emphasis on "love" as per our example.
Here's an illustration of what we discussed so far👇
Understanding LLMs & LLMOps is going to be a high leverage skill in future!
@LightningAI provides state of the art tutorials on LLMs & LLMOps, I have personally learnt a lot from there.
I have shared a link to their LLM learning lab in next tweet!
______________
If you enjoyed reading this & interested in more content like this:
Find me → @akshay_pachaar ✔️
Everyday, I share tutorials around LLMs, MLOps & ML Engineering!
______________
Thanks for reading! 🥂
callmeDJ 😜 alter ego #businessman #csengineer retweeted
Who needs a Udemy course to help them reach that next level? Like, comment & retweet. I'll pick a few people & give them the Udemy course of their choice.
@appwrite has partnered with me so we can give away over $500 in courses to help those that need to reach the next level!
callmeDJ 😜 alter ego #businessman #csengineer retweeted
#CaptainMiller First Look : 25-06-23 / 29-06-23.
Almost Confirmed 🔥
@dhanushkraja
callmeDJ 😜 alter ego #businessman #csengineer retweeted
Umpire bhaiyo, food for thought aaj raat k liye 😉
callmeDJ 😜 alter ego #businessman #csengineer retweeted
Ather fans enjoying the TNPL thiruvizha in Coimbatore!🥳@atherenergy
Watch Shriram Capital TNPL on @StarSportsTamil @StarSportsIndia
Also, streaming live for free, only on @supergillies !Download the app now!
#NammaOoruNammaGethu
#TNPL2022
#TNPLonVoot
#TNPLonStarSportsTamil
callmeDJ 😜 alter ego #businessman #csengineer retweeted
Replying to @TheOfficialSBI
@TheOfficialSBI what do I do if the clerk in charge is not available in his seat for the customer support for banking services in the bank premises
callmeDJ 😜 alter ego #businessman #csengineer retweeted
So far BJP wins 0.0005% seats and kinda poor performance from previous elections. For what they are trending #நாங்க_வந்துட்டோம்னு_சொல்லு ?? Enaku purila. Ungalukku??
callmeDJ 😜 alter ego #businessman #csengineer retweeted
மக்களே ஞாபகம் வச்சிக்கோங்க! நீங்க போடுற ஒவ்வொரு ஓட்டும் வீட்டிற்குள் இருக்கவைப்பதற்கு!! @Vivo_India #BiggBossTamil #VivoBiggBoss










