Abstract
TCBERT is a specialized suite of BERT models optimized for Chinese topic classification. Through supervised continued pre-training on 2.1 million annotated samples using a combination of prompt-based masking and contrastive learning, TCBERT achieves state-of-the-art performance on few-shot classification benchmarks, significantly surpassing general-purpose Chinese BERT models.
Introduction
General-purpose Large Language Models (LLMs) like BERT often require extensive fine-tuning to excel in specialized domains. In Chinese Natural Language Processing (NLP), topic classification—categorizing text into domains such as finance, sports, or travel—is a foundational task. Standard BERT models typically rely on unsupervised Masked Language Modeling (MLM) on massive unlabeled datasets. However, this approach does not explicitly capture the relationship between a sentence and its semantic category. TCBERT addresses this by utilizing "continued supervised pre-training" on labeled data to bridge the gap between general pre-training and specific downstream tasks, especially in data-scarce few-shot scenarios.
Methodology
The development of TCBERT (Topic Classification BERT) centers on three primary strategies:
- Prompt-based Masked Language Modeling: Rather than masking random tokens, input text is wrapped in a prompt template (e.g., "The following is a news item about [MASK][MASK]: [Text Content]"). The model predicts category names at the
[MASK]positions, forcing an explicit association between content and semantic labels. - Prompt-based Contrastive Learning: To enhance sentence-level representations, a contrastive objective is employed. A raw sentence and its prompted version form a positive pair, encouraging the model to align sentence embeddings with their corresponding category descriptions in the embedding space.
- Model Scaling: TCBERT is released in three sizes: Base (110M parameters), Large (330M), and a 1.3B parameter version to evaluate the impact of model scale on performance.
Experimental Setup
Datasets
- Pre-training Data: An internal dataset of 2.1 million annotated Chinese samples across diverse topics (e.g., travel, movies, finance).
- Evaluation Benchmarks: Three datasets from the FewCLUE benchmark: TNEWS (short news), CSLDCP (computer science literature), and IFLYTEK (app descriptions).
Key Results and Insights
TCBERT consistently outperforms baseline MacBERT models across various evaluation metrics.
- Fine-tuning Performance: On the CSLDCP dataset, TCBERT-1.3B achieved 65.10% accuracy, outperforming the Erlangshen-1.3B baseline (62.35%).
- Similarity-based Classification: Even without full fine-tuning, TCBERT-1.3B reached 54.78% on TNEWS using sentence similarity with whitening, a significant improvement over the MacBERT-base score of 47.16%.
- Impact of Whitening: Feature decorrelation via "whitening" significantly boosts accuracy in similarity-based classification tasks, as shown in the comparative results.
- Prompt Sensitivity: The choice of prompt template impacts performance; simpler templates (Prompt-1) generally yielded better fine-tuning results than more complex alternatives.
Limitations and Future Work
Despite its strong performance, TCBERT has certain trade-offs. Full fine-tuning offers the highest accuracy but is computationally expensive. Similarity-based classification is faster but yields lower accuracy. Additionally, performance remains tied to the diversity of the 2.1M supervised samples. Future work will explore expanding the supervised set to more niche domains and further optimizing hyperparameters like momentum coefficients in contrastive learning.
Availability: Models are open-sourced on Hugging Face under the IDEA-CCNL organization.
Summary updated