21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

1-bit LLM の Bonsai を Google Pixel 7aのLinuxターミナルで試す

21
Posted at

はじめに

PrismMLが開発した 1-bit LLM の Bonsai-8B と Bonsai-1.7B を Google Pixel 7a の Linuxターミナルで試します。Bonsai-8B はモデルサイズが 1.15GB と小さく、Raspberry Pi 4B でも動作するそうです。「「スマホで動く」80億パラメーターLLM――1.15GBで実運用レベルうたう「1-bit Bonsai」が話題に」と書かれているので、スマホで動くか試してみました。

参考情報

動作確認環境

  • Google Pixel 7a
  • Android 16
  • Linuxターミナル

環境構築

Linuxターミナルの有効化

Pixel端末でのLinuxターミナルの有効化は、Google Pixel のLinuxターミナルを使ってAWS Bedrock APIを実行するの記事を参考にしてください。

llama.cppのビルド

こちらの記事を参考に、llama.cppをビルドします。

ビルドに必要なパッケージをインストールします。

sudo apt update
sudo apt install -y git cmake build-essential libopenblas-dev pkg-config openssl libssl-dev

PrismMLが管理するllama.cppのフォークをcloneします。

git clone https://github.com/PrismML-Eng/llama.cpp && cd llama.cpp

ビルドします。約15分ほどかかります。

cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
cmake --build build --config Release -j2

モデルの実行

PixelのLinuxターミナルでは日本語入力ができないため、'hello' という単純なプロンプトを入力しました。いずれのモデルともストリーミングの出力が遅く、PixelのLinuxターミナルでは実用に耐えるものではありませんでした。また、頻繁にLinuxターミナルがクラッシュしフルリカバリーが必要となったので、下記の 2 パターン程度しか検証を行うことができませんでした。

Bonsai-8B

初回はモデルのダウンロードが行われるため、実行に時間がかかります。-c でコンテキストサイズを指定しなかった場合、Segmentation fault が発生しました。そのため、https://zenn.dev/kun432/scraps/ce16474a3be277#comment-3592ca1fdb0075 を参考に、コンテキストサイズを 32784 に指定しました。

./build/bin/llama-cli \
  -hf prism-ml/Bonsai-8B-gguf \
  -p "hello" \
  -c 32784
Bonsai-8Bの実行結果

結果は、以下のようになりました。
[Prompt: 1.5 t/s | Generation: 0.1 t/s]

Bonsai-1.7B

同様に、Bonsai-1.7B を実行します。このモデルではコンテキストサイズの指定は不要でした。

./build/bin/llama-cli \
  -hf prism-ml/Bonsai-1.7B-gguf \
  -p "hello"
Bonsai-1.7Bの実行結果

結果は、以下のようになりました。
[Prompt: 4.4 t/s | Generation: 1.5 t/s]

まとめ

Google Pixel 7a の Linuxターミナルで Bonsai-8B と Bonsai-1.7B を試しました。2つのモデルとも動作することは確認できました。しかし、軽量モデルとはいえ、端末の性能が足らず実用に耐えるものではありませんでした。とはいえ、ビルドがきちんと通ったのは興味深い結果でした。

21
15
2

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
21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?