Skip to content
ACS Infra

Blue noise sampling

Blue noise sampling spreads out the unlikely tokens of a text, so they do not come in runs. This page explains how it picks a token, what it keeps of the model's probabilities, and what it changes. Spread out unlikely tokens says how to ask for it.

The draw that picks a token

Inference picks each token with a draw, a number from 0 to 1. It sorts the tokens from most to least likely, and it takes the first token whose running sum of probabilities passes the draw. A low draw then picks a likely token, and a high draw picks an unlikely one.

Ordinary sampling makes each draw at random. Now and then, high draws come one after another, and the text takes unlikely tokens one after another. With blue_noise: true, Inference makes draws that push apart. After a high draw, the next draw is low more often, and after a low draw, it is high more often. The unlikely tokens then come spread out over the text.

The sampling fields still apply. Inference applies temperature, top_p, top_k, min_p, and the penalties first, and blue noise picks among the tokens that they leave. At temperature 0, Inference takes the likeliest token, and blue noise changes nothing.

One step keeps the model's rates

At each position, each token comes with the probability that the model gives it. Each draw alone is spread evenly from 0 to 1, as an ordinary draw is. A CPU measurement sampled four tokens, with probabilities 0.5, 0.3, 0.15, and 0.05, at one position for 100,000 seeds. Each token's share was within 2.4 standard errors of its probability. The positions went from 0 to 2,147,483,648.

A whole text leans toward likely tokens

Over a whole text, blue noise gives likely tokens more often than the model does. At each position, the model's probabilities depend on the tokens before it, and blue noise ties each draw to the one before. As a result, a token that makes itself more likely comes less often than the model says. A word does that when the text turns to its topic.

The same CPU measurement used a model of two tokens. The rare token has probability 0.1 after the common one and 0.5 after itself, so it has probability 1/6 at every position. With ordinary draws, it was 16.7% of the tokens at position 10, over 100,000 texts. With blue noise, it was 12.4%. A draw of 1/2 or more followed another one only a quarter of the time. The rare token then followed itself 20% of the time, not 50%. Its longest run in a text of 64 tokens fell from 3.8 tokens to 1.8 on average.

A text from a Base model leans by its own amount, which depends on the model and the prompt.

Log probabilities are the model's own

logprobs and prompt_logprobs give the model's probabilities, as without blue noise. Inference computes them before any sampling. They do not say how likely blue noise was to write a text. A set of texts that mixes blue-noise texts with ordinary ones mixes two distributions. Each saved request keeps blue_noise, so the request of a Job, a Run, or a Loom Node shows how it sampled.

Seeds and blue noise

The seed keys the draws, and each position has its own draw. The same request with the same seed then gets the same tokens again, except where vLLM's batching changes a token (Why repeats differ). Choice i of n draws with the seed + i, so the choices of one request differ. How to sample says what the API does for a request without a seed, and which seeds draw the same numbers.

Models that take blue noise

capabilities.blue_noise in GET /v1/models is true for a model that takes it, and false for one that does not. The API refuses blue_noise: true for a model without it, with 400 and param set to blue_noise. A model takes blue noise only after a test of blue noise on its servers passes. Until then, capabilities.blue_noise is false for it.

Where blue noise sampling comes from

Blue noise sampling is the work of Jan Boon (Kaetemi), in Blue Noise Token Sampling. Inference uses his stateless generator blue32_continuous_at, from Stateless Blue Noise Generators. A draw of this generator depends only on the seed and the position. A request that vLLM stops and starts again then continues with the same draws.

On this page