Flexible Language Modeling in Continuous Space with Transformer-based Autoregressive Flows

Ruixiang Zhang, Shuangfei Zhai, Jiatao Gu, Yizhe Zhang, Huangjie Zheng, Tianrong Chen, Miguel Ángel Bautista, Joshua M. Susskind, Navdeep Jaitly

TL;DR

TarFlowLM moves language modeling from the rigid world of discrete tokens into a fluid, continuous latent space using Transformer-based autoregressive flows. By doing so, it maintains the sequential logic of traditional models while gaining the ability to "edit" text across multiple passes, generate blocks of text at once, and incorporate global bi-directional context.

The Problem: The Straightjacket of Discrete Tokens

Most modern Large Language Models (LLMs) are fundamentally "discrete" and "unidirectional." They predict one specific token at a time, usually from left to right, in a single pass. While incredibly successful, this design is restrictive. It makes it difficult for a model to go back and "refine" a previous word based on what it just wrote, and it struggles to look "ahead" during the generation process without complex workarounds.

Generative frameworks like diffusion models have shown that working in continuous space (where data is represented as continuous vectors rather than discrete IDs) allows for more flexible, iterative refinement. However, diffusion models often lose the efficient sequential factorization that makes autoregressive (AR) models so adept at capturing long-range dependencies. The authors of this paper ask: Can we get the best of both worlds?

Methods: Introducing TarFlowLM

The authors introduce TarFlowLM, a framework that uses a Variational Autoencoder (VAE) to map discrete text into a continuous latent space. The core innovation lies in the Prior, which is modeled using a stack of Transformer-based autoregressive normalizing flows.

Architecture of TarFlowLM, illustrating the continuous latent space mapping, alternating Transformer AR flows, and patch-based generation.

Key technical innovations include:

  • Mixture-based Coupling Transformations: Standard flows use simple "affine" (scale and shift) transforms, which are too weak for the complex, multi-modal distributions of language. TarFlowLM introduces 1D Mixture-CDF and d-D Mixture-Rosenblatt flows. These use Mixtures of Gaussians to map complex latent data into a simple, standard Gaussian distribution.
  • Stacked Alternating Flows: By stacking multiple flow layers and alternating their direction (e.g., one layer goes left-to-right, the next goes right-to-left), the model can capture global, bi-directional context while remaining mathematically invertible.
  • Progressive Layer-wise Training: To stabilize deep flow networks, the authors train the first few layers until they converge, freeze them, and then add more layers on top—a curriculum approach for "normalizing" the data.

Key Insights and Ideas

The "Aha" Moment for Mixtures

The authors found that simple affine flows barely improved performance over a baseline. The real breakthrough came from the mixture-based couplings. Because discrete tokens mapped to continuous space create "clumps" of data, the model needs the mathematical flexibility of mixtures to "smooth out" those clumps into a standard Gaussian.

Ablation study and training curves demonstrating the significant performance gains from mixture-based couplings and progressive layer-wise training.

Invertibility as an Editing Tool

Because the flow is fully invertible, you can take a sequence, pass it through a few layers of the flow, "nudge" it in latent space, and pass it back. This allows for hierarchical multi-pass generation, where early layers decide the broad structure and later layers refine the specific wording.

Theoretical Equivalence

The paper provides a mathematical proof showing that if you make the latent space narrow enough (zero variance), TarFlowLM becomes mathematically equivalent to a standard cross-entropy discrete AR model. This suggests that continuous-space modeling is a strict generalization of the current paradigm.

Key Results

The model was evaluated on two standard language modeling benchmarks: Text8 (character-level) and OpenWebText (word-level).

  • Strong Likelihoods: On Text8, TarFlowLM achieved a score of 1.30 BPC (Bits Per Character), outperforming several recent diffusion and normalizing flow baselines.
  • Competitive Perplexity: On OpenWebText, it reached a perplexity of 22.64, which is significantly better than previous continuous-space models and approaches the performance of pure discrete Transformers.
  • Flexible Generation: The authors demonstrated block-wise generation (predicting "patches" of tokens at once). They showed that while standard models break down when forced to predict multiple tokens simultaneously, TarFlowLM maintains high quality because its latent layers can exchange information within the patch.
  • Visualizing Refinement: Qualitative results show the model "editing" text across flow layers—changing a word like "problems" to "marriage" to better fit the emerging context of a sentence.

Limitations and Future Work

While TarFlowLM is highly flexible, it is still an autoregressive model at its core. This means generation is sequential and can be slower than non-autoregressive diffusion models that generate entire sequences in parallel. Furthermore, stacking many Transformer-based flow layers increases the FLOP count per token compared to a single-pass model.

Future directions include exploring more efficient sampling techniques (like parallel decoding) and applying this framework to non-text sequences, such as protein folding or genomic data, where bi-directionality and continuous refinement are critical.

Summary updated

BibTeX
@inproceedings{zhang2025flexible,
  author = {Ruixiang ZHANG and Shuangfei Zhai and Jiatao Gu and Yizhe Zhang and Huangjie Zheng and Tianrong Chen and Miguel Ángel Bautista and Joshua M. Susskind and Navdeep Jaitly},
  title = {{Flexible Language Modeling in Continuous Space with Transformer-based Autoregressive Flows}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=MR7Fn23hSE},
}
Figure