NewsCrawler.org

Generalized belief states in transformers

Generalized belief states in transformers
Belief states projected onto all six pairs of four principal components
Process-weighted PCA of the 963-coordinate recurrent state (KV cache and one-hot current token)
GHMM initialization, directly fitted decoder, and encoder round trip
Image: lesswrong.com

A new framework for sequence models such as transformers proposes a general way to define, decode and manipulate their internal representations. The approach centers on generalized belief states[1]: statistics of past observations that are sufficient for predicting future data, can be updated recursively as new observations arrive, and are low-dimensional enough to visualize and interpret. The author shows that such states can be mapped to the internal activations and dynamics of a sequence model, and illustrates the idea with a transformer trained on a simple stochastic process generated by a hidden Markov model (HMM)[2], where the KV cache[3] plays a key role. The work is directly inspired by the 2024 paper "Transformers Represent Belief State Geometry in their Residual Stream" by Adam Shai, Paul Riechers and collaborators, and one section compares the two approaches.

In the classical setting, a belief state is the Bayesian posterior distribution over the hidden states of an HMM given the observed history; it is sufficient for next-token prediction and can be updated recursively from the previous state and the new token. Belief states can be written as nonnegative vectors that sum to 1, and for HMMs with few hidden states they form a low-dimensional space with a fractal structure. The running example is MRRXOR, a stochastic process generated by an HMM with five hidden states that emits two independent random bits, then their XOR, and then resets. Projected with principal component analysis (PCA)[4], its belief states show that PC1 tracks the belief that an XOR triple has just been completed, PC2 separates histories by their last token, PC3 codes for the XOR of the last two tokens with the next-token probability depending only on it, and PC4 contrasts histories where one random bit has been emitted with those where the XOR bit is still pending.

The post also separates next-token prediction from predicting a long future continuation: for MRRXOR, PC3 is sufficient for the next token but not for the whole future, while a belief state — or any recurrent state sufficient for next-token prediction — is sufficient for the entire future continuation.

Read the original lesswrong.com

Discussion

The comment welcomes the post's publication and expresses interest in seeing more discussion of the work.

Sources

  • LessWrong

    Generalized belief states in transformers

    30 points10 votes1 comment

Published: First seen: Читать по-русски

Open as a page