
编译llamp.cpp项目,在Window环境下跑对话模型 以通义千问模型为例 Step0 工具软件、模型文件的下载和安装 下载mingw-w64编译器和和配置环境变量配置 下载地址 hub.gitmirror.com/https://git… 环境变量Path里加入编译器的bin目录,然后重启电脑 下载git并安装 下载地址 mirrors.tuna.tsinghua.edu.cn/github-rele… 设置好PATH变量并且安装好git以后重启电脑 打开终端 键入git --version确保git安装成功 bash 复制代码 git --version 此时正常情况下命令行输出版本号 例如 git version 2.38.1.windows.1 配置git bash 复制代码 git config --global user.name 你的用户名 git config --global user.email 你的邮箱 键入cmake --version确保编译器目录设置成功 bash 复制代码 cmake --version 此时正常情况下命令行输出版本号 例如 cmake version 3.27.8 CMake suite maintained and supported by Kitware (kitware.com/cmake). Step1 git获取llama源码 git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp Step2 cmake编译源码 mkdir build cd build cmake .. cmake --build . --config Release Step3 进入build目录查看编译结果(build/bin/Release) 从源码目录【llama.cpp】文件夹中拷贝【prompts】文件夹到 【build/bin/Release/】 下 Step4. 下载通义千问模型
访问ai快站 aifasthub.com/ Step5. 命令行启动大模型 例如 ./main -m models/qwen1.5-0.5b-chat-q8_0.gguf -n 4096 --color -i -cml -f prompts/chat-with-qwen.txt models/qwen1.5-0.5b-chat-q8_0.gguf 是通义千问模型的路径 为了方便起见,编写一个启动脚本 #!/bin/bash options=( "qwen1.5-0.5b-chat-q8_0.gguf" "qwen1.5-1_8b-chat-q8_0.gguf" "qwen1.5-4b-chat-q8_0.gguf" "qwen1.5-7b-chat-q5_k_m.gguf" "qwen1.5-14b-chat-q5_k_m.gguf" ) if [ $# -gt 0 ] && [ $1 -gt 0 ] && [ $1 -lt 6 ] then index=[ $1-1 ] else index=0 fi selectItem=${options[$index]} echo "【$selectItem】" /d/develop/llama/main -m /d/aimodels/$selectItem -n 4096 --color -i -cml -f /d/develop/llama/prompts/chat-with-qwen.txt fi 根据个人电脑CPU性能来选择相应的模型
同步链接:https://juejin.cn/post/7332652230711509055