Using In-Context Learning to Improve Dialogue Safety

Nicholas Meade, Spandana Gella, Devamanyu Hazarika, Prakhar Gupta, Di Jin +3 more
2/2/2023
cs.CL

No official code found. Best implementation: ncmeade/icl-safety (0 stars, MIT, last commit 2025-08-17).

Abstract

While large neural-based conversational models have become increasingly proficient dialogue agents, recent work has highlighted safety issues with these systems. For example, these systems can be goaded into generating toxic content, which often perpetuates social biases or stereotypes. We investigate a retrieval-based method for reducing bias and toxicity in responses from chatbots. It uses in-context learning to steer a model towards safer generations. Concretely, to generate a response to an unsafe dialogue context, we retrieve demonstrations of safe responses to similar dialogue contexts. We find our method performs competitively with strong baselines without requiring training. For instance, using automatic evaluation, we find our best fine-tuned baseline only generates safe responses to unsafe dialogue contexts from DiaSafety 4.04% more than our approach. Finally, we also propose a re-ranking procedure which can further improve response safeness.

View on arXivView PDF

Code Implementations(1)

ncmeade/icl-safetyCommunity63%
MIT

Findings of EMNLP 2023: Using In-Context Learning to Improve Dialogue Safety

00Shell, PythonAug 17, 20251 years agoMIT

Similar Papers

Cite this paper

@article{meade2023using,
  title  = {Using In-Context Learning to Improve Dialogue Safety},
  author = {Nicholas Meade and Spandana Gella and Devamanyu Hazarika and Prakhar Gupta and Di Jin and Siva Reddy and Yang Liu and Dilek Hakkani-Tür},
  year   = {2023},
  eprint = {2302.00871},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2302.00871v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2302.00871.svg)](https://codeofpaper.com/paper/2302.00871)

Discussion