🚀 Bioformer-8L
Bioformer-8Lは、バイオメディカルテキストマイニング用の軽量BERTモデルです。バイオメディカルボキャブラリを使用し、バイオメディカルドメインのコーパスのみでゼロから事前学習されています。実験によると、Bioformer-8LはBERT-baseの3倍の速度で、下流のNLPタスクでBioBERT/PubMedBERTと同等以上の性能を達成します。
⚠️ 重要提示
bioformer-cased-v1.0
はbioformer-8L
に名称変更されました。bioformer-cased-v1.0
へのすべてのリンクは、git操作を含め、自動的にbioformer-8L
にリダイレクトされます。ただし、混乱を避けるために、既存のローカルクローンを新しいリポジトリURLに更新することをお勧めします。
🚀 クイックスタート
Bioformer-8Lの使い方は標準的なBERTモデルと同じです。BERTのドキュメントはこちらから参照できます。
✨ 主な機能
- 高速性能:BERT-baseの3倍の速度で動作します。
- 高性能:下流のNLPタスクでBioBERT/PubMedBERTと同等以上の性能を達成します。
- バイオメディカル特化:バイオメディカルボキャブラリを使用し、バイオメディカルドメインのコーパスのみで事前学習されています。
📦 インストール
前提条件
python3、pytorch、transformers、datasets
インストール手順
pytorchをインストールするには、こちらの指示に従ってください。
transformers
とdatasets
ライブラリをインストールするには、以下のコマンドを実行します。
pip install transformers
pip install datasets
💻 使用例
基本的な使用法
from transformers import pipeline
unmasker8L = pipeline('fill-mask', model='bioformers/bioformer-8L')
unmasker8L("[MASK] refers to a group of diseases that affect how the body uses blood sugar (glucose)")
unmasker16L = pipeline('fill-mask', model='bioformers/bioformer-16L')
unmasker16L("[MASK] refers to a group of diseases that affect how the body uses blood sugar (glucose)")
出力例
bioformer-8L
の出力
[{'score': 0.3207533359527588,
'token': 13473,
'token_str': 'Diabetes',
'sequence': 'Diabetes refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.19234347343444824,
'token': 17740,
'token_str': 'Obesity',
'sequence': 'Obesity refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.09200277179479599,
'token': 10778,
'token_str': 'T2DM',
'sequence': 'T2DM refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.08494312316179276,
'token': 2228,
'token_str': 'It',
'sequence': 'It refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.0412776917219162,
'token': 22263,
'token_str':
'Hypertension',
'sequence': 'Hypertension refers to a group of diseases that affect how the body uses blood sugar ( glucose )'}]
bioformer-16L
の出力
[{'score': 0.7262957692146301,
'token': 13473,
'token_str': 'Diabetes',
'sequence': 'Diabetes refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.124954953789711,
'token': 10778,
'token_str': 'T2DM',
'sequence': 'T2DM refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.04062706232070923,
'token': 2228,
'token_str': 'It',
'sequence': 'It refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.022694870829582214,
'token': 17740,
'token_str': 'Obesity',
'sequence': 'Obesity refers to a group of diseases that affect how the body uses blood sugar ( glucose )'},
{'score': 0.009743048809468746,
'token': 13960,
'token_str': 'T2D',
'sequence': 'T2D refers to a group of diseases that affect how the body uses blood sugar ( glucose )'}]
📚 ドキュメント
Bioformer-8Lのボキャブラリ
Bioformer-8Lは、バイオメディカルコーパスから学習された大文字小文字を区別するWordPieceボキャブラリを使用しています。このコーパスには、すべてのPubMedアブストラクト(2021年2月1日時点で3300万件)と100万件のPMC全文記事が含まれています。PMCには360万件の記事がありますが、PubMedアブストラクトとPMC全文記事の合計サイズがほぼ等しくなるように、100万件にダウンサンプリングしました。語彙外問題を軽減し、バイオメディカル文献の特殊記号(例:男性と女性の記号)を含めるために、2つのリソースのUnicodeテキストからBioformerのボキャブラリを学習させました。Bioformer-8Lのボキャブラリサイズは32768(2^15)で、元のBERTと同様です。
Bioformer-8Lの事前学習
Bioformer-8Lは、ボキャブラリと同じコーパス(3300万件のPubMedアブストラクト + 100万件のPMC全文記事)でゼロから事前学習されました。マスク付き言語モデリング(MLM)の目的で、マスキング率15%の全単語マスキングを使用しました。次文予測(NSP)の目的が下流タスクの性能を向上させるかどうかについては議論があります。エンドユーザーが次文の予測を必要とする場合もあるため、事前学習実験に含めました。すべての学習テキストの文分割は、SciSpacyを使用して行われました。
Bioformer-8Lの事前学習は、単一のCloud TPUデバイス(TPUv2、8コア、コアあたり8GBメモリ)で行われました。最大入力シーケンス長は512に固定され、バッチサイズは256に設定されました。Bioformer-8Lを200万ステップ事前学習し、約8.3日かかりました。
🔧 技術詳細
Bioformer-8Lは8層(トランスフォーマーブロック)で、隠れ埋め込みサイズは512で、自己注意ヘッドの数は8です。総パラメータ数は42,820,610です。
📄 ライセンス
このプロジェクトはApache-2.0ライセンスの下でライセンスされています。
🏆 受賞歴
Bioformer-8Lは、BioCreative VII COVID-19マルチラベルトピック分類チャレンジ(https://doi.org/10.1093/database/baac069)で最高の性能(最高のマイクロF1スコア)を達成しました。
🔗 関連リンク
Bioformer-16L
🙏 謝辞
Bioformer-8Lの学習と評価は、Google TPU Research Cloud (TRC)プログラム、国立医学図書館(NLM)、国立衛生研究所(NIH)の研究所内研究プログラム、およびNIH/NLMの助成金LM012895と1K99LM014024-01によって支援されています。
❓ 質問
何か質問がある場合は、こちらに問題を提出してください:https://github.com/WGLab/bioformer/issues
また、Li Fang (fangli9@mail.sysu.edu.cn, https://fangli80.github.io/) にメールを送ることもできます。
📖 引用
arXivでのプレプリントを引用することができます:
Fang L, Chen Q, Wei C-H, Lu Z, Wang K: Bioformer: an efficient transformer language model for biomedical text mining. arXiv preprint arXiv:2302.01588 (2023). DOI: https://doi.org/10.48550/arXiv.2302.01588
BibTeX形式:
@ARTICLE{fangli2023bioformer,
author = {{Fang}, Li and {Chen}, Qingyu and {Wei}, Chih-Hsuan and {Lu}, Zhiyong and {Wang}, Kai},
title = "{Bioformer: an efficient transformer language model for biomedical text mining}",
journal = {arXiv preprint arXiv:2302.01588},
year = {2023}
}