第15章自然言語処理:事前学習
15.6.1. The fastText Model15.6.1 fastTextモデル
Recall how words are represented in word2vec. In both the skip-gram model and the continuous bag-of-words model, different inflected forms of the same word are directly represented by different vectors without shared parameters. To use morphological information, the fastText model proposed a subword embedding approach, where a subword is a character -gram (Bojanowski et al., 2017). Instead of learning word-level vector representations, fastText can be considered as the subword-level skip-gram, where each center word is represented by the sum of its subword vectors.
英語のヒント
word2vecで単語がどう表されるかを思い出そう。スキップグラムモデルでも連続バッグオブワーズモデルでも、同じ単語の異なる語形変化形は、パラメータを共有しない異なるベクトルでそのまま表される。形態の情報を使うため、fastTextモデルはサブワード埋め込みというやり方を提案した。そこでは、サブワードは文字のグラムである(Bojanowski et al., 2017)。fastTextは、単語単位のベクトル表現を学習する代わりに、サブワード単位のスキップグラムとみなせる。そこでは、各中心語はそのサブワードのベクトルの和で表される。
Let’s illustrate how to obtain subwords for each center word in fastText using the word “where”. First, add special characters “<” and “>” at the beginning and end of the word to distinguish prefixes and suffixes from other subwords. Then, extract character -grams from the word. For example, when , we obtain all subwords of length 3: “<wh”, “whe”, “her”, “ere”, “re>”, and the special subword “<where>”.
英語のヒント
単語「where」を使って、fastTextで各中心語のサブワードをどう得るかを示そう。まず、接頭辞と接尾辞をほかのサブワードと区別するため、単語の始めと終わりに特殊文字「<」と「>」を加える。次に、単語から文字のグラムを抽出する。たとえば、のとき、長さ3のすべてのサブワード「<wh」「whe」「her」「ere」「re>」と、特殊なサブワード「<where>」が得られる。
In fastText, for any word , denote by the union of all its subwords of length between 3 and 6 and its special subword. The vocabulary is the union of the subwords of all words. Letting be the vector of subword in the dictionary, the vector for word as a center word in the skip-gram model is the sum of its subword vectors:
英語のヒント
fastTextでは、任意の単語について、長さが3から6までのそのすべてのサブワードと、その特殊なサブワードとの和集合をで表す。語彙は、すべての単語のサブワードの和集合である。辞書のサブワードのベクトルをとすると、スキップグラムモデルで中心語としての単語のベクトルは、そのサブワードのベクトルの和である。
(15.6.1)
The rest of fastText is the same as the skip-gram model. Compared with the skip-gram model, the vocabulary in fastText is larger, resulting in more model parameters. Besides, to calculate the representation of a word, all its subword vectors have to be summed, leading to higher computational complexity. However, thanks to shared parameters from subwords among words with similar structures, rare words and even out-of-vocabulary words may obtain better vector representations in fastText.
英語のヒント
fastTextの残りの部分はスキップグラムモデルと同じである。スキップグラムモデルと比べて、fastTextの語彙は大きく、その結果モデルのパラメータが多くなる。さらに、単語の表現を計算するには、そのすべてのサブワードのベクトルを足し合わせなければならず、計算の複雑さが高くなる。しかし、似た構造をもつ単語の間でサブワードからのパラメータが共有されるおかげで、まれな単語や、語彙にない単語でさえ、fastTextではよりよいベクトル表現が得られることがある。