Latent Reasoning with Normalizing Flows

Guancheng Tu, Xiangjun Fu, Suhao Yu, Yao Tang, Haoqiang Kang, Lianhui Qin, Yizhe Zhang, Jiatao GuarXiv 2026

TL;DR

NF-CoT introduces a novel latent reasoning framework for Large Language Models (LLMs) that replaces verbose text-based "chains of thought" with compact, continuous hidden states modeled via normalizing flows. By embedding an autoregressive flow directly into the LLM's causal stream, it achieves significant speedups and performance gains on coding benchmarks while preserving exact likelihoods, probabilistic sampling, and KV-cache compatibility.

What Problem Does This Paper Address?

Chain-of-Thought (CoT) prompting has drastically improved LLM reasoning by forcing models to generate intermediate steps before answering. However, standard CoT is computationally expensive and slow because it relies on generating discrete text tokens. Text is a verbose, low-information-density medium for "thinking."

To fix this, researchers have explored latent reasoning, where the model thinks in continuous vector spaces rather than words. But existing methods have a catch:

  • Methods like Coconut generate deterministic hidden states, losing the ability to probabilistically sample different reasoning paths.
  • Diffusion-based methods like LaDiR offer probabilistic sampling but require iterative denoising steps, making them incompatible with the native left-to-right, single-pass decoding and KV-caching that make modern LLMs efficient.
Four paradigms for chain-of-thought reasoning.

The authors propose NF-CoT to bridge this gap, giving continuous thoughts the exact same modeling status as language tokens.

Methods

NF-CoT integrates a scalable, autoregressive normalizing flow (specifically building on STARFlow) directly inside a shared LLM backbone.

  1. The Thought Space: First, a pretrained Text VAE compresses explicit text CoT traces into latent targets ($e_{1:K}$). A stack of shallow, invertible autoregressive flow blocks maps these targets into an LLM-facing continuous thought space ($u_{1:K}$).
  2. Unified Architecture: During a single causal forward pass, the LLM backbone processes the prompt, generates continuous thoughts via a specialized Normalizing Flow (NF) head (which outputs Gaussian parameters $\mu$ and $\sigma$), and then seamlessly switches to a standard Language Modeling (LM) head to output the final text answer.
  3. Training Curriculum: Training happens in two stages. First, the LLM backbone is frozen while the shallow flow blocks learn to align the latent space. Then, the entire network is unfrozen for joint end-to-end maximum likelihood training.
  4. Latent Reinforcement Learning: Because normalizing flows provide an exact, tractable likelihood for the continuous thoughts, the authors can apply standard policy-gradient optimization (like GRPO) directly to the latent reasoning space using execution-guided rewards (unit tests).
Training and inference pipeline of NF-CoT.

Datasets

The model was fine-tuned and evaluated on Python code-generation tasks:

  • Training: Fine-tuned on Ling-Coder (1.4M Python instruction-following samples). The RL stage utilized data from AceCoder and KodCode.
  • Evaluation: Evaluated across five standard benchmarks: HumanEval, MBPP, their stricter variants HumanEval+ and MBPP+ (which feature expanded test cases), and LiveCodeBench v6.

Key Insights and Ideas

  • Continuous Thoughts as Distributed Control Variables: By perturbing the continuous thoughts with Gaussian noise, the authors discovered that the latent space is locally smooth. Interestingly, adding noise changed the implementation style (e.g., switching from a loop to a regular expression) rather than breaking the code's functionality. The continuous thoughts act as high-level algorithmic steering wheels.
  • Tractable Likelihood Unlocks RL: Unlike diffusion models where the trajectory density is implicit, NF-CoT's exact likelihood allows seamless integration with reinforcement learning.
  • Mitigating Pass@k Collapse: Standard token-space RL often causes models to collapse onto a single mode, destroying solution diversity at higher sampling budgets ($k$). In contrast, applying RL to NF-CoT's continuous space improved pass@1 accuracy while preserving structural diversity and the upward scaling trend for large $k$.
Pass@k diversity before and after reinforcement learning.

Key Results

  • Performance Boost: NF-CoT (Unified) achieved the best average performance on the coding benchmarks, improving the Qwen3-8B-Base model's average pass@1 score from 55.8% to 68.8% (+13.0%). It also outperformed the strong diffusion baseline, LaDiR, by +7.1% on average.
  • Efficiency Gains: NF-CoT compresses an average of 385 text tokens into just 64 latent tokens (a ~6.0× compression rate).
  • Inference Speed: Because it avoids the multi-step iterative denoising required by diffusion models, NF-CoT (Unified) was 2.70× faster at latent generation and 1.92× faster overall than LaDiR, while consuming 2.48× less compute (19.9T vs 49.3T FLOPs per sample).
Pass@k scaling on MBPP+ and HumanEval+.

Limitations and Future Work

  • Domain Specificity: The evaluation was strictly focused on code generation, where automated unit tests provide a clean reward signal for RL. Generalizing this to broader reasoning domains without exact verifiers remains an open challenge.
  • Fixed Latent Budget: The model uses a fixed number of latent slots (64 tokens), which might be an overkill for simple problems and insufficient for highly complex, multi-step reasoning tasks.
  • Interpretability: Because the reasoning happens entirely in a continuous latent space, the "thoughts" are not human-readable, making the model's internal logic difficult to audit directly without decoding them back to text via a VAE.

Summary updated

BibTeX
@misc{tu2026latent,
  author = {Guancheng Tu and Xiangjun Fu and Suhao Yu and Yao Tang and Haoqiang Kang and Lianhui Qin and Yizhe Zhang and Jiatao Gu},
  title = {{Latent Reasoning with Normalizing Flows}},
  year = {2026},
  eprint = {2606.06447},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.06447},
}
Figure