Learn Before
Definition icon
Definition

Kullback-Leibler Divergence

Kullback-Leibler (KL) divergence, also known as relative entropy, measures how one probability distribution diverges from a second, reference probability distribution. For discrete probability distributions PP and QQ defined on the same probability space, the KL divergence from QQ to PP, denoted DKL(P∥∥Q)D_{\text{KL}}(P \|\| Q), is the expectation of the logarithmic difference between the probabilities given by the two distributions, where the expectation is taken using the probabilities of PP. The formula is: DKL(P∥∥Q)=∑xP(x)log⁡(P(x)Q(x))=Ex∼P[log⁡P(x)−log⁡Q(x)]D_{\text{KL}}(P \|\| Q) = \sum_{\mathbf{x}} P(\mathbf{x}) \log\left(\frac{P(\mathbf{x})}{Q(\mathbf{x})}\right) = \mathbb{E}_{\mathbf{x} \sim P} [\log P(\mathbf{x}) - \log Q(\mathbf{x})] KL divergence is non-negative (DKL(P∥∥Q)≥0D_{\text{KL}}(P \|\| Q) \ge 0) and is zero if and only if PP and QQ are identical. It is an asymmetric measure, meaning that DKL(P∥∥Q)D_{\text{KL}}(P \|\| Q) is generally not equal to DKL(Q∥∥P)D_{\text{KL}}(Q \|\| P).

0

1

Definition icon
Updated 2026-07-04

Tags

Data Science

Foundations of Large Language Models Course

Computing Sciences

Ch.4 Alignment - Foundations of Large Language Models

Foundations of Large Language Models