
Module 6 Lesson 3: Why Outputs Change
Why does the AI say things differently every time? In our final lesson of Module 6, we look at the trade-offs between Determinism and Creativity in model responses.
Module 6 Lesson 3: Why Outputs Change
If you've spent any time with LLMs, you've seen the "Regenerate" button. You click it, and even though the prompt is identical, the answer is different.
To some, this feels like the AI is "thinking" or "feeling." To a computer scientist, it's the result of Probabilistic Sampling. In this final lesson of Module 6, we will explore why this happens and how we can control it for consistent results.
1. Randomness is the Default
As we learned in Lesson 2, LLMs deal in probabilities. If the model says there is a 60% chance for word A and a 40% chance for word B, it will usually pick A, but sometimes it will pick B.
This randomness is actually essential for human-like conversation. Without it, the model becomes rigid, boring, and susceptible to getting stuck in mathematical loops.
2. Seeds: The Secret to Consistency
If you need the model to give the exact same answer every time (important for scientific testing or debugging), you can use a Seed.
- A Seed is a specific number (like
42) that you feed to the random number generator. - If you use the same Seed, the same Prompt, and the same Temperature, the "random" choices the model makes will be the same every time.
graph LR
P["Same Prompt"] --> S1["Seed: 42"]
P --> S2["Seed: 42"]
P --> S3["Seed: 99"]
S1 --> R1["Output: 'Hello'"]
S2 --> R2["Output: 'Hello' (Reproduced)"]
S3 --> R3["Output: 'Hi' (New Randomness)"]
3. The Trade-off: Consistency vs. Quality
You might think: "If I can makes the AI consistent, why wouldn't I do that all the time?"
The Catch: Often, the "best" answer isn't a single path. By forcing the model to be deterministic (Temperature 0.0), you might actually lower the quality of its reasoning.
- Sometimes, the model needs to "stumble" upon a slightly lower-probability word that leads to a much better chain of thought later in the sentence.
- This is why many creative writers prefer a high temperature (around 0.8), even if it means they have to regenerate the response occasionally.
4. Deterministic Uses in the Real World
While "variety" is good for a chatbot, "consistency" is required for:
- Structured Outputs: If you need the AI to return a specific JSON or XML format for a database.
- Comparative Testing: If you are testing whether Model A is better than Model B, you need to eliminate randomness to get a fair result.
- Security: Ensuring that safety filters act reliably every single time.
Lesson Exercise
Goal: Understand consistency in your own life.
- Think of a question someone asks you often (e.g., "How are you?").
- Do you answer with the exact same words every time?
- Why do you change your answer? (Mood, social context, variety).
- Now imagine if you were a bank teller. Should your answer to "What is my balance?" have variety or be deterministic?
Observation: LLMs are designed to be "Social" by default, but we can force them to be "Technical" using the knobs we've studied.
Conclusion of Module 6
Congratulations! You have mastered Inference:
- Lesson 1: The process of Prompt to Output (Autoregression).
- Lesson 2: Control mechanisms like Temperature and Top-p.
- Lesson 3: The balance of randomness and determinism.
Next Module: We face the "Dark Side" of generative AI. In Module 7: Why LLMs Hallucinate, we'll learn why these machines can lie with such confidence and how we can stop them.