✨Why GPT needs Positional Encoding


When we type something to GPT , have u ever wonder “How does the model understand what comes after what or who is going to whom ?”
After all language is more than just words, right !
Its also about structure, order and context. That’s where the Positional Encoding comes in.
🧠Why Transformers need Positional Encoding
Transformers are designed to look up at all words at once. This makes it incredibly powerful and but also makes them blind to word order unless we do something about it.
Imagine this sentence below
The cat chased the mouse
Now scramble the words
Mouse the cat chased the
Both sentences are created via same words , but one is meaningful and other one is meaningless and makes no sense .
Without knowing who comes first ,the model won’t understand the message.
🧩What is Positional Encoding
Positional encoding is technique to inject order while processing text in parallel by model.
Its like whispering to the model :
“Hey, this word is the first, this one’s the second, this one’s near the verb, and this one’s at the end.”
It does not change the words, just adds the sense of position to each one.
Let’s talk about Context
Consider the word “bank”.
He sat by the bank and watched the sunset.
He deposited his cash at the bank.
Same word ,but different meaning right !
How does the model figure this out ?
The word bank in each sentence is surrounded by different neighboring words, in different positions. Positional encoding helps GPT combine :
Where the word is
What’s around it
This gives the contextual meaning to the model.
📦Types of Positional Encoding (No Math, Promise)
Sinusoidal Encoding : Adds a pattern to each word based on its position — kind of like each word dancing to a different rhythm. This helps the model to feel the “beat” of every sentence.
Learnable Encoding : The model learns what position feels like. (Used in modern models)
🧠Final Takeaway
Positional Encoding gives words a sense of place — like a tag saying “I’m first,” “I come after the subject,” or “I’m the closing word.”
Subscribe to my newsletter
Read articles from Immanuel Dsouza directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
