Generative AI models such as large language models write text by predicting what comes next. This lesson explains tokens, embeddings, prompts and the temperature setting, so you can describe how a model turns a prompt into a completion on the AI-901 exam.
Predicting the next token
A large language model (LLM) is trained to continue text. The text you send in is the prompt, and what the model writes back is the completion. Picture a search box that suggests how your sentence might end, scaled up enormously. At each step the model weighs how strongly each earlier word bears on what follows, then picks the likeliest continuation. It adds that piece to the sequence and repeats, stopping when it predicts an end. Small language models (SLMs) are compact versions of the same idea. They are also trained to produce completions from prompts.
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.
System prompts, user prompts and context
A prompt is any input you give the model. Two kinds do different jobs.
| Prompt type | Who writes it | Purpose |
|---|---|---|
| System prompt | The application developer | Defines the assistant's role, style and limits |
| User prompt | The person chatting, or the app for them | States the task or question to answer now |
Most chat apps also remember the conversation by sending earlier messages back with each new prompt, so a follow-up such as "and the deadline?" has context. Retrieval augmented generation (RAG) adds another layer: the app first fetches relevant documents, then places them in the prompt, so the answer is grounded in that material. In both cases the model itself is unchanged.
Controlling randomness
Settings sent with a request change how the model samples its output. The best known is temperature. Raise it for more random, varied output, which suits brainstorming a marketing slogan. Lower it for more focused, predictable output, which suits writing a product specification. Top_p is a second setting that also influences randomness, though by a different method, and the usual advice is to adjust only one of the two at a time. Examples placed in a prompt (few-shot examples) steer the reply to that one request and do not permanently alter the model.
On the exam
Watch for three traps. First, rules and tone that must apply to every conversation belong in the system prompt, not in each user prompt. Second, temperature controls randomness, not accuracy or length. Third, when the need is to answer from your own current documents without retraining, the answer is RAG: retrieve the relevant text and add it to the prompt. If a question says the model must remember an earlier turn, think conversation history sent back inside the next prompt, not a change to the model.