Downloads · 30 days
351
2% of all-time downloads
recruit-jp/japanese-typo-detector-roberta-base
japanese-typo-detector-roberta-base is a token classification model from recruit-jp. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as cc-by-sa-4.0.
- 日本語の文章を入力すると各文字ごとに誤字脱字である確率を出力します - 各ラベルの意味は以下の通りです - 誤り種類の詳細については学習データセットの元論文をご参照ください - 日本語 Wikipedia の編集履歴に基づく 入力誤りデータセットと訂正システムの改良
Downloads · 30 days
351
2% of all-time downloads
All-time downloads
17.3K
Public
Parameters
99.6M
398 MB on disk
Likes
14
Public
Click a slice to open those files.
.safetensors398 MB · 100%
From the Hugging Face model README
日本語の文章を入力すると各文字ごとに誤字脱字である確率を出力します
各ラベルの意味は以下の通りです
| id | label | meaning |
|---|---|---|
| 0 | OK | 誤字なし |
| 1 | deletion | 1文字の抜け |
| 2 | insertion_a | 余分な1文字の挿入 |
| 3 | insertion_b | 直前の文字列と一致する2文字以上の余分な文字の挿入 |
| 4 | kanji-conversion_a | 同一の読みを持つ漢字の入れ替え(誤変換) |
| 5 | kanji-conversion_b | 近い読みを持つ漢字の入れ替え(誤変換) |
| 6 | substitution | 1文字の入れ替え |
| 7 | transposition | 隣接する2文字間の転置 |
| 8 | others | その他の入力誤り |
誤り種類の詳細については学習データセットの元論文をご参照ください
その他、モデルの詳細については当社ブログ記事をご参照ください
from transformers import AutoTokenizer,AutoModelForTokenClassification
import torch
import numpy as np
model_name = 'recruit-jp/japanese-typo-detector-roberta-base'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(model_name)
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = model.to(device)
in_text = "これは日本語の誤植を検出する真相学習モデルです。"
test_inputs = tokenizer(in_text, return_tensors='pt').get('input_ids')
test_outputs = model(test_inputs.to(torch.device(device)))
for chara, logit in zip(list(in_text), test_outputs.logits.squeeze().tolist()[1:-1]):
err_type_ind = np.argmax(logit)
err_name = model.config.id2label[err_type_ind]
err_desc = f"Detected!(err_index={err_type_ind}, err_name={err_name})" if err_type_ind > 0 else f""
print(f"{chara} : {err_desc}")
こ :
れ :
は :
日 :
本 :
語 :
の :
誤 :
植 :
を :
検 :
出 :
す :
る :
真 : Detected!(err_index=4, err_name=kanji-conversion_a)
相 : Detected!(err_index=4, err_name=kanji-conversion_a)
学 :
習 :
モ :
デ :
ル :
で :
す :
。 :