Smart Expert System: Large Language Models as Text Classifiers

Zhiqiang Wang, Yiran Pang, Yanbin Lin · DOI

Introduction: The Complexity of Traditional NLP

Traditional text classification is often a "heavy-lift" process. It typically requires extensive data preprocessing—such as removing stop words, stemming, and tokenization—followed by manual feature engineering using techniques like TF-IDF or word embeddings. This workflow necessitates significant domain-specific expertise to design and tune the right architecture for every new task. Furthermore, traditional models like Logistic Regression or Naive Bayes struggle to adapt to new categories or "unseen" data without significant retraining.

Traditional multi-step NLP pipeline requiring extensive preprocessing and feature engineering.

A Paradigm Shift: LLM-Centric Classification

To address these challenges, this research proposes a streamlined framework that replaces complex, multi-step traditional pipelines with Large Language Models (LLMs). The goal is to create an adaptable and reliable system that lowers the technical barrier for non-experts, such as small businesses, while maintaining high performance in dynamic environments where data distributions frequently shift.

The proposed framework moves away from the rigid "pipeline" approach toward an "LLM-centric" module. Instead of manual preprocessing, raw text is fed directly into LLMs, which leverage their vast internal pre-training to understand context and semantics natively.

The proposed LLM-centric architecture for adaptable and reliable text classification.

Methodology and Learning Strategies

The study evaluates three primary learning strategies across diverse datasets:

  1. Zero-shot: The model is asked to classify text based solely on instructions, without any prior examples.
  2. Few-shot: The model is provided with a small number of labeled examples within the prompt to guide its decision-making.
  3. Fine-tuning: The model is specifically trained on a domain-specific dataset to optimize its weights for the target task.

A key contribution of this work is the introduction of the Uncertainty/Error Rate (U/E) metric. Unlike standard accuracy, this metric quantifies model reliability by measuring how often a model either refuses to classify (uncertainty) or provides a hallucinated result (error). The formula is defined as $U/E = (U + E) / N$, where $N$ is the total number of samples.

Experimental Results and Key Insights

The researchers benchmarked traditional machine learning (Random Forest, SVM) and deep learning (GRU, LSTM) against state-of-the-art LLMs, including GPT-4, Llama-3, and Qwen, across four datasets: COVID-19 tweets, economic texts, e-commerce descriptions, and SMS spam.

Fine-tuning as the "Silver Bullet"

While zero-shot LLMs offer convenience, they do not always outperform specialized deep learning models. However, once fine-tuned, LLMs like Qwen-7B and Llama-3-8B became the top performers across all datasets, often by a significant margin. For instance, on the COVID-19 dataset, fine-tuned Qwen-7B reached an accuracy of 0.8388, a massive improvement over its zero-shot performance of 0.4913 and the best traditional model (GRU at 0.6913).

The "Few-Shot" Paradox

Interestingly, providing a few examples did not always improve performance. In some cases, it confused the models or led to marginal drops in accuracy, suggesting that prompt engineering is highly sensitive to the specific model and dataset.

Reliability and the U/E Metric

The U/E metric revealed that while some models have decent accuracy, they may suffer from high uncertainty. Fine-tuning was found to be the most effective way to reduce the U/E rate to near zero, effectively eliminating hallucinations and refusals in production-like scenarios. In the SMS Spam task, fine-tuned Llama-3-8B achieved an accuracy of 0.9825, transforming from an ineffective zero-shot model into a highly reliable top-tier classifier.

Conclusion and Future Directions

This framework demonstrates that LLMs can democratize AI by removing the need for complex feature engineering, allowing non-experts to achieve state-of-the-art results. However, challenges remain, including inconsistent output formats, safety-filter-induced refusals in closed-source models, and high resource intensity. Future work suggests using a secondary LLM to monitor the primary classifier, further enhancing reliability and reducing the U/E rate.

Summary updated

BibTeX
@inproceedings{wang2024smart,
  author = {Zhiqiang Wang and Yiran Pang and Yanbin Lin},
  title = {{Smart Expert System: Large Language Models as Text Classifiers}},
  booktitle = {Workshops @ ICDM},
  year = {2024},
  doi = {10.1109/icdmw65004.2024.00015},
}
Figure