Sub topic 1
How a Model Writes: Predicting the Next Token
Prerequisites
Assume you have used a chat-based LLM assistant and understand that models learn patterns from large text collections. You should be able to read short Python examples.
How a Model Writes: Predicting the Next Token
A language model generates text one token at a time. A token is a small text unit, such as a word, part of a word, or punctuation mark. Given the conversation so far, the model calculates probabilities for possible next tokens.
For example, after “The capital of France is,” the token “Paris” may receive a high probability. The model then adds a token to the context and predicts the next one. This repeats until it reaches a stopping point.
import math
def softmax(logits, temperature=1.0):
scaled = [x / temperature for x in logits]
largest = max(scaled)
values = [math.exp(x - largest) for x in scaled]
total = sum(values)
return [value / total for value in values]
print(softmax([2.0, 1.0, 0.5], temperature=1.0))
print(softmax([2.0, 1.0, 0.5], temperature=0.5))A lower temperature makes the most likely token more dominant. A higher temperature spreads probability across more choices. Neither setting checks whether a choice is factually correct.
Why Fluent Does Not Mean True
Training rewards the model for producing likely text patterns, not for consulting reality. The model can reproduce the style of an explanation while lacking evidence for its claims. Fluency measures how natural the sequence sounds. Truth requires support from reliable evidence.
A confident sentence can therefore be statistically likely but factually wrong.
> callout warning > Treat fluent wording as a presentation property, not as proof. Check important claims independently.
What We Mean by a Hallucination
A hallucination is generated content that appears relevant or authoritative but is unsupported, fabricated, or false. Examples include an invented citation, a nonexistent person, or a number that has no reliable source.
An ordinary mistake may come from a calculation or misunderstanding. A hallucination often adds details that were never established.
Gaps in What the Model Has Learned
Models have incomplete, uneven knowledge. Rare entities, newly published facts, obscure dates, and ambiguous names create larger gaps. When the prompt supplies a false premise, the model may continue it instead of challenging it.
Use missing information as a reason to verify, not as evidence that the model is correct.
Exercise
Why can lowering temperature make an answer more consistent without making it more truthful?
Show answer
It favors the model’s most likely token choices, but those choices can still be based on incomplete or incorrect learned patterns.