MASC-CSC stands for Mechanism-Aware Selective Collaboration for Chinese Spelling Correction.
This repository contains a Chinese spelling correction project with two layers:
multimodal frontend for character-level correctionMASC-CSC collaboration layer for mechanism inference, constrained candidate generation, selective routing, and local LLM verificationThe repository is intended not only for running code, but also for continued development and research handoff.
MASC_CSC/
├── docs/
│ ├── 01_implementation_thinking_zh.md
│ ├── 02_architecture_and_interfaces_zh.md
│ └── 03_development_handover_and_limitations_zh.md
├── models/
│ └── multimodal_frontend.py
├── masc_csc/
│ ├── mechanism.py
│ ├── candidate_generator.py
│ ├── router.py
│ ├── llm_verifier.py
│ └── pipeline.py
├── scripts/
│ ├── data_process.py
│ └── run_masc_csc.py
├── utils/
├── train.py
├── train_frontend.sh
└── requirements.txt
Recommended environment:
Example:
conda create -n masc_csc python=3.10
conda activate masc_csc
cd MASC_CSC
pip install -r requirements.txt
Current requirements.txt includes:
lightningtransformerstorchtorchvisionpypinyinThe current frontend training pipeline expects CSV files with the following format:
src,tgt
我喜换吃平果,我喜欢吃苹果
今田天气很好,今天天气很好
Requirements:
src and tgt must have the same lengthsrc,tgtIf you already have CSC pickle data in the expected format, you can convert it with:
python scripts/data_process.py
By default, this script generates:
sighan_2013_test.csvsighan_2014_test.csvsighan_2015_test.csvtrain.csvThe current train.py is for the frontend model only.
Supported model names:
multimodal_frontendfrontendmasc_frontendpython train.py \
--model multimodal_frontend \
--datas train.csv \
--batch-size 32 \
--epochs 20 \
--workers 0
sh train_frontend.sh
python train.py \
--model multimodal_frontend \
--data sighan_2015_test.csv \
--batch-size 32 \
--ckpt-path ./ckpt/frontend.ckpt \
--test
Run the collaboration pipeline on a single sentence:
python scripts/run_masc_csc.py \
--ckpt-path ./ckpt/frontend.ckpt \
--sentence "我喜换吃平果,逆呢?"
python scripts/run_masc_csc.py \
--ckpt-path ./ckpt/frontend.ckpt \
--sentence "我喜换吃平果,逆呢?" \
--use-llm \
--llm-model Qwen/Qwen3-8B \
--llm-base-url http://127.0.0.1:8000/v1
Expected local verifier requirements:
/v1/chat/completions endpointCurrently implemented:
predict_with_metadata() for frontend output exposureNot fully implemented yet:
This means the repository is already usable for research prototyping, but it is not yet a fully polished benchmark package.
If someone receives this repository and wants to continue development, read in this order:
README.mddocs/01_implementation_thinking_zh.mddocs/02_architecture_and_interfaces_zh.mddocs/03_development_handover_and_limitations_zh.mdmodels/multimodal_frontend.pymasc_csc/pipeline.pyThis repository includes three handoff-oriented Chinese documents:
docs/01_implementation_thinking_zh.md
docs/02_architecture_and_interfaces_zh.md
docs/03_development_handover_and_limitations_zh.md
If you continue this project, the most recommended next steps are:
predict_with_metadata()mechanism.pycandidate_generator.pyMASC-CSC stands for Mechanism-Aware Selective Collaboration for Chinese Spelling Correction.
This repository contains a Chinese spelling correction project with two layers:
multimodal frontend for character-level correctionMASC-CSC collaboration layer for mechanism inference, constrained candidate generation, selective routing, and local LLM verificationThe repository is intended not only for running code, but also for continued development and research handoff.
MASC_CSC/
├── docs/
│ ├── 01_implementation_thinking_zh.md
│ ├── 02_architecture_and_interfaces_zh.md
│ └── 03_development_handover_and_limitations_zh.md
├── models/
│ └── multimodal_frontend.py
├── masc_csc/
│ ├── mechanism.py
│ ├── candidate_generator.py
│ ├── router.py
│ ├── llm_verifier.py
│ └── pipeline.py
├── scripts/
│ ├── data_process.py
│ └── run_masc_csc.py
├── utils/
├── train.py
├── train_frontend.sh
└── requirements.txt
Recommended environment:
Example:
conda create -n masc_csc python=3.10
conda activate masc_csc
cd MASC_CSC
pip install -r requirements.txt
Current requirements.txt includes:
lightningtransformerstorchtorchvisionpypinyinThe current frontend training pipeline expects CSV files with the following format:
src,tgt
我喜换吃平果,我喜欢吃苹果
今田天气很好,今天天气很好
Requirements:
src and tgt must have the same lengthsrc,tgtIf you already have CSC pickle data in the expected format, you can convert it with:
python scripts/data_process.py
By default, this script generates:
sighan_2013_test.csvsighan_2014_test.csvsighan_2015_test.csvtrain.csvThe current train.py is for the frontend model only.
Supported model names:
multimodal_frontendfrontendmasc_frontendpython train.py \
--model multimodal_frontend \
--datas train.csv \
--batch-size 32 \
--epochs 20 \
--workers 0
sh train_frontend.sh
python train.py \
--model multimodal_frontend \
--data sighan_2015_test.csv \
--batch-size 32 \
--ckpt-path ./ckpt/frontend.ckpt \
--test
Run the collaboration pipeline on a single sentence:
python scripts/run_masc_csc.py \
--ckpt-path ./ckpt/frontend.ckpt \
--sentence "我喜换吃平果,逆呢?"
python scripts/run_masc_csc.py \
--ckpt-path ./ckpt/frontend.ckpt \
--sentence "我喜换吃平果,逆呢?" \
--use-llm \
--llm-model Qwen/Qwen3-8B \
--llm-base-url http://127.0.0.1:8000/v1
Expected local verifier requirements:
/v1/chat/completions endpointCurrently implemented:
predict_with_metadata() for frontend output exposureNot fully implemented yet:
This means the repository is already usable for research prototyping, but it is not yet a fully polished benchmark package.
If someone receives this repository and wants to continue development, read in this order:
README.mddocs/01_implementation_thinking_zh.mddocs/02_architecture_and_interfaces_zh.mddocs/03_development_handover_and_limitations_zh.mdmodels/multimodal_frontend.pymasc_csc/pipeline.pyThis repository includes three handoff-oriented Chinese documents:
docs/01_implementation_thinking_zh.md
docs/02_architecture_and_interfaces_zh.md
docs/03_development_handover_and_limitations_zh.md
If you continue this project, the most recommended next steps are:
predict_with_metadata()mechanism.pycandidate_generator.py