第15章自然言語処理:事前学習
15.2.2. Hierarchical Softmax15.2.2 階層的ソフトマックス
As an alternative approximate training method, hierarchical softmax uses the binary tree, a data structure illustrated in Fig. 15.2.1, where each leaf node of the tree represents a word in dictionary .
英語のヒント
もう一つの近似的な訓練方法として、階層的ソフトマックスは、図15.2.1に示したデータ構造である二分木を使う。そこでは、木の各葉ノードが辞書の単語を表す。
Fig. 15.2.1図15.2.1
Hierarchical softmax for approximate training, where each leaf node of the tree represents a word in the dictionary.
英語のヒント
近似的な訓練のための階層的ソフトマックス。木の各葉ノードは辞書の単語を表す。
Denote by the number of nodes (including both ends) on the path from the root node to the leaf node representing word in the binary tree. Let be the node on this path, with its context word vector being . For example, in Fig. 15.2.1. Hierarchical softmax approximates the conditional probability in (15.1.4) as
英語のヒント
(15.2.7)
where function is defined in (15.2.2), and is the left child node of node : if is true, ; otherwise .
英語のヒント
ここで、関数は(15.2.2)で定義したものであり、はノードの左の子ノードである。が真なら、そうでなければである。
To illustrate, let’s calculate the conditional probability of generating word given word in Fig. 15.2.1. This requires dot products between the word vector of and non-leaf node vectors on the path (the path in bold in Fig. 15.2.1) from the root to , which is traversed left, right, then left:
英語のヒント
(15.2.8)
Since , it holds that the conditional probabilities of generating all the words in dictionary based on any word sum up to one:
英語のヒント
なので、任意の単語にもとづいて辞書のすべての単語を生成する条件付き確率の和は1になる。
(15.2.9)
Fortunately, since is on the order of due to the binary tree structure, when the dictionary size is huge, the computational cost for each training step using hierarchical softmax is significantly reduced compared with that without approximate training.
英語のヒント
幸い、二分木の構造のおかげではのオーダーなので、辞書の大きさがとても大きいとき、階層的ソフトマックスを使った各訓練ステップの計算コストは、近似的な訓練をしない場合と比べて大幅に減る。