1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ラズパイのローカルLLMと会話(1)LLM設定と動作確認

1
Posted at

はじめに

ラズパイ5(RAM 8GByte)でローカルLLMを構築してみました。QWENの3Bモデルなら、何とか動きましたので、記録として残しておきます。

まずは、update & upgrade して、再起動します。

sudo apt update && sudo apt upgrade -y
sudo reboot

必要ツールをインストールしておきます。

sudo apt install -y git cmake build-essential python3-pip portaudio19-dev ffmpeg

音声認識には、Whisper を使います。

git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
cmake -B build
cmake --build build -j4

音声認識用モデル(軽量版)を取得します

bash models/download-ggml-model.sh base

会話用AIは llama を使います。

cd ~
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
cmake -B build
cmake --build build -j4

llamaが使う日本語モデル(Qwen2.5-3B-Instruct GGUF(Q4_K_M))を取得します。
3Bなので、ラズパイでも大丈夫です。Hugging Face から取得します。

cd ~/llama.cpp
mkdir -p models
cd models
wget https://huggingface.co/bartowski/Qwen2.5-3B-Instruct-GGUF/resolve/main/Qwen2.5-3B-Instruct-Q4_K_M.gguf

ダウンロードできたら、以下で確認します。

ls -lh

実行します

cd ~/llama.cpp
./build/bin/llama-cli -m models/Qwen2.5-3B-Instruct-Q4_K_M.gguf -p "こんにちは。自己紹介してください。"

すると、以下が表示されます。

Loading model...  


▄▄ ▄▄
██ ██
██ ██  ▀▀█▄ ███▄███▄  ▀▀█▄    ▄████ ████▄ ████▄
██ ██ ▄█▀██ ██ ██ ██ ▄█▀██    ██    ██ ██ ██ ██
██ ██ ▀█▄██ ██ ██ ██ ▀█▄██ ██ ▀████ ████▀ ████▀
                                    ██    ██
                                    ▀▀    ▀▀

build      : b8855-81df3f7cf
model      : Qwen2.5-3B-Instruct-Q4_K_M.gguf
modalities : text

available commands:
  /exit or Ctrl+C     stop or exit
  /regen              regenerate the last response
  /clear              clear the chat history
  /read <file>        add a text file
  /glob <pattern>     add text files using globbing pattern


> こんにちは。自己紹介してください。

こんにちは。私は Alibaba Cloudによって作成された言語モデルQwenの名前です。私は Alibaba Cloudのチームによって訓練されました。私の主な目的は、あなたが知りたい情報を提供したり、質問に答えることで、あなたの助けになることです。何か質問があれば、どんなテーマについてでもお聞きください!

[ Prompt: 26.6 t/s | Generation: 5.4 t/s ]

> 

終わりに

わりと順調に進んだ感じです。次は、音声関係を進めていきます。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?