「Google Colab」で「MPT」を試したので、まとめました。
MPT
MPTは、MosaicMLが開発したオープンソースで商用利用可能な大規模言語モデル(LLM)のシリーズであり、MosaicMLは効率的でスケーラブルなディープラーニングプラットフォームを提供している企業です。
MPT-7B
MPT-7Bはシリーズの最初のモデルであり、67億のパラメータを持ち、1兆のテキストとコードのトークンで訓練されました。
これはMetaが開発した別のLLMであるLLaMA-7Bと同等の品質を持っていますが、LLaMA-7Bとは異なり商業利用が許可されています。
MPT-7Bには、高速な訓練と推論のためのFlashAttentionや、最大84,000トークンの非常に長い入力を処理するためのALiBiなど、独自の特徴もあります。
モデル一覧
「MPT」は、次の14つのモデルが提供されています。
(2023年7月1日現在)
Model | Task | Last Updated | Stars | Forks |
---|---|---|---|---|
mosaicml/mosaic-bert-base | Fill-Mask | 17 days ago | 3.24k | 19 |
mosaicml/mosaic-bert-base-seqlen-1024 | Fill-Mask | May 31 | 251 | 7 |
mosaicml/mosaic-bert-base-seqlen-2048 | Fill-Mask | May 31 | 456 | 6 |
mosaicml/mosaic-bert-base-seqlen-512 | Fill-Mask | May 2 | 54 | 3 |
mosaicml/mosaic-bert-base-seqlen-256 | Fill-Mask | May 2 | 178 | 1 |
mosaicml/mpt-1b-redpajama-200b | Text Generation | Apr 21 | 2.61k | 69 |
mosaicml/mpt-1b-redpajama-200b-dolly | Text Generation | Apr 21 | 15.3k | 73 |
mosaicml/mpt-30b | Text Generation | 2 days ago | 7.93k | 223 |
mosaicml/mpt-30b-chat | Text Generation | 2 days ago | 3.51k | 117 |
mosaicml/mpt-30b-instruct | Text Generation | 2 days ago | 3.05k | 61 |
mosaicml/mpt-7b | Text Generation | 2 days ago | 113k | 970 |
mosaicml/mpt-7b-chat | Text Generation | 2 days ago | 33.9k | 445 |
mosaicml/mpt-7b-instruct | Text Generation | 2 days ago | 2.92M | 395 |
mosaicml/mpt-7b-storywriter | Text Generation | 2 days ago | 19.5k | 627 |
引用
Hugging Face モデル:https://huggingface.co/mosaicml
Github: https://github.com/mosaicml/llm-foundry
資料:https://www.mosaicml.com/blog/mpt-7b
Colabでの実行
Google Colab: GPU | V100 | Hight Memory
Usage: GPU RAM 38/40
実行手順は、次のとおりです。
パッケージのインストール。
!apt-get install tree
!pip install -q datasets evaluate transformers[sentencepiece] einops
モデルの準備。
import transformers
checkpoint = "mosaicml/mpt-7b"
pretrain_cache_dir = "/content/model/v00"
model = transformers.AutoModelForCausalLM.from_pretrained(
checkpoint,
trust_remote_code=True,
cache_dir=pretrain_cache_dir,
)
トークナイザーの確認
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('EleutherAI/gpt-neox-20b')
推論の確認
# English
import torch
from transformers import pipeline
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
with torch.autocast('cuda', dtype=torch.bfloat16):
print(
pipe('Here is a recipe for vegan banana bread:\n',
max_new_tokens=100,
do_sample=True,
use_cache=True))
結果
[{'generated_text': "Here is a recipe for vegan banana bread:\n1/2 teab. baking powder\n1/4 tsap. vanilla extract\n(not included in photo)\nMix it all up in a bowl. If you're using a food processor, you don't really need to mash the banana first, but if you're using a fork or hand masher, it's a good idea to make sure the banana is as close to puree consistency as possible. Add any raisins, nuts, and/or chocolate chips at this point"}]
# Japanese
import torch
from transformers import pipeline
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
with torch.autocast('cuda', dtype=torch.bfloat16):
print(
pipe('日本は:\n',
max_new_tokens=100,
do_sample=True,
use_cache=True))
結果
[{'generated_text': '日本は:\nThe Sapporo International Art Festival\nThe Sapporo International Art Festival has been held annually since 1978. It is a summer festival in which people in Hokkaido participate with art activities. The festival presents cultural activities such as plays, festivals, musical performances, art exhibitions and art workshops. The activities are held outdoors in public sites such as parks, plazas, plaza side and promenade on a large scale. Some festivals are held in traditional festivals, while some performances are'}]