Overview
Autoregressive Large Language Models (LLMs) are fundamentally designed to generate text left-to-right. While this makes standard text generation straightforward, it renders tasks that require satisfying complex constraints—like filling in the blanks or generating diverse reasoning chains—computationally intractable. This paper proposes a novel approach: fine-tuning LLMs using Generative Flow Networks (GFlowNets) to learn to sample directly from these complex posterior distributions. This "distribution-matching" technique outperforms standard reinforcement learning (like PPO) and supervised fine-tuning, particularly in data-scarce reasoning and tool-use tasks.
The Challenge of Intractable Posteriors
LLMs are trained to predict the next token given a preceding context, optimizing for left-to-right generation. However, many real-world applications require sampling from an intractable posterior distribution where the end goal or surrounding context is already fixed.
Consider story infilling: generating the middle of a story given both the beginning and the end. Or consider Chain-of-Thought (CoT) reasoning: finding the hidden logical steps that successfully connect a specific question to a known answer.
Traditionally, solving these problems relies on slow search algorithms (like Markov Chain Monte Carlo or beam search) or standard Reinforcement Learning (RL) techniques like Proximal Policy Optimization (PPO). Unfortunately, standard RL is designed to maximize a reward. This often leads to "mode collapse," where the model finds a single high-reward sequence and repeats it endlessly, losing all generation diversity. The core challenge is teaching an LLM to quickly sample a diverse range of high-quality sequences that satisfy complex constraints.
Methodology: GFlowNets and Amortized Inference
The authors reframe complex generation and reasoning as a latent variable modeling problem. The hidden reasoning steps (or the missing middle of a story) are treated as latent variables ($Z$) that connect the input ($X$) to the output ($Y$).
To sample these latent variables efficiently, the researchers employ Generative Flow Networks (GFlowNets).
- Diversity-Seeking RL: Instead of using standard RL to greedily maximize a reward, GFlowNets act as a "diversity-seeking" RL algorithm. They train a policy to generate samples with a probability proportional to their reward.
- Distribution Matching: The authors initialize a GFlowNet policy with a pre-trained LLM. They define a reward function based on the LLM's own likelihoods (e.g., how likely the LLM thinks the sequence $X \rightarrow Z \rightarrow Y$ is) and fine-tune the LLM using a GFlowNet objective.
- Amortization: By training the LLM to match this target distribution, the heavy computational lifting of Bayesian inference is "amortized"—baked directly into the model's weights. At test time, the model can generate complex, constrained sequences in a single, fast left-to-right pass.
Key Insights and Results
The authors evaluated their approach across several distinct tasks, including sentence continuation (OpenWebText), story infilling (ROCStories), few-shot reasoning (SUBJ), and multi-step reasoning with tool use (Synthetic Integer Arithmetic).
Chain-of-Thought as Bayesian Inference
The authors elegantly frame CoT reasoning not just as a prompting trick, but as a formal probabilistic inference problem where the reasoning chain is a latent variable. Because GFlowNets match the whole distribution rather than collapsing to a single mode, they generate highly diverse reasoning paths.
This diversity is incredibly powerful for "Bayesian model averaging." Generating multiple different reasoning chains for a math problem and taking a majority vote yields significantly better results than relying on a single path. Furthermore, by matching the distribution instead of maximizing it, GFlowNet fine-tuning is far more robust to imperfect reward signals, avoiding the "reward hacking" common in standard RL.
Empirical Performance
- Integer Arithmetic & Tool Use: Using a 6B parameter model (GPT-J) with only 50 training demonstrations, GFlowNet fine-tuning achieved 95.2% accuracy, vastly outperforming Supervised Fine-Tuning (SFT) (72.1%) and PPO (30.6%).
- Out-of-Distribution Generalization: On longer math problems (5 operands instead of the 3-4 seen in training), the GFlowNet model maintained 40.7% accuracy, while SFT plummeted to 12.8% and PPO to 5.6%.
- Subjectivity Classification: In a highly data-constrained regime (just 10 labeled examples), GFlowNet fine-tuning achieved a 10.9% absolute improvement over SFT.
- Story Infilling: GFlowNet-generated infills were significantly more coherent and closer to human references than standard prompting or SFT, scoring higher on BERTScore, BLEU, and GPT-4 evaluations.
Limitations and Future Directions
While promising, the approach has limitations. Due to resource constraints, the authors only tested models up to 6 billion parameters; scaling behavior to massive models like GPT-4 remains an open question. Additionally, like all on-policy RL methods, GFlowNets struggle with the "exploration problem" in vast combinatorial spaces, requiring the training buffer to be seeded with good examples. Finally, this method improves an LLM's ability to reason over the knowledge it already has, but it does not fix fundamental knowledge gaps or hallucinations.
Future work may extend this paradigm beyond left-to-right text generation to structured reasoning formats, like Tree-of-Thoughts or Graph-of-Thoughts, and apply it to complex domains like program synthesis.
Summary updated