The AI reads every word in a sentence at the exact same time. It has no idea what order they are in! To the AI, "The dog bit the man" and "The man bit the dog" look completely identical. To fix this, we create a second set of embeddings that just represent "Position 1", "Position 2", etc., and we blend them together with the word meanings.
We create another lookup table (just like in the previous chapter), but instead of looking up word IDs, we look up position numbers (0, 1, 2, 3...). We grab the decimal numbers for the word's meaning, grab the decimal numbers for the word's position, and simply add them together!
Description: A simple list counting up, representing the position of each word in the sequence. For our master sentence "The quick, brown fox...", we need positions for all words.
Example:
positions = tensor([0, 1, 2, 3, 4]) # For the first 5 tokens
Description: A 3D block of decimal numbers, shaped as (Batch Size, Sequence Length, Embedding Size). This looks just like the output from Chapter 3, but now the numbers contain BOTH the meaning of the word AND its location in the sentence.