Autoregressive Model

An autoregressive model factorizes the joint distribution as a product of conditionals, generating one element at a time conditioned on previous ones.

The core factorization is:

Training usually maximizes the likelihood of the observed sequence, or equivalently minimizes negative log-likelihood:

For a Transformer decoder, the conditional distribution is typically:

where is the hidden state and maps it to vocabulary logits.

Sampling

Sampling applies a decoding rule to the conditional distribution:

where may be the original model distribution, temperature-scaled probabilities, top-, nucleus sampling, greedy decoding, or beam search. The decoding rule changes diversity and failure modes, so it belongs to the model contract.

Ordering Contract

Autoregressive modeling needs an ordering:

where is a serialization of the object. For text, the ordering is natural. For molecules, graphs, sets, or structures, the ordering is a modeling choice.

ObjectOrdering ChoiceRisk
textdocument ordercontext truncation and prompt leakage
protein sequenceresidue orderhomolog and family leakage
molecule SMILESstring traversalmultiple strings for same molecule
graphnode/edge serializationpermutation-sensitive likelihood
3D structureatom/residue ordercoordinate validity not guaranteed by token likelihood

If the object is not naturally sequential, likelihood can partly measure serialization quality rather than object quality.

Teacher Forcing vs Free Running

Training usually uses teacher forcing:

Sampling uses generated prefixes:

This gap explains why low token NLL can still produce invalid long outputs. Generation notes should report both likelihood-style metrics and sample-level validity or utility.

Decoding Contract

A generated output is a property of both model and decoder:

where is the decoding algorithm and contains temperature, top-, top-, beam width, repetition penalties, stopping rules, or validity filters. Comparisons should fix or report sensitivity.

Why It Matters

  • Exact likelihood and stable training make it a default for sequences.
  • Backbone of large language models and many token-based generators.
  • Sequential sampling can be slow for long outputs.

Failure Modes

  • Exposure bias: training conditions on true prefixes while sampling conditions on generated prefixes.
  • Ordering bias: a bad serialization can make local conditionals harder than necessary.
  • Degeneration: decoding can repeat, collapse, or produce invalid long-range structure.
  • Evaluation mismatch: low NLL does not always imply useful or valid samples.
  • Filter dependence: post-processing or rejection sampling may produce the apparent quality.

Checks

  • Does the ordering of elements suit the data?
  • Is exposure bias between training and sampling a problem?
  • Can sampling be parallelized or distilled for speed?
  • Is the decoding rule fixed before comparing models?
  • Does the output validity metric match the generated object?
  • Are invalid, duplicate, or rejected samples included in the denominator?