Attribute Controlled Fine-tuning for Large Language Models: A Case Study on Detoxification

Tao Meng, Ninareh Mehrabi, Palash Goyal, Anil Ramakrishna, Aram Galstyan, Richard S. Zemel, Kai-Wei Chang, Rahul Gupta, Charith Peris

Introduction

As Large Language Models (LLMs) become increasingly integrated into user-facing applications, the challenge of ensuring they adhere to safety and stylistic constraints has become paramount. Generating content that is toxic, biased, or unsafe remains a significant risk. Existing solutions to this problem typically fall into three categories: post-hoc filtering, which is computationally inefficient; data filtering, which can lead to catastrophic forgetting; and Reinforcement Learning (RL), which is often unstable and requires extensive preference data.

This paper proposes a "middle way": a principled fine-tuning method that regularizes the model's distribution toward a "feasible region" of safe outputs. This approach maintains the model's original utility while ensuring adherence to specific attribute constraints, such as detoxification.

Methodology: Posterior Regularization and NADO

The core of the proposed approach is Posterior Regularization. Rather than relying solely on next-token prediction loss, the researchers introduce a regularization term that penalizes the model if its output distribution drifts too far from a desired distribution—specifically, one that satisfies predefined constraints (the "feasible region" $Q$).

Conceptual visualization of pushing the base LLM distribution towards the feasible region where constraints are satisfied.

To implement this at scale, the authors employ two key innovations:

  1. Neurally-Decomposed Oracle (NADO): High-level constraints like "avoid toxicity" apply to entire sequences, making them difficult to enforce during token-by-token generation. NADO is an auxiliary model that decomposes these sequence-level constraints into token-level probabilities. It essentially predicts the likelihood that a partial sequence will result in a non-toxic final output, providing the necessary guidance for the LLM during training.
  2. Iterative Refinement: One-shot estimation of the target distribution is rarely sufficient. By iteratively pushing the model toward the feasible region, the guidance provided by the NADO model becomes progressively more accurate, leading to a more robust final model.

Efficient Training via Parallel Fine-tuning

Traditionally, updating an auxiliary model and the primary LLM would require a sequential process, which is time-consuming. The authors developed a Parallel Fine-tuning scheme where the LLM, the data labeling oracle, and the NADO model are updated concurrently across different iterations.

Comparison between sequential (a) and parallel (b) fine-tuning schemes, demonstrating the concurrent update process.

This parallelization achieves a 3x speedup over sequential methods, making the computational cost of controlled fine-tuning nearly identical to standard fine-tuning. This efficiency is critical for scaling the method to larger models and more complex constraint sets.

Experimental Evaluation

The researchers evaluated their framework on the task of detoxification using datasets such as RealToxicPrompts (RTP) and ToxiGen. To ensure the model retained its general capabilities, they used Wikitext for utility preservation and standard benchmarks like MMLU and Commonsense Reasoning.

Key Results

  • Superior Detoxification: On Llama-7B, the method reduced toxicity scores from a baseline of 0.315 to 0.259, notably outperforming standard Reinforcement Learning approaches (0.269).
  • Utility Preservation: Unlike many safety-tuning methods that degrade reasoning performance, this approach maintained high scores across general knowledge benchmarks.
  • Enhanced Understanding: Interestingly, the method improved the model's ability to classify toxic content. By learning to avoid toxicity through regularization rather than simple filtering, the model develops a better internal representation of what constitutes toxic language.

Conclusion

This research demonstrates that attribute control in LLMs does not have to come at the cost of training efficiency or general model utility. By combining posterior regularization with a parallelized training schema, the authors provide a scalable framework for aligning LLMs with complex safety constraints. Future work may extend this framework to other attributes such as sentiment, style, and multi-constraint optimization.

Summary updated

BibTeX
@inproceedings{meng2024attribute,
  author = {Tao Meng and Ninareh Mehrabi and Palash Goyal and Anil Ramakrishna and Aram Galstyan and Richard S. Zemel and Kai-Wei Chang and Rahul Gupta and Charith Peris},
  title = {{Attribute Controlled Fine-tuning for Large Language Models: A Case Study on Detoxification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.779},
}
Figure