Binary Spam Detection Using GRPO and LoRA on Qwen 2.5-3B-Instruct
摘要
This paper introduces a novel approach to binary email classification (spam vs. ham) by fine-tuning the Qwen 2.5-3B-Instruct generative language model via the use of Group Relative Policy Optimization. In response to the limitations of standard fine-tuning methods, which tend to produce verbose, multi-sentence outputs that are highly sensitive to prompt variations and do not reliably yield label-only predictions through prompt design alone, we leverage GRPO in combination with Low-Rank Adaptation to optimize the model for concise and accurate classifications. This study is the first exploration of GRPO’s implementation in a classification task that establishes innovative approaches in multiple academic fields. The experiment was conducted using four different datasets, consisting of both imbalanced and balanced datasets. The GRPO-enhanced model shows substantial performance improvement. Particularly, it is as accurate as 94.17% and has an F1-score of 79.50% on the SpamClassify dataset, 93.94% accuracy and 93.91% F1-score on the SpamDetection dataset, 96.55% accuracy and 89.47% F1-score on the LingSpam dataset, and 80.60% accuracy with an F1-score of 77.99% on the SpamAssassin dataset. These results indicate consistent and substantial improvements over the base Qwen 2.5-3B-Instruct model without GRPO across all evaluated datasets. In addition, the model is always highly accurate in single-word responses (over 96% on all datasets), which confirms that the generative LLM is effectively constrained to act as a classifier rather than a verbose text generator, and improves inference efficiency by about 40% relative to unrestricted generative approaches. The GRPO model achieved a considerable reduction in inference latency up to 77.42% and an increase in throughput of up to 338.89%, thus making GRPO method better suited for real-time and resource constrained classification systems. The trade-off between performance, efficiency and small size highlights the effectiveness of GRPO for adapting generative LLMs to classification tasks, providing a robust methodology for improving spam filtering systems and offering a promising approach for other low-latency text classification tasks, such as sentiment analysis.