This paper, presented at ICLR 2024, introduces a powerful new way to fine-tune Large Language Models (LLMs) by treating complex reasoning and generation tasks as problems of amortized Bayesian inference. By leveraging Generative Flow Networks (GFlowNets), the authors enable LLMs to sample diverse, high-quality sequences from distributions that are typically mathematically intractable to compute.
TL;DR
Instead of training LLMs to just find the "single best" answer, this work uses GFlowNets to fine-tune models to sample a diverse set of valid reasoning chains. This approach significantly improves performance in low-data regimes and enhances out-of-distribution generalization for tasks like multi-step arithmetic and story infilling.
What Problem Does This Paper Address?
Standard LLMs are great at predicting the next token in a sequence (autoregressive sampling). However, many important tasks require "filling in the blanks" or reasoning toward a specific goal. Mathematically, these are posterior inference problems: given a question ($X$) and a desired answer ($Y$), what is the most likely reasoning chain ($Z$)?
The challenge is that the "true" distribution of these reasoning chains is intractable. You can't easily calculate the probability of a specific chain without summing over every possible sequence of words, which is impossible. Existing solutions have major flaws:
- Maximum Likelihood (MLE): Requires massive amounts of high-quality human demonstrations.
- Standard Reinforcement Learning (e.g., PPO): Often suffers from "mode collapse," where the model finds one "good enough" answer and stops exploring others, leading to poor diversity and brittle generalization.
- MCMC Sampling: Too slow for real-time text generation.
Methods
The authors propose fine-tuning LLMs using GFlowNets. Unlike standard RL, which seeks to maximize a reward, GFlowNets are designed for distribution matching. They train a policy to sample objects (like a sentence or a reasoning chain) with a probability proportional to a given reward function.
Key technical components include:
- Latent Variable Modeling: They treat the "Chain-of-Thought" ($Z$) as a hidden variable between the input ($X$) and output ($Y$).
- Subtrajectory Balance (SubTB): A specific GFlowNet objective used to train the model to match the target distribution efficiently.
- Amortization: By training the model on various inputs, it "learns" the inference process, allowing it to generate rationales for new, unseen questions instantly at test time.
- LoRA (Low-Rank Adaptation): Used to make fine-tuning large models (up to 6B parameters) computationally feasible.
Datasets
The researchers evaluated their method across four distinct types of tasks:
- Random Number Generation: A "sanity check" task using a prompt to generate uniform integers between 0 and 100.
- Sentence Continuation: Using OpenWebText to generate diverse and likely next sentences.
- Story Infilling: Using the ROCStories corpus, where the model must generate a middle sentence that connects a given beginning and end.
- Reasoning & Tool Use:
- SUBJ: A subjectivity classification dataset (movie reviews).
- Integer Arithmetic: A synthetic dataset of addition and subtraction problems requiring a calculator tool.
Key Insights and Ideas
- Diversity is a Feature, Not a Bug: In Bayesian modeling, we often want to sample multiple rationales and "vote" on the final answer. GFlowNets provide the diversity needed for this "Bayesian model averaging" to work effectively.
- Robustness to Reward Misspecification: Standard RL (PPO) can "hack" a reward function by finding weird, non-human-like sequences that technically get a high score. Because GFlowNets try to match the entire distribution of high-reward sequences, they are much more robust to these spurious modes.
- Generalization through Diversity: By learning a diverse set of ways to solve a problem, the model generalizes better to harder, out-of-distribution (OOD) examples (e.g., solving math problems with more numbers than seen during training).
Key Results
- Subjectivity Classification: With only 10 labeled examples, GFlowNet fine-tuning achieved 71.4% accuracy, a 10.9% absolute improvement over standard supervised fine-tuning (SFT).
- Arithmetic Reasoning: On OOD problems (5 operands when trained on 3-4), GFlowNet outperformed SFT and PPO by 63%, reaching 40.7% accuracy compared to SFT's 12.8%.
- Likelihood vs. Diversity: For sentence continuation, GFlowNet achieved a better trade-off than beam search, producing sentences with higher log-likelihood while maintaining significantly higher semantic diversity.
Limitations and Future Work
- Model Scale: The experiments were limited to models up to 6B parameters due to compute constraints. The authors expect the benefits to scale even further with larger models.
- Knowledge vs. Inference: This method improves the model's ability to query its internal knowledge (inference) but doesn't necessarily add new knowledge. Issues like hallucinations stemming from the base model's training data remain.
- Exploration: For extremely complex latent spaces, finding the initial "good" samples to start the GFlowNet training remains a challenge.
Future directions include building "universal reasoners" that share a GFlowNet policy across different tasks and extending the framework to more complex structures like tree-of-thought reasoning or program synthesis.
Summary updated