第10章現代のリカレントニューラルネットワーク
10.8.3. Beam Search10.8.3 ビームサーチ
You could view sequence decoding strategies as lying on a spectrum, with beam search striking a compromise between the efficiency of greedy search and the optimality of exhaustive search. The most straightforward version of beam search is characterized by a single hyperparameter, the beam size, . Let’s explain this terminology. At time step 1, we select the tokens with the highest predicted probabilities. Each of them will be the first token of candidate output sequences, respectively. At each subsequent time step, based on the candidate output sequences at the previous time step, we continue to select candidate output sequences with the highest predicted probabilities from possible choices.
英語のヒント
系列の復号の戦略は、一つのスペクトルの上に並んでいるとみなせる。そこでは、ビームサーチが、貪欲探索の効率と全探索の最適性のあいだの折り合いをつける。最も素直な版のビームサーチは、一つのハイパーパラメータ、ビームサイズで特徴づけられる。この用語を説明しよう。時間ステップ1では、予測確率が最も高い個のトークンを選ぶ。それぞれが、個の候補の出力系列のそれぞれ最初のトークンになる。続く各時間ステップでは、前の時間ステップの個の候補の出力系列にもとづいて、通りのありうる選択から、予測確率が最も高い個の候補の出力系列を選び続ける。
Fig. 10.8.3図10.8.3
The process of beam search (beam size ; maximum length of an output sequence ). The candidate output sequences are , , , , , and .
英語のヒント
ビームサーチの過程(ビームサイズ、出力系列の最大の長さ)。候補の出力系列は、、、、、である。
Fig. 10.8.3 demonstrates the process of beam search with an example. Suppose that the output vocabulary contains only five elements: , where one of them is “<eos>”. Let the beam size be two and the maximum length of an output sequence be three. At time step 1, suppose that the tokens with the highest conditional probabilities are and . At time step 2, for all we compute
英語のヒント
図10.8.3は、例を使ってビームサーチの過程を示している。出力の語彙が五つの要素だけを含み、そのうちの一つが「<eos>」だとする。ビームサイズを2、出力系列の最大の長さを3とする。時間ステップ1で、条件付き確率が最も高いトークンがとだとする。時間ステップ2では、すべてのについて次を計算する。
(10.8.2)
and pick the largest two among these ten values, say and . Then at time step 3, for all , we compute
英語のヒント
そして、これら10個の値のうち最も大きい二つ、たとえばとを選ぶ。次に時間ステップ3で、すべてのについて次を計算する。
(10.8.3)
and pick the largest two among these ten values, say and As a result, we get six candidates output sequences: (i) ; (ii) ; (iii) , ; (iv) , ; (v) , , ; and (vi) , , .
英語のヒント
そして、これら10個の値のうち最も大きい二つ、たとえばとを選ぶ。その結果、六つの候補の出力系列が得られる。(i)、(ii)、(iii)、、(iv)、、(v)、、、(vi)、、。
In the end, we obtain the set of final candidate output sequences based on these six sequences (e.g., discard portions including and after “<eos>”). Then we choose the output sequence which maximizes the following score:
英語のヒント
最後に、これら六つの系列にもとづいて、最終的な候補の出力系列の集合を得る(たとえば、「<eos>」とその後の部分を捨てる)。そして、次のスコアを最大にする出力系列を選ぶ。
(10.8.4)
here is the length of the final candidate sequence and is usually set to 0.75. Since a longer sequence has more logarithmic terms in the summation of (10.8.4), the term in the denominator penalizes long sequences.
英語のヒント
ここで、は最終的な候補の系列の長さであり、はふつう0.75に設定される。長い系列ほど(10.8.4)の和の中の対数の項が多いので、分母の項が長い系列にペナルティを与える。
The computational cost of beam search is . This result is in between that of greedy search and that of exhaustive search. Greedy search can be treated as a special case of beam search arising when the beam size is set to 1.
英語のヒント
ビームサーチの計算の費用はである。この結果は、貪欲探索と全探索のあいだにある。貪欲探索は、ビームサイズを1に設定したときに生じるビームサーチの特別な場合として扱える。