第9章リカレントニューラルネットワーク
9.3. Language Models9.3 言語モデル
In Section 9.2, we saw how to map text sequences into tokens, where these tokens can be viewed as a sequence of discrete observations such as words or characters. Assume that the tokens in a text sequence of length are in turn . The goal of language models is to estimate the joint probability of the whole sequence:
英語のヒント
9.2節では、テキストの系列をトークンに写す方法を見た。これらのトークンは、単語や文字のような離散的な観測の系列とみなせる。長さのテキスト系列のトークンが順にであるとしよう。言語モデルの目標は、系列全体の同時確率を推定することである。
(9.3.1)
Language models are incredibly useful. For instance, an ideal language model should generate natural text on its own, simply by drawing one token at a time . Quite unlike the monkey using a typewriter, all text emerging from such a model would pass as natural language, e.g., English text. Furthermore, it would be sufficient for generating a meaningful dialog, simply by conditioning the text on previous dialog fragments. Clearly we are still very far from designing such a system, since it would need to understand the text rather than just generate grammatically sensible content.
英語のヒント
言語モデルは信じられないほど役に立つ。たとえば、理想的な言語モデルは、一度に一つのトークンを引くだけで、自分で自然なテキストを生成できるはずである。タイプライターを使うサルとはまったく違って、そうしたモデルから出てくるテキストはどれも、自然言語、たとえば英語のテキストとして通用するだろう。さらに、それまでの対話の断片をテキストの条件とするだけで、意味のある対話を生成するのに十分だろう。明らかに、そうしたシステムの設計にはまだほど遠い。文法的に筋の通った内容を生成するだけでなく、テキストを理解する必要があるからである。
Nonetheless, language models are of great service even in their limited form. For instance, the phrases “to recognize speech” and “to wreck a nice beach” sound very similar. This can cause ambiguity in speech recognition, which is easily resolved through a language model that rejects the second translation as outlandish. Likewise, in a document summarization algorithm it is worthwhile knowing that “dog bites man” is much more frequent than “man bites dog”, or that “I want to eat grandma” is a rather disturbing statement, whereas “I want to eat, grandma” is much more benign.
英語のヒント
それでも、言語モデルは限られた形でも大いに役に立つ。たとえば、「to recognize speech(音声を認識する)」と「to wreck a nice beach(すてきな浜辺を壊す)」という句は、とてもよく似た音に聞こえる。これは音声認識で曖昧さを生みうるが、2番目の訳を奇妙なものとして退ける言語モデルによって簡単に解消される。同じように、文書要約のアルゴリズムでは、「dog bites man(犬が人をかむ)」は「man bites dog(人が犬をかむ)」よりずっと頻繁であることや、「I want to eat grandma(おばあちゃんを食べたい)」はかなり穏やかでない発言なのに対し、「I want to eat, grandma(おばあちゃん、食べたいよ)」はずっと無害であることを知っておく価値がある。
import torch
from d2l import torch as d2l