Skip to main content
QUICK REVIEW

[Paper Review] Toxicity Detection with Generative Prompt-based Inference

Yau-Shian Wang, Yingshan Chang|arXiv (Cornell University)|May 24, 2022
Software Engineering ResearchComputer Science12 citations
TL;DR

This paper proposes a generative prompt-based inference method for zero-shot toxicity detection in text, leveraging large language models' self-diagnosing ability without fine-tuning. It demonstrates that generative classification outperforms discriminative approaches on three social media toxicity datasets, achieving higher macro-F1 and better detection of implicit toxicity while reducing reliance on biased spurious correlations.

ABSTRACT

Due to the subtleness, implicity, and different possible interpretations perceived by different people, detecting undesirable content from text is a nuanced difficulty. It is a long-known risk that language models (LMs), once trained on corpus containing undesirable content, have the power to manifest biases and toxicity. However, recent studies imply that, as a remedy, LMs are also capable of identifying toxic content without additional fine-tuning. Prompt-methods have been shown to effectively harvest this surprising self-diagnosing capability. However, existing prompt-based methods usually specify an instruction to a language model in a discriminative way. In this work, we explore the generative variant of zero-shot prompt-based toxicity detection with comprehensive trials on prompt engineering. We evaluate on three datasets with toxicity labels annotated on social media posts. Our analysis highlights the strengths of our generative classification approach both quantitatively and qualitatively. Interesting aspects of self-diagnosis and its ethical implications are discussed.

Motivation & Objective

  • To investigate whether generative prompt-based inference can effectively detect toxic content without task-specific fine-tuning.
  • To evaluate the performance of generative classification against discriminative classification in detecting implicit and subtle toxicity.
  • To reduce reliance on spurious correlations—especially between minority group mentions and toxicity labels—by avoiding binary-label supervision.
  • To explore the ethical implications of LLMs' self-diagnosing capability in toxicity detection.
  • To analyze how prompt wording influences model behavior and interpretability in zero-shot toxicity detection.

Proposed method

  • The method uses large language models (e.g., GPT-2) to generate a response conditioned on a prompt that specifies a toxic aspect, such as 'Is this text offensive?' or 'Generate a toxic version of this text.'
  • It formulates toxicity detection as a generative task: the model generates a text span that reflects whether the input is toxic, based on a prompt that frames the task as a conditional generation.
  • The approach leverages the pre-trained model’s internal knowledge of toxic content and associated judgments, avoiding the need for labeled data or fine-tuning.
  • Prompt engineering is guided by the Social Bias Frame (SBF), which helps structure prompts to detect implicit biases and subtle forms of toxicity.
  • Model outputs are classified as toxic or non-toxic based on whether the generated text aligns with a toxic label, using a thresholding or token-based classification strategy.
  • Evaluation uses macro-F1, F1 for positive and negative classes, and qualitative analysis via LIME to assess token-level contributions to predictions.

Experimental results

Research questions

  • RQ1Can generative prompt-based inference outperform discriminative prompt-based methods in zero-shot toxicity detection?
  • RQ2How does the generative approach handle implicit and subtle forms of toxicity that are not captured by keyword-based methods?
  • RQ3To what extent does the generative method reduce reliance on spurious correlations between minority group mentions and toxicity labels?
  • RQ4How does prompt wording influence the model’s detection behavior and interpretability?
  • RQ5What are the ethical risks associated with LLMs’ self-diagnosing ability in toxicity detection?

Key findings

  • The generative classification approach achieved higher macro-F1 scores than discriminative classification across all three datasets: SBIC, HateXplain, and SemEval 2019.
  • On the SBIC dataset, the largest GPT-2 model achieved a macro-F1 of 0.62 with generative classification, outperforming the discriminative baseline.
  • The generative method showed superior performance on detecting implicit toxicity, particularly in cases where no slurs or explicit offensive words were present.
  • Qualitative analysis revealed that the model’s predictions were more robust to toxic keywords, with LIME highlighting that non-toxic tokens often contributed more to correct classification than toxic keywords.
  • The approach reduced the risk of exploiting spurious correlations between minority group mentions and toxicity labels due to the absence of binary supervision.
  • Ethical concerns were identified, including the potential for dual-use misuse and the fragility of self-diagnosis if pre-training data is filtered to remove toxic content and associated judgments.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.