AI Wiki中文/EN

Pretraining objectives: compare the information before the loss

预训练目标

Enumerate a noisy-parity distribution to compare causal, masked and joint span prediction fairly.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A lower loss may mean an easier question

Imagine three binary switches. The first two are fair and independent. Usually, the third records whether they disagree, but it flips that answer with probability 0.1. Predicting the first switch without seeing anything is difficult. Predicting it after seeing both other switches is much easier. A model receiving the second question can have a lower loss without being a better model.

This is the first check to make when comparing pretraining objectives: identify the target, the visible evidence and the unit in which the loss is averaged. GPT’s original objective predicts a token from preceding tokens. BERT selects positions for prediction after corrupting the input, while its encoder can use both directions. T5 constructs a new target from removed spans and predicts that target autoregressively from the corrupted source. These are different conditional problems. GPT BERT T5

An architecture constrains what can be read; an objective decides which predictions are rewarded. A bidirectional encoder does not mandate one particular corruption recipe. An encoder–decoder stack can use different source/target transformations. Conversely, similar-looking cross-entropy formulas may train substantially different tasks. Start with conditional probability and entropy.

The same joint distribution gives different optimal losses when the visible evidence or target factorization changes.
The same joint distribution gives different optimal losses when the visible evidence or target factorization changes.

Hold the distribution fixed and change the evidence

Use the artificial switch distribution described above. Let A,BA,B be independent fair bits and EE an independent Bernoulli noise variable with parameter ε=0.1\varepsilon=0.1. Define CC by exclusive OR, denoted ⊕\oplus:

