🚀 中文テキスト修正モデル
このモデルは、中国語のテキストにおけるスペルミスや文法エラーを修正するためのものです。shibing624/chinese-text-correction-7b
を使用することで、正確なテキスト修正が可能です。
🚀 クイックスタート
モデルの評価結果
shibing624/chinese-text-correction-7b
のテストデータ評価結果は以下の通りです。
CSC テストの全体的なパフォーマンス:
入力テキスト |
予測テキスト |
文本纠错: 少先队员因该为老人让坐。 |
少先队员应该为老人让座。 |
利用可能なモデル
名前 |
ベースモデル |
ダウンロード |
chinese-text-correction-1.5b |
Qwen/Qwen2.5-1.5B-Instruct |
🤗 Hugging Face |
chinese-text-correction-1.5b-lora |
Qwen/Qwen2.5-1.5B-Instruct |
🤗 Hugging Face |
chinese-text-correction-7b |
Qwen/Qwen2.5-7B-Instruct |
🤗 Hugging Face |
chinese-text-correction-7b-lora |
Qwen/Qwen2.5-7B-Instruct |
🤗 Hugging Face |
評価結果の詳細
- 評価指標:F1
- CSC(Chinese Spelling Correction):スペル修正モデルで、音似、形似、文法などの長さが一致するエラー修正が可能です。
- CTC(CHinese Text Correction):テキスト修正モデルで、スペル、文法などの長さが一致するエラー修正に加え、多字、少字などの長さが一致しないエラー修正もサポートします。
- GPU:Tesla V100、メモリ 32 GB
💻 使用例
pycorrectorを使用する場合
このプロジェクトは pycorrector
プロジェクトでオープンソース化されています:pycorrector。大規模モデルの微調整後にテキスト修正に使用できます。以下のコマンドで呼び出すことができます。
パッケージのインストール:
pip install -U pycorrector
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()
HuggingFace Transformersを使用する場合
pycorrector を使用せずに、以下のようにモデルを使用できます。
まず、入力をトランスフォーマーモデルに渡し、生成された文を取得します。
パッケージのインストール:
pip install transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "shibing624/chinese-text-correction-7b"
device = "cuda"
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]))
出力:
少先队员应该为老人让座。
モデルファイルの構成
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
訓練パラメータ
訓練データセット
中国語修正データセット
Qwenの修正モデルを訓練する場合は、https://github.com/shibing624/pycorrector または https://github.com/shibing624/MedicalGPT を参照してください。
📄 ライセンス
このモデルは apache-2.0
ライセンスの下で提供されています。
📚 引用
@software{pycorrector,
author = {Xu Ming},
title = {pycorrector: Implementation of language model finetune},
year = {2024},
url = {https://github.com/shibing624/pycorrector},
}