📋 Model Description


library_name: transformers base_model: Qwen/Qwen2.5-1.5B-Instruct license: apache-2.0 datasets:
  • shibing624/chinesetextcorrection
language:
  • zh
metrics:
  • f1
tags:
  • text-generation-inference
widget:
  • text: "文本纠错:\n少先队员因该为老人让坐。"

Chinese Text Correction Model

中文文本纠错模型chinese-text-correction-1.5b:用于拼写纠错、语法纠错

shibing624/chinese-text-correction-1.5b evaluate test data:

The overall performance of CSC test:

inputtextpredicttext
文本纠错:\n少先队员因该为老人让坐。少先队员应该为老人让座。

Models

NameBase ModelDownload
chinese-text-correction-1.5bQwen/Qwen2.5-1.5B-Instruct🤗 Hugging Face
chinese-text-correction-1.5b-loraQwen/Qwen2.5-1.5B-Instruct🤗 Hugging Face
chinese-text-correction-7bQwen/Qwen2.5-7B-Instruct🤗 Hugging Face
chinese-text-correction-7b-loraQwen/Qwen2.5-7B-Instruct🤗 Hugging Face

评估结果

  • 评估指标:F1
  • CSC(Chinese Spelling Correction): 拼写纠错模型,表示模型可以处理音似、形似、语法等长度对齐的错误纠正
  • CTC(CHinese Text Correction): 文本纠错模型,表示模型支持拼写、语法等长度对齐的错误纠正,还可以处理多字、少字等长度不对齐的错误纠正
  • GPU:Tesla V100,显存 32 GB
Model NameModel LinkBase ModelAvgSIGHAN-2015EC-LAWMCSCGPU/CPUQPS
Kenlm-CSCshibing624/chinese-kenlm-klmkenlm0.34090.31470.37630.3317CPU9
Mengzi-T5-CSCshibing624/mengzi-t5-base-chinese-correctionmengzi-t5-base0.39840.77580.31560.1039GPU214
ERNIE-CSCPaddleNLP/ernie-cscPaddlePaddle/ernie-1.0-base-zh0.43530.83830.33570.1318GPU114
MacBERT-CSCshibing624/macbert4csc-base-chinesehfl/chinese-macbert-base0.39930.83140.16100.2055GPU224
ChatGLM3-6B-CSCshibing624/chatglm3-6b-csc-chinese-loraTHUDM/chatglm3-6b0.45380.65720.43690.2672GPU3
Qwen2.5-1.5B-CTCshibing624/chinese-text-correction-1.5bQwen/Qwen2.5-1.5B-Instruct0.68020.30320.78460.9529GPU6
Qwen2.5-7B-CTCshibing624/chinese-text-correction-7bQwen/Qwen2.5-7B-Instruct0.82250.49170.97980.9959GPU3

Usage (pycorrector)

本项目开源在pycorrector项目:pycorrector,可支持大模型微调后用于文本纠错,通过如下命令调用:

Install package:

pip install -U pycorrector

from pycorrector.gpt.gpt_corrector import GptCorrector

if name == 'main':
error_sentences = [
'真麻烦你了。希望你们好好的跳无',
'少先队员因该为老人让坐',
'机七学习是人工智能领遇最能体现智能的一个分知',
'一只小鱼船浮在平净的河面上',
'我的家乡是有明的渔米之乡',
]
m = GptCorrector("shibing624/chinese-text-correction-1.5b")

batchres = m.correctbatch(error_sentences)
for i in batch_res:
print(i)
print()

Usage (HuggingFace Transformers)

Without pycorrector, you can use the model like this:

First, you pass your input through the transformer model, then you get the generated sentence.

Install package:

pip install transformers

# pip install transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "shibing624/chinese-text-correction-1.5b"

device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)

input_content = "文本纠错:\n少先队员因该为老人让坐。"

messages = [{"role": "user", "content": input_content}]
inputtext=tokenizer.applychat_template(messages, tokenize=False)

print(input_text)

inputs = tokenizer.encode(inputtext, returntensors="pt").to(device)
outputs = model.generate(inputs, maxnewtokens=1024, temperature=0, dosample=False, repetitionpenalty=1.08)

print(tokenizer.decode(outputs[0]))

output:

少先队员应该为老人让座。

模型文件组成:

shibing624/chinese-text-correction-1.5b
|-- added_tokens.json
|-- config.json
|-- generation_config.json
|-- merges.txt
|-- model.safetensors
|-- model.safetensors.index.json
|-- README.md
|-- specialtokensmap.json
|-- tokenizer_config.json
|-- tokenizer.json
`-- vocab.json

#### 训练参数:

  • numepochs: 8
  • batchsize: 4
  • steps: 36000
  • evalloss: 0.14
  • base model: Qwen/Qwen2.5-1.5B-Instruct
  • train data: shibing624/chinesetextcorrection
  • train time: 9 days 8 hours
  • evalloss:
  • trainloss:

训练数据集

#### 中文纠错数据集

如果需要训练Qwen的纠错模型,请参考https://github.com/shibing624/pycorrector 或者 https://github.com/shibing624/MedicalGPT

Citation

@software{pycorrector,
  author = {Xu Ming},
  title = {pycorrector: Implementation of language model finetune},
  year = {2024},
  url = {https://github.com/shibing624/pycorrector},
}

📂 GGUF File List

📁 Filename 📦 Size ⚡ Download
chinese-text-correction-1.5b.Q2_K.gguf
LFS Q2
644.97 MB Download
chinese-text-correction-1.5b.Q3_K.gguf
LFS Q3
786 MB Download
chinese-text-correction-1.5b.Q3_K_L.gguf
LFS Q3
839.39 MB Download
chinese-text-correction-1.5b.Q3_K_M.gguf
LFS Q3
786 MB Download
chinese-text-correction-1.5b.Q3_K_S.gguf
LFS Q3
725.69 MB Download
chinese-text-correction-1.5b.Q4_0.gguf
Recommended LFS Q4
891.64 MB Download
chinese-text-correction-1.5b.Q4_1.gguf
LFS Q4
969.74 MB Download
chinese-text-correction-1.5b.Q4_K.gguf
LFS Q4
940.37 MB Download
chinese-text-correction-1.5b.Q4_K_M.gguf
LFS Q4
940.37 MB Download
chinese-text-correction-1.5b.Q4_K_S.gguf
LFS Q4
896.75 MB Download
chinese-text-correction-1.5b.Q5_0.gguf
LFS Q5
1.02 GB Download
chinese-text-correction-1.5b.Q5_1.gguf
LFS Q5
1.1 GB Download
chinese-text-correction-1.5b.Q5_K.gguf
LFS Q5
1.05 GB Download
chinese-text-correction-1.5b.Q5_K_M.gguf
LFS Q5
1.05 GB Download
chinese-text-correction-1.5b.Q5_K_S.gguf
LFS Q5
1.02 GB Download
chinese-text-correction-1.5b.Q6_K.gguf
LFS Q6
1.19 GB Download
chinese-text-correction-1.5b.Q8_0.gguf
LFS Q8
1.53 GB Download