Do BERT-Like Bidirectional Models Still Perform Better on Text Classification in the Era of LLMs?

Junyan Zhang, Yiming Huang, Shuliang Liu, Yubo Gao, Xuming Hu

Introduction

In the current NLP landscape, the prevailing assumption is that Large Language Models (LLMs) are the superior choice for nearly every task. However, as research shifts toward a "bigger is better" philosophy, the specialized strengths of traditional bidirectional encoder models—such as BERT and RoBERTa—are often overlooked. This paper investigates whether these smaller models still hold a performance and efficiency advantage in text classification, particularly in high-difficulty scenarios involving subtle linguistic patterns or adversarial perturbations.

The Problem: LLM-Centricity in Classification

Most modern LLMs are decoder-only architectures optimized for next-token prediction. While they excel at generative tasks, the authors question if this architecture is truly optimal for text classification compared to the bidirectional attention mechanisms of BERT-like models. Specifically, they address the performance gap in "cloaked" text detection (e.g., implicit hate speech using homophones or emojis) and specialized domains like legal or malicious code analysis.

Methodology

The study systematically compares three distinct approaches across various model architectures:

  1. BERT-like Fine-tuning: Utilizing models such as BERT, RoBERTa, ERNIE, and ELECTRA (~100M–120M parameters).
  2. LLM Internal State Utilization (LLM-IS): Probing the hidden layers of 7B+ parameter models (e.g., Qwen2.5-7B, Llama-3-8B) using techniques like SAPLMA (an MLP classifier) and MM-Probe (mass-mean probing).
  3. LLM Zero-Shot Inference (LLM-Q): Direct prompting of LLMs to classify text without parameter updates.

To diagnose model behavior, the researchers employed Principal Component Analysis (PCA) to visualize class separation in hidden states and layer-wise linear probing to track how classification "knowledge" accumulates through the network layers.

Experimental Setup and Datasets

The evaluation focused on six high-difficulty datasets designed to test the limits of model understanding:

  • ToxiCloakCN (Base, Emoji, Homo): A Chinese dataset for implicit hate speech detection featuring "cloaked" text (homophone substitutions and emoji replacements).
  • LegalText (openSUSE): Classification of complex legal documentation and source code.
  • MaliciousCode: Identification of harmful vs. benign software code.
  • Hallucination: Factually true vs. false statements, testing world knowledge and reasoning.

Key Insights: Pattern vs. Knowledge

The research reveals a fundamental divide in task requirements:

  • Pattern-Driven Tasks: BERT-like models excel at tasks requiring structural nuance, such as detecting linguistic cloaking. Their bidirectional attention captures local and global context simultaneously, which is critical for identifying subtle intent. PCA visualizations showed that for these tasks, LLM hidden states are often "intermingled," whereas BERT’s [CLS] token achieves high linear separability early in the model.
  • Knowledge-Intensive Tasks: LLMs dominate tasks like hallucination detection, where the model must rely on the vast world knowledge acquired during pre-training to verify factual claims.

Results and Efficiency

The performance data highlights the continued relevance of smaller models:

  • Hate Speech Detection: On the ToxiCloakCNHomo dataset, BERT-like models achieved an AUC of ~91.2%, significantly outperforming LLM zero-shot querying (~68.6%) and LLM internal state probing (~84.4%).
  • Hallucination Detection: LLMs proved superior here, with SAPLMA probing reaching 95.9% AUC, compared to 85.5% for the best BERT-like model (ELECTRA).
  • Computational Efficiency: BERT-like models achieved these competitive results with approximately 1/70th the parameters of a standard 7B LLM, offering a more sustainable and cost-effective solution for production environments.

The TaMAS Strategy

Based on these findings, the authors propose the Task-aware Model Adaptation Strategy (TaMAS). This framework suggests a rationalized approach to model selection: deploying BERT-like models for general, pattern-driven text classification and reserving computationally expensive LLMs for tasks that strictly require deep semantics or external factual verification.

Conclusion

While LLMs are transformative, they are not a universal replacement for specialized encoder models. For many classification tasks, BERT-like models remain the "rational" choice, providing higher accuracy on structural patterns with a fraction of the computational overhead. Future work will look to expand this evaluation to broader datasets and refine the TaMAS framework for automated model selection.

Summary updated

BibTeX
@misc{zhang2025do,
  author = {Junyan Zhang and Yiming Huang and Shuliang Liu and Yubo Gao and Xuming Hu},
  title = {{Do BERT-Like Bidirectional Models Still Perform Better on Text Classification in the Era of LLMs?}},
  year = {2025},
  eprint = {2505.18215},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.18215},
}
Figure