Learn Before
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(PQ)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(PQ)=xP(x)log(P(x)Q(x))=ExP[logP(x)logQ(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(PQ)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(PQ)D_{\text{KL}}(P \|\| Q) is generally not equal to DKL(QP)D_{\text{KL}}(Q \|\| P).

0

1

Updated 2025-10-08

Tags

Data Science

Foundations of Large Language Models Course

Computing Sciences

Ch.4 Alignment - Foundations of Large Language Models

Foundations of Large Language Models