本文档介绍如何在Firefly ITX-3588J上使用llama.cpp进行大语言模型推理。
Firefly 的 ITX-3588J 是一款基于瑞芯微 RK3588 芯片的高性能开发板,具有强大的计算能力和丰富的接口资源,以下是其详细介绍:
基本参数
llama.cpp 是一个高性能的开源大语言模型推理框架,由开发者 Georgi Gerganov 基于 Meta 的 LLaMA 模型开发,使用纯 C/C++ 实现,旨在让大语言模型能够在各种硬件平台上高效运行,特别是消费级设备和边缘设备。
主要特点:
git clone https://github.com/ggml-org/llama.cpp.git
sudo apt install cmake gcc g++
cmake -B build -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8-a
cmake --build build --config Release -j8
这里以 phi-2 为例子。
请使用 git LFS 克隆仓库
git lfs install
git clone git clone https://huggingface.co/TheBloke/phi-2-GGUF
选择采用Q4_0
方法量化的模型版本:phi-2.Q4_0.gguf
。
(base) firefly@firefly:~/llama.cpp$ ./build/bin/llama-bench -m ~/models/phi-2.Q4_0.gguf -t 4
| model | size | params | backend | threads | test | t/s |
| ------------------------------ | ---------: | ---------: | ---------- | ------: | --------------: | -------------------: |
| phi2 3B Q4_0 | 1.49 GiB | 2.78 B | CPU | 4 | pp512 | 6.08 ± 0.00 |
| phi2 3B Q4_0 | 1.49 GiB | 2.78 B | CPU | 4 | tg128 | 5.56 ± 0.00 |