メインコンテンツへスキップ
  1. Posts/

GALACTICAをローカルで動かす

·2 分· loading · loading · · ·
Python AI
kame404
著者
kame404
こんにちは! kame404 です🥰 「軽さ」と「美味しさ」を両立した食べ物のCGを作ります。
目次

MetaAIの研究チームが公開したGalacticaをローカルで動かします。 Galacticaは大量の研究論文や資料で訓練されているそうです。

PaperGitHubリポジトリ
Galactica: A Large Language Model for Sciencegalai

実行環境
#

  • Windows 11 Version 22H2 (OS Build 25236.1010)
  • Miniconda3 Windows 64-bit
  • NVIDIA GeForce GTX 1070 8GB

仮想環境作成
#

Miniconda3のプロンプトを開き、python3.9の仮想環境を作ります

conda create -n galactica python=3.9

仮想環境をactivateします

conda activate galactica

pipでインストールします

pip install git+https://github.com/paperswithcode/galai

実行してみる
#

Lecture 1: The Ising Modelと入力して、イジング模型について書いてもらいましょう

import galai as gal

model = gal.load_model("base")
model.generate("Lecture 1: The Ising Model\n\n", new_doc=True, top_p=0.7, max_length=200)

AssertionError: Torch not compiled with CUDA enabled

AssertionErrorが出てしまいました。PyTorch.orgのSTART LOCALLYの手順に従ってCUDAをセットアップします

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

再挑戦
#

import galai as gal

model = gal.load_model("base")
model.generate("Lecture 1: The Ising Model\n\n", new_doc=True, top_p=0.7, max_length=200)

RuntimeError: CUDA error: invalid device ordinal

RuntimeErrorが出てしまいました。 GPUの数がデフォルト(8個)より少ない場合は、モデルをロードするときにGPUの数を指定する必要があるようです

再々挑戦
#

import galai as gal

model = gal.load_model(name = 'base', num_gpus = 1)
model.generate("Lecture 1: The Ising Model\n\n", new_doc=True, top_p=0.7, max_length=200)

The Ising model is a prototypical example of a system that can be exactly solved, and this is why it is also a prototypical example of a critical system. The Ising model is also a prototypical example of a system that is solvable exactly in the infinite volume limit, and this is why it is also a prototypical example of a critical system. It is a simplified version of the Heisenberg model, and its hamiltonian can be expressed by the following formula. \(\mathcal{H} = -\sum_{\langle i,j\rangle} J \sigma_i\sigma_j\)

数式を含む文章が生成されました。文中の\(\mathcal{H} = -\sum_{\langle i,j\rangle} J \sigma_i\sigma_j\)は実際にある数式のようです learn.microsoft.com Ising model

model = gal.load_model("base")

今回はbaseモデルを指定していますが、以下の5つのモデルを指定できます

SizeParameters
mini125 M
base1.3 B
standard6.7 B
large30 B
huge120 B

関連記事

3Dモデルのテスト
·1 分· loading · loading
3D モデリング