What is Kullback-Leibler (KL) divergence?
In Turkish: KL ıraksaması · Topic: Math foundations
A measure of how different two probability distributions are. It shows the extra information cost of using one distribution in place of the true one, and it is zero when the two distributions are identical.
How does it work?
KL divergence looks at the ratio of the probabilities the two distributions assign to events and averages it according to the true distribution. It is zero when the distributions are identical, grows as they move apart and is never negative. It is not symmetric: the value from P to Q differs from the value from Q to P, so it is not a distance in the strict sense. It equals the gap between cross-entropy and entropy. As a result, for a fixed target distribution, minimizing cross-entropy is equivalent to minimizing KL divergence.
Why does it matter?
KL divergence appears inside many modern methods: variational autoencoders, limiting policy updates in reinforcement learning, and keeping a fine-tuned language model from drifting too far from its original version. When news coverage mentions a penalty for deviating from a reference model, this measure is usually what is meant.
Example
In a chatbot fine-tuned with reinforcement learning from human feedback (RLHF), a KL-type penalty can be added between the model and its starting version, so that while chasing reward the model does not drift far enough to damage its language ability.
FAQ
Why isn't KL divergence a true distance?
Because it is not symmetric: the value measured from P to Q need not equal the value from Q to P. It also fails the triangle inequality, which is why it is called a divergence.
Does the direction of KL divergence matter?
Yes. The forward and reverse directions behave differently: the reverse direction tends to make an approximation lock onto a single peak of the target, while the forward direction tends to cover all the peaks. Which one is used depends on the method.