--- license: apache-2.0 language: - zh tags: - chinese - spelling-correction - csc - bert - text-correction library_name: pytorch --- # BERTc-315M-CSC BERTc-315M-CSC is a Chinese spelling correction model fine-tuned from `Ismantic/BERTc-315M`. 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.8346** - Accuracy: **0.8430** - Precision: **0.9396** - Recall: **0.7507** - TP/FP/FN/TN: 280 / 18 / 93 / 316 Training recipe: - backbone: `Ismantic/BERTc-315M` - epochs: 10 - batch size: 32 - learning rate: 3e-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 ```python 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.