第15章自然言語処理:事前学習
15.10. Pretraining BERT15.10 BERTの事前学習
With the BERT model implemented in Section 15.8 and the pretraining examples generated from the WikiText-2 dataset in Section 15.9, we will pretrain BERT on the WikiText-2 dataset in this section.
英語のヒント
import torch
from torch import nn
from d2l import torch as d2lTo start, we load the WikiText-2 dataset as minibatches of pretraining examples for masked language modeling and next sentence prediction. The batch size is 512 and the maximum length of a BERT input sequence is 64. Note that in the original BERT model, the maximum length is 512.
英語のヒント
まず、WikiText-2のデータセットを、マスク言語モデリングと次文予測のための事前学習の事例のミニバッチとして読み込む。バッチの大きさは512で、BERTの入力系列の最大の長さは64である。元のBERTモデルでは、最大の長さは512であることに注意しよう。
batch_size, max_len = 512, 64
train_iter, vocab = d2l.load_data_wiki(batch_size, max_len)