Décodage guidé par un discriminateur avec le Monte Carlo Tree Search pour la génération de texte contrainte (Discriminator-guided decoding with Monte Carlo Tree Search for constrained text generation )

Antoine Chaffin, Vincent Claveau, Ewa KijakTALN-RECITAL 2022

Introduction

Controlling the output of Large Language Models (LLMs)—such as ensuring non-toxicity or enforcing a specific emotional tone—remains a significant challenge. While fine-tuning is a common solution, it is computationally expensive and often impossible for massive, proprietary models. This paper introduces PPL-MCTS (Plug and Play Language - Monte Carlo Tree Search), a novel decoding algorithm that uses an external discriminator to steer frozen LLMs toward specific constraints by simulating future tokens.

The Challenge: Overcoming "Short-Sighted" Decoding

Existing "plug-and-play" methods typically use a small classifier (discriminator) to guide the LLM during generation. However, these methods often suffer from "myopia," scoring only the immediate next token. If a discriminator makes a poor judgment early on due to a lack of context, the entire generation can derail into a suboptimal path.

Tree representation of text generation where nodes represent tokens and branches represent conditional probabilities and constraint scores.

As shown in the figure above, text generation can be viewed as a search tree. PPL-MCTS addresses the short-sightedness of standard methods by "looking ahead" to see how a sentence might unfold before committing to a specific token.

Methodology: The PPL-MCTS Framework

The authors frame text generation as a game tree exploration problem. They adapt the Monte Carlo Tree Search (MCTS) algorithm—famed for its success in AlphaGo—to the domain of natural language processing. The process follows a four-step cycle:

  1. Selection: The tree is traversed using a modified PUCT (Polynomial Upper Confidence Tree) formula, balancing the LLM's prior probability (exploitation) with the need to explore new paths.
  2. Expansion: The frozen LLM generates potential next tokens to expand the current node.
  3. Simulation (Roll-out): The algorithm rapidly samples tokens from the current node to a fixed horizon or the end of the sequence to gain a long-term view.
  4. Backpropagation: The external discriminator evaluates the completed simulation. This score is passed back up the tree to inform the selection of the immediate next token.
The four stages of the MCTS cycle adapted for text generation: Selection, Expansion, Simulation, and Backpropagation.

To balance fluency and constraint satisfaction, the authors introduce a parameter ($\alpha$) to control the trade-off between the LLM's likelihood and the discriminator's score.

Experimental Setup and Results

The researchers evaluated PPL-MCTS across English and French datasets, including amazon_polarity (sentiment), CLS (French sentiment), and emotion (multi-class tweet categorization).

Key Insights

  • Lookahead Utility: MCTS roll-outs allow the discriminator to evaluate complete thoughts rather than fragmented prefixes, preventing the model from reaching "dead ends."
  • Efficiency via Partial Roll-outs: While full simulations are expensive, the authors discovered that rolling out just 5 to 10 tokens ahead provides performance nearly identical to full roll-outs, offering a practical compromise.
  • Performance: PPL-MCTS matched or outperformed state-of-the-art fine-tuning methods like GeDi without requiring any model updates. On the amazon_polarity dataset, it achieved a precision of 0.97 with a low perplexity of 5.69.
  • Human Validation: Blind human evaluations on the French CLS dataset confirmed that PPL-MCTS produces text that is both on-target and highly readable, significantly outperforming older methods like PPLM.

Conclusion and Future Work

PPL-MCTS demonstrates that sophisticated search algorithms can effectively guide LLMs toward complex constraints without the need for retraining. While MCTS introduces computational overhead, future work focusing on adaptive roll-out sizes—stopping simulations once confidence thresholds are met—could further optimize the balance between generation quality and speed.

Summary updated

BibTeX
@inproceedings{chaffin2022decodage,
  author = {Antoine Chaffin and Vincent Claveau and Ewa Kijak},
  title = {{Décodage guidé par un discriminateur avec le Monte Carlo Tree Search pour la génération de texte contrainte (Discriminator-guided decoding with Monte Carlo Tree Search for constrained text generation )}},
  booktitle = {TALN-RECITAL},
  year = {2022},
}
Figure