Skip to main content
QUICK REVIEW

[Paper Review] Spam-T5: Benchmarking Large Language Models for Few-Shot Email Spam Detection

Maxime Labonne, Seán Moran|arXiv (Cornell University)|Apr 3, 2023
Spam and Phishing DetectionComputer Science13 citations
TL;DR

The paper benchmarks LLMs across three families (BERT-like, Sentence Transformers, Seq2Seq) and traditional baselines for email spam detection, introducing Spam-T5, a Flan-T5 fine-tuned model that excels in few-shot scenarios.

ABSTRACT

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ïve 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.

Motivation & Objective

  • Motivate the need for effective spam detection under data scarcity, distribution shift, and adversarial drift in emails.
  • Evaluate LLMs from multiple families against traditional baselines on four public spam datasets.
  • Develop Spam-T5, a Flan-T5 fine-tuned model tailored for email spam detection.
  • Assess full-training and few-shot performance to understand data efficiency and generalization.

Proposed method

  • Compare RoBERTa (BERT-like), SetFit (Sentence Transformer), and Flan-T5 (Seq2Seq) against Naïve Bayes, Logistic Regression, KNN, SVM, XGBoost, and LightGBM.
  • Fine-tune hyperparameters per model (batch size, learning rate, epochs) and perform feature selection for tf-idf based baselines via stratified 5-fold cross-validation.
  • Adapt Flan-T5 into Spam-T5 by adding a classification prefix “classify as ham or spam:” and post-process outputs to binary labels.
  • Use four datasets (Ling-Spam, SMS Spam Collection, SpamAssassin Public Corpus, Enron) and evaluate with F1, precision, and recall.
  • Conduct full training (80% of data) and few-shot experiments with k in {4,8,16,32,64,128,256,Full} samples.

Experimental results

Research questions

  • RQ1How do leading LLMs compare to traditional baselines in both full-training and few-shot spam detection settings?
  • RQ2Is a fine-tuned Seq2Seq model (Spam-T5) superior to other LLMs in very few-shot scenarios?
  • RQ3What is the trade-off between accuracy and computational efficiency when using LLMs versus traditional models for spam detection?
  • RQ4How do datasets with different spam/ham distributions affect model performance?
  • RQ5Does Spam-T5 maintain robustness across varying training sample sizes?

Key findings

  • LLMs generally outperform baseline methods on SMS and Enron datasets in full-training settings.
  • Spam-T5 achieves the highest overall F1 (average 0.9742) across full-training results, with RoBERTa and SetFit close behind (0.9670).
  • In few-shot settings, Spam-T5 dominates very-few-shot performance (4–16 samples) and maintains robustness across sizes.
  • On average over datasets, SVM among baselines performs best (average F1 0.9560), with XGBoost being the weakest (0.8842).
  • Spam-T5 shows strongest performance particularly when labeled data is scarce, highlighting its few-shot data efficiency.

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.