What is a probability decay function?

A probability decay function assigns steadily shrinking probabilities to larger values, the underlying shape behind the exponential distribution HNSW uses for random level assignment.
Created: Updated: 3 min read

A probability decay function is any function that produces smaller and smaller probabilities as its input grows larger, and it’s the underlying mathematical shape that gives the exponential distribution covered elsewhere in this glossary its characteristic pattern of favoring small outcomes while allowing progressively rarer large ones.

What does “decay” actually describe about how this kind of function behaves?

Picture a function that starts out assigning a relatively high probability to small values and then steadily assigns lower and lower probabilities as the values it’s evaluating get larger, never rising back up along the way. That steady, one-directional decline is what “decay” refers to here: the probability of reaching each successively larger value keeps shrinking, following a smooth, predictable curve rather than dropping off arbitrarily or unevenly. The exponential distribution’s probability decay function specifically shrinks by the same proportional amount for each equal step further out, which is what gives it its distinctive, mathematically clean shape.

How does this decay pattern connect directly to HNSW’s layer-assignment behavior?

Random level assignment, covered elsewhere in this glossary, uses exactly this kind of decaying probability to decide how many layers each newly inserted vector belongs to: the probability of a vector reaching any given layer decays steadily as that layer gets higher, which is precisely why most vectors end up confined to the lowest layer while only a steadily shrinking fraction reach each successively higher layer. This decay behavior is what produces the graph’s coarse-to-fine pyramid shape, covered throughout this site’s coverage of building the algorithm from scratch, without needing any explicit rule that directly caps how many vectors are allowed on any particular layer — the decaying probability alone produces that effect on its own, purely as a statistical consequence of how the function is shaped.

What role does the level multiplier play in controlling how quickly this probability decays?

The rate at which this decay happens isn’t fixed — it’s controlled by a scaling constant generally called the level multiplier or mL, covered in its own dedicated page in this glossary, that determines exactly how steeply the probability shrinks with each additional layer. Choosing a larger level multiplier produces a gentler decay, allowing relatively more vectors to reach higher layers, while a smaller level multiplier produces a steeper decay that concentrates vectors more heavily toward the bottom. This single constant is what lets the abstract shape of a probability decay function be tuned into a concrete, adjustable setting for a real index.

A probability decay function is the general mathematical concept underlying the specific exponential distribution HNSW relies on, and recognizing this shape helps explain why the algorithm’s layer proportions behave as predictably as they do. From here, the pages on the exponential distribution and the level multiplier work through exactly how this decaying shape gets applied and tuned in practice.