BERTをfine-tuningする際のTips [自分用メモ]

AI SHIFT様が作成されたブログ記事が分かりやすかったので、筆者としての解釈を自分用メモとして残すことにする。
Kaggleで学んだBERTをfine-tuningする際のTips①〜学習効率化編〜 | 株式会社AI ...
BEiTのlast_hidden_stateを理解する

を参照すると,以下のようにBEiTから特徴を抽出するコードが書かれている.
from transformers import BeitFeatureExtractor, BeitModelfrom PIL import Imag ...TransformerでTokenizeしたSpanを入力文から特定

Hugging faceで文をTokenizeすると元の文のSpan情報が失われてしまう。これにより、NERでラベル付けしたトークンの位置をサブワード分割された文の中で見失ってしまうことがある。この困りごとを解決してくれるのが、ret ...
なぜBERTの隠れ層の次元が768なのか?

BERTを用いて文や単語から特徴抽出していると、取り出されたベクトルに出現する数字が、バッチサイズを示しているのか、トークン数を示しているのかなどが分からなくなってしまう。見覚えがあるが何の数字だったか混乱した場合は、「BERT 76 ...
RuntimeError: The size of tensor a (1104) must match the size of tensor b (512) at non-singleton dimension 1

Hugging FaceのTransformersを使って,事前学習済モデルを読み込んで推定させるとタイトルのようなエラーがでることがある.
このエラーはBERTにおけるトークン(サブワード)の最大長512を超えた文が入力 ...