Concept

Log Probabilities

In computational models (such as n-gram language models), multiplying many small probabilities can cause arithmetic underflow, where the product becomes too small to be represented by standard floating-point numbers and rounds to zero. To prevent this, computations are performed in log space. Transforming the multiplication of probabilities into the addition of their logarithms maintains numerical stability:

p1×p2×p3×p4=exp(logp1+logp2+logp3+logp4)p_1 \times p_2 \times p_3 \times p_4 = \exp(\log{p_1} + \log{p_2} + \log{p_3} + \log{p_4})

Values only need to be converted back to raw probabilities (using the exponential function) at the very end of the process, if necessary.

0

1

Updated 2026-06-19

Tags

Data Science

Foundations of Large Language Models Course

Computing Sciences

Related