What are positional encodings?

Positional encodings are special numbers that help machines understand where something is in a sequence.

Imagine you're reading a storybook. Each word has its own place, the first word is at the start, the next one follows it, and so on. If all the words looked the same, you wouldn’t know which came first or last! That’s why we need positional encodings, like invisible labels that tell each word where it lives in the story.

How It Works

Think of it like numbered seats at a movie theater. Each seat has a number: 1 is by the door, 2 is next to it, and so on. The numbers help you find your spot quickly. In the same way, positional encodings give each word in a sentence its own number, or code, that tells the machine where it appears.

So when a computer reads a sentence, it doesn’t just see words; it sees words with invisible labels showing their order. That helps the computer understand meaning better, like knowing that "the cat chased the mouse" is different from "the mouse chased the cat."

Take the quiz →

Examples

  1. A child knows where they are in a line by counting how many people are ahead of them, positional encoding does something similar for words in a sentence.
  2. Imagine giving each person in a queue a number based on their position to help others know who is next, that's like positional encoding.
  3. If you're reading a book and the sentences were all mixed up, positional encodings would help your brain put them back in order.

Ask a question

See also

Discussion

Recent activity