プリンキピア

第16章自然言語処理:応用

16.7. Natural Language Inference: Fine-Tuning BERT16.7 自然言語推論:BERTを微調整する

In earlier sections of this chapter, we have designed an attention-based architecture (in Section 16.5) for the natural language inference task on the SNLI dataset (as described in Section 16.4). Now we revisit this task by fine-tuning BERT. As discussed in Section 16.6, natural language inference is a sequence-level text pair classification problem, and fine-tuning BERT only requires an additional MLP-based architecture, as illustrated in Fig. 16.7.1.
英語のヒント
この章の前の節では、(16.4節で説明した)SNLIのデータセットでの自然言語推論のタスクのために、注意にもとづくアーキテクチャを(16.5節で)設計した。ここでは、BERTを微調整してこのタスクに再び取り組む。16.6節で論じたように、自然言語推論は系列単位のテキスト対の分類の問題であり、BERTの微調整には、図16.7.1に示すように、MLPにもとづく追加のアーキテクチャしか必要ない。
Fig. 16.7.1図16.7.1
This section feeds pretrained BERT to an MLP-based architecture for natural language inference.
英語のヒント
この節では、事前学習したBERTを、自然言語推論のためのMLPにもとづくアーキテクチャに入れる。
In this section, we will download a pretrained small version of BERT, then fine-tune it for natural language inference on the SNLI dataset.
英語のヒント
この節では、事前学習したBERTの小さな版をダウンロードし、それをSNLIのデータセットでの自然言語推論のために微調整する。
import json
import multiprocessing
import os
import torch
from torch import nn
from d2l import torch as d2l