Your LLM Is a Sampler, Not a Function
From the publisher’s feed, collected in the ZeroLabs newsroom.
A random number experiment explains most of what looks weird about LLM behaviorAsk Claude (or Gemini, or ChatGPT) for a random number between 1 and 10 with no other context. You will get 7.Not most of the time. Every time. The standard deviation is zero.Ask two frontier LLMs for a random byte (0 to 255), and both will converge on 173 as the modal value. Across providers. Across runs.What’s actually happening when you get 7: No latent space walk. No search. No evaluation of what “random” means. The model has learned, from many training examples of humans being asked to pick a random number between 1 and 10, that humans say 7 more often than any other number. When the prompt ends with that request, the token that most often followed it in training is “7.” At argmax sampling, highest probability wins.If the model were reasoning about randomness, a deterministic answer (i.e. 7) would be incoherent with the request. The deterministic answer is the evidence that no reasoning is happening. The model is reading off the mode of a conditional distribution, nothing more.A LinkedIn experiment published this week ran these tests with rigor: a clean 2x2x2 design, 8,000 numbers sampled, KS uniformity tests, autocorrelation, FFT, and the NIST cryptographic battery. In batch mode, where the model is asked for 125 numbers in one call, the output passed uniformity tests and failed every independence test, with NIST rejections at p = 0.000000. In sequential mode, where each number is a separate call with no context, both models collapsed onto a single value.The findings might come as a surprise. They are not. The autoregressive mechanism predicts all of it. And the mental model that makes them obvious is the same one that explains most of the other things practitioners find weird about LLMs in production.The mental modelThe dichotomy in the title is technical and worth pinning down before anything else.A function, in the software engineering sense, maps inputs to outputs deterministically. Same input, same output, every time. Unit tests, CI/CD, and “works on my machine” as a bug all rest on this contract.A sampler draws realizations from a probability distribution. The distribution is fixed, but any single draw can land anywhere the distribution has mass. Calling the sampler twice with identical setup produces two outputs that may differ. Both are valid draws from the same distribution.Every LLM call draws a sample from a probability distribution:output ~ P(tokens | context)Read this as “the output is drawn from the probability distribution over tokens, given the context.” The bar means “given” or “conditional on.” The distribution over outputs depends on what context the model has seen, and changes when the context changes.The context is everything the model has seen: the system prompt, the user turn, and any tokens the model has already produced in the current response. The distribution is fixed by training and RLHF. Temperature does not change the distribution. It controls how sharply you sample from it. At temperature 0, you take the argmax. At temperature 1, you sample proportionally to the probabilities.This framing is almost trivial to state, and practitioners consistently reason as if the LLM is a function that sometimes goes wrong. That is the wrong mental model. The LLM is a sampler that behaves exactly as specified. Most of what looks like a bug is the distribution doing its job.Once you hold the sampler model in your head, the random number results are mechanical.Sequential calls with no context sample from P(n | “give me a random number between 1 and 10”). That distribution peaks hard at 7, because in training data humans asked for a random number between 1 and 10 picked 7 more often than any other number. At temperature 0, or with a sufficiently peaked distribution at any temperature, you get 7 every time. Zero variance around a non-uniform mean is extreme bias by any definition, and it is what argmax sampling from a peaked distribution produces.Batch calls sample from a joint distribution over all 125 numbers in sequence. Each number conditions on all the previous ones through the attention mechanism. The model has seen enough examples of “random” sequences in training to self-correct for marginal uniformity across the full batch. What it cannot escape is the sequential dependency. Every token shifts the distribution over every subsequent token. Uniform margins plus correlated draws is what the mechanism produces by construction.The cross-model convergence on 173 for the byte range is the same story at higher resolution. Both models were trained on broadly overlapping web corpora, so both encode a similar distribution over “what a human would write when asked for a random byte.” The modal value in that distribution is the same value in both models.What the model predicts about other phenomenaThe sampler framing generalizes. Here are five things practitioners run into in production that the model predicts cleanly.Inconsistency across callsTwo calls to the same prompt produce different outputs. Under the function mental model, this is a reliability problem. Under the sampler model, this is what a sampler does. The relevant question is not “why is the output different?” It is “what is the shape of P(output | prompt), and how much variance around the mode is acceptable for this task?” This reframes the testing stack from assertion to distribution characterization.Scoring bias in LLM-as-judgeAsk a model to score an answer from 1 to 10. It will return 5, 6, 7, or 8 on almost every call. This is central tendency bias, and the sampler model predicts it: the distribution P(score | rubric, content) has most of its mass in the middle of the range because training data rating distributions cluster there. Endpoint aversion is the same effect on the tails.There is a second effect specific to judging that the sampler model also predicts. If the judge is asked to explain its reasoning first, then produce a score, the score token is sampled from a distribution that conditions on the reasoning it just generated. If the reasoning trended positive, the score follows, not because of independent evaluation but because coherence is what the sampler optimizes for. Score-then-explain and explain-then-score produce different score distributions on identical inputs. The difference is not noise. It is conditioning.Chain-of-thought effectsChain-of-thought works by extending the context that the final answer conditions on. The sampler model treats this cleanly: P(answer | prompt + reasoning) is a different distribution than P(answer | prompt). If the reasoning is sound, the new distribution is sharper around the correct answer. If the reasoning drifts, the new distribution is sharper around the wrong one. This is also why “think step by step” makes small models hallucinate more confidently. The instruction did not make the model better at the task. It made the model condition its answer on more of its own output.Position and order effectsSwap the order of two options in a prompt and the model’s preference shifts. Under the function model, this is bewildering. Under the sampler model, position is part of the context, the context defines the distribution, and the distribution is asymmetric with respect to position because training data is asymmetric with respect to position. Any prompt that includes a list of options has a positional bias you must measure or average over, not ignore.HallucinationHallucination is the sampler producing high-probability output that happens to be factually wrong. The model is sampling from a distribution that puts high mass on plausible text, and plausibility is only loosely correlated with truth. The mechanism is the same as returning 7 when asked for a random number between 1 and 10. The output is what the distribution says is most likely given the context.How to actually get numbers out of an LLMIf the sampler model is right, sampling is the wrong operation for most quantitative use cases. Read the distribution instead.A recent paper (LLM-as-a-Verifier) formalizes this for scoring. The verifier reward is expected value over the logprobs of ordered score tokens:R(t, τ) = Σ p_θ(v_g | t, c, τ) · φ(v_g)For each score token (digits 1 through 20, say), read its logprob, multiply by the scalar value it represents, sum. That is the expected value of the score under the model’s distribution. It uses information that argmax sampling throws away. On Terminal-Bench 2 and SWE-Bench Verified, this method reaches 86.4% and 77.8% respectively, better than any argmax-based judging approach on those benchmarks.The paper identifies three scaling axes, independent of each other:Score granularity (G): how many score tokens to read. 20 beats 10 beats 5 because a finer grid captures a richer distribution.Repeated verification (K): how many times to run the judge. Each run contributes a logprob distribution that gets averaged at the distribution level, not the scalar level.Criteria decomposition (C ): how many rubric dimensions to score separately. Decomposed criteria produce sharper conditional distributions than a single aggregate score.Scaling any of these improves the score. Scaling the wrong one wastes compute. Scaling K without logprobs is the least efficient path: running the judge eight times and averaging argmax outputs reduces variance around a biased estimator without changing the bias. This is exactly what the random number experiment encountered. Eight runs of batch sampling failed NIST for the same reason one run would have.Pair the verifier method with validation against human labels (Cohen’s Kappa, as NVIDIA’s judges study documents) and you have a principled loop for building numerical evaluators with LLMs. Compute scores with expected value over logprobs. Validate that the scores track reality with Kappa against expert labels. Iterate on prompt, granularity, or decomposition until agreement crosses a threshold. This is how you operationalize probabilistic systems engineering on top of a sampler.The stakesIf your mental model is “LLM is a function that sometimes goes wrong,” your testing, monitoring, and failure analysis are all miscalibrated. You will write assertions that fail intermittently and call them flaky. You will spot-check outputs and miss the failure modes that are structurally encoded in the distribution. You will scale evaluation by sampling more aggressively, which does not fix bias. And you will be surprised by results like the random number experiment, which the mechanism predicts before the first API call.If your mental model is “LLM is a sampler from a context-dependent distribution,” you get a different operating posture. You measure distributions. You scale evaluation along the axes that actually reduce error. You treat inconsistency across calls as signal about the shape of P(output | prompt) rather than as noise. You read distributions directly when the task is numerical. And you design systems that degrade gracefully when the distribution is wider than you want, rather than pretending you can assert it into submission.The random number experiment is a tight teaching case, but it is not the interesting application. The interesting application is every quantitative task a production LLM pipeline runs: scoring, ranking, rating, estimating, voting, classifying. All of it is sampling from conditional distributions. All of it benefits from reading the distribution directly. And all of it gets predictably worse when the function mental model is used to reason about it.The author works on AI and data infrastructure for wealth management at Advisor360°. We spend our production time building LLM-judged evaluation pipelines for agentic workflows, which is where the sampler-vs-function mismatch shows up at scale.Your LLM Is a Sampler, Not a Function was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.