プリンキピア

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

15.5.2. The GloVe Model15.5.2 GloVeモデル

In view of this, the GloVe model makes three changes to the skip-gram model based on squared loss (Pennington et al., 2014):
英語のヒント
このことを踏まえて、GloVeモデルは、二乗損失にもとづいて、スキップグラムモデルに三つの変更を加える(Pennington et al., 2014)。
  1. Use variables pij′=xij and qij′=exp⁡(𝐮j⊤𝐯i) that are not probability distributions and take the logarithm of both, so the squared loss term is (logpij′−logqij′)2=(𝐮j⊤𝐯i−logxij)2.
    英語のヒント
    確率分布ではない変数pij′=xijとqij′=exp⁡(𝐮j⊤𝐯i)を使い、その両方の対数をとる。すると、二乗損失の項は(logpij′−logqij′)2=(𝐮j⊤𝐯i−logxij)2になる。
  2. Add two scalar model parameters for each word wi: the center word bias bi and the context word bias ci.
    英語のヒント
    各単語wiについて、スカラーのモデルパラメータを二つ、つまり中心語のバイアスbiと文脈語のバイアスciを加える。
  3. Replace the weight of each loss term with the weight function h(xij), where h(x) is increasing in the interval of [0,1].
    英語のヒント
    各損失項の重みを重み関数h(xij)に置き換える。ここで、h(x)は区間[0,1]で増加する。
Putting all things together, training GloVe is to minimize the following loss function:
英語のヒント
すべてをまとめると、GloVeを訓練することは、次の損失関数を最小化することである。
∑i∈𝒱∑j∈𝒱h(xij)(𝐮j⊤𝐯i+bi+cj−logxij)2.(15.5.4)
For the weight function, a suggested choice is: h(x)=(x/c)α (e.g α=0.75) if x<c (e.g., c=100); otherwise h(x)=1. In this case, because h(0)=0, the squared loss term for any xij=0 can be omitted for computational efficiency. For example, when using minibatch stochastic gradient descent for training, at each iteration we randomly sample a minibatch of non-zero xij to calculate gradients and update the model parameters. Note that these non-zero xij are precomputed global corpus statistics; thus, the model is called GloVe for Global Vectors.
英語のヒント
重み関数として提案されている選び方は、x<c(たとえばc=100)ならh(x)=(x/c)α(たとえばα=0.75)、そうでなければh(x)=1とするものである。この場合、h(0)=0なので、xij=0となるものの二乗損失の項は、計算の効率のために省いてよい。たとえば、訓練にミニバッチ確率的勾配降下法を使うときは、各反復で、0でないxijのミニバッチをランダムに抜き出して勾配を計算し、モデルのパラメータを更新する。これらの0でないxijは前もって計算したコーパス全体の統計であることに注意しよう。そのため、このモデルは大域ベクトル(Global Vectors)にちなんでGloVeと呼ばれる。
It should be emphasized that if word wi appears in the context window of word wj, then vice versa. Therefore, xij=xji. Unlike word2vec that fits the asymmetric conditional probability pij, GloVe fits the symmetric logxij. Therefore, the center word vector and the context word vector of any word are mathematically equivalent in the GloVe model. However in practice, owing to different initialization values, the same word may still get different values in these two vectors after training: GloVe sums them up as the output vector.
英語のヒント
単語wiが単語wjの文脈窓に現れるなら、その逆も成り立つことを強調しておくべきである。したがって、xij=xjiである。非対称な条件付き確率pijに当てはめるword2vecとは違って、GloVeは対称なlogxijに当てはめる。したがって、GloVeモデルでは、どの単語の中心語ベクトルと文脈語ベクトルも数学的に同値である。しかし実際には、初期値が異なるため、訓練の後でも同じ単語がこの二つのベクトルで異なる値をとることがある。GloVeは、それらを足し合わせたものを出力ベクトルとする。