Text Classification via Large Language Models

Xiaofei Sun, Xiaoya Li, Jiwei Li, Fei Wu, Shangwei Guo, Tianwei Zhang, Guoyin Wang

Introduction

Large Language Models (LLMs) like GPT-3 have demonstrated remarkable capabilities across various natural language tasks. However, in the specific domain of text classification, they often underperform compared to smaller, task-specific models such as BERT or RoBERTa. This performance gap stems from two primary bottlenecks: reasoning deficits in handling linguistic nuances (e.g., irony, negation) and the context window limitation, which prevents LLMs from leveraging the vast amount of training data available to fine-tuned models.

To address these challenges, we introduce CARP (Clue And Reasoning Prompting), a framework designed to enhance LLM performance in text classification through structured reasoning and efficient demonstration retrieval.

Methodology

Clue And Reasoning Prompting (CARP)

The core of the CARP framework is a three-step progressive reasoning process that mimics human cognitive strategies for classification. Instead of directly predicting a label, the model is prompted to:

  1. Identify Clues: Extract local evidence such as keywords, phrases, semantic relations, and tone.
  2. Diagnostic Reasoning: Use the identified clues and the input text as premises to deduce a logical reasoning path.
  3. Decision Making: Determine the final sentiment or category based on the accumulated evidence and reasoning.
The CARP prompting strategy, illustrating the extraction of clues and the subsequent diagnostic reasoning process.

To overcome the context window limitation, CARP utilizes a fine-tuned k-Nearest Neighbor (kNN) retriever. By fine-tuning a RoBERTa model on the target task, the system can identify the most relevant demonstrations from the full training set for any given test input. This ensures that the few examples provided in the prompt are highly informative and contextually similar to the target instance, effectively "tunneling" task-specific knowledge into the LLM's context window.

Experimental Evaluation

The CARP framework was evaluated across five benchmark datasets: SST-2 (sentiment), AGNews (topic), R8/R52 (Reuters news), and MR (movie reviews). The evaluation covered zero-shot, few-shot, and low-resource settings, as well as cross-domain adaptation.

Key Results

CARP achieved new state-of-the-art (SOTA) results on four out of five benchmarks. Notably, it consistently outperformed standard "Chain-of-Thought" (CoT) prompting, highlighting the importance of the explicit clue collection step.

Performance comparison of CARP against supervised methods and other prompting strategies across five benchmarks.

As shown in the results table, CARP with a fine-tuned kNN-Sampler (FT kNN-Sampler) achieves superior performance, reaching 97.39% accuracy on SST-2 and 96.40% on AGNews when using weighted voting (WP Vote).

Insights and Discussion

  • Efficiency in Low-Resource Scenarios: CARP demonstrates exceptional data efficiency. With only 16 examples per class, it achieves performance comparable to supervised models trained on 1,024 examples.
  • Robustness to Domain Shift: Unlike supervised models that are sensitive to distribution changes, CARP maintains high performance across domains. In a shift from movie reviews (SST-2) to product reviews (Yelp), CARP showed only a 0.5% performance drop, compared to a 7.2% drop for fine-tuned RoBERTa.
  • The Hybrid Advantage: The integration of a task-specific retriever with a general-purpose LLM allows the system to benefit from both specialized knowledge and broad reasoning capabilities.

Conclusion

The CARP framework effectively bridges the gap between LLMs and task-specific models in text classification. By structuring the reasoning process and optimizing demonstration selection, CARP provides a robust and efficient solution for high-performance NLP, particularly in scenarios with limited data or domain shifts. Future work will explore the application of CARP to more complex natural language understanding tasks.

Summary updated

BibTeX
@inproceedings{sun2023text,
  author = {Xiaofei Sun and Xiaoya Li and Jiwei Li and Fei Wu and Shangwei Guo and Tianwei Zhang and Guoyin Wang},
  title = {{Text Classification via Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.603},
}
Figure