🚀 韩语拼写矫正器(Korean Typos Corrector)
这是一款基于ETRI - et5模型进行微调的韩语口语专用拼写矫正器,能够有效纠正韩语口语中的拼写错误。
✨ 主要特性
- 基于ETRI的ET5模型(https://aiopen.etri.re.kr/et5Model )进行微调,具备强大的语言处理能力。
- 使用“ 모두의 말뭉치 ”(https://corpus.korean.go.kr/request/reausetMain.do?lang=ko )的拼写矫正数据进行训练,数据来源可靠。
📦 安装指南
文档中未提及具体安装步骤,可参考transformers
库的安装方式进行安装。
💻 使用示例
基础用法
from transformers import T5ForConditionalGeneration, T5Tokenizer
model = T5ForConditionalGeneration.from_pretrained("j5ng/et5-typos-corrector")
tokenizer = T5Tokenizer.from_pretrained("j5ng/et5-typos-corrector")
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = model.to(device)
input_text = "아늬 진짜 무ㅓ하냐고"
input_encoding = tokenizer("맞춤법을 고쳐주세요: " + input_text, return_tensors="pt")
input_ids = input_encoding.input_ids.to(device)
attention_mask = input_encoding.attention_mask.to(device)
output_encoding = model.generate(
input_ids=input_ids,
attention_mask=attention_mask,
max_length=128,
num_beams=5,
early_stopping=True,
)
output_text = tokenizer.decode(output_encoding[0], skip_special_tokens=True)
print(output_text)
高级用法
from transformers import T5ForConditionalGeneration, T5Tokenizer, pipeline
model = T5ForConditionalGeneration.from_pretrained('j5ng/et5-typos-corrector')
tokenizer = T5Tokenizer.from_pretrained('j5ng/et5-typos-corrector')
typos_corrector = pipeline(
"text2text-generation",
model=model,
tokenizer=tokenizer,
device=0 if torch.cuda.is_available() else -1,
framework="pt",
)
input_text = "완죤 어이업ㅅ네진쨬ㅋㅋㅋ"
output_text = typos_corrector("맞춤법을 고쳐주세요: " + input_text,
max_length=128,
num_beams=5,
early_stopping=True)[0]['generated_text']
print(output_text)
🔧 技术细节
数据预处理
- 去除特殊字符(逗号、句号)。
- 去除空值("")。
- 去除过短的句子(长度小于等于2)。
- 去除句子中包含&name&、name1等名称标签的单词(仅去除单词,保留句子)。
- 处理后的数据总量为318,882对。
📄 许可证
本项目采用Apache - 2.0许可证。