QuantFactory/chinese-text-correction-7b-GGUF
21k
libraryname: transformers basemodel: Qwen/Qwen2.5-7B-Instruct license: apache-2.0 datasets:
- shibing624/chinesetextcorrection language:
- zh metrics:
- f1 tags:
- text-generation-inference widget:
- text: "文本纠错:\n少先队员因该为老人让坐。"

QuantFactory/chinese-text-correction-7b-GGUF
This is quantized version of shibing624/chinese-text-correction-7b created using llama.cpp
Original Model Card
Chinese Text Correction Model
中文文本纠错模型chinese-text-correction-7b:用于拼写纠错、语法纠错
shibing624/chinese-text-correction-7b evaluate test data:
The overall performance of CSC test:
Models
评估结果
- 评估指标:F1
- CSC(Chinese Spelling Correction): 拼写纠错模型,表示模型可以处理音似、形似、语法等长度对齐的错误纠正
- CTC(CHinese Text Correction): 文本纠错模型,表示模型支持拼写、语法等长度对齐的错误纠正,还可以处理多字、少字等长度不对齐的错误纠正
- GPU:Tesla V100,显存 32 GB
Usage (pycorrector)
本项目开源在pycorrector项目:pycorrector,可支持大模型微调后用于文本纠错,通过如下命令调用:
Install package:
pip install -U pycorrectorfrom pycorrector.gpt.gpt_corrector import GptCorrector
if __name__ == '__main__':
error_sentences = [
'真麻烦你了。希望你们好好的跳无',
'少先队员因该为老人让坐',
'机七学习是人工智能领遇最能体现智能的一个分知',
'一只小鱼船浮在平净的河面上',
'我的家乡是有明的渔米之乡',
]
m = GptCorrector("shibing624/chinese-text-correction-7b")
batch_res = m.correct_batch(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-7b"
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}]
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
print(input_text)
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0, do_sample=False, repetition_penalty=1.08)
print(tokenizer.decode(outputs[0]))output:
少先队员应该为老人让座。模型文件组成:
shibing624/chinese-text-correction-7b
|-- added_tokens.json
|-- config.json
|-- generation_config.json
|-- merges.txt
|-- model.safetensors
|-- model.safetensors.index.json
|-- README.md
|-- special_tokens_map.json
|-- tokenizer_config.json
|-- tokenizer.json
`-- vocab.json训练参数:
- num_epochs: 8
- batch_size: 2
- steps: 36000
- eval_loss: 0.12
- base model: Qwen/Qwen2.5-7B-Instruct
- train data: shibing624/chinese_text_correction
- train time: 10 days
- 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},
}