Files
wehub-resource-sync e06fe8e8c6
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Waiting to run
New model PR merged notification / Notify new model (push) Waiting to run
Update Transformers metadata / build_and_package (push) Waiting to run
Secret Leaks / trufflehog (push) Failing after 1s
Build documentation / build (push) Failing after 1s
Build documentation / build_other_lang (push) Failing after 0s
CodeQL Security Analysis / CodeQL Analysis (push) Failing after 0s
PR CI / pr-ci (push) Failing after 1s
Slow tests on important models (on Push - A10) / Get all modified files (push) Failing after 1s
Slow tests on important models (on Push - A10) / Model CI (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 11:57:37 +08:00

2.8 KiB

BERTology

大規模なトランスフォーマー、例えばBERTの内部動作を調査する研究領域が急成長しています(これを「BERTology」とも呼びます)。この分野の良い例は以下です:

  • BERT Rediscovers the Classical NLP Pipeline by Ian Tenney, Dipanjan Das, Ellie Pavlick: 論文リンク
  • Are Sixteen Heads Really Better than One? by Paul Michel, Omer Levy, Graham Neubig: 論文リンク
  • What Does BERT Look At? An Analysis of BERT's Attention by Kevin Clark, Urvashi Khandelwal, Omer Levy, Christopher D. Manning: 論文リンク
  • CAT-probing: A Metric-based Approach to Interpret How Pre-trained Models for Programming Language Attend Code Structure: 論文リンク

この新しい分野の発展を支援するために、BERT/GPT/GPT-2モデルにいくつかの追加機能を組み込み、人々が内部表現にアクセスできるようにしました。これらの機能は、主にPaul Michel氏の優れた研究(論文リンク)に基づいています。具体的には、以下の機能が含まれています:

  • BERT/GPT/GPT-2のすべての隠れ状態にアクセスすることができます。
  • BERT/GPT/GPT-2の各ヘッドの注意重みにアクセスできます。
  • ヘッドの出力値と勾配を取得し、ヘッドの重要性スコアを計算し、論文リンクで説明されているようにヘッドを削減できます。

これらの機能を理解し、使用するのを支援するために、特定のサンプルスクリプト「bertology.py」を追加しました。このスクリプトは、GLUEで事前トレーニングされたモデルから情報を抽出し、ヘッドを削減する役割を果たします。