2
0

Dolly2.0をGoogle Colabで動かしてみた

Last updated at Posted at 2023-04-14

はじめに

Open SorceのLanguage Larage Model(LLM)であるDolly 2.0が発表された (https://www.databricks.com/blog/2023/04/12/dolly-first-open-commercially-viable-instruction-tuned-llm) ので、Google Colabで試してみました。

2023/04/14現在、以下の3つのモデルが用意されていました (https://huggingface.co/databricks) が、無料のCollab環境では、12b,7bはメモリオーバーになってしまったので、3bを使用しました。
・databricks/dolly-v2-12b
・databricks/dolly-v2-7b
・databricks/dolly-v2-3b

実施内容

モデルの説明の手順 (https://huggingface.co/databricks/dolly-v2-3b) に従って実施しました。

1.google colabで新規ファイルを作成

2.pytorch等ライブラリのインストール

!pip install accelerate>=0.12.0 transformers[torch]==4.25.1

3.モデルを呼び込んだpipelineの作成

import torch
from transformers import pipeline

generate_text = pipeline(model="databricks/dolly-v2-3b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")

4.パイプラインに指示文を与え、実行

generate_text("Explain to me the difference between nuclear fission and fusion.")

'Nuclear fission is the splitting of the nucleus of an atom by the action of a strong force. It occurs when a large enough heavy nucleus, such as uranium 235, tries to split itself in two. When two sufficiently small nuclei collide, they may fuse together to form a larger, more stable nucleus. Nuclear fusion is the process by which two or more light nuclei combine to form a heavier one. Nuclear fusion releases enormous amounts of energy that is readily usable to produce electricity or propulsion.'

※同じ質問を日本語で入力してみた結果は以下のようになりました。日本語対応は現状不十分なようです。

generate_text("核分裂と核融合の違いについて説明してください。")

'核分裂とは原子核を結合させた構成要素が成分ぎ instead of molecules, つまり原子核となる element-235 のことです。核融合には核融合物 (nucleus-dipping material) のことと付けます。さらに核融合物は核の指数関係で構成要素をやり取りします。イオンが地球温暖化が原因とされる一因の 1/5 程度が核融合物によってして地球の 20% 程度とも言われています。現在の地球温暖化についても核融合物によって予想されていますが、現在の地球温暖化カーブも変化します。'
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0