Text Generation
Transformers
Safetensors
Chinese
qwen3
chinese
text-correction
grammatical-error-correction
spelling-check
chain-of-thought
reinforcement-learning
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use twnlp/ChineseErrorCorrector4-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use twnlp/ChineseErrorCorrector4-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="twnlp/ChineseErrorCorrector4-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("twnlp/ChineseErrorCorrector4-4B") model = AutoModelForCausalLM.from_pretrained("twnlp/ChineseErrorCorrector4-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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use twnlp/ChineseErrorCorrector4-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "twnlp/ChineseErrorCorrector4-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/ChineseErrorCorrector4-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/twnlp/ChineseErrorCorrector4-4B
- SGLang
How to use twnlp/ChineseErrorCorrector4-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/ChineseErrorCorrector4-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/ChineseErrorCorrector4-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/ChineseErrorCorrector4-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/ChineseErrorCorrector4-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use twnlp/ChineseErrorCorrector4-4B with Docker Model Runner:
docker model run hf.co/twnlp/ChineseErrorCorrector4-4B
Add library_name metadata
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,44 +1,45 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
| 3 |
-
- zh
|
| 4 |
-
license: apache-2.0
|
| 5 |
-
tags:
|
| 6 |
-
- chinese
|
| 7 |
-
- text-correction
|
| 8 |
-
- grammatical-error-correction
|
| 9 |
-
- spelling-check
|
| 10 |
-
- qwen3
|
| 11 |
-
- chain-of-thought
|
| 12 |
-
- reinforcement-learning
|
| 13 |
base_model: Qwen/Qwen3-4B
|
| 14 |
datasets:
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
metrics:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
model-index:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
---
|
| 43 |
|
| 44 |
# ChineseErrorCorrector4-4B (CSRP)
|
|
@@ -59,6 +60,8 @@ model-index:
|
|
| 59 |
|
| 60 |
---
|
| 61 |
|
|
|
|
|
|
|
| 62 |
## 🔥 Recent Updates
|
| 63 |
|
| 64 |
| Date | Update |
|
|
@@ -70,7 +73,7 @@ model-index:
|
|
| 70 |
|
| 71 |
## 💡 Introduction
|
| 72 |
|
| 73 |
-
**ChineseErrorCorrector4-4B** is
|
| 74 |
|
| 75 |
### The Problem: Over-Correction Bias
|
| 76 |
|
|
@@ -98,10 +101,6 @@ Traditional LLM-based correction systems often suffer from **over-correction bia
|
|
| 98 |
| CEC3 (4B) | 54.20 | 34.75 | 48.74 |
|
| 99 |
| **CSRP (4B) [Ours]** ✅ | **57.17** | **35.60** | **50.99** |
|
| 100 |
|
| 101 |
-
> 🔥 **超越 14B 大模型:** 参数量仅为三成,$F_{0.5}$ 相比 ScholarGEC-14B 提升 **+3.64**!
|
| 102 |
-
>
|
| 103 |
-
> 🔥 **极高准确率 (Precision 57.17%):** 远超其他模型,最大程度压制了 false-positive(假阳性改写),真正做到"**无错不改,有错必精**"。
|
| 104 |
-
|
| 105 |
---
|
| 106 |
|
| 107 |
### 榜单二:中文拼写检查(CSC)— CSCD 基准
|
|
@@ -199,24 +198,6 @@ print(response)
|
|
| 199 |
下个星期,我跟我朋友打算去法国玩儿。
|
| 200 |
```
|
| 201 |
|
| 202 |
-
**Supported error types:**
|
| 203 |
-
|
| 204 |
-
| 错误类型 | 说明 |
|
| 205 |
-
|---------|------|
|
| 206 |
-
| 错别字 | Typos / wrong characters |
|
| 207 |
-
| 词语搭配错误 | Wrong word collocation |
|
| 208 |
-
| 词性错误 | Wrong part of speech |
|
| 209 |
-
| 语序错误 | Wrong word order |
|
| 210 |
-
| 成分残缺 | Missing sentence components |
|
| 211 |
-
| 成分赘余 | Redundant components |
|
| 212 |
-
| 关联词使用错误 | Wrong conjunction usage |
|
| 213 |
-
| 指代不明 | Ambiguous reference |
|
| 214 |
-
| 语义逻辑不通 | Semantic/logical inconsistency |
|
| 215 |
-
| 无误 | No error |
|
| 216 |
-
|
| 217 |
-
---
|
| 218 |
-
|
| 219 |
-
|
| 220 |
---
|
| 221 |
|
| 222 |
## 📜 License
|
|
@@ -237,4 +218,4 @@ This project is released under the [Apache 2.0 License](LICENSE).
|
|
| 237 |
primaryClass={cs.CL},
|
| 238 |
url={https://arxiv.org/abs/2606.00020},
|
| 239 |
}
|
| 240 |
-
```
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model: Qwen/Qwen3-4B
|
| 3 |
datasets:
|
| 4 |
+
- twnlp/ChineseErrorCorrector
|
| 5 |
+
language:
|
| 6 |
+
- zh
|
| 7 |
+
license: apache-2.0
|
| 8 |
metrics:
|
| 9 |
+
- f1
|
| 10 |
+
- precision
|
| 11 |
+
- recall
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
+
library_name: transformers
|
| 14 |
+
tags:
|
| 15 |
+
- chinese
|
| 16 |
+
- text-correction
|
| 17 |
+
- grammatical-error-correction
|
| 18 |
+
- spelling-check
|
| 19 |
+
- qwen3
|
| 20 |
+
- chain-of-thought
|
| 21 |
+
- reinforcement-learning
|
| 22 |
model-index:
|
| 23 |
+
- name: ChineseErrorCorrector4-4B
|
| 24 |
+
results:
|
| 25 |
+
- task:
|
| 26 |
+
type: text-generation
|
| 27 |
+
name: Chinese Grammatical Error Correction
|
| 28 |
+
dataset:
|
| 29 |
+
name: NACGEC
|
| 30 |
+
type: nacgec
|
| 31 |
+
metrics:
|
| 32 |
+
- type: f0.5
|
| 33 |
+
value: 50.99
|
| 34 |
+
- task:
|
| 35 |
+
type: text-generation
|
| 36 |
+
name: Chinese Spelling Check
|
| 37 |
+
dataset:
|
| 38 |
+
name: CSCD
|
| 39 |
+
type: cscd
|
| 40 |
+
metrics:
|
| 41 |
+
- type: f1
|
| 42 |
+
value: 59.61
|
| 43 |
---
|
| 44 |
|
| 45 |
# ChineseErrorCorrector4-4B (CSRP)
|
|
|
|
| 60 |
|
| 61 |
---
|
| 62 |
|
| 63 |
+
**ChineseErrorCorrector4-4B** is a high-precision Chinese Grammatical Error Correction (CGEC) and Chinese Spelling Check (CSC) model, presented in the paper [CSRP: Chain-of-Thought Reasoning for Chinese Text Correction via Reinforcement Learning with Efficiency-Aware Rewards](https://huggingface.co/papers/2606.00020).
|
| 64 |
+
|
| 65 |
## 🔥 Recent Updates
|
| 66 |
|
| 67 |
| Date | Update |
|
|
|
|
| 73 |
|
| 74 |
## 💡 Introduction
|
| 75 |
|
| 76 |
+
**ChineseErrorCorrector4-4B** is built on the **CSRP (CPT → SFT → RL)** three-stage training framework.
|
| 77 |
|
| 78 |
### The Problem: Over-Correction Bias
|
| 79 |
|
|
|
|
| 101 |
| CEC3 (4B) | 54.20 | 34.75 | 48.74 |
|
| 102 |
| **CSRP (4B) [Ours]** ✅ | **57.17** | **35.60** | **50.99** |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
---
|
| 105 |
|
| 106 |
### 榜单二:中文拼写检查(CSC)— CSCD 基准
|
|
|
|
| 198 |
下个星期,我跟我朋友打算去法国玩儿。
|
| 199 |
```
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
---
|
| 202 |
|
| 203 |
## 📜 License
|
|
|
|
| 218 |
primaryClass={cs.CL},
|
| 219 |
url={https://arxiv.org/abs/2606.00020},
|
| 220 |
}
|
| 221 |
+
```
|