初始化项目,由ModelHub XC社区提供模型
Model: QuantFactory/chinese-text-correction-7b-GGUF Source: Original Platform
This commit is contained in:
49
.gitattributes
vendored
Normal file
49
.gitattributes
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
chinese-text-correction-7b.Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
181
README.md
Normal file
181
README.md
Normal file
@@ -0,0 +1,181 @@
|
||||
|
||||
---
|
||||
|
||||
library_name: transformers
|
||||
base_model: Qwen/Qwen2.5-7B-Instruct
|
||||
license: apache-2.0
|
||||
datasets:
|
||||
- shibing624/chinese_text_correction
|
||||
language:
|
||||
- zh
|
||||
metrics:
|
||||
- f1
|
||||
tags:
|
||||
- text-generation-inference
|
||||
widget:
|
||||
- text: "文本纠错:\n少先队员因该为老人让坐。"
|
||||
|
||||
---
|
||||
|
||||
[](https://hf.co/QuantFactory)
|
||||
|
||||
|
||||
# QuantFactory/chinese-text-correction-7b-GGUF
|
||||
This is quantized version of [shibing624/chinese-text-correction-7b](https://huggingface.co/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**:
|
||||
|
||||
|input_text|predict_text|
|
||||
|:--- |:--- |
|
||||
|文本纠错:\n少先队员因该为老人让坐。|少先队员应该为老人让座。|
|
||||
|
||||
# Models
|
||||
|
||||
| Name | Base Model | Download |
|
||||
|-----------------|-------------------|-----------------------------------------------------------------------|
|
||||
| chinese-text-correction-1.5b | Qwen/Qwen2.5-1.5B-Instruct | [🤗 Hugging Face](https://huggingface.co/shibing624/chinese-text-correction-1.5b) |
|
||||
| chinese-text-correction-1.5b-lora | Qwen/Qwen2.5-1.5B-Instruct | [🤗 Hugging Face](https://huggingface.co/shibing624/chinese-text-correction-1.5b-lora) |
|
||||
| chinese-text-correction-7b | Qwen/Qwen2.5-7B-Instruct | [🤗 Hugging Face](https://huggingface.co/shibing624/chinese-text-correction-7b) |
|
||||
| chinese-text-correction-7b-lora | Qwen/Qwen2.5-7B-Instruct | [🤗 Hugging Face](https://huggingface.co/shibing624/chinese-text-correction-7b-lora) |
|
||||
|
||||
|
||||
### 评估结果
|
||||
- 评估指标:F1
|
||||
- CSC(Chinese Spelling Correction): 拼写纠错模型,表示模型可以处理音似、形似、语法等长度对齐的错误纠正
|
||||
- CTC(CHinese Text Correction): 文本纠错模型,表示模型支持拼写、语法等长度对齐的错误纠正,还可以处理多字、少字等长度不对齐的错误纠正
|
||||
- GPU:Tesla V100,显存 32 GB
|
||||
|
||||
| Model Name | Model Link | Base Model | Avg | SIGHAN-2015 | EC-LAW | MCSC | GPU/CPU | QPS |
|
||||
|:-----------------|:------------------------------------------------------------------------------------------------------------------------|:---------------------------|:-----------|:------------|:-------|:-------|:--------|:--------|
|
||||
| Kenlm-CSC | [shibing624/chinese-kenlm-klm](https://huggingface.co/shibing624/chinese-kenlm-klm) | kenlm | 0.3409 | 0.3147 | 0.3763 | 0.3317 | CPU | 9 |
|
||||
| Mengzi-T5-CSC | [shibing624/mengzi-t5-base-chinese-correction](https://huggingface.co/shibing624/mengzi-t5-base-chinese-correction) | mengzi-t5-base | 0.3984 | 0.7758 | 0.3156 | 0.1039 | GPU | 214 |
|
||||
| ERNIE-CSC | [PaddleNLP/ernie-csc](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/text_correction/ernie-csc) | PaddlePaddle/ernie-1.0-base-zh | 0.4353 | 0.8383 | 0.3357 | 0.1318 | GPU | 114 |
|
||||
| MacBERT-CSC | [shibing624/macbert4csc-base-chinese](https://huggingface.co/shibing624/macbert4csc-base-chinese) | hfl/chinese-macbert-base | 0.3993 | 0.8314 | 0.1610 | 0.2055 | GPU | **224** |
|
||||
| ChatGLM3-6B-CSC | [shibing624/chatglm3-6b-csc-chinese-lora](https://huggingface.co/shibing624/chatglm3-6b-csc-chinese-lora) | THUDM/chatglm3-6b | 0.4538 | 0.6572 | 0.4369 | 0.2672 | GPU | 3 |
|
||||
| Qwen2.5-1.5B-CTC | [shibing624/chinese-text-correction-1.5b](https://huggingface.co/shibing624/chinese-text-correction-1.5b) | Qwen/Qwen2.5-1.5B-Instruct | 0.6802 | 0.3032 | 0.7846 | 0.9529 | GPU | 6 |
|
||||
| Qwen2.5-7B-CTC | [shibing624/chinese-text-correction-7b](https://huggingface.co/shibing624/chinese-text-correction-7b) | Qwen/Qwen2.5-7B-Instruct | **0.8225** | 0.4917 | 0.9798 | 0.9959 | GPU | 3 |
|
||||
|
||||
## Usage (pycorrector)
|
||||
|
||||
本项目开源在`pycorrector`项目:[pycorrector](https://github.com/shibing624/pycorrector),可支持大模型微调后用于文本纠错,通过如下命令调用:
|
||||
|
||||
Install package:
|
||||
```shell
|
||||
pip install -U pycorrector
|
||||
```
|
||||
|
||||
```python
|
||||
from 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](https://github.com/shibing624/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
|
||||
```
|
||||
|
||||
```python
|
||||
# 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:
|
||||
```shell
|
||||
少先队员应该为老人让座。
|
||||
```
|
||||
|
||||
|
||||
模型文件组成:
|
||||
```
|
||||
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](https://huggingface.co/datasets/shibing624/chinese_text_correction)
|
||||
- train time: 10 days
|
||||
- eval_loss: 
|
||||
- train_loss: 
|
||||
|
||||
### 训练数据集
|
||||
#### 中文纠错数据集
|
||||
|
||||
- 数据:[shibing624/chinese_text_correction](https://huggingface.co/datasets/shibing624/chinese_text_correction)
|
||||
|
||||
|
||||
如果需要训练Qwen的纠错模型,请参考[https://github.com/shibing624/pycorrector](https://github.com/shibing624/pycorrector) 或者 [https://github.com/shibing624/MedicalGPT](https://github.com/shibing624/MedicalGPT)
|
||||
|
||||
## Citation
|
||||
|
||||
```latex
|
||||
@software{pycorrector,
|
||||
author = {Xu Ming},
|
||||
title = {pycorrector: Implementation of language model finetune},
|
||||
year = {2024},
|
||||
url = {https://github.com/shibing624/pycorrector},
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
3
chinese-text-correction-7b.Q2_K.gguf
Normal file
3
chinese-text-correction-7b.Q2_K.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c0e2326d01d5442274faf5d1aa90dc7186daa6c0b8f8c69121561aad9218beb
|
||||
size 3015940544
|
||||
3
chinese-text-correction-7b.Q3_K_L.gguf
Normal file
3
chinese-text-correction-7b.Q3_K_L.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bdf142a21b86a09eed1ef25c5c1c5d3acce05ae69e8ed168ea5b6afcb49b826b
|
||||
size 4088459712
|
||||
3
chinese-text-correction-7b.Q3_K_M.gguf
Normal file
3
chinese-text-correction-7b.Q3_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:29f42b8c51b919a942ada3b21926f6c715d606b4901b9aa276950d623413737a
|
||||
size 3808391616
|
||||
3
chinese-text-correction-7b.Q3_K_S.gguf
Normal file
3
chinese-text-correction-7b.Q3_K_S.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bc63183f4f890f8fa6ddf1a92d0edf4ce09c9545fa0000f1e5d84b90af17ec1e
|
||||
size 3492368832
|
||||
3
chinese-text-correction-7b.Q4_0.gguf
Normal file
3
chinese-text-correction-7b.Q4_0.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e3043599565aaf9ad38871569c6474cac2e06a2ba96f7b77a0aaf55176630ac0
|
||||
size 4431391168
|
||||
3
chinese-text-correction-7b.Q4_1.gguf
Normal file
3
chinese-text-correction-7b.Q4_1.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2efc9b473d144500c92c377b63abc5c17996874e88e3a04e7b10d9647e5a3e58
|
||||
size 4873284032
|
||||
3
chinese-text-correction-7b.Q4_K_M.gguf
Normal file
3
chinese-text-correction-7b.Q4_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7547d4ab4636b263d9b7f76e4b35ed1699702c349c5718e39df08d49fafef5d9
|
||||
size 4683073984
|
||||
3
chinese-text-correction-7b.Q4_K_S.gguf
Normal file
3
chinese-text-correction-7b.Q4_K_S.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:277121dd65dfa93f7231e46488bbf14716e57b1c68b78ff1bfd5580f7965e22d
|
||||
size 4457769408
|
||||
3
chinese-text-correction-7b.Q5_0.gguf
Normal file
3
chinese-text-correction-7b.Q5_0.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d7a1629a505191f0318702cb621c07d387501c445ccc1e4e448b7e54ce8dd520
|
||||
size 5315176896
|
||||
3
chinese-text-correction-7b.Q5_1.gguf
Normal file
3
chinese-text-correction-7b.Q5_1.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c280de35575cffbe9178a46015c9016e781533174e4c8b05002b2759d753ab82
|
||||
size 5757069760
|
||||
3
chinese-text-correction-7b.Q5_K_M.gguf
Normal file
3
chinese-text-correction-7b.Q5_K_M.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f8ed7b56bc19f9f27058130c61a3016a7b038b35950a78cc11fb10e1d89252f7
|
||||
size 5444831680
|
||||
3
chinese-text-correction-7b.Q5_K_S.gguf
Normal file
3
chinese-text-correction-7b.Q5_K_S.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22105df67f28a44025fdea3ae032cfa807f458dc0df91935ab8304a70b293e9a
|
||||
size 5315176896
|
||||
3
chinese-text-correction-7b.Q6_K.gguf
Normal file
3
chinese-text-correction-7b.Q6_K.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ec50833e71c921e72522e7eb1a5362e5a9ff5d43eba5aa8ee71f5f05b4be1387
|
||||
size 6254199232
|
||||
3
chinese-text-correction-7b.Q8_0.gguf
Normal file
3
chinese-text-correction-7b.Q8_0.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8a13926e8c69400e20f2f20c7c13294b58bd17f3101da4956155fe34bdd4c777
|
||||
size 8098525632
|
||||
1
configuration.json
Normal file
1
configuration.json
Normal file
@@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "others", "allow_remote": true}
|
||||
Reference in New Issue
Block a user