🚀 Dynamic-TinyBERT
Dynamic-TinyBERTは、質問応答というNLPタスクに対して微調整されたモデルです。SQuAD 1.1データセットを使用して訓練されており、任意の計算予算で推論効率を向上させることができます。
🚀 クイックスタート
Dynamic-TinyBERTは、質問応答タスクに最適化されたNLPモデルです。以下のセクションでは、モデルの詳細、使用方法、性能分析などを紹介します。
✨ 主な機能
- 推論効率の向上: シーケンス長の削減とハイパーパラメータ最適化を利用して、任意の計算予算で推論効率を向上させます。
- 高精度: BERTと同等の性能を発揮し、他の効率的なアプローチよりも優れた精度と速度のトレードオフを達成します。
📦 インストール
このモデルはHugging FaceのTransformersライブラリを使用して利用できます。以下のコマンドでライブラリをインストールできます。
pip install transformers
💻 使用例
基本的な使用法
import torch
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("Intel/dynamic_tinybert")
model = AutoModelForQuestionAnswering.from_pretrained("Intel/dynamic_tinybert")
context = "remember the number 123456, I'll ask you later."
question = "What is the number I told you?"
tokens = tokenizer.encode_plus(question, context, return_tensors="pt", truncation=True)
input_ids = tokens["input_ids"]
attention_mask = tokens["attention_mask"]
outputs = model(input_ids, attention_mask=attention_mask)
start_scores = outputs.start_logits
end_scores = outputs.end_logits
answer_start = torch.argmax(start_scores)
answer_end = torch.argmax(end_scores) + 1
answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(input_ids[0][answer_start:answer_end]))
print("Answer:", answer)
📚 ドキュメント
モデル詳細
属性 |
详情 |
モデルの著者 - 会社 |
Intel |
モデルカードの著者 |
IntelとHugging Faceの共同制作 |
日付 |
2021年11月22日 |
バージョン |
1 |
モデルタイプ |
NLP - 質問応答 |
アーキテクチャ |
"For our Dynamic-TinyBERT model we use the architecture of TinyBERT6L: a small BERT model with 6 layers, a hidden size of 768, a feed forward size of 3072 and 12 heads." Guskin et al. (2021) |
論文またはその他のリソース |
論文; ポスター; GitHubリポジトリ |
ライセンス |
Apache 2.0 |
質問またはコメント |
コミュニティタブ と Intel Developers Discord |
意図された使用法
意図された使用法 |
説明 |
主な意図された使用法 |
このモデルは、質問応答のNLPタスクに使用できます。与えられたテキストコーパスに対して質問を行い、そのテキスト内から答えを見つけます。 |
主な意図されたユーザー |
質問応答を行うすべてのユーザー |
想定外の使用法 |
このモデルは、人々に敵意や疎外感を与える環境を意図的に作り出すために使用してはいけません。 |
要因
要因 |
説明 |
グループ |
訓練データには、質問と回答のラベル付けがされた多くのWikipedia記事が含まれています。 |
計測機器 |
- |
環境 |
訓練はTitan GPUで完了しました。 |
カードプロンプト |
代替のハードウェアとソフトウェアでのモデル展開は、モデルの性能を変化させます。 |
メトリクス
メトリクス |
説明 |
モデル性能測定 |
F1 |
決定閾値 |
- |
不確実性と変動性へのアプローチ |
- |
訓練と評価データ
訓練と評価データ |
説明 |
データセット |
SQuAD1.1: "Stanford Question Answering Dataset (SQuAD) is a reading comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles, where the answer to every question is a segment of text, or span, from the corresponding reading passage, or the question might be unanswerable." (https://huggingface.co/datasets/squad) |
動機 |
質問応答タスクに対して効率的かつ高精度なモデルを構築すること。 |
前処理 |
"We start with a pre-trained general-TinyBERT student, which was trained to learn the general knowledge of BERT using the general-distillation method presented by TinyBERT. We perform transformer distillation from a fine- tuned BERT teacher to the student, following the same training steps used in the original TinyBERT: (1) intermediate-layer distillation (ID) — learning the knowledge residing in the hidden states and attentions matrices, and (2) prediction-layer distillation (PD) — fitting the predictions of the teacher." (Guskin et al., 2021) |
モデル性能分析
モデル |
最大F1 (フルモデル) |
BERT-1%以内の最良のスピードアップ |
Dynamic-TinyBERT |
88.71 |
3.3x |
倫理的な考慮事項
倫理的な考慮事項 |
説明 |
データ |
訓練データはWikipedia記事から取得されています。 |
人間の生活 |
このモデルは、人間の生活や繁栄に核心的な決定を下すための情報提供を目的としていません。ラベル付けされたWikipedia記事の集合です。 |
緩和策 |
モデル開発中に追加のリスク緩和策は考慮されていません。 |
リスクと危害 |
多くの研究が、言語モデルのバイアスと公平性の問題を探求しています (例えば、Sheng et al., 2021 および Bender et al., 2021 を参照)。このモデルによって生成される予測には、保護されたクラス、アイデンティティ特性、および敏感な社会的および職業的グループにまたがる有害なステレオタイプが含まれる可能性があります。これ以外にも、このモデルを使用することによるリスクの範囲は不明です。 |
使用事例 |
- |
注意事項と推奨事項
ユーザー (直接的なユーザーと下流のユーザーの両方) は、このモデルのリスク、バイアス、および制限事項を認識する必要があります。このモデルに関する追加の注意事項や推奨事項はありません。
📄 ライセンス
このモデルはApache 2.0ライセンスの下で提供されています。
BibTeXエントリと引用情報
@misc{https://doi.org/10.48550/arxiv.2111.09645,
doi = {10.48550/ARXIV.2111.09645},
url = {https://arxiv.org/abs/2111.09645},
author = {Guskin, Shira and Wasserblat, Moshe and Ding, Ke and Kim, Gyuwan},
keywords = {Computation and Language (cs.CL), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Dynamic-TinyBERT: Boost TinyBERT's Inference Efficiency by Dynamic Sequence Length},
publisher = {arXiv},
year = {2021},