Fine-Grained Transfer Learning for Harmful Content Detection through Label-Specific Soft Prompt Tuning

Faeze Ghorbanpour, Viktor Hangya, Alexander FraserNAACL 2025 · OpenReview

Abstract

The spread of harmful content online is a dynamic issue evolving over time. Existing detection models, reliant on static data, are becoming less effective and generalizable. Developing new models requires sufficient up-to-date data, which is challenging. A potential solution is to combine existing datasets with minimal new data. However, detection tasks vary—some focus on hate speech, offensive, or abusive content, which differ in the intent to harm, while others focus on identifying targets of harmful speech such as racism, sexism, etc.—raising the challenge of handling nuanced class differences. To address these issues, we introduce a novel transfer learning method that leverages class-specific knowledge to enhance harmful content detection. In our approach, we first present label-specific soft prompt tuning, which captures and represents class-level information. Secondly, we propose two approaches to transfer this fine-grained knowledge from source (existing tasks) to target (unseen and new tasks): initializing the target task prompts from source prompts and using an attention mechanism that learns and adjusts attention scores to utilize the most relevant information from source prompts. Experiments demonstrate significant improvements in harmful content detection across English and German datasets, highlighting the effectiveness of label-specific representations and knowledge transfer.

Introduction: The Challenge of Evolving Toxicity

Detecting harmful content is a moving target. Language evolves rapidly, and what constitutes "hate speech" in one dataset might be labeled as "offensive" or "abusive" in another. Standard transfer learning often struggles with these nuances because it treats a dataset as a monolithic task, ignoring the fine-grained semantic differences between labels.

Furthermore, fine-tuning massive Large Language Models (LLMs) for every new niche dataset is computationally prohibitive. While Parameter-Efficient Fine-Tuning (PEFT) methods like Soft Prompt Tuning—adding a small set of tunable vectors to the input—mitigate costs, they typically learn a single representation for an entire task. This paper, presented at NAACL 2025, argues that such an approach is too blunt for toxicity detection, where the distinction between "normal" and "hateful" is more critical than the distinction between two different datasets.

Methodology: Label-Specific and Attentional Tuning

The researchers introduce two major innovations to move from task-level to label-level representations:

  1. Label-Specific Soft Prompt Tuning: Instead of one prompt for a task, the model creates $k$ prompts for $k$ classes. The classification problem is transformed into a contrastive format: the model receives an input and a label-specific prompt and must predict "yes" if they match or "no" if they do not. This forces the model to learn the distinct semantic "flavor" of each individual label.
  2. Fine-Grained Transfer Learning: To move knowledge from source tasks to new target tasks, the authors propose two mechanisms:
  3. Initialization-based: Manually "seeding" a new target prompt (e.g., "racism") with the weights of a similar source prompt (e.g., "hate").
  4. Attentional Transfer: An attention mechanism allows the model to automatically determine which source label prompts from a library of existing tasks are most relevant to a new target label. For instance, a "sexism" detector might learn to prioritize previous "hate" and "insult" prompts over "normal" ones.
Figure 2: Overview of Initialization-Based and Attentional Target Prompt Tuning architectures.

Key Insights: Labels as Stable Semantic Anchors

A core finding of the study is that labels are often more stable than tasks. A "hate" label in a German dataset often shares more underlying features with a "hate" label in an English dataset than it does with the "normal" label in its own dataset. By focusing on labels, the model captures these cross-task commonalities.

Using t-SNE to visualize the prompt vectors, the authors found that prompts for similar concepts (like different types of profanity or targeted harassment) naturally clustered together in vector space, even when they originated from entirely different datasets. This empirical evidence supports the use of label-specific prompts as effective semantic anchors for transfer learning.

Figure 4: t-SNE visualizations showing the clustering of similar label prompts across different datasets.

Experimental Results

The study utilized a diverse array of benchmarks, including GermEval 18, HASOC 19, HateSpeech 18, OLID, and SRW 16, covering binary classification and fine-grained types across English and German.

  • Performance Gains: Label-specific tuning consistently outperformed standard task-specific prompt tuning across T5-Small, Base, and Large models.
  • Transfer Efficiency: The attentional transfer method provided a significant jump in F1-macro scores compared to training on target data alone. It acts as a "smart filter," eliminating the need for manual selection of source datasets.
  • Few-Shot Robustness: The method excels when data is scarce. In 1-shot and 16-shot experiments, the label-specific attentional method significantly outperformed task-specific baselines, proving that "borrowing" label knowledge is crucial with limited examples.
  • Cross-Lingual Success: The approach worked effectively across English and German, suggesting the learned label representations capture concepts that transcend specific languages.

Conclusion

By shifting the focus from tasks to labels, this research provides a more surgical and parameter-efficient approach to harmful content detection. While the current study focused on explicit content and the T5 model series, future work may explore implicit toxicity ("dog whistles") and the behavior of these label-specific prompts in larger decoder-only models like Llama or GPT-4.

Reference: Ghorbanpour, F., Hangya, V., & Fraser, A. (2025). Fine-Grained Transfer Learning for Harmful Content Detection through Label-Specific Soft Prompt Tuning. Proceedings of NAACL 2025.

Summary updated

Abstract

The spread of harmful content online is a dynamic issue evolving over time. Existing detection models, reliant on static data, are becoming less effective and generalizable. Developing new models requires sufficient up-to-date data, which is challenging. A potential solution is to combine existing datasets with minimal new data. However, detection tasks vary—some focus on hate speech, offensive, or abusive content, which differ in the intent to harm, while others focus on identifying targets of harmful speech such as racism, sexism, etc.—raising the challenge of handling nuanced class differences. To address these issues, we introduce a novel transfer learning method that leverages class-specific knowledge to enhance harmful content detection. In our approach, we first present label-specific soft prompt tuning, which captures and represents class-level information. Secondly, we propose two approaches to transfer this fine-grained knowledge from source (existing tasks) to target (unseen and new tasks): initializing the target task prompts from source prompts and using an attention mechanism that learns and adjusts attention scores to utilize the most relevant information from source prompts. Experiments demonstrate significant improvements in harmful content detection across English and German datasets, highlighting the effectiveness of label-specific representations and knowledge transfer.
BibTeX
@inproceedings{ghorbanpour2025fine,
  author = {Faeze Ghorbanpour and Viktor Hangya and Alexander Fraser},
  title = {{Fine-Grained Transfer Learning for Harmful Content Detection through Label-Specific Soft Prompt Tuning}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=nzK3L7ZoGt},
}
Figure