見出し画像

Google Colab で StripedHyena-7B を試す

「Google Colab」で「StripeHyena-7B」を試したので、まとめました。

【注意】Google Colab Pro/Pro+のA100で動作確認しています。


1. StripeHyena-7B

TripedHyena-7B」は、短期および長期コンテキストの評価において最高のオープンソース「Transformers」と競合する代替モデルです。長さ32k / 64k / 128kのシーケンスでのエンドツーエンド学習において、 >30%、>50%、>100% 高速です。Hyenaオペレータに配置されたアテンションとゲート畳み込みのハイブリッドになります。

2. StripedHyena-7B のモデル

現在提供されている「StripedHyena-7B」のモデルは、次の2つです。

togethercomputer/StripedHyena-Hessian-7B : ベースモデル
togethercomputer/StripedHyena-Nous-7B : チャットモデル

3. Colabでの実行

Colabでの実行手順は、次のとおりです。

(1) Colabのノートブックを開き、メニュー「編集 → ノートブックの設定」で「GPU」で「A100」を選択。

(2) パッケージのインストール。

# パッケージのインストール
!pip install ninja tokenizers==0.14.1 einops transformers==4.34.1 accelerate flash_attn

(2) リポジトリのクローン。

# リポジトリのクローン
!git clone https://github.com/togethercomputer/stripedhyena
%cd stripedhyena

(3) 推論の実行。
今回は、「togethercomputer/StripedHyena-Nous-7B」を使用します。

# 推論の実行
!python generate_transformers.py \
    --model-name togethercomputer/StripedHyena-Nous-7B \
    --input-file ./test_prompt.txt

Colabでは、以下のエラーが発生しました。

ImportError: For `use_flash_rmsnorm`: `pip install git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/layer_norm`

(4) エラーメッセージの指示に従ってインストール。
完了まで34分ほどかかりました。

!pip install git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/layer_norm

(5) 推論の実行。

# 推論の実行
!python generate_transformers.py \
    --model-name togethercomputer/StripedHyena-Nous-7B \
    --input-file ./test_prompt.txt

Colabでは、以下のエラーが発生しました。d

     28         msg += 'Possible files are located at %s.' % str(locs)
     29         msg += 'Please create a symlink of libcuda.so to any of the file.'
---> 30     assert any(os.path.exists(os.path.join(path, 'libcuda.so')) for path in dirs), msg
     31     return dirs

(6) Colabのリンクからエラー箇所を開き、「assert any(os.path.exists(…」をコメントアウトし、メニュー「ランタイム→セッションを再開する」で再起動し、「%cd stripedhyena」で元のフォルダに戻る。
コメントアウトで良いかは不明。dirsは[]でした。

# assert any(os.path.exists(os.path.join(path, 'libcuda.so')) for path in dirs), msg

(7) 推論の実行。

# 推論の実行
!python generate_transformers.py \
    --model-name togethercomputer/StripedHyena-Nous-7B \
    --input-file ./test_prompt.txt

(8) メッセージの入力。
以下のメッセージが表示されたら、「./test_prompt.txt」にメッセージ「Who is the cutest in Madoka Magica?」を記述して改行。

Press enter to read ./test_prompt.txt
<s> User: Who is the cutest in Madoka Magica?
Assistant: Initializing inference params...

### Response:
In the anime series "Puella Magi Madoka Magica," the character who is often considered the cutest is Kyubey. Kyubey is a small, white, cat-like creature who serves as the wish

【翻訳】
アニメシリーズ「魔法少女まどか☆マギカ」で最もかわいいとよく言われるキャラクターはキュゥべえです。 キュゥべえは、願いを叶える白くて小さな猫のような生き物です。



この記事が気に入ったらサポートをしてみませんか?