What is the level multiplier (mL)?
The level multiplier, usually written as mL, is the single tunable constant that controls exactly how steeply HNSW’s random level assignment thins out from one layer to the next, making it the direct dial between the abstract probability decay function covered elsewhere in this glossary and the concrete shape a real graph ends up with.
What does mL actually do inside the level-assignment calculation?
Random level assignment, covered elsewhere in this glossary, draws a value from a uniform random variable and then applies a transformation involving a logarithm to turn that value into a highest layer for a newly inserted vector, and mL is the constant that scales the result of that transformation. A larger mL stretches the calculation so that vectors are more likely to reach higher layers, while a smaller mL compresses the calculation so that vectors are pushed more heavily toward the bottom layer. This makes mL the direct lever for controlling how many layers a graph ends up with overall and how many vectors populate each one, without needing to change anything else about how the underlying random draw itself works.
Why does the choice of mL actually matter for how the finished graph performs?
A larger mL produces more layers with relatively more vectors on the higher ones, which means search spends more of its time navigating through those upper layers before dropping down to the bottom layer for its finest-grained work, covered throughout this site’s coverage of how the layered structure supports search. A smaller mL produces fewer effective layers with vectors concentrated overwhelmingly at the bottom, shifting more of the search’s actual work onto that single bottom layer instead of spreading it across a taller hierarchy. Neither extreme is automatically better — the right setting depends on balancing how much benefit the upper layers provide for quickly narrowing down the search area against the extra memory and construction cost of maintaining more layers in the first place, covered in this site’s tuning-focused sections.
Is there a commonly used default value for mL, and where does it come from?
A frequently used choice for mL is based on the natural logarithm of the average number of connections each vector maintains per layer, a parameter covered elsewhere on this site as M, since this particular relationship between mL and M tends to produce a well-balanced number of layers relative to the size of a typical dataset. This isn’t a value forced by any hard mathematical requirement, though, and different implementations and use cases sometimes deviate from it, adjusting mL directly based on empirical testing rather than relying on the commonly used default, particularly when a dataset’s size or access patterns differ meaningfully from what that default was built around.
The level multiplier is the concrete knob that turns the abstract shape of a probability decay function into an actual, tunable property of a real HNSW index. From here, the pages on random level assignment and on the probability decay function fill in the mechanics mL is directly adjusting, and this site’s tuning coverage works through how to actually choose a good value for a specific dataset.