Goodtriever: Adaptive Toxicity Mitigation with Retrieval-augmented Models

TL;DR

Goodtriever uses retrieval-augmented methods to reduce inference latency by 43% while maintaining state-of-the-art toxicity mitigation.

cs.AI 🔴 Advanced 2023-10-11 18 views
Luiza Pozzobon Beyza Ermis Patrick Lewis Sara Hooker
AI safety retrieval-augmented toxicity mitigation model efficiency continual learning

Key Findings

Methodology

Goodtriever employs a retrieval-augmented inference framework combining two external datastores—one toxic, one non-toxic—to control text generation. It integrates a Transformer-based language model with a retrieval mechanism that searches for k-nearest neighbors in each datastore based on context embeddings. The retrieved probabilities are combined with the base model via a product of experts approach, allowing dynamic, real-time adjustment of toxicity levels without retraining the core model. This setup enables flexible, efficient toxicity mitigation suitable for static and continual learning scenarios, significantly reducing inference latency and computational costs.

Key Results

  • In static toxicity mitigation tasks, Goodtriever achieves comparable performance to state-of-the-art methods, with a 43% reduction in inference latency and a 43% decrease in parameters, while lowering EMT toxicity scores by up to 48%.
  • Across models from 124M to 6.9B parameters, Goodtriever maintains consistent mitigation effectiveness, demonstrating scalability and robustness.
  • Automatic and human-annotated datastore experiments show that smaller, automatically labeled datastores can outperform full-sized human-annotated ones in toxicity control, highlighting efficiency gains.

Significance

This work addresses the critical need for adaptable, low-cost, and scalable toxicity mitigation in large language models deployed in dynamic real-world environments. By enabling models to dynamically incorporate new toxicity types and update their knowledge without retraining, it paves the way for safer AI systems. The approach also reduces inference latency, making real-time applications feasible, and offers a flexible framework that can be extended to multi-modal and multi-task settings, significantly advancing AI safety research.

Technical Contribution

The core innovation lies in combining multiple retrieval mechanisms with a product of experts fusion strategy, allowing flexible, real-time control over generated content. The method supports dynamic storage editing, enabling rapid updates to toxicity data. It also demonstrates that retrieval-augmented models can outperform static fine-tuning in continual learning scenarios, providing a new paradigm for scalable, adaptable toxicity mitigation that reduces computational costs and model complexity.

Novelty

This is the first systematic integration of multiple retrieval sources with a product of experts fusion for dynamic toxicity control, moving beyond static fine-tuning or constraint-based decoding. It emphasizes real-time adaptability, storage editing, and scalability, addressing key limitations of prior approaches and establishing a new standard for flexible, efficient toxicity mitigation in language models.

Limitations

  • The effectiveness depends heavily on the quality and representativeness of the toxic and non-toxic datastores; automatic labeling may introduce biases or inaccuracies.
  • Retrieval mechanisms may struggle with out-of-distribution inputs or highly novel toxic patterns, requiring further optimization.
  • Scaling to extremely large models or multi-modal data remains challenging, with potential increases in retrieval latency and storage costs.

Future Work

Future directions include enhancing automatic datastore labeling accuracy, integrating multi-modal retrieval for richer context understanding, optimizing retrieval efficiency for ultra-large models, and exploring federated or decentralized learning frameworks to improve scalability and privacy in continual toxicity mitigation.

AI Executive Summary

The rapid deployment of large-scale pre-trained language models (LLMs) like GPT-3 and beyond has revolutionized natural language processing, enabling unprecedented capabilities in text generation, translation, and understanding. However, these models also pose significant safety concerns, notably the generation of toxic, biased, or harmful content. Traditional mitigation strategies—such as fine-tuning or constrained decoding—are effective but often costly, static, and unable to adapt to the evolving nature of language and toxicity patterns.

In response, this paper introduces Goodtriever, a novel retrieval-augmented framework designed to dynamically control toxicity during inference. By leveraging external datastores containing toxic and non-toxic examples, Goodtriever retrieves relevant context information in real-time, which is then combined with the base language model’s predictions through a product of experts approach. This method allows for flexible, on-the-fly adjustments to the generated content, significantly reducing toxicity without retraining the core model.

The key advantage of Goodtriever lies in its efficiency. It achieves a 43% reduction in inference latency compared to previous state-of-the-art methods like DExperts, while requiring fewer parameters—three times fewer—making it suitable for large-scale deployment. Extensive experiments across different model sizes (from 124 million to 6.9 billion parameters) demonstrate consistent toxicity mitigation, with EMT scores decreasing by up to 48%. The framework also excels in continual learning scenarios, quickly adapting to new toxicity types and domains, outperforming traditional fine-tuning approaches.

This work marks a significant step forward in AI safety, offering a scalable, adaptable, and low-cost solution to toxicity control. Its ability to incorporate new knowledge dynamically and maintain high performance underlines its potential for real-world applications, including content moderation, dialogue systems, and social media platforms. Future research will focus on multi-modal extensions, improving automatic datastore annotation, and optimizing retrieval efficiency for even larger models, aiming to create safer, more reliable AI systems in an ever-changing linguistic landscape.

Deep Dive

Abstract

Considerable effort has been dedicated to mitigating toxicity, but existing methods often require drastic modifications to model parameters or the use of computationally intensive auxiliary models. Furthermore, previous approaches have often neglected the crucial factor of language's evolving nature over time. In this work, we present a comprehensive perspective on toxicity mitigation that takes into account its changing nature. We introduce Goodtriever, a flexible methodology that matches the current state-of-the-art toxicity mitigation while achieving 43% relative latency reduction during inference and being more computationally efficient. By incorporating a retrieval-based approach at decoding time, Goodtriever enables toxicity-controlled text generation. Our research advocates for an increased focus on adaptable mitigation techniques, which better reflect the data drift models face when deployed in the wild. Code and data are available at https://github.com/for-ai/goodtriever.

cs.AI