A decoder-only transformer generates text by taking a partially written document and predicting a likely next token. It is the architecture behind systems such as GPT and Gemini, though its fluent output should not be confused with human understanding or reasoning. section 3.1
A simple generation loop looks like this:
- Represent tokens as numerical embedding vectors and add position information so the model can track word order. section 3.5
- Use attention, a fuzzy-dictionary process involving queries, keys, and values, to relate parts of the context. section 3.5
- Produce probabilities for every possible next token, then select one through unembedding or sampling. section 3.5
- Feed the selected token back with all previous tokens and repeat, making the process autoregressive. section 3.5
Continuing a document
Given a partially written document, the model predicts a likely continuation one token at a time. Adjusting sampling randomness can make the result more consistent or more creative, but not necessarily more accurate. section 3.1 section 3.5







