Reading the notation

A cheat sheet for the probability notation in LLM papers. Every symbol, how to read it aloud, and the formulas you'll meet most often, each linked to the page that explains it.

Papers compress a lot into a little notation. Most of it is the same few dozen symbols. Keep this page open next to a paper.

Symbols

NotationRead asMeans
P(A)P(A), p(x)p(x)"probability of A", "p of x"Probability of an event, or of a value xx. Capital PP for events, small pp for distributions
p(y∣x)p(y \mid x)"p of y given x"Probability of yy when xx is known: conditional
p(x,y)p(x, y)"p of x and y"Joint probability of both
x∼px \sim p"x drawn from p"xx is a random sample from distribution pp
x1,…,xn∼iidpx_1, \dots, x_n \overset{\text{iid}}{\sim} p"independent and identically distributed"nn independent samples from the same pp: independence
Ex∼p[f(x)]\mathbb{E}_{x \sim p}[f(x)]"expectation of f under p"Probability-weighted average of ff: expected value
Var⁡[X]\operatorname{Var}[X], σ2\sigma^2"variance"Average squared distance from the mean: variance
∝\propto"proportional to"Equal up to a constant that makes things add to 1
ZZ"partition function", "normaliser"That constant: Z=∑yp~(y)Z = \sum_y \tilde p(y)
πθ\pi_\theta"pi theta"The policy (the model) with weights θ\theta
πref\pi_\text{ref}, πθold\pi_{\theta_\text{old}}"reference", "old policy"The model before RL; the model that generated the batch
μ\mu"behaviour policy"Whatever actually generated the samples (often the inference engine)
qq, oo, yy"query", "output"A prompt and a generated answer; oi,to_{i,t} is token tt of answer ii
y<ty_{\lt t}, oi,<to_{i,\lt t}"y before t"All tokens before position tt
∣y∣\lvert y \rvert"length of y"Number of tokens in the answer
1[⋅]\mathbb{1}[\cdot]"indicator"1 if the condition is true, else 0
θ^\hat\theta, A^\hat A"theta hat"An estimate of θ\theta or of the advantage, computed from samples
∇θ\nabla_\theta"gradient with respect to theta"Direction in weight space that increases the quantity fastest
sg[⋅]\mathrm{sg}[\cdot], stopgrad⁡\operatorname{stopgrad}"stop gradient"Treat this as a constant when differentiating
KL(p∥q)\mathrm{KL}(p \Vert q), DKL\mathbb{D}_\text{KL}"KL from q to p"KL divergence; order matters: divergences
H(p)\mathcal H(p), H(p)H(p)"entropy of p"Average surprise: entropy
σ(⋅)\sigma(\cdot)"sigmoid"1/(1+e−x)1/(1 + e^{-x}): sigmoid. Also used for standard deviation; context decides
N(μ,σ2)\mathcal N(\mu, \sigma^2)"normal"Gaussian with mean μ\mu, variance σ2\sigma^2: common distributions
Bern⁡(p)\operatorname{Bern}(p), Beta⁡(a,b)\operatorname{Beta}(a, b)"Bernoulli", "Beta"A coin flip; a distribution over probabilities: common distributions
arg⁡max⁡xf(x)\arg\max_x f(x)"arg max"The xx that makes ff largest (not the largest value itself)
L\mathcal L, J\mathcal J"loss", "objective"What's minimised; what's maximised
clip⁡(r,1−ϵ,1+ϵ)\operatorname{clip}(r, 1-\epsilon, 1+\epsilon)"clip"Keep rr inside that range: PPO
O(⋅)\mathcal O(\cdot)"big O"Grows at most like; ignore constants

Formulas you'll meet

Chain rule for a sequence, and the log-likelihood it gives (chain rule):

pθ(y∣x)=∏t=1∣y∣pθ(yt∣x,y<t),log⁡pθ(y∣x)=∑tlog⁡pθ(yt∣x,y<t)p_\theta(y \mid x) = \prod_{t=1}^{\lvert y \rvert} p_\theta(y_t \mid x, y_{\lt t}), \qquad \log p_\theta(y \mid x) = \sum_t \log p_\theta(y_t \mid x, y_{\lt t})

Bayes' rule (Bayes):

p(z∣y)=p(y∣z) p(z)p(y)∝p(y∣z) p(z)p(z \mid y) = \frac{p(y \mid z)\, p(z)}{p(y)} \propto p(y \mid z)\, p(z)

Marginalising a hidden variable (reasoning as a hidden variable):

p(y∣x)=∑zp(z∣x) p(y∣x,z)p(y \mid x) = \sum_z p(z \mid x)\, p(y \mid x, z)

Maximum likelihood = minimising cross-entropy = minimising forward KL to the data (likelihood):

θ∗=arg⁡max⁡θ∑ilog⁡pθ(yi∣xi)\theta^* = \arg\max_\theta \sum_i \log p_\theta(y_i \mid x_i)

Monte Carlo estimate of an expectation (Monte Carlo):

Ex∼p[f(x)]≈1n∑i=1nf(xi),xi∼p,SE=σn\mathbb{E}_{x \sim p}[f(x)] \approx \frac1n \sum_{i=1}^n f(x_i), \quad x_i \sim p, \qquad \text{SE} = \frac{\sigma}{\sqrt n}

Importance sampling (importance sampling in depth):

