| ISSUE 383/456 · COMPUTER SCIENCE |
~4 MIN |
FOUNDATION / LANGUAGE STRUCTURE · READING DATE 2027-10-19 · OCTOBER 2027 — LANGUAGE MODELS AND MEASUREMENT
How a language model keeps word order visible
START HERE
"Dogs chase cats" and "Cats chase dogs" contain the same words but describe different events. Positional encoding is numerical information added to a text-processing program to identify where pieces of text occur in a sequence. Without an appropriate way to represent order, a calculation can lose a distinction that changes the sentence’s meaning.
|
/ WHY NOW
A model needs more than a list of which words appeared. A translation or instruction-following system must distinguish who acts on whom, and moving the same words can reverse that relationship without changing the vocabulary.
|
/ THE IDEA
Models represent text pieces as lists of numbers, called embeddings. Attention combines information from such lists. If a calculation treats input positions interchangeably, changing their order simply moves the corresponding lists; it does not supply an intrinsic label saying first, second or third. One design adds a position-dependent list to each text representation before further processing. The original Transformer used smoothly varying sine and cosine patterns at several scales. Other designs use learned position values or modify comparisons according to relative separation. These are mechanisms for exposing order, not storage of a human-written grammar rule.
THE FORMAL IDEA
h_position = e_token + p_position
| h = number list supplied to the next calculation; e = number list for a text piece; p = number list for its position. The subscripts label which piece or position is meant. | | The plus sign means add matching numerical entries. Each list must have the same length; these numbers have no physical units. The example below uses only two entries. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Toy word representation e_dog = (2, 1). Position 1 has p_1 = (0, 1): h = (2, 2). Change only the position to 2 with p_2 = (1, 0): h = (3, 1). The word stayed the same, but its input representation now carries a different position signal.
|
This does not by itself make the model understand the sentence. It gives later learned calculations information they can use to distinguish the two arrangements. Supplying a useful distinction and learning how to exploit it are separate steps.
/ SO WHAT?
It also separates order handling from context length. A system can accept many positions yet use their relationships poorly, and a position formula that extends mathematically does not guarantee reliable performance beyond the lengths encountered during training. Test order-sensitive tasks rather than assuming a large advertised input window solves them.
ONE CAVEAT |
| The vectors are invented and are not actual sinusoidal encodings. Modern architectures vary, and a causal attention mask also constrains which positions can see which others. This example isolates one additive position mechanism. |
KEEP THIS
Position signals let the same text piece enter different calculations when its place in the sequence changes.
|
NEXT: How a magnetic field pushes a voltage sideways
|