Abstract
Large Language Models (LLMs) excel at fluent text generation but struggle with fine-grained control over attributes like sentiment or toxicity without expensive fine-tuning. We present PPL-MCTS (Plug and Play Language - Monte Carlo Tree Search), a decoding strategy that treats text generation as a tree search problem. Guided by a simple discriminator, PPL-MCTS explores potential future sequences to ensure long-term constraint satisfaction. Our method achieves state-of-the-art results on sentiment and emotion control tasks across multiple languages while remaining compatible with any frozen LLM.
Introduction
While models like GPT-2 and GPT-3 generate highly fluent text, steering their output toward specific constraints—such as maintaining a positive sentiment or avoiding toxic language—remains a significant challenge. Traditional approaches rely on fine-tuning, which is computationally expensive and requires maintaining separate model versions for every constraint. Existing "plug-and-play" methods often suffer from a "myopic" view, selecting tokens based on immediate probability without considering how a locally optimal choice might lead to a constraint violation later in the sequence.
To address this, we propose PPL-MCTS, which gives decoding "long-term vision" by treating the generation process as a tree exploration task, similar to the logic used in AlphaGo.
Methodology: PPL-MCTS
PPL-MCTS adapts the Monte Carlo Tree Search algorithm to natural language generation. For every token generated, the model performs an iterative four-step process:
- Selection: The algorithm navigates the tree of possible word sequences using the PUCT (Polynomial Upper Confidence Trees) algorithm. This balances exploitation (choosing words the language model prefers) with exploration (investigating less likely paths that might better satisfy the constraint).
- Expansion: The frozen language model identifies potential next tokens to expand the search tree.
- Simulation (Roll-out): This critical "look-ahead" step involves sampling a few tokens into the future to estimate the eventual outcome of a specific path. Even a short look-ahead (e.g., 5 tokens) drastically improves performance.
- Backpropagation: A small, external discriminator (e.g., a BERT-based classifier) scores the resulting sequence. This score is propagated back up the tree to update the value of the preceding tokens.
Crucially, PPL-MCTS only requires access to the language model's output logits, making it compatible with models accessed via API.
Experimental Evaluation
The effectiveness of PPL-MCTS was evaluated across three distinct tasks and two languages:
- Sentiment Control (English): Using the
amazon_polaritydataset. - Emotion Control (English): Using the
emotiondataset (8 classes). - Cross-lingual Sentiment (French): Using the
CLSdataset from the FLUE benchmark.
Key Results and Insights
- State-of-the-Art Performance: On
amazon_polarity, PPL-MCTS achieved 97% accuracy in sentiment control, outperforming PPLM (89%) and matching fine-tuned models like GeDi. - Human Preference: Blind human evaluations rated PPL-MCTS higher than baselines in both constraint adherence ("Polarity") and naturalness ("Readability").
- Diversity and Re-ranking: The study found that generating a diverse set of candidate sequences is essential; if the pool is diverse, a simple discriminator can effectively identify the best path.
Conclusion and Limitations
PPL-MCTS demonstrates that sophisticated decoding strategies can match the performance of fine-tuned models without the associated costs. However, the method is computationally more expensive than greedy decoding due to its multi-path exploration. Future work includes optimizing this cost through adaptive roll-outs and applying the framework to complex constraints like factual correctness in summarization.
Summary updated