手元のマシンでオープンソースのLLMをローカル実行するためのガイド。
ローカルAIがなぜ必要?
- プライバシー
- APIコストなし
- オフラインで動作
簡単セットアップ
pip install llama-cpp-python
wget https://huggingface.co/TheBloke/Mistral-7B-GGUF/resolve/main/mistral-7b-instruct.Q4_K_M.gguf
from llama_cpp import Llama
llm = Llama(model_path="./mistral-7b-instruct.Q4_K_M.gguf")
output = llm("Q: こんにちは!A:", max_tokens=64)
print(output["choices"][0]["text"])