C=A⊕B⊕E,p(a,b,c)=14{1−ε,c=a⊕b,ε,c≠a⊕b. C=A\oplus B\oplus E,\qquad p(a,b,c)=\frac14\begin{cases}1-\varepsilon,&c=a\oplus b,\\\varepsilon,&c\ne a\oplus b.\end{cases}

Every one of the eight outcomes has positive probability. The four parity-consistent outcomes have probability 0.225 each; the other four have probability 0.025 each. Every individual bit is fair, and every pair is independent. All three together carry the noisy parity constraint. This distribution is deliberately small enough to enumerate exactly; no neural network needs to be trained.

For an arbitrary predictor qq, the expected logarithmic loss has a useful decomposition:

E[−log⁡q(Y∣V)]=H(Y∣V)+EVDKL ⁣(p(Y∣V)∥q(Y∣V)). \mathbb E[-\log q(Y\mid V)] =H(Y\mid V)+\mathbb E_V D_{\mathrm{KL}}\!\left(p(Y\mid V)\parallel q(Y\mid V)\right).

Here VV is the evidence available to the prediction. The minimum over all conditional predictors occurs at the true conditional pp, giving conditional entropy. Changing VV changes that minimum before optimization, parameter count or architecture enters the comparison. Natural logarithms give units of nats.

A left-to-right predictor of A,B,CA,B,C first sees nothing, then AA, then A,BA,B. The chain rule produces:

H(A,B,C)=H(A)+H(B∣A)+H(C∣A,B)=2log⁡2+h(ε), H(A,B,C)=H(A)+H(B\mid A)+H(C\mid A,B)=2\log2+h(\varepsilon),

where h(ε)=−εlog⁡ε−(1−ε)log⁡(1−ε)h(\varepsilon)=-\varepsilon\log\varepsilon-(1-\varepsilon)\log(1-\varepsilon). At noise 0.1, the three losses are approximately 0.693147, 0.693147 and 0.325083. Their mean is 0.570459 nats per predicted bit. This is the exact Bayes optimum for those three conditional tasks, not an empirical training score.

Next, hide one bit while revealing both others. By symmetry, each missing bit can be recovered up to the noise probability:

H(A∣B,C)=H(B∣A,C)=H(C∣A,B)=h(ε). H(A\mid B,C)=H(B\mid A,C)=H(C\mid A,B)=h(\varepsilon).

The mean single-mask loss is therefore 0.325083. It is lower than 0.570459 because each prediction gets different evidence, not because masking has defeated the autoregressive chain rule. Real BERT corruption also includes multiple selected positions, random replacements and unchanged selected tokens; this single-mask oracle isolates one information effect rather than reproducing the full BERT objective. BERT, section 3.1

Now reveal only AA and hide B,CB,C. If two heads predict the missing bits independently, each sees a fair marginal. A joint autoregressive target can predict BB first and then condition CC on both AA and the correct preceding BB during training:

H(B∣A)+H(C∣A)⏟independent missing-token predictions=2log⁡2,H(B,C∣A)=log⁡2+h(ε). \underbrace{H(B\mid A)+H(C\mid A)}_{\text{independent missing-token predictions}}=2\log2, \qquad H(B,C\mid A)=\log2+h(\varepsilon).

The totals are 1.386294 and 1.018230 nats, respectively. The second is 0.509115 per missing bit. Its advantage over the independent total is the conditional mutual information:

H(B∣A)+H(C∣A)−H(B,C∣A)=I(B;C∣A)=log⁡2−h(ε). H(B\mid A)+H(C\mid A)-H(B,C\mid A)=I(B;C\mid A)=\log2-h(\varepsilon).

That gap is 0.368064 nats. It describes dependence lost by multiplying independent marginal predictions. It is not a measured advantage of T5 over BERT: our comparison uses exact probabilities, fixed masking patterns and no learned representations. T5’s ordered span target provides an architectural way to represent such target dependence, but practical results depend on much more than this example. T5, section 3.1.4

Enumerate before you optimize

The original NumPy program sums the eight probabilities consistent with each condition. It computes the probability of the actual target under that condition, then averages negative log probabilities using the true outcome weights. It does not approximate the expectation with sampled frequencies.

"""Exact information comparison on a positive, noisy-parity distribution."""
import itertools
import json
import numpy as np


def distribution(noise=.1):
    if not 0<noise<1:raise ValueError('Noise must be in (0,1)')
    rows=np.array(list(itertools.product([0,1],repeat=3)))
    p=np.array([(1-noise if (a^b)==c else noise)/4 for a,b,c in rows])
    return rows,p


def conditional(rows,p,target,observed=()):
    target=tuple(target);observed=tuple(observed)
    if not target or len(set(target+observed))!=len(target+observed) or not set(target+observed)<=set(range(rows.shape[1])):
        raise ValueError('Target and observed index sets must be disjoint and valid')
    q=[]
    for row in rows:
        context=np.all(rows[:,observed]==row[list(observed)],axis=1)
        matches=np.all(rows[:,target]==row[list(target)],axis=1)
        q.append(p[context & matches].sum()/p[context].sum())
    return np.array(q)


def entropy(rows,p,target,observed=()):
    q=conditional(rows,p,target,observed)
    return float(-p@np.log(q))


def demo():
    rows,p=distribution()
    ar=[entropy(rows,p,[i],range(i)) for i in range(3)]
    mlm=[entropy(rows,p,[i],[j for j in range(3) if j!=i]) for i in range(3)]
    independent=sum(entropy(rows,p,[i],[0]) for i in (1,2))
    joint=entropy(rows,p,[1,2],[0])
    # Scores below use different visible evidence and target units.
    return dict(rows=rows.tolist(),probabilities=p.tolist(),autoregressive_terms=ar,
                autoregressive_per_token=float(np.mean(ar)),single_mask_terms=mlm,
                two_missing_independent_total=independent,two_missing_joint_total=joint,
                two_missing_joint_per_token=joint/2, independent_extra_nats=independent-joint,
                joint_entropy=float(-p@np.log(p)),
                scope='Exact Bayes conditional entropies in nats, no fitted model or cross-objective performance ranking')


if __name__=='__main__':
    print(json.dumps(demo(),indent=2))

Check the printed chain-rule terms, three single-mask terms and two versions of the missing-pair loss. The totals differ even though all calculations use the same data distribution and the best possible conditionals. The accompanying tests verify the independent entropy formulas and repeat the comparison at noise 0.5, where all three bits become independent and the gap disappears.

For NN enumerated states, this deliberately simple implementation scans NN states for each queried state, taking O(N2)O(N^2) time per conditional table and O(N)O(N) working memory beyond the input. Here N=8N=8. With kk binary variables, exhaustive enumeration already requires 2k2^k states; this is a teaching method, not a scalable language-model estimator. A table keyed by context can reduce repeated scans without removing the exponential state space.

Specify what is being compared

Real objectives average over corruption patterns and datasets, not just one fixed missing set. The selected-token denominator, sentinel tokens, EOS, padding and document boundaries all change the reported average. A per-target-token value is not interchangeable with a per-original-token value. Report both the transformation and the denominator before comparing numbers.

The exact conditional oracle removes model error and optimization error on purpose. A finite trained model may fail to represent its target distribution or may not reach the optimum. More informative conditioning can also cost additional computation. Equal loss, equal parameter count, equal training tokens and equal compute are separate experimental controls; satisfying one does not imply the others.

The joint conditional distribution for a corrupted example is a distribution over its missing content. It is not automatically an unconditional model of the whole original text. Likewise, multiplying all single-token bidirectional conditionals does not apply the ordered chain rule. A low masked loss alone neither establishes a normalized sentence probability nor proves strong free-running generation.

Change one assumption at a time

  1. Why is H(B∣A)=log⁡2H(B\mid A)=\log2 even though the three bits obey a noisy parity relation?

Answer: AA and BB were sampled independently and fairly. Without CC, observing AA says nothing about BB. The dependency appears when considering all three variables, not from a pairwise correlation between AA and BB.

  1. Set the noise to 0.5. What happens to the single-mask loss and the independent-versus-joint gap?

Answer: Noise completely randomizes the parity relation. Every target is a fair bit even after conditioning on the other two, so each single-mask loss is log⁡2\log2. Both missing-pair totals equal 2log⁡22\log2, and the gap is zero.

  1. Let the noise approach zero. Does a near-zero single-mask loss imply a near-zero left-to-right loss per bit?

Answer: No. Any one missing bit becomes determined by the other two, so its conditional entropy approaches zero. In left-to-right order, the first two bits remain fair and independent. The mean approaches 2log⁡2/32\log2/3, approximately 0.462098 nats.

  1. A paper reports 0.4 nats per selected token and another reports 0.6 per original token. Which objective is better?

Answer: The values do not determine a ranking. They differ in denominator and may differ in visible context, corruption, tokenizer, data and trained model. First align a common downstream or likelihood evaluation; retain the original objective-specific losses as separate diagnostics.

Compare recipes through controlled tasks

The original GPT report combines language-model pretraining with supervised adaptation and an auxiliary language-model term. BERT combines selected-token prediction with next-sentence prediction. T5 studies multiple architectures and objectives before selecting a combined recipe. Read which components were held fixed before assigning a result to “the objective.” GPT BERT T5

A follow-up experiment can fit a small conditional model to the eight-state table, compare its loss with the exact oracle and report the excess. Then change only the evidence set. This separates insufficient information from imperfect fitting. For a language experiment, define a shared evaluation, freeze the data split and tokenizer, and report training costs as well as downstream scores. The toy provides the accounting rules; it does not supply a universal winning pretraining objective.

Make a prediction, then check

Does lower masked-token loss prove a better autoregressive model?

Choose one answer

Learning objectives

  • Enumerate a noisy-parity distribution to compare causal, masked and joint span prediction fairly.
  • Decompose conditional log loss into irreducible uncertainty and model mismatch.
  • Use conditional mutual information to quantify dependence lost by independent missing-token predictions.

Prerequisites & connections

Explore related knowledge →

References

  1. Improving Language Understanding by Generative Pre-Training
    Alec Radford; Karthik Narasimhan; Tim Salimans; Ilya Sutskever · 2018
  2. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
    Jacob Devlin; Ming-Wei Chang; Kenton Lee; Kristina Toutanova · 2019
  3. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    Colin Raffel; Noam Shazeer; Adam Roberts; Katherine Lee; Sharan Narang; Michael Matena; Yanqi Zhou; Wei Li; Peter J. Liu · 2020

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author compared specified GPT/BERT/T5 objective definitions. Six paired equations and four explained exercises independently derive conditional-entropy plus KL, noisy-parity chain rule and conditional mutual information. Eight-state exact enumeration, positive probabilities and independent-noise control; losses use different visible evidence and do not rank trained models.

  • Single AI author compared specified GPT/BERT/T5 objective definitions. Six paired equations and four explained exercises independently derive conditional-entropy plus KL, noisy-parity chain rule and conditional mutual information. Eight-state exact enumeration, positive probabilities and independent-noise control; losses use different visible evidence and do not rank trained models.
  • Four computed SVG variants per topic. Fifteen numeric/geometry tests and42 responsive cases passed; fourteen final Chinese-mobile/English-desktop screenshots actually inspected. Initial English mobile-heading clipping and corrections preserved. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.