Abstract
This study evaluates the efficacy of Large Language Models (LLMs), specifically GPT-4, GPT-3.5, and Llama2, as zero-shot text classifiers. By comparing these models against traditional machine learning and specialized deep learning architectures across four diverse domains, the research demonstrates that LLMs can achieve competitive performance without task-specific training data. While specialized models maintain a slight advantage in high-data scenarios, GPT-4 often matches or exceeds state-of-the-art performance, offering a streamlined alternative to traditional supervised learning pipelines.
Introduction
Traditional text classification relies on a supervised learning paradigm, requiring extensive, hand-labeled datasets to train task-specific models like Support Vector Machines (SVM) or Bi-Directional Long Short-Term Memory (Bi-LSTM) networks. This process is resource-intensive and results in "brittle" models that struggle with out-of-distribution classes. This paper investigates whether the reasoning capabilities of LLMs can bypass the training phase entirely through Zero-Shot Learning (ZSL), allowing a general-purpose model to classify text based solely on a descriptive prompt.
Methodology
The researchers compared three distinct approaches to text classification:
- Traditional Machine Learning: Algorithms such as Multinomial Naive Bayes (MNB), Random Forest (RF), and SVM.
- Deep Learning (DL): Specialized architectures including RNNs, LSTMs, and Gated Recurrent Units (GRUs).
- Zero-Shot LLMs: GPT-3.5, GPT-4, and Llama2-70B.
Unlike traditional pipelines that require complex feature extraction and model training, the LLM strategy utilizes a single-step prompt. The models were instructed to act as AI assistants, provided with category lists, and asked to output results in a structured JSON format. To ensure reproducibility, the model temperature was set to 0.01.
Experimental Setup
The models were evaluated across four distinct datasets to test robustness:
- COVID-19 Tweets: Sentiment analysis (Positive, Neutral, Negative) of social media posts.
- Economic Texts: Sentiment analysis of financial news.
- E-commerce Text: Four-class classification (Household, Books, Clothing, Electronics).
- SMS Spam Collection: Binary classification (Spam vs. Ham).
Results and Analysis
GPT-4 emerged as the superior zero-shot classifier, frequently outperforming other LLMs and even specialized DL models. In the economic sentiment task, GPT-4 achieved 71.33% accuracy, surpassing the best DL model (LSTM at 65.33%). In the SMS Spam task, GPT-4 reached 97.33% accuracy, trailing the specialized GRU model (98.67%) by only a narrow margin.
The Cleaning Paradox
A notable finding was the impact of data pre-processing. For GPT-3.5 and Llama2, removing "noise" (URLs, hashtags) from social media data actually decreased performance, suggesting these models utilize metadata for context. Conversely, GPT-4’s accuracy improved with cleaning, indicating a stronger reliance on core linguistic structures.
Consistency and Constraints
While OpenAI's models followed formatting instructions reliably, Llama2 occasionally struggled with the zero-shot constraint, adding conversational text despite instructions to output only JSON. Furthermore, the COVID-19 dataset proved the most challenging for LLMs (hovering around 52-55% accuracy), suggesting that highly nuanced, slang-heavy sentiment still benefits from task-specific fine-tuning.
Conclusion
LLMs represent a viable "good enough" baseline for text classification, significantly reducing the need for expensive data labeling. While specialized models still hold an edge in niche or high-accuracy domains, the zero-shot capabilities of models like GPT-4 provide a powerful tool for rapid deployment. Future work will explore the use of "Critic Agents" to refine classifications and the impact of more detailed prompt engineering to close the remaining performance gap.
Summary updated