Pretraining objectives: compare the information before the loss
预训练目标
Enumerate a noisy-parity distribution to compare causal, masked and joint span prediction fairly.
pretraining-objectivesA 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.
Hold the distribution fixed and change the evidence
Use the artificial switch distribution described above. Let be independent fair bits and an independent Bernoulli noise variable with parameter . Define by exclusive OR, denoted :
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 , the expected logarithmic loss has a useful decomposition:
Here is the evidence available to the prediction. The minimum over all conditional predictors occurs at the true conditional , giving conditional entropy. Changing changes that minimum before optimization, parameter count or architecture enters the comparison. Natural logarithms give units of nats.
A left-to-right predictor of first sees nothing, then , then . The chain rule produces:
where . 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:
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 and hide . If two heads predict the missing bits independently, each sees a fair marginal. A joint autoregressive target can predict first and then condition on both and the correct preceding during training:
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:
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 enumerated states, this deliberately simple implementation scans states for each queried state, taking time per conditional table and working memory beyond the input. Here . With binary variables, exhaustive enumeration already requires 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
- Why is even though the three bits obey a noisy parity relation?
Answer: and were sampled independently and fairly. Without , observing says nothing about . The dependency appears when considering all three variables, not from a pairwise correlation between and .
- 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 . Both missing-pair totals equal , and the gap is zero.
- 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 , approximately 0.462098 nats.
- 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?
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
- Improving Language Understanding by Generative Pre-Training
Alec Radford; Karthik Narasimhan; Tim Salimans; Ilya Sutskever · 2018 - BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Jacob Devlin; Ming-Wei Chang; Kenton Lee; Kristina Toutanova · 2019 - 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:
- Improving Language Understanding by Generative Pre-Training · Read sections3.1–3.3 and4.1; viewed PDF3: language-model pretraining, supervised adaptation and auxiliary LM objective. No benchmark reproduction.
- BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding · Identical historical Source object preserved; additionally read section3.1 selection/corruption and NSP. No BERT training or benchmark claims.
- Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer · Identical historical Source object preserved; additional current reading: 3.1.4 target factorization and3.3.4 span construction; PDF13/24 viewed. Scope recorded in source-evidence-012i.md; no benchmark reproduction.
Related topics