Instructions to use twnlp/ChineseErrorCorrector3-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use twnlp/ChineseErrorCorrector3-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="twnlp/ChineseErrorCorrector3-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("twnlp/ChineseErrorCorrector3-4B") model = AutoModelForCausalLM.from_pretrained("twnlp/ChineseErrorCorrector3-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use twnlp/ChineseErrorCorrector3-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "twnlp/ChineseErrorCorrector3-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "twnlp/ChineseErrorCorrector3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/twnlp/ChineseErrorCorrector3-4B
- SGLang
How to use twnlp/ChineseErrorCorrector3-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "twnlp/ChineseErrorCorrector3-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "twnlp/ChineseErrorCorrector3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "twnlp/ChineseErrorCorrector3-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "twnlp/ChineseErrorCorrector3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use twnlp/ChineseErrorCorrector3-4B with Docker Model Runner:
docker model run hf.co/twnlp/ChineseErrorCorrector3-4B
ChineseErrorCorrector3-4B
ChineseErrorCorrector3-4B is part of a comprehensive platform for Chinese text correction, integrating academic research, model training, evaluation, and inference. It covers two core directions: Spelling Correction (CSC) and Grammatical Error Correction (CGEC).
The methodology behind this line of models is presented in the paper CSRP: Chain-of-Thought Reasoning for Chinese Text Correction via Reinforcement Learning with Efficiency-Aware Rewards.
- Project Page: ChineseErrorCorrector GitHub
- Paper: arXiv:2606.00020
模型描述
一个面向中文文本纠错任务的综合平台,集学术研究、模型训练、模型评测和推理部署于一体,覆盖拼写纠错与语法纠错两个核心方向。
- twnlp/ChineseErrorCorrector3-4B: 使用200万纠错数据进行全量训练,适用于语法纠错和拼写纠错,效果最好,推荐使用。
模型评测(NaCGEC Data)
| Model Name | Base Model | Avg | SIGHAN-2015 | EC-LAW | MCSC | GPU | QPS |
|---|---|---|---|---|---|---|---|
| ChatGLM3-6B-CSC | THUDM/chatglm3-6b | 0.4538 | 0.6572 | 0.4369 | 0.2672 | GPU | 3 |
| Qwen2.5-1.5B-CTC | Qwen/Qwen2.5-1.5B-Instruct | 0.6802 | 0.3032 | 0.7846 | 0.9529 | GPU | 6 |
| Qwen2.5-7B-CTC | Qwen/Qwen2.5-7B-Instruct | 0.8225 | 0.4917 | 0.9798 | 0.9959 | GPU | 3 |
| Qwen3-4B-CTC(Our) | Qwen/Qwen3-4B | 0.8521 | 0.6340 | 0.9360 | 0.9864 | GPU | 5 |
Sample Usage
You can use the model with the transformers library as follows:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "twnlp/ChineseErrorCorrector3-4B"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "你是一个文本纠错专家,纠正输入句子中的语法错误,并输出正确的句子,输入句子为:"
text_input = "对待每一项工作都要一丝不够。"
messages = [
{"role": "user", "content": prompt + text_input}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
# Output: 对待每一项工作都要一丝不苟。
Citation
If you find this work helpful, please cite:
@misc{tian2026csrpchainofthoughtreasoningchinese,
title={CSRP: Chain-of-Thought Reasoning for Chinese Text Correction via Reinforcement Learning with Efficiency-Aware Rewards},
author={Wei Tian and Yuhao Zhou and Man Lan},
year={2026},
eprint={2606.00020},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2606.00020},
}
@misc{tian2025chineseerrorcorrector34bstateoftheartchinesespelling,
title={ChineseErrorCorrector3-4B: State-of-the-Art Chinese Spelling and Grammar Corrector},
author={Wei Tian and YuhaoZhou},
year={2025},
eprint={2511.17562},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2511.17562},
}
- Downloads last month
- 427