Loading lesson…
Writing software on top of an LLM is not like writing software on top of a database. Treat it as a stochastic system or it will bite you.
An LLM does not return an answer. It returns a probability distribution over possible next tokens. Sampling from that distribution produces text. Even identical prompts will produce different text unless you control the randomness explicitly.
| Parameter | Effect |
|---|---|
| temperature | Scales logits. 0 = greedy, higher = more random |
| top_p (nucleus) | Keep smallest set of tokens whose cumulative probability exceeds p |
| top_k | Keep only the top k tokens |
| repetition_penalty | Down-weight tokens already in context |
| seed | Pin the pseudo-random generator for reproducibility |
# Robust evaluation of a probabilistic system import statistics import anthropic client = anthropic.Anthropic() def evaluate(prompt, n=10): outputs = [] for _ in range(n): resp = client.messages.create( model="claude-opus-4-7", max_tokens=200, messages=[{"role": "user", "content": prompt}], ) outputs.append(resp.content[0].text) # Measure pass@k, agreement, or similar return outputs results = evaluate("Classify: 'great product'", n=10) print(f"Unique outputs: {len(set(results))}")Sample multiple times and reason statistically. One call is anecdote, ten calls are data.An LLM in production is a distribution, not a function. Design accordingly.
— A platform engineer
The big idea: LLMs are stochastic systems. The tooling, testing, and architecture patterns that assume deterministic code need to be re-thought from the ground up when you put one in the loop.
8 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-creators-probabilistic-systems
What is the main idea of "Probabilistic Systems: Why LLMs Do Not Act Like Code"?
Which concept is most central to "Probabilistic Systems: Why LLMs Do Not Act Like Code"?
Which use of AI fits this topic best?
What should a careful learner remember about "Temperature 0 is not fully deterministic"?
You want to use AI after this lesson. What is the safest next step?
How should AI output about probabilistic be treated?
Name one way to verify an AI answer about probabilistic.
Which action would help you apply "Probabilistic Systems: Why LLMs Do Not Act Like Code" responsibly?