Abstract
Controllable Text Generation (CTG) aims to steer Large Language Models (LLMs) toward specific attributes like sentiment or style. Traditional reinforcement learning (RL) methods often rely on coarse-grained sentence-level rewards, which struggle to provide precise guidance during the generation process. This paper introduces TOLE (TOken-LEvel feedback), an RL algorithm that provides granular feedback for every generated token. By utilizing Bayesian token-level rewards, a "First Quantize, Then Noise" paradigm to prevent reward hacking, and a specialized weigher module for multi-attribute control, TOLE achieves superior precision and fluency. Experimental results across sentiment control, detoxification, and multi-attribute tasks demonstrate that TOLE significantly outperforms existing baselines in both attribute accuracy and text quality.
Introduction
Controllable Text Generation (CTG) is essential for tailoring LLM outputs to specific constraints, such as maintaining a positive sentiment, ensuring academic formality, or filtering toxic content. Existing approaches generally fall into two categories: post-processing methods that nudge token selection during inference, often at the cost of fluency, and reinforcement learning (RL) methods that fine-tune models on their own outputs.
A major bottleneck in RL-based CTG is the reliance on sentence-level rewards. Providing a single score for an entire sequence is "coarse-grained"; it fails to pinpoint which specific tokens contributed to the desired attribute or caused a deviation. This lack of precision leads to slow convergence and suboptimal control. To address this, researchers have developed TOLE, a framework designed to provide token-level guidance, enabling more efficient and precise steering of LLMs.
Methods
The TOLE framework introduces three core innovations to refine the RL training process for CTG:
- Bayesian Token-Level Rewards: Instead of waiting for a complete sentence, TOLE calculates a reward for every token. It employs a classifier to measure the "probability shift"—the change in the probability of satisfying a target attribute after a specific word is added. This granular feedback acts as a precise "GPS" for the model.
- "First Quantize, Then Noise" Paradigm: RL models often suffer from "reward hacking," where they find mathematical shortcuts to high scores that result in unnatural text. TOLE mitigates this by grouping reward scores into discrete buckets (quantization) and adding Gaussian noise. This encourages the model to prioritize relative quality and diversity over over-optimizing for specific decimal values.
- The Weigher Module: For tasks requiring multi-attribute control (e.g., positive sentiment + specific topic), TOLE uses a trainable MLP "weigher." This module analyzes the model's internal states to dynamically prioritize different attributes throughout the generation of a sentence.
Experimental Setup
TOLE was evaluated on several standard benchmarks to test its versatility:
- Sentiment Control: 10K prompts from the OpenWebText Corpus, with rewards derived from the SST-5 sentiment dataset.
- Detoxification: Training on 100k prompts from RealToxicityPrompts and evaluating on the WritingPrompts dataset for out-of-domain robustness.
- Multi-Attribute Control: Utilizing the Yelp restaurant review dataset to simultaneously control sentiment (Positive/Negative), topic (Asian/American/Mexican), and tense (Past/Present).
Results and Discussion
TOLE consistently outperformed both post-processing and RL baselines across all metrics.
- Sentiment and Fluency: In positive sentiment tasks, TOLE achieved an attribute correctness of 69.36%, significantly higher than the previous RL state-of-the-art, QUARK (47.32%). Crucially, it maintained a competitive Perplexity (PPL) score of 17.05, indicating high naturalness.
- Detoxification: TOLE achieved the lowest average maximum toxicity (0.206) among all tested models, including specialized detoxification baselines like DExpert.
- Multi-Attribute Success: In complex "Triple Control" tasks, TOLE maintained high accuracy across all three categories, avoiding the "attribute collapse" often seen in baseline models where one attribute is sacrificed for others.
The efficiency of TOLE is also noteworthy. Due to the precision of token-level feedback, the model converges in significantly fewer training steps compared to sentence-level methods like PPO. Furthermore, the "Quantize & Noise" strategy effectively preserves text diversity, preventing the model from becoming a "one-trick pony" that repeats high-scoring but repetitive phrases.
Conclusion and Future Work
TOLE represents a significant step forward in controllable text generation by providing granular, token-level reinforcement. While highly effective, the framework is currently optimized for attribute-level control. Future research will explore its applicability to structural constraints, such as lexical requirements or table-to-text generation. Additionally, while the quantization strategy mitigates reward hacking, further work is needed to ensure robustness against more complex or adversarial reward models in high-stakes safety applications.
Summary updated