aopolin-lv/ECSpell

[TALLIP] General and Domain Adaptive Chinese Spelling Check with Error Consistent Pretraining

65

stars

15

commits

Python

primary language

Aug 10, 2026

updated

dl.acm.org/doi/abs/10.1145/3564271

README

ECSpell

Code for paper "General and Domain Adaptive Chinese Spelling Check with Error Consistent Pretraining"

๐Ÿ“– Introduction

This repository contains the official PyTorch implementation for ECSpell. Our approach leverages error-consistent pretraining to improve generalization and domain adaptation for Chinese Spelling Check (CSC).

๐Ÿ› ๏ธ Environment Setup

We recommend Python 3.8+ and PyTorch >= 1.9.0.

conda create -n ecspell python=3.8 -y
conda activate ecspell
pip install torch transformers jieba pypinyin Pinyin2Hanzi tqdm scipy

Install the local glyce library:

cd glyce
python setup.py develop
pip show glyce   # to ensure the successful installation of glyce lib

๐Ÿ“ Data Preparation

  1. Model Weights: Download the pre-trained weights from Google Drive and place them in Transformers/glyce/.
  2. Datasets: Download SIGHAN or other CSC datasets. Organize them following the structure:
    • Data/domains_data/ for domain-specific data.
    • data/basedata/simplified/ or data/basedata/traditional/ for baseline training data.
  3. Tokenization (if required):
    python3 Code/tokenize_sequence.py
    

๐Ÿ‹๏ธ Training

Set the Python path and run the training script:

export PYTHONPATH=$PYTHONPATH:./:./Code
python Code/train_baseline.py \
  --config_path Transformers/glyce_bert_both_font.json \
  --output_dir ./outputs

(Adjust arguments in train_baseline.py as needed for your specific setup.)

๐Ÿ“Š Evaluation & Inference

  • For evaluation, use the scripts in csc_evaluation/ or modify the training script to enable evaluation mode.
  • csc_evaluation/build_train_data.py can be used to construct and split training/validation datasets.

๐Ÿ“ Data Usage Notes

Path: Data/domains_data

  • For zero-shot tasks, you should combine the *.train file and *.test file.
  • For common tasks, the *.train file is used to do training and do evaluating while *.test is adopted to do predicting.

๐Ÿ“œ Citation

If you use this code in your research, please cite our paper:

@article{lv2023general,
  title={General and Domain-adaptive Chinese Spelling Check with Error-consistent Pretraining},
  author={Lv, Qi and Cao, Ziqiang and Geng, Lei and Ai, Chunhui and Yan, Xu and Fu, Guohong},
  journal={ACM Transactions on Asian and Low-Resource Language Information Processing},
  volume={22},
  number={5},
  pages={1--18},
  year={2023},
  publisher={ACM New York, NY}
}

Contributors

aopolin-lv

14 commits

webbrain-one

1 commits

aopolin-lv/ECSpell

[TALLIP] General and Domain Adaptive Chinese Spelling Check with Error Consistent Pretraining

65

stars

15

commits

Python

primary language

Aug 10, 2026

updated

dl.acm.org/doi/abs/10.1145/3564271

README

ECSpell

Code for paper "General and Domain Adaptive Chinese Spelling Check with Error Consistent Pretraining"

๐Ÿ“– Introduction

This repository contains the official PyTorch implementation for ECSpell. Our approach leverages error-consistent pretraining to improve generalization and domain adaptation for Chinese Spelling Check (CSC).

๐Ÿ› ๏ธ Environment Setup

We recommend Python 3.8+ and PyTorch >= 1.9.0.

conda create -n ecspell python=3.8 -y
conda activate ecspell
pip install torch transformers jieba pypinyin Pinyin2Hanzi tqdm scipy

Install the local glyce library:

cd glyce
python setup.py develop
pip show glyce   # to ensure the successful installation of glyce lib

๐Ÿ“ Data Preparation

  1. Model Weights: Download the pre-trained weights from Google Drive and place them in Transformers/glyce/.
  2. Datasets: Download SIGHAN or other CSC datasets. Organize them following the structure:
    • Data/domains_data/ for domain-specific data.
    • data/basedata/simplified/ or data/basedata/traditional/ for baseline training data.
  3. Tokenization (if required):
    python3 Code/tokenize_sequence.py
    

๐Ÿ‹๏ธ Training

Set the Python path and run the training script:

export PYTHONPATH=$PYTHONPATH:./:./Code
python Code/train_baseline.py \
  --config_path Transformers/glyce_bert_both_font.json \
  --output_dir ./outputs

(Adjust arguments in train_baseline.py as needed for your specific setup.)

๐Ÿ“Š Evaluation & Inference

  • For evaluation, use the scripts in csc_evaluation/ or modify the training script to enable evaluation mode.
  • csc_evaluation/build_train_data.py can be used to construct and split training/validation datasets.

๐Ÿ“ Data Usage Notes

Path: Data/domains_data

  • For zero-shot tasks, you should combine the *.train file and *.test file.
  • For common tasks, the *.train file is used to do training and do evaluating while *.test is adopted to do predicting.

๐Ÿ“œ Citation

If you use this code in your research, please cite our paper:

@article{lv2023general,
  title={General and Domain-adaptive Chinese Spelling Check with Error-consistent Pretraining},
  author={Lv, Qi and Cao, Ziqiang and Geng, Lei and Ai, Chunhui and Yan, Xu and Fu, Guohong},
  journal={ACM Transactions on Asian and Low-Resource Language Information Processing},
  volume={22},
  number={5},
  pages={1--18},
  year={2023},
  publisher={ACM New York, NY}
}

Contributors

aopolin-lv

14 commits

webbrain-one

1 commits

Languages

Python

99.9%