Microsoftは、Bingで使用している超高速有限ステートマシンと正規表現操作ライブラリ「Bling Fire」をGitHubで公開した。従来のライブラリよりも高速で、例えばPythonから容易に利用できる。
この記事は会員限定です。会員登録(無料)すると全てご覧いただけます。
Microsoftの検索エンジン「Bing」の改良を担当する「Bling(Beyond Language Understanding)」チームは、Bingで使われている「超高速有限ステートマシン」と正規表現操作ライブラリ「Bling Fire」をGitHubで公開した。「Fire」は、FInite state machine and REgular expression manipulation libraryの略語。
Bling Fireは、Bing内のさまざまな言語操作に使われている。その一部を挙げると、トークナイゼーション(トークン化)や複数語表現マッチング、未知語の推測、ステミング/レンマ化などがある。
ステミングは、テキスト内の語の語幹を取り出す作業。レンマ化は、テキスト内の語を、見出し語(レンマ)を決めるために分類整理することを指す。
Bling Fireトークナイザは、自然言語テキストの高速で高品質なトークン化を行うように設計されている。主に、Pythonの自然言語処理(NLP)ライブラリ「NLTK」のトークン化ロジックに従うが、例外もある。ハイフン付きの語が分割されることと、幾つかのエラーが修正されていることだ。
NLTKとBling Fireのトークン化がどの程度異なるのかを次に示す。
The South Florida/Miami area has previously hosted the event 10 times . Names such as French , ( De ) Roche , Devereux , D'Arcy , Treacy and Lacy are particularly common in the southeast of Ireland . Marconi 's European experiments in July 1899 - Marconi may have transmitted the letter S ( dot/dot/dot ) in a naval demonstration In the confirmation window , click OK. Review the FMT Real - time Report ES . Go to C : \Users\Public\Documents\hyper - v\Virtual hard disks\ and delete MSIT_Win10.VHDX . … and an agency / vendor company are regulated by the country ' s civil code ; labor relationships between a …
The South Florida / Miami area has previously hosted the event 10 times . Names such as French , ( De ) Roche , Devereux , D' Arcy , Treacy and Lacy are particularly common in the southeast of Ireland . Marconi 's European experiments in July 1899 - Marconi may have transmitted the letter S ( dot / dot / dot ) in a naval demonstration In the confirmation window , click OK . Review the FMT Real - time Report ES . Go to C : \ Users \ Public \ Documents \ hyper - v \ Virtual hard disks \ and delete MSIT_Win10 . VHDX . … and an agency / vendor company are regulated by the country 's civil code ; labor relationships between a …
現在リリースされているモデルは、東アジアの言語(日本語、韓国語、簡体中国語、繁体中国語、タイ語)以外の大半の言語をサポートしている。スペースをトークン区切りとして使用する言語では、良好な結果が期待できるだろうと、Blingチームは述べている。
Bling FireトークナイザのハイレベルAPIは、構成や初期化、追加ファイルを必要とせず、PythonやPerl、C#、Javaなどの言語から使いやすように設計されている。決定論的ステートマシンを利用したことで、高速に動作する。
Blingチームによると、Bling Fireと他の一般的なNLPライブラリでトークン化タスクの実行速度を比べたところ、Bling Fireは約10倍の速度を記録したという。
システム | 平均実行時間(秒/1万パッセージ) |
---|---|
Bling Fire | 0.823 |
SpaCy | 8.653 |
NLTK | 17.821 |
独自のトークン化やセグメント化、ステミングなどのロジックを作成したい場合や、有限ステートマシンを他の目的で使用する必要がある場合は、WindowsやLinux上でCMakeを用いてプロジェクトをビルドすればよい。
Bling Fireを単にPythonで使いたい場合は、以下のようにpipを使えば最新リリースをインストールできる。
pip install blingfire
Pythonのコードでは、次のようにBling Fireを使えばよい。
from blingfire import * text = 'This is the Bling-Fire tokenizer' output = text_to_words(text)
Copyright © ITmedia, Inc. All Rights Reserved.