第16章自然言語処理:応用
16.6.4. Question Answering16.6.4 質問応答
As another token-level application, question answering reflects capabilities of reading comprehension. For example, the Stanford Question Answering Dataset (SQuAD v1.1) consists of reading passages and questions, where the answer to every question is just a segment of text (text span) from the passage that the question is about (Rajpurkar et al., 2016). To explain, consider a passage “Some experts report that a mask’s efficacy is inconclusive. However, mask makers insist that their products, such as N95 respirator masks, can guard against the virus.” and a question “Who say that N95 respirator masks can guard against the virus?”. The answer should be the text span “mask makers” in the passage. Thus, the goal in SQuAD v1.1 is to predict the start and end of the text span in the passage given a pair of question and passage.
英語のヒント
もう一つのトークン単位の応用として、質問応答は読解の能力を反映する。たとえば、スタンフォード質問応答データセット(SQuAD v1.1)は読解用の文章と質問からなり、どの質問の答えも、その質問が対象とする文章の中のテキストの一部分(テキストスパン)にすぎない(Rajpurkar et al., 2016)。説明のため、文章「Some experts report that a mask’s efficacy is inconclusive. However, mask makers insist that their products, such as N95 respirator masks, can guard against the virus.」(マスクの効果は決定的でないと報告する専門家もいる。しかし、マスクの製造業者は、N95防護マスクのような自社の製品はウイルスを防げると主張している)と、質問「Who say that N95 respirator masks can guard against the virus?」(N95防護マスクがウイルスを防げると言っているのは誰か)を考えよう。答えは、文章の中のテキストスパン「mask makers」(マスクの製造業者)であるべきである。したがって、SQuAD v1.1での目標は、質問と文章の対が与えられたとき、文章の中のテキストスパンの始まりと終わりを予測することである。
Fig. 16.6.4図16.6.4
Fine-tuning BERT for question answering. Suppose that the input text pair has two and three tokens.
英語のヒント
質問応答のためのBERTの微調整。入力のテキスト対には二つと三つのトークンがあるとする。
To fine-tune BERT for question answering, the question and passage are packed as the first and second text sequence, respectively, in the input of BERT. To predict the position of the start of the text span, the same additional fully connected layer will transform the BERT representation of any token from the passage of position into a scalar score . Such scores of all the passage tokens are further transformed by the softmax operation into a probability distribution, so that each token position in the passage is assigned a probability of being the start of the text span. Predicting the end of the text span is the same as above, except that parameters in its additional fully connected layer are independent from those for predicting the start. When predicting the end, any passage token of position is transformed by the same fully connected layer into a scalar score . Fig. 16.6.4 depicts fine-tuning BERT for question answering.
英語のヒント
質問応答のためにBERTを微調整するには、BERTの入力の中に、質問と文章をそれぞれ一つ目と二つ目のテキストの系列として詰める。テキストスパンの始まりの位置を予測するため、同じ追加の全結合層が、文章の位置にある任意のトークンのBERT表現をスカラーのスコアに変換する。文章のすべてのトークンのそうしたスコアは、さらにソフトマックス演算で確率分布に変換され、文章の各トークンの位置に、テキストスパンの始まりである確率が割り当てられる。テキストスパンの終わりの予測も上と同じだが、その追加の全結合層のパラメータは、始まりを予測するためのものとは独立である。終わりを予測するときは、位置にある文章の任意のトークンが、同じ全結合層でスカラーのスコアに変換される。図16.6.4は、質問応答のためのBERTの微調整を描いている。
For question answering, the supervised learning’s training objective is as straightforward as maximizing the log-likelihoods of the ground-truth start and end positions. When predicting the span, we can compute the score for a valid span from position to position (), and output the span with the highest score.
英語のヒント
質問応答では、教師あり学習の訓練の目的は、正解の始まりと終わりの位置の対数尤度を最大化するという素直なものである。スパンを予測するときは、位置から位置までの有効なスパン()についてスコアを計算し、スコアが最も高いスパンを出力すればよい。