Thursday, December 3, 2026 | London 11°C · Overcast
DailyGlimpse

AI

How AI Distinguishes 'Dog Bites Man' from 'Man Bites Dog': The Secret of Positional Encoding

sourcecode 1 min read

At first glance, the phrases "dog bites man" and "man bites dog" use the exact same words. Yet their meanings are opposites. For a human, word order makes the difference clear. But for a transformer — the architecture behind modern AI like ChatGPT, Claude, and Gemini — word order is invisible. Without a special trick, these models would treat both phrases as identical.

The solution is positional encoding. Each word in a sentence is assigned a numeric position tag (word 1, word 2, word 3, etc.), allowing the model to distinguish "I love coffee" from "coffee I love." This mechanism was not part of the original transformer design; it was added later as a workaround to give AI an understanding of sequence.

This insight comes from Episode 16 of the AI Math Shorts series, which breaks down complex AI concepts in under 90 seconds. Previous episodes covered Mixture of Experts, KV Cache, Softmax, Attention, Tokenization, and more — all essential for understanding how large language models work.

React