Ex∼p[f(x)]=Ex∼q[p(x)q(x)f(x)]\mathbb{E}_{x \sim p}[f(x)] = \mathbb{E}_{x \sim q}\Big[\frac{p(x)}{q(x)} f(x)\Big]

Policy gradient with a baseline (score function):

∇θEy∼πθ[r(y)]=Ey∼πθ[(r(y)−b) ∇θlog⁡πθ(y)]\nabla_\theta \mathbb{E}_{y \sim \pi_\theta}[r(y)] = \mathbb{E}_{y \sim \pi_\theta}\big[(r(y) - b)\, \nabla_\theta \log \pi_\theta(y)\big]

GRPO objective, as written in papers (GRPO):

J(θ)=E[1G∑i=1G1∣oi∣∑t=1∣oi∣min⁡(ri,t(θ)A^i,t, clip⁡(ri,t(θ),1−ϵ,1+ϵ)A^i,t)−β DKL[πθ∥πref]]\mathcal J(\theta) = \mathbb{E}\Bigg[\frac{1}{G} \sum_{i=1}^{G} \frac{1}{\lvert o_i \rvert} \sum_{t=1}^{\lvert o_i \rvert} \min\Big(r_{i,t}(\theta) \hat A_{i,t},\ \operatorname{clip}\big(r_{i,t}(\theta), 1 - \epsilon, 1 + \epsilon\big) \hat A_{i,t}\Big) - \beta\, \mathbb{D}_\text{KL}\big[\pi_\theta \Vert \pi_\text{ref}\big]\Bigg]

with

ri,t(θ)=πθ(oi,t∣q,oi,<t)πθold(oi,t∣q,oi,<t),A^i,t=ri−mean⁡(r)std⁡(r)r_{i,t}(\theta) = \frac{\pi_\theta(o_{i,t} \mid q, o_{i,\lt t})}{\pi_{\theta_\text{old}}(o_{i,t} \mid q, o_{i,\lt t})}, \qquad \hat A_{i,t} = \frac{r_i - \operatorname{mean}(\mathbf r)}{\operatorname{std}(\mathbf r)}

where rir_i (no tt) is answer ii's reward. Yes, rr means two things in one formula; papers do this.

KL-regularised optimum and DPO (tilted distributions):

π∗(y∣x)=1Z(x) πref(y∣x) er(x,y)/β,LDPO=−log⁡σ(βlog⁡πθ(yw∣x)πref(yw∣x)−βlog⁡πθ(yl∣x)πref(yl∣x))\pi^*(y \mid x) = \frac{1}{Z(x)}\, \pi_\text{ref}(y \mid x)\, e^{r(x, y)/\beta}, \qquad \mathcal L_\text{DPO} = -\log \sigma\Big(\beta \log \frac{\pi_\theta(y_w \mid x)}{\pi_\text{ref}(y_w \mid x)} - \beta \log \frac{\pi_\theta(y_l \mid x)}{\pi_\text{ref}(y_l \mid x)}\Big)

Unbiased pass@k (Monte Carlo):

pass@k=Eproblems[1−(n−ck)/(nk)]\text{pass@}k = \mathbb{E}_\text{problems}\Big[1 - \binom{n - c}{k} \Big/ \binom{n}{k}\Big]

Speculative decoding acceptance (rejection sampling):

P(accept x)=min⁡(1,p(x)q(x)),α=∑xmin⁡(p(x),q(x))=1−TV(p,q)P(\text{accept } x) = \min\Big(1, \frac{p(x)}{q(x)}\Big), \qquad \alpha = \sum_x \min(p(x), q(x)) = 1 - \mathrm{TV}(p, q)

Evidence lower bound (reasoning as a hidden variable, diffusion LMs):

log⁡p(y)≥Ez∼q[log⁡p(y,z)−log⁡q(z)]\log p(y) \ge \mathbb{E}_{z \sim q}\big[\log p(y, z) - \log q(z)\big]

Habits of notation

  • Subscripts on E\mathbb{E} tell you what's random. Ey∼πθ\mathbb{E}_{y \sim \pi_\theta} means the answers come from the current model; Ey∼πθold\mathbb{E}_{y \sim \pi_{\theta_\text{old}}} means they came from an older one, and an importance ratio must appear somewhere.
  • Hats mean estimates. AA is the true advantage; A^\hat A is what was computed from a group of samples.
  • Dropping arguments: πθ(ot)\pi_\theta(o_t) usually means πθ(ot∣q,o<t)\pi_\theta(o_t \mid q, o_{\lt t}). Papers drop the conditioning once it's been stated.
  • Log base: in ML papers, log⁡\log is the natural log unless the units are bits.
  • Where the sum's normaliser goes (1/∣oi∣1/\lvert o_i \rvert per answer, or one 1/∑i∣oi∣1/\sum_i \lvert o_i \rvert for the batch) is a real design choice, not a typo: GRPO fixes.
  • "Unbiased" always means unbiased for something. Check whether that's a value or a gradient: Monte Carlo.

Related

  • chain-rule - The probability of a sequence is a product of conditionals, one per step. Every GPT-style model is built on this one identity, and its log turns the product into a sum.
  • monte-carlo - Almost every number in an LLM paper is an average over samples standing in for an expectation nobody can compute. How to judge such an estimate, and why papers fuss over "unbiased" and "low-variance".
  • tilting - Reweight a distribution by exp(reward / β) and renormalise. That one operation is the exact solution of KL-regularised RLHF, the starting point of DPO, a Bayesian posterior, and the yardstick for best-of-n.