Tokens and embeddings
Before a model can work with text, the text is split into tokens: pieces that may be whole words, fragments of words, punctuation marks or other frequent character strings. Each token in the model's vocabulary has its own numeric ID. During training, every token is also given a vector, which is a list of numbers. A transformer model then uses attention, which weighs the neighboring tokens, to refine each vector. The refined vectors are called embeddings, and they carry meaning from context. Tokens used in similar settings end up with similar embeddings, as "invoice" and "receipt" might. When the model generates text, its decoder uses masked attention, so it looks only at the tokens that come before the one being predicted.