fastHan: A BERT-based Multi-Task Toolkit for Chinese NLP

Zhichao Geng, Hang Yan, Xipeng Qiu, Xuanjing Huang

Introduction

In Chinese Natural Language Processing (NLP), foundational tasks such as Chinese Word Segmentation (CWS), Part-of-Speech (POS) tagging, Named Entity Recognition (NER), and Dependency Parsing are traditionally handled via a pipeline approach. This method often suffers from significant resource inefficiency—requiring separate models for each task—and error propagation, where mistakes in early stages like CWS compromise downstream performance.

To address these challenges, the authors introduce fastHan, an open-source toolkit providing a unified, BERT-based solution. By leveraging multi-task learning (MTL) and a pruned BERT architecture, fastHan achieves state-of-the-art (SOTA) performance while remaining significantly more memory-efficient than deploying multiple independent models.

Architecture and Methodology

The core of fastHan is a joint-model architecture built upon a pruned version of BERT. Recognizing that a full 12-layer BERT is computationally expensive for basic NLP tasks, the authors developed two versions: a "large" model using the first 8 layers and a "base" model with 4 layers. The base model is compressed using the Theseus strategy, which progressively replaces modules during training to maintain high performance at a smaller scale.

The fastHan architecture features a shared BERT-based encoder and task-specific decoders for CWS, POS, NER, and dependency parsing.

Multi-Task Learning (MTL)

To handle diverse datasets simultaneously, fastHan prepends a "corpus tag" to input sequences. This allows the model to learn shared linguistic features across 13 different corpora while respecting dataset-specific nuances. The architecture employs specialized decoders for each task:

  • CWS & POS: Utilizes a Multi-Layer Perceptron (MLP) followed by a Conditional Random Field (CRF).
  • NER: Employs a CRF to manage label dependencies.
  • Dependency Parsing: Uses a Biaffine Parser. Notably, the parser incorporates POS tagging outputs as additional features, directly exploiting the correlation between word categories and grammatical relationships.

Additionally, fastHan supports user-defined lexicons to handle domain-specific jargon, biasing the decoding process toward known terms.

Experimental Setup

The model was trained and evaluated on a massive collection of 13 corpora, including PKU, MSR, and CTB-6 for CWS; CTB-9 for POS and Dependency Parsing; and MSRA and OntoNotes for NER. To evaluate real-world robustness, the authors conducted transferability testing on the Weibo dataset, representing social media text that often deviates from formal training data.

Results and Discussion

Experimental results demonstrate that fastHan's joint training approach significantly reduces "Out of Vocabulary" (OOV) errors by exposing the model to a broader internal vocabulary.

Performance comparison of fastHan against SOTA models across multiple Chinese NLP tasks.

As shown in the performance table, the fastHan large model achieved SOTA results in CWS (97.41 F1) and POS tagging (95.66 F1), while remaining competitive in NER and Dependency Parsing. The base model, weighing only 151MB, offers a 4x reduction in memory usage compared to separate task-specific models.

Transferability and Speed

On the Weibo test set, fastHan achieved a 93.38 F1 score, vastly outperforming popular segmenters like jieba (83.58). In terms of efficiency, the base model processes between 55 and 111 sentences per second for CWS, POS, and NER on a standard CPU. However, dependency parsing remains a computational bottleneck due to the complexity of the biaffine parser.

Conclusion

fastHan represents a significant step forward for Chinese NLP toolkits, offering a balance of high accuracy, compact size, and robust transferability. By unifying core tasks into a single BERT-based framework, it mitigates error propagation and resource waste, making it an ideal choice for both academic research and practical deployment. Future work will focus on further optimizing parsing speed and exploring meta-learning for domain adaptation.

Summary updated

BibTeX
@inproceedings{geng2021fasthan,
  author = {Zhichao Geng and Hang Yan and Xipeng Qiu and Xuanjing Huang},
  title = {{fastHan: A BERT-based Multi-Task Toolkit for Chinese NLP}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-demo.12},
}
Figure