Reinforcement Learning with Token-level Feedback for Controllable Text Generation

Wendi Li, Wei Wei, Kaihe Xu, Wenfeng Xie, Dangyang Chen, Yu Cheng · DOI

Abstract

Controllable Text Generation (CTG) is essential for steering Large Language Models (LLMs) toward specific styles, sentiments, or safety constraints. Traditional reinforcement learning (RL) approaches for CTG often rely on coarse-grained sentence-level rewards, which can lead to slow convergence and imprecise attribute control. This paper introduces TOLE (TOken-LEvel guidance), a framework that shifts feedback from the sentence level to the token level. By utilizing the "probability shift" of attribute classifiers at each generation step and employing a "first-quantize-then-noise" paradigm to prevent reward hacking, TOLE achieves superior performance and faster convergence across single and multi-attribute control tasks with minimal computational overhead.

Introduction

Controllable Text Generation aims to modify the output of LLMs to satisfy specific constraints, such as formality, sentiment, or the absence of toxicity. While RL is a powerful tool for this task, most existing methods provide feedback only after a full sentence is generated. This coarse-grained approach suffers from "semantic twists"—where a sentence may fluctuate between desired and undesired attributes—and slow convergence due to the lack of precise, step-by-step guidance. Furthermore, models often overfit to reward functions, leading to "semantic collapse" or repetitive, low-quality text.

Methodology

TOLE addresses these challenges through a three-pronged architecture designed for fine-grained control and robustness.

Token-level Rewards via Bayesian Factorization

Instead of a single terminal reward, TOLE calculates a reward for every token based on the probability shift. This metric measures how much a specific token changes the classifier's confidence that the final sequence will satisfy the target attribute. This provides the model with immediate, precise signals regarding which words contribute most effectively to the desired goal.

First-Quantize-Then-Noise (FQTN)

To mitigate "reward hacking"—where the RL agent exploits mathematical artifacts in the classifier rather than improving text quality—TOLE introduces the FQTN paradigm. Rewards are first quantized into discrete buckets (quantiles) and then perturbed with Gaussian noise. This strategy preserves the relative ranking of tokens while disrupting fixed scoring patterns that lead to overfitting.

Overview of the TOLE framework, illustrating the Exploration, Learning, and Quantize & Noise components.

Multi-Attribute Weigher

For tasks requiring multiple constraints (e.g., positive sentiment and specific topics), TOLE utilizes a trainable "weigher" module. This module analyzes the LLM's internal hidden states to dynamically prioritize different attributes for each token, ensuring that topic-specific words and sentiment-bearing words are rewarded appropriately.

Experimental Results

The authors evaluated TOLE on sentiment control (OpenWebText/SST-5), detoxification (RealToxicityPrompts), and multi-attribute control (Yelp reviews).

Performance and Efficiency

TOLE demonstrated significant improvements in attribute correctness. In sentiment tasks, TOLE achieved accuracy between 69-72%, far outperforming standard PPO methods (~43-47%). Notably, TOLE utilizes prompt-tuning, training only 0.003% of total parameters, which ensures high efficiency.

Convergence and Robustness

As shown in the training plots, the inclusion of noise (Gaussian) and token-level feedback allows the model to reach peak accuracy faster than sentence-level baselines while maintaining higher linguistic diversity (measured by dist-3).

Training curves showing accuracy (acc) and diversity (dist-3) over 20,000 steps for different reward strategies.

Key Insights

  • The Power of the Shift: Measuring the change in probability provides a more actionable signal for RL than absolute probability scores.
  • Regularization through Noise: Adding noise to quantized rewards acts as a powerful regularizer, preventing the model from becoming a "stochastic parrot" that repeats a limited set of high-reward tokens.
  • Context-Aware Control: The dynamic weigher allows the model to handle complex, overlapping constraints by identifying which tokens are relevant to which attributes in real-time.

Conclusion and Future Work

TOLE represents a significant step forward in making LLMs more controllable and efficient. By providing token-level guidance and robust reward mechanisms, it achieves state-of-the-art results in detoxification and style transfer. Future research will focus on expanding TOLE to more diverse LLM architectures and exploring its efficacy on hard lexical constraints, such as specific word exclusions or structural requirements.

Summary updated

BibTeX
@inproceedings{li2024reinforcement,
  author = {Wendi Li and Wei Wei and Kaihe Xu and Wenfeng Xie and Dangyang Chen and Yu Cheng},
  title = {{Reinforcement Learning with Token-level Feedback for Controllable Text Generation}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-naacl.111},
}
Figure