TorchScale は、研究者や開発者がトランスフォーマーを効率的かつ効果的にスケールアップできるようにする PyTorch ライブラリです。 モデリングの一般性と機能を向上させるための基礎研究の実施、およびトランスフォーマーのスケーリングの安定性と効率のトレーニングがあります。
インストールするには:
pip install torchscale
または、ローカルで開発することもできます。
git clone https://github.com/microsoft/torchscale.git cd torchscale pip install -e .
数行のコードで、上記の基本的な研究機能を有効にしたモデルを作成できます。BERTのようなエンコーダーをすばやく入手する方法は次のとおりです。
>>> from torchscale.architecture.config import EncoderConfig
>>> from torchscale.architecture.encoder import Encoder
>>> config = EncoderConfig(vocab_size=64000)
>>> model = Encoder(config)
>>> print(model)
また、アーキテクチャとアーキテクチャもサポートしています。
Decoder
EncoderDecoder
# Creating a decoder model
>>> from torchscale.architecture.config import DecoderConfig
>>> from torchscale.architecture.decoder import Decoder
>>> config = DecoderConfig(vocab_size=64000)
>>> decoder = Decoder(config)
>>> print(decoder)
# Creating a encoder-decoder model
>>> from torchscale.architecture.config import EncoderDecoderConfig
>>> from torchscale.architecture.encoder_decoder import EncoderDecoder
>>> config = EncoderDecoderConfig(vocab_size=64000)
>>> encdec = EncoderDecoder(config)
>>> print(encdec)
ポストレイヤーノルムトランスフォーマーのトレーニング安定性を向上させるディープノーム
Config
FeedForwardNetwork
スパースクリップ:スパースMoEモデルのグラデーションクリッピングの改善
上記の機能のほとんどは、対応するパラメーターをconfigに渡すだけで使用できます。例えば:
>>> from torchscale.architecture.config import EncoderConfig
>>> from torchscale.architecture.encoder import Encoder
>>> config = EncoderConfig(vocab_size=64000, deepnorm=True, multiway=True)
>>> model = Encoder(config)
>>> print(model)
次のシナリオ/タスクで TorchScale を使用する方法の例があります。
言語
視覚
演説
マルチ モーダル
さまざまなタスク(ビジョン事前トレーニングや音声認識など)やさまざまなディープラーニングツールキット(DeepSpeedやMegatron-LMなど)に関するより多くの例を提供する予定です。コメントやPRは大歓迎です!
TorchScale を使用するとトレーニング曲線が滑らかになりますが、ベースラインのトランスフォーマーは収束できません。
TorchScaleは任意の深さと幅をサポートし、痛みを伴わずにモデルを正常にスケールアップします。
TorchScale のいくつかの実装は、FairSeqリポジトリとUniLMリポジトリから適応またはインスピレーションを得ています。
このリポジトリがお役に立てば、私たちの研究を引用することを検討してください。
@article{torchscale, author = {Shuming Ma and Hongyu Wang and Shaohan Huang and Wenhui Wang and Zewen Chi and Li Dong and Alon Benhaim and Barun Patra and Vishrav Chaudhary and Xia Song and Furu Wei}, title = {{TorchScale}: {Transformers} at Scale}, journal = {CoRR}, volume = {abs/2211.13184}, year = {2022} }
@article{deepnet, author = {Hongyu Wang and Shuming Ma and Li Dong and Shaohan Huang and Dongdong Zhang and Furu Wei}, title = {{DeepNet}: Scaling {Transformers} to 1,000 Layers}, journal = {CoRR}, volume = {abs/2203.00555}, year = {2022}, }
@article{magneto, author = {Hongyu Wang and Shuming Ma and Shaohan Huang and Li Dong and Wenhui Wang and Zhiliang Peng and Yu Wu and Payal Bajaj and Saksham Singhal and Alon Benhaim and Barun Patra and Zhun Liu and Vishrav Chaudhary and Xia Song and Furu Wei}, title = {Foundation {Transformers}}, journal = {CoRR}, volume = {abs/2210.06423}, year = {2022} }
@inproceedings{xmoe, title={On the Representation Collapse of Sparse Mixture of Experts}, author={Zewen Chi and Li Dong and Shaohan Huang and Damai Dai and Shuming Ma and Barun Patra and Saksham Singhal and Payal Bajaj and Xia Song and Xian-Ling Mao and Heyan Huang and Furu Wei}, booktitle={Advances in Neural Information Processing Systems}, year={2022}, url={https://openreview.net/forum?id=mWaYC6CZf5} }
このプロジェクトは、貢献と提案を歓迎します。ほとんどの投稿では、 コントリビューターライセンス契約(CLA)は、あなたが私たちに付与する権利があり、実際に付与することを宣言しています あなたの投稿を使用する権利。詳しくは、https://cla.opensource.microsoft.com をご覧ください。
プルリクエストを送信すると、CLAボットは、提供する必要があるかどうかを自動的に判断します CLAであり、PRを適切に装飾します(ステータスチェック、コメントなど)。指示に従ってください ボットによって提供されます。これは、CLAを使用してすべてのリポジトリで一度だけ行う必要があります。
このプロジェクトでは、マイクロソフト オープンソース行動規範を採用しています。 詳細については、行動規範に関するFAQまたは 追加の質問やコメントがある場合は、フルウェイとシュミンマに連絡してください。
このプロジェクトには、プロジェクト、製品、またはサービスの商標またはロゴが含まれている場合があります。マイクロソフトの許可された使用 商標またはロゴは、Microsoft の商標およびブランド ガイドラインの対象であり、それに従う必要があります。 このプロジェクトの修正バージョンでのマイクロソフトの商標またはロゴの使用は、混乱を引き起こしたり、マイクロソフトのスポンサーシップを暗示したりしてはなりません。 第三者の商標またはロゴの使用は、それらの第三者のポリシーの対象となります。