プリンキピア

第15章自然言語処理:事前学習

15.5.1. Skip-Gram with Global Corpus Statistics15.5.1 コーパス全体の統計を使ったスキップグラム

Denoting by qij the conditional probability P(wj∣wi) of word wj given word wi in the skip-gram model, we have
英語のヒント
スキップグラムモデルで、単語wiが与えられたときの単語wjの条件付き確率P(wj∣wi)をqijで表すと、次のようになる。
qij=exp⁡(𝐮j⊤𝐯i)∑k∈𝒱exp⁡(𝐮k⊤𝐯i),(15.5.1)
where for any index i vectors 𝐯i and 𝐮i represent word wi as the center word and context word, respectively, and 𝒱={0,1,…,|𝒱|−1} is the index set of the vocabulary.
英語のヒント
ここで、任意のインデックスiについて、ベクトル𝐯iと𝐮iは、それぞれ中心語と文脈語としての単語wiを表し、𝒱={0,1,…,|𝒱|−1}は語彙のインデックスの集合である。
Consider word wi that may occur multiple times in the corpus. In the entire corpus, all the context words wherever wi is taken as their center word form a multiset 𝒞i of word indices that allows for multiple instances of the same element. For any element, its number of instances is called its multiplicity. To illustrate with an example, suppose that word wi occurs twice in the corpus and indices of the context words that take wi as their center word in the two context windows are k,j,m,k and k,l,k,j. Thus, multiset 𝒞i={j,j,k,k,k,k,l,m}, where multiplicities of elements j,k,l,m are 2, 4, 1, 1, respectively.
英語のヒント
コーパスの中に何度も現れうる単語wiを考えよう。コーパス全体で、wiが中心語とされるすべての箇所の文脈語は、同じ要素が複数回現れることを許す単語のインデックスの多重集合𝒞iをなす。どの要素についても、それが現れる回数をその重複度と呼ぶ。例で示すと、単語wiがコーパスに2回現れ、二つの文脈窓でwiを中心語とする文脈語のインデックスがk,j,m,kとk,l,k,jだとする。すると多重集合は𝒞i={j,j,k,k,k,k,l,m}であり、要素j,k,l,mの重複度はそれぞれ2、4、1、1である。
Now let’s denote the multiplicity of element j in multiset 𝒞i as xij. This is the global co-occurrence count of word wj (as the context word) and word wi (as the center word) in the same context window in the entire corpus. Using such global corpus statistics, the loss function of the skip-gram model is equivalent to
英語のヒント
ここで、多重集合𝒞iでの要素jの重複度をxijで表そう。これは、コーパス全体を通じて、単語wj(文脈語として)と単語wi(中心語として)が同じ文脈窓の中で共起する回数である。そうしたコーパス全体の統計を使うと、スキップグラムモデルの損失関数は次と同値になる。
−∑i∈𝒱∑j∈𝒱xijlogqij.(15.5.2)
We further denote by xi the number of all the context words in the context windows where wi occurs as their center word, which is equivalent to |𝒞i|. Letting pij be the conditional probability xij/xi for generating context word wj given center word wi, (15.5.2) can be rewritten as
英語のヒント
さらに、wiが中心語として現れる文脈窓の中のすべての文脈語の数をxiで表す。これは|𝒞i|と同じである。中心語wiが与えられたときに文脈語wjを生成する条件付き確率xij/xiをpijとすると、(15.5.2)は次のように書き直せる。
−∑i∈𝒱xi∑j∈𝒱pijlogqij.(15.5.3)
In (15.5.3), −∑j∈𝒱pijlogqij calculates the cross-entropy of the conditional distribution pij of global corpus statistics and the conditional distribution qij of model predictions. This loss is also weighted by xi as explained above. Minimizing the loss function in (15.5.3) will allow the predicted conditional distribution to get close to the conditional distribution from the global corpus statistics.
英語のヒント
(15.5.3)で、−∑j∈𝒱pijlogqijは、コーパス全体の統計の条件付き分布pijと、モデルの予測の条件付き分布qijの交差エントロピーを計算する。この損失は、上で説明したようにxiで重みづけもされている。(15.5.3)の損失関数を最小化すると、予測した条件付き分布をコーパス全体の統計から得た条件付き分布に近づけられる。
Though being commonly used for measuring the distance between probability distributions, the cross-entropy loss function may not be a good choice here. On the one hand, as we mentioned in Section 15.2, the cost of properly normalizing qij results in the sum over the entire vocabulary, which can be computationally expensive. On the other hand, a large number of rare events from a large corpus are often modeled by the cross-entropy loss to be assigned with too much weight.
英語のヒント
交差エントロピー損失関数は、確率分布の間の距離を測るのによく使われるが、ここではよい選択ではないかもしれない。一つには、15.2節で述べたように、qijをきちんと正規化するコストは語彙全体にわたる和になり、計算が高くつきうる。もう一つには、大きなコーパスの多数のまれな事象が、交差エントロピー損失によって、しばしば重すぎる重みを割り当てられるようにモデル化されてしまう。