参考:
https://www.listera.top/ji-xu-zhe-teng-xia-chinese-llama-alpaca/
https://blog.csdn.net/qq_38238956/article/details/130113599
cmake Windows インストール リファレンス: https://blog.csdn.net/weixin_42357472/article/details/131314105
llama.cppのダウンロードとコンパイル
1. ダウンロード:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
2.コンパイル
mkdir build
cd build
cmake ..
cmake --build . --config Release
3. 試運転
cd bin\Release
./main -h
LLaMA-7B モデル テストを実行する
参考:
https://zhuanlan.zhihu.com/p/638427280
モデルのダウンロード:
https://huggingface.co/nyanko7/LLaMA-7B/tree/main
ダウンロード後、llama.cpp-master\models\ の下に LLamda\7B ディレクトリを作成します。
1. 7B モデルを ggml FP16 形式に変換します
。 .py ファイルは llama.cpp-master の下にあります
python3 convert.py models/7B/
2. llama.cpp-master\build\bin\Release にある quantize.exe でモデルを 4 ビットに量子化します (q4_0 メソッドを使用) 。量子化後のボリュームは約 13G ~ 4G 未満です。
.\quantize.exe D:\llm\llama.cpp-master\models\LLamda\7B\ggml-model-f16.bin D:\llm\llama.cpp-master\models\LLamda\7B\ggml-model-q4_0.bin q4_0
3.
llama.cpp-master\build\bin\Release にあるコマンド ラインで main.exe を対話的に実行します。
.\main.exe -m D:\llm\llama.cpp-master\models\LLamda\7B\ggml-model-q4_0.bin -n 128 --repeat_penalty 1.0 --color -i -r "User:" -f D:\llm\llama.cpp-master\prompts\chat-with-bob.txt
LLaMAの中国語サポートはあまり良くありませんが、意味は大まかに理解できますが、中国語サポートが必要な場合は他のモデルを選択する必要があるかもしれません
サードパーティが変換した ggml モデル、Llama-2 を直接ダウンロードすることもできます。
参考アドレス:
https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML
https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML
Windows の実行は多くのメモリを消費し、基本的に 32g がいっぱいで、生成速度も非常に遅いですが、13b llama-2 世代モデルは中国語に直接応答できます。
##运行
.\main.exe -m "C:\Users\loong\Downloads\llama-2-13b-chat.ggmlv3.q4_0.bin" -n 128 --repeat_penalty 1.0 --color -i -r "User:" -f D:\llm\llama.cpp-master\prompts\chat-with-bob.txt
Chinese-Llama-2 中国二世
モデルのダウンロード:
https://huggingface.co/soulteary/ Chinese-Llama-2-7b-ggml-q4
##运行
.\main.exe -m "C:\Users\loong\Downloads\Chinese-Llama-2-7b-ggml-q4.bin" -n 128 --repeat_penalty 1.0 --color -i -r "User:" -f D:\llm\llama.cpp-master\prompts\chat-with-bob.txt