模型列表
模型名称 | 纠错类型 | 描述 |
---|---|---|
twnlp/ChineseErrorCorrector3-4B | 语法+拼写 | 使用200万纠错数据进行全量训练,适用于语法纠错和拼写纠错,效果最好,推荐使用。 |
twnlp/ChineseErrorCorrector2-7B | 语法+拼写 | 使用200万纠错数据进行多轮迭代训练,适用于语法纠错和拼写纠错,效果较好。 |
模型评测(NaCGEC Data)
Model Name | Prec | Rec | F0.5 |
---|---|---|---|
twnlp/ChineseErrorCorrector3-4B | 0.743 | 0.7294 | 0.7402 |
twnlp/ChineseErrorCorrector2-7B | 0.5686 | 0.57 | 0.5689 |
HW_TSC_nlpcc2023_cgec(华为) | 0.5095 | 0.3129 | 0.4526 |
鱼饼啾啾Plus(北京大学) | 0.5708 | 0.1294 | 0.3394 |
CUHK_SU(香港中文大学) | 0.3882 | 0.1558 | 0.2990 |
Without ChineseErrorCorrector, 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
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "twnlp/ChineseErrorCorrector3-4B"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "你是一个文本纠错专家,纠正输入句子中的语法错误,并输出正确的句子,输入句子为:"
text_input = "对待每一项工作都要一丝不够。"
messages = [
{"role": "user", "content": prompt + text_input}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
output:
对待每一项工作都要一丝不苟。
- Downloads last month
- 536
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
1
Ask for provider support