Toxic content detection is crucial for online services to remove inappropriate content that violates community standards. To automate the detection process, prior works have proposed varieties of machine learning (ML) approaches to train Language Models (LMs) for toxic content detection. However, both their accuracy and transferability across datasets are limited. Recently, Large Language Models (LLMs) have shown promise in toxic content detection due to their superior zero-shot and few-shot in-context learning ability as well as broad transferability on ML tasks. However, efficiently designing prompts for LLMs remains challenging. Moreover, the high run-time cost of LLMs may hinder their deployments in production. To address these challenges, in this work, we propose BD-LLM, a novel and efficient approach to Bootstrapping and Distilling LLMs for toxic content detection. Specifically, we design a novel prompting method named Decision-Tree-of-Thought (DToT) to bootstrap LLMs' detection performance and extract high-quality rationales. DToT can automatically select more fine-grained context to re-prompt LLMs when their responses lack confidence. Additionally, we use the rationales extracted via DToT to fine-tune student LMs. Our experimental results on various datasets demonstrate that DToT can improve the accuracy of LLMs by up to 4.6%. Furthermore, student LMs fine-tuned with rationales extracted via DToT outperform baselines on all datasets with up to 16.9\% accuracy improvement, while being more than 60x smaller than conventional LLMs. Finally, we observe that student LMs fine-tuned with rationales exhibit better cross-dataset transferability.
翻译:有害内容检测对于在线服务至关重要,能够移除违反社区规范的不当内容。为自动化检测流程,先前研究提出了多种机器学习方法,通过训练语言模型进行有害内容检测。然而,这些方法的准确性和跨数据集迁移能力均有限。近期,大语言模型凭借其卓越的零样本和少样本上下文学习能力以及广泛的机器学习任务迁移性,在有害内容检测中展现出潜力。但高效设计大语言模型的提示词仍具挑战性,且大语言模型的高运行时成本可能阻碍其实际部署。为解决这些问题,本文提出BD-LLM——一种新颖高效的有害内容检测方法,通过自助法和知识蒸馏对大语言模型进行优化。具体而言,我们设计了一种名为思维决策树的新型提示方法,用于提升大语言模型的检测性能并提取高质量推理依据。当大语言模型响应置信度不足时,DToT可自动选择更细粒度的上下文重新提示模型。此外,我们利用DToT提取的推理依据微调学生语言模型。在多个数据集上的实验结果表明,DToT可将大语言模型的准确率提升高达4.6%。同时,经DToT提取推理依据微调的学生语言模型在所有数据集上均优于基线方法,准确率提升最高达16.9%,而模型规模仅为传统大语言模型的1/60以下。最后,我们发现经推理依据微调的学生语言模型展现出更优的跨数据集迁移能力。