プリンキピア

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

15.1.1. One-Hot Vectors Are a Bad Choice15.1.1 ワンホットベクトルはよくない選択である

We used one-hot vectors to represent words (characters are words) in Section 9.5. Suppose that the number of different words in the dictionary (the dictionary size) is N, and each word corresponds to a different integer (index) from 0 to N−1. To obtain the one-hot vector representation for any word with index i, we create a length-N vector with all 0s and set the element at position i to 1. In this way, each word is represented as a vector of length N, and it can be used directly by neural networks.
英語のヒント
9.5節では、単語(そこでは文字が単語である)を表すのにワンホットベクトルを使った。辞書にある異なる単語の数(辞書の大きさ)をNとし、各単語が0からN−1までの異なる整数(インデックス)に対応するとしよう。インデックスがiの任意の単語のワンホットベクトル表現を得るには、すべて0の長さNのベクトルを作り、位置iの要素を1にする。こうして、各単語は長さNのベクトルとして表され、ニューラルネットワークでそのまま使える。
Although one-hot word vectors are easy to construct, they are usually not a good choice. A main reason is that one-hot word vectors cannot accurately express the similarity between different words, such as the cosine similarity that we often use. For vectors 𝐱,𝐲∈ℝd, their cosine similarity is the cosine of the angle between them:
英語のヒント
ワンホットの単語ベクトルは作るのはたやすいが、ふつうはよい選択ではない。主な理由は、ワンホットの単語ベクトルでは、よく使うコサイン類似度のような、異なる単語の間の類似度を正確に表せないことである。ベクトル𝐱,𝐲∈ℝdについて、それらのコサイン類似度は、それらのなす角のコサインである。
𝐱⊤𝐲∥𝐱∥∥𝐲∥∈[−1,1].(15.1.1)
Since the cosine similarity between one-hot vectors of any two different words is 0, one-hot vectors cannot encode similarities among words.
英語のヒント
任意の異なる二つの単語のワンホットベクトルどうしのコサイン類似度は0なので、ワンホットベクトルは単語の間の類似度を符号化できない。