This paper investigates the effectiveness of large language models (LLMs) in email spam detection by comparing prominent models from three distinct families: BERT-like, Sentence Transformers, and Seq2Seq. Additionally, we examine well-established machine learning techniques for spam detection, such as Na\"ive Bayes and LightGBM, as baseline methods. We assess the performance of these models across four public datasets, utilizing different numbers of training samples (full training set and few-shot settings). Our findings reveal that, in the majority of cases, LLMs surpass the performance of the popular baseline techniques, particularly in few-shot scenarios. This adaptability renders LLMs uniquely suited to spam detection tasks, where labeled samples are limited in number and models require frequent updates. Additionally, we introduce Spam-T5, a Flan-T5 model that has been specifically adapted and fine-tuned for the purpose of detecting email spam. Our results demonstrate that Spam-T5 surpasses baseline models and other LLMs in the majority of scenarios, particularly when there are a limited number of training samples available. Our code is publicly available at https://github.com/jpmorganchase/emailspamdetection.
翻译:本文通过比较三类代表性模型(BERT类、Sentence Transformers和Seq2Seq),研究了大语言模型在邮件垃圾检测中的有效性。此外,我们采用朴素贝叶斯和LightGBM等成熟的机器学习垃圾检测技术作为基线方法。我们利用不同数量的训练样本(完整训练集与小样本设置)在四个公开数据集上评估了这些模型的性能。研究结果表明,在多数情况下,大语言模型的表现优于常见的基线方法,尤其是在小样本场景中。这种适应性使得大语言模型特别适合标注样本数量有限且需要频繁更新的垃圾检测任务。我们还提出了Spam-T5——一个经专门适配和微调用于邮件垃圾检测的Flan-T5模型。实验结果表明,在大多数场景下,尤其是训练样本数量有限时,Spam-T5在性能上超越了基线模型及其他大语言模型。我们的代码已开源至https://github.com/jpmorganchase/emailspamdetection。