Token IDs Become Position-Aware Records
Integer IDs select rows from a learned token table, then matching learned position rows are added. Calculate the frozen records, derive shapes and parameters, and reject invalid vocabulary IDs or context positions.
The model receives integer IDs, not words and not one-hot vectors. An embedding lookup selects one row from a learned table for each ID.
The chapter vocabulary is:
| ID | Token |
|---|---|
| 0 | <bos> |
| 1 | A |
| 2 | B |
| 3 | C |
| 4 | D |
| 5 | X |
| 6 | Y |
| 7 | <eos> |
For input <bos> A B C, the ID tensor is . The frozen token rows
are the first four standard basis vectors, and the position table adds 0.1 to
feature 1, 2, 3, or 4 at positions 0, 1, 2, or 3 respectively. The combined
records are therefore
Lookup Has the Same Result as a One-Hot Product
A one-hot row for ID 2 multiplied by selects row 2, but implementations use direct indexed lookup. The one-hot view can explain the algebra; it should not be mistaken for the required stored input representation.
For , lookup produces . Adding positions broadcasts across the batch. It must not broadcast one position across every token.
Validate IDs and Length Before Lookup
Every ID must satisfy . The sequence length must satisfy for this learned position table. Negative IDs, ID 8, or a fifth position are configuration errors, not unknown values that the model can infer.
The embedding contains learned entries. The position table contains .
Q1. Combine one token and position row
Token A has ID 1 and embedding . At position 1, the position row is
. What combined record enters the first block?
Compute it first, then check your number.