🚀 タイポ検出器
このモデルは、文章中のタイポを検出することができ、Transformerベースのアプローチを用いて高精度なタイポ検出を実現しています。
🚀 クイックスタート
このセクションでは、このタイポ検出器の基本的な使い方を説明します。
✨ 主な機能
- NeuSpellコーパスを用いた学習により、高精度なタイポ検出が可能です。
- Transformersパイプラインを使用して簡単に予測を行うことができます。
📦 インストール
必要なライブラリをインストールするには、以下のコマンドを実行します。
pip install transformers
💻 使用例
基本的な使用法
import torch
from transformers import AutoConfig, AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
model_name_or_path = "m3hrdadfi/typo-detector-distilbert-en"
config = AutoConfig.from_pretrained(model_name_or_path)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForTokenClassification.from_pretrained(model_name_or_path, config=config)
nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="average")
高度な使用法
以下のコードは、複数の文章に対してタイポを検出する例です。
sentences = [
"He had also stgruggled with addiction during his time in Congress .",
"The review thoroughla assessed all aspects of JLENS SuR and CPG esign maturit and confidence .",
"Letterma also apologized two his staff for the satyation .",
"Vincent Jay had earlier won France 's first gold in gthe 10km biathlon sprint .",
"It is left to the directors to figure out hpw to bring the stry across to tye audience .",
]
for sentence in sentences:
typos = [sentence[r["start"]: r["end"]] for r in nlp(sentence)]
detected = sentence
for typo in typos:
detected = detected.replace(typo, f'<i>{typo}</i>')
print(" [Input]: ", sentence)
print("[Detected]: ", detected)
print("-" * 130)
出力結果:
[Input]: He had also stgruggled with addiction during his time in Congress .
[Detected]: He had also <i>stgruggled</i> with addiction during his time in Congress .
----------------------------------------------------------------------------------------------------------------------------------
[Input]: The review thoroughla assessed all aspects of JLENS SuR and CPG esign maturit and confidence .
[Detected]: The review <i>thoroughla</i> assessed all aspects of JLENS SuR and CPG <i>esign</i> <i>maturit</i> and confidence .
----------------------------------------------------------------------------------------------------------------------------------
[Input]: Letterma also apologized two his staff for the satyation .
[Detected]: <i>Letterma</i> also apologized <i>two</i> his staff for the <i>satyation</i> .
----------------------------------------------------------------------------------------------------------------------------------
[Input]: Vincent Jay had earlier won France 's first gold in gthe 10km biathlon sprint .
[Detected]: Vincent Jay had earlier won France 's first gold in <i>gthe</i> 10km biathlon sprint .
----------------------------------------------------------------------------------------------------------------------------------
[Input]: It is left to the directors to figure out hpw to bring the stry across to tye audience .
[Detected]: It is left to the directors to figure out <i>hpw</i> to bring the <i>stry</i> across to <i>tye</i> audience .
----------------------------------------------------------------------------------------------------------------------------------
📚 ドキュメント
データセット情報
この特定のタスクでは、NeuSpellコーパスを生データとして使用しました。
評価
以下の表は、モデルの全体的なスコアと各クラスごとのスコアをまとめたものです。
属性 |
詳情 |
モデルタイプ |
タイポ検出器 |
訓練データ |
NeuSpellコーパス |
# |
適合率 |
再現率 |
F1スコア |
サポート |
タイポ |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
マイクロ平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
マクロ平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
加重平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
質問はこちら
TypoDetector IssuesリポジトリにGitHubのissueを投稿してください。