Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chlon 2025 - LLMs are Bayesian in Expectation

LLMs are Bayesian, in Expectation, not in Realization

This paper uses information theoretic lens to analyze the effect of positional encoding on permutation qualities of LLMs and propose an algorithm to derive the optimal chain of thought length.

Summary

In context learning allows LLMs to adapt to new tasks using only a few examples at inference time. A theoretical framework for interpreting ICL is through the lens of bayesian inference (see Xie 2022 - ICL as Implicit Bayesian Inference). It proposes that transformers implicitly perform posterior updates over a latent concept variable, with the pretraining distribution encoding a prior over possible tasks.

This perspective has been challenged by Falck 2024 - Is ICL in LLMs bayesian?, which demonstrates empirically that transformer based language models systematically violate the martingale property. Specifically, for exchangeable data where the order of observations carries no information, bayesian posterior predictive distributions must satisfy:

For any permutation and bounded function . The experiments show that LLMs like GPT-3.5 consistently violate this property under input permutation.

This paper observes that while bayesian inference assumes exchangeable data, position encodings fundamentally break the symmetry. This is formalized using two complexity measures:

  • Kolmogorov complexity of a sequence, which is permutation invariant for exchangeable data
  • Conditional complexity given a specific ordering

It then shows that transformers with position encoding minimizes:

Where:

  • denotes the uniform distribution over permutations consistent with sufficient statistics of the data
    • For iid data, we can just sample uniformly over all permutations
  • is the mutual information between sequences and their orderings

Note that this is a well known theorem (the kolomogorov version of Shannon's information identity) applied to this context.

Notations

  • denotes a sequence of observations
  • is the sufficient statistic for bernoulli sequences
  • represents a permutation of elements
  • denotes a transformer with parameters
  • is the kolmogorv complexity of sequence
  • is the binary entropy function
  • denotes the number of chain of thought tokens
  • denotes the target error tolerance