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.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-creators-probabilistic-systems
What is the core idea behind "Probabilistic Systems: Why LLMs Do Not Act Like Code"?
Which term best describes a foundational idea in "Probabilistic Systems: Why LLMs Do Not Act Like Code"?
A learner studying Probabilistic Systems: Why LLMs Do Not Act Like Code would need to understand which concept?
Which of these is directly relevant to Probabilistic Systems: Why LLMs Do Not Act Like Code?
Which of the following is a key point about Probabilistic Systems: Why LLMs Do Not Act Like Code?
Which of these does NOT belong in a discussion of Probabilistic Systems: Why LLMs Do Not Act Like Code?
Which statement is accurate regarding Probabilistic Systems: Why LLMs Do Not Act Like Code?
Which of these does NOT belong in a discussion of Probabilistic Systems: Why LLMs Do Not Act Like Code?
What is the key insight about "Temperature 0 is not fully deterministic" in the context of Probabilistic Systems: Why LLMs Do Not Act Like Code?
What is the key insight about "Beware hidden non-determinism" in the context of Probabilistic Systems: Why LLMs Do Not Act Like Code?
What is the key insight about "Review date" in the context of Probabilistic Systems: Why LLMs Do Not Act Like Code?
Which statement accurately describes an aspect of Probabilistic Systems: Why LLMs Do Not Act Like Code?
What does working with Probabilistic Systems: Why LLMs Do Not Act Like Code typically involve?
Which best describes the scope of "Probabilistic Systems: Why LLMs Do Not Act Like Code"?
Which section heading best belongs in a lesson about Probabilistic Systems: Why LLMs Do Not Act Like Code?