Command Palette
Search for a command to run...
KL Divergence
Relative entropy (KL Divergence, also known as KL divergence) is a quantity that measures the difference between two probability distributions, with discrete form KL(p‖q) = Σ p(x) log(p(x)/q(x)), and continuous form replacing the sum with an integral. It represents the average additional coding length per sample when using distribution q to encode samples from distribution p; therefore it is always nonnegative and is zero if and only if the two distributions are equal almost everywhere. This quantity was introduced by Solomon Kullback and Richard A. Leibler in their 1951 paper On Information and Sufficiency, originally for information discrimination in statistical hypothesis testing. KL divergence is neither symmetric nor does it satisfy the triangle inequality, so it is not a distance: forward KL(p‖q) tends to cover all modes of the true distribution, while reverse KL(q‖p) tends to lock onto a single mode among them; this difference directly affects the shape of results in variational inference and knowledge distillation. Its relationship with cross-entropy is H(p,q) = H(p) + KL(p‖q); and the training objective of variational autoencoders, the penalty term for policy deviation in RLHF, and the KL regularization term in the variational lower bound (ELBO) of diffusion models all use relative entropy as a core building block.
Build AI with AI
From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.