プリンキピア

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

15.5.3. Interpreting GloVe from the Ratio of Co-occurrence Probabilities15.5.3 共起確率の比からGloVeを解釈する

We can also interpret the GloVe model from another perspective. Using the same notation in Section 15.5.1, let pij=defP(wj∣wi) be the conditional probability of generating the context word wj given wi as the center word in the corpus. tab_glove lists several co-occurrence probabilities given words “ice” and “steam” and their ratios based on statistics from a large corpus.
英語のヒント
GloVeモデルは別の視点からも解釈できる。15.5.1節と同じ記法を使い、コーパスの中でwiを中心語として与えたときに文脈語wjを生成する条件付き確率をpij=defP(wj∣wi)とする。tab_gloveは、大きなコーパスの統計にもとづいて、単語「ice」と「steam」が与えられたときのいくつかの共起確率とその比を挙げている。
:Word-word co-occurrence probabilities and their ratios from a large corpus (adapted from Table 1 in Pennington et al. (2014))
英語のヒント
:大きなコーパスから得た単語どうしの共起確率とその比(Pennington et al.(2014)の表1をもとに改変)
Table 15.5.1表15.5.1
label:tab_glove
英語のヒント
label:tab_glove
wk=solidsolid(固体)gasgas(気体)waterwater(水)fashionfashion(ファッション)
p1=P(wk∣ice)0.000190.0000660.0030.000017
p2=P(wk∣steam)0.0000220.000780.00220.000018
p1/p28.90.0851.360.96
We can observe the following from tab_glove:
英語のヒント
tab_gloveから次のことが見てとれる。
  • For a word wk that is related to “ice” but unrelated to “steam”, such as wk=solid, we expect a larger ratio of co-occurence probabilities, such as 8.9.
    英語のヒント
    wk=solidのように、「ice」に関係があり「steam」には関係のない単語wkについては、8.9のような、より大きな共起確率の比が予想される。
  • For a word wk that is related to “steam” but unrelated to “ice”, such as wk=gas, we expect a smaller ratio of co-occurence probabilities, such as 0.085.
    英語のヒント
    wk=gasのように、「steam」に関係があり「ice」には関係のない単語wkについては、0.085のような、より小さな共起確率の比が予想される。
  • For a word wk that is related to both “ice” and “steam”, such as wk=water, we expect a ratio of co-occurence probabilities that is close to 1, such as 1.36.
    英語のヒント
    wk=waterのように、「ice」とも「steam」とも関係のある単語wkについては、1.36のような、1に近い共起確率の比が予想される。
  • For a word wk that is unrelated to both “ice” and “steam”, such as wk=fashion, we expect a ratio of co-occurence probabilities that is close to 1, such as 0.96.
    英語のヒント
    wk=fashionのように、「ice」とも「steam」とも関係のない単語wkについては、0.96のような、1に近い共起確率の比が予想される。
It can be seen that the ratio of co-occurrence probabilities can intuitively express the relationship between words. Thus, we can design a function of three word vectors to fit this ratio. For the ratio of co-occurrence probabilities pij/pik with wi being the center word and wj and wk being the context words, we want to fit this ratio using some function f:
英語のヒント
共起確率の比は、単語の間の関係を直観的に表せることがわかる。そこで、この比に当てはめるために、三つの単語ベクトルの関数を設計できる。wiを中心語、wjとwkを文脈語とする共起確率の比pij/pikについて、ある関数fを使ってこの比に当てはめたい。
f(𝐮j,𝐮k,𝐯i)≈pijpik.(15.5.5)
Among many possible designs for f, we only pick a reasonable choice in the following. Since the ratio of co-occurrence probabilities is a scalar, we require that f be a scalar function, such as f(𝐮j,𝐮k,𝐯i)=f((𝐮j−𝐮k)⊤𝐯i). Switching word indices j and k in (15.5.5), it must hold that f(x)f(−x)=1, so one possibility is f(x)=exp⁡(x), i.e.,
英語のヒント
fとして考えられる多くの設計の中から、以下では妥当な選び方を一つだけとる。共起確率の比はスカラーなので、fはf(𝐮j,𝐮k,𝐯i)=f((𝐮j−𝐮k)⊤𝐯i)のようなスカラー関数であることを求める。(15.5.5)で単語のインデックスjとkを入れ替えると、f(x)f(−x)=1が成り立たなければならないので、一つの可能性はf(x)=exp⁡(x)、つまり次のようにすることである。
f(𝐮j,𝐮k,𝐯i)=exp⁡(𝐮j⊤𝐯i)exp⁡(𝐮k⊤𝐯i)≈pijpik.(15.5.6)
Now let’s pick exp⁡(𝐮j⊤𝐯i)≈αpij, where α is a constant. Since pij=xij/xi, after taking the logarithm on both sides we get 𝐮j⊤𝐯i≈logα+logxij−logxi. We may use additional bias terms to fit −logα+logxi, such as the center word bias bi and the context word bias cj:
英語のヒント
ここで、αを定数としてexp⁡(𝐮j⊤𝐯i)≈αpijを選ぼう。pij=xij/xiなので、両辺の対数をとると𝐮j⊤𝐯i≈logα+logxij−logxiが得られる。−logα+logxiに当てはめるために、中心語のバイアスbiや文脈語のバイアスcjのような、追加のバイアス項を使ってよい。
𝐮j⊤𝐯i+bi+cj≈logxij.(15.5.7)
Measuring the squared error of (15.5.7) with weights, the GloVe loss function in (15.5.4) is obtained.
英語のヒント
(15.5.7)の二乗誤差を重みつきで測ると、(15.5.4)のGloVeの損失関数が得られる。