プリンキピア

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

15.7. Word Similarity and Analogy15.7 単語の類似度と類推

In Section 15.4, we trained a word2vec model on a small dataset, and applied it to find semantically similar words for an input word. In practice, word vectors that are pretrained on large corpora can be applied to downstream natural language processing tasks, which will be covered later in Section 16. To demonstrate semantics of pretrained word vectors from large corpora in a straightforward way, let’s apply them in the word similarity and analogy tasks.
英語のヒント
15.4節では、小さなデータセットでword2vecのモデルを訓練し、それを当てはめて、入力した単語に意味の似た単語を見つけた。実際には、大きなコーパスで事前学習した単語ベクトルを、下流の自然言語処理のタスクに当てはめることができる。これについては後で第16章で扱う。大きなコーパスから事前学習した単語ベクトルの意味の性質を手っ取り早く示すため、それらを単語の類似度と類推のタスクに当てはめてみよう。
import os
import torch
from torch import nn
from d2l import torch as d2l