BERTc-165M-CSC / README.md
tf-bao's picture
Upload BERTc-165M-CSC release
93da7d8 verified
|
Raw
History Blame Contribute Delete
1.6 kB
metadata
license: apache-2.0
language:
  - zh
tags:
  - chinese
  - spelling-correction
  - csc
  - bert
  - text-correction
library_name: pytorch

BERTc-165M-CSC

BERTc-165M-CSC is a Chinese spelling correction model fine-tuned from Ismantic/BERTc-165M. It uses a Modern BERTc encoder with two heads:

  • correction head: tied to the input embedding matrix
  • detection head: binary error detection

Metrics

SIGHAN-15 sentence-level evaluation using the pycorrector-style 707-sample protocol:

  • Sentence F1: 0.8308
  • Accuracy: 0.8416
  • Precision: 0.9516
  • Recall: 0.7373
  • TP/FP/FN/TN: 275 / 14 / 98 / 320

Training recipe:

  • backbone: Ismantic/BERTc-165M
  • epochs: 5
  • batch size: 64
  • learning rate: 5e-5
  • warmup ratio: 0.1
  • detection loss weight: 0.3
  • inference threshold: 0.7
  • max length: 128

Files

  • model.safetensors: CSC state dict. cor_head.weight is intentionally omitted and tied to bert.embed.weight by csc_model.py.
  • config.json: BERTc backbone architecture.
  • csc_config.json: task and metric metadata.
  • model.py: Modern BERTc implementation.
  • csc_model.py: CSC wrapper and batch correction helper.
  • piece.model: tokenizer model; load with piece_tokenizer using cn_dict="no".

Usage

from csc_model import BERTcForCSC, PieceCharTokenizer

tok = PieceCharTokenizer(".")
model = BERTcForCSC.from_pretrained(".")
texts = ["少先队员因该为老人让坐。"]
print(model.correct(texts, tok, threshold=0.7))

This is not a generative model. It performs same-length character replacement for Chinese spelling correction.