There are three common kinds of AI system: recognition, prediction and generation. A large language model is one example of generation: a model that, given some text, produces the text that comes next. Once trained, the model writes an answer one word at a time. To be exact, the model works with small pieces of text, called tokens. A token is not always a word. Each time the model writes a token, it is asked what comes next. The question is the tokens so far with a blank at the end, such as "I drink coffee from a". The junk filter kept a list of words. The model's list is made of all the tokens it uses, and it is called the vocabulary.
Inside the model are many numbers, called weights. Together, the weights give every token in the vocabulary a score for how likely it is to come next. Each token's score is the chance that it comes next. That chance is called the token's probability. The probabilities of all the tokens add up to a hundred percent. After "I drink coffee from a", a model might give "cup" a high probability. "Mug" might get a lower one, and "car" almost none.
One token is chosen using these probabilities. Then the chosen token is added to the end of the tokens so far. The model is asked again what comes next. Choosing the next token this way, again and again, is called next-token prediction. The model does not write the whole answer and then show it. Each token is chosen after the one before it.
The chosen token is not always the one with the highest probability. A setting in the model's software, called temperature, decides how often a less likely token is chosen. Set to zero, the model always chooses the most likely token. Set higher, it more often chooses one of the others. So the same question can get a different answer. For example, in ChatGPT, asking the same question again can give a different answer.
A vocabulary can also hold a token that is not a piece of text. It is a stop mark. For example, GPT-3's vocabulary calls it end of text. When the model chooses it, the answer is finished, and the model stops. There is also a limit on how many tokens an answer may have. When the limit is reached, the answer stops there.
Every token gets a probability: the chance that it comes next. All the probabilities add up to a hundred percent. One token is chosen, added to the end of the tokens so far, and the model is asked again. Doing this again and again is next-token prediction. A setting called temperature decides how often a less likely token is chosen. So the same question can get a different answer. The stop mark, or a limit on tokens, ends the answer. When an answer matters, ask the same question again, and compare the answers.