juechafun/Untitled 5.md

133 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
#领域/未知
#复盘/0 #临时/备忘 #状态/待处理
20260311-备忘-主题名-文件内容
## 一句话描述
[________]
---
```bash
# 新建并进入项目文件夹
mkdir LLM-KnowledgeBase && cd LLM-KnowledgeBase
# 克隆llama.cpp仓库
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# 安装依赖
pip install -r requirements.txt
# 编译Windows自动用Visual Studio编译等待1-2分钟
make
```
```
apt update && apt install build-essential
```
#### 1. 先安装 CMake如果未安装
在你的 Debian/Ubuntu 环境下执行:
bash
运行
```
apt update && apt install cmake
```
#### 2. 标准 CMake 构建流程
`llama.cpp` 目录下,按顺序执行以下命令:
bash
运行
```
# 1. 创建并进入构建目录
mkdir -p build && cd build
# 2. 生成构建文件(启用所有可用功能)
cmake .. -DLLAMA_ALL_WARNINGS=ON -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=ON
# 3. 编译(-j 后面跟 CPU 核心数,比如 -j4 用4核加速
make -j4
```
### 🔍 问题原因
从截图可以看到,`llama.cpp` 新版本里,**主程序文件名已经从 `main` 改成了 `llama-simple``llama-cli`**,所以执行 `./main` 会提示 `no such file or directory`
---
### 🛠️ 解决方案:用正确的可执行文件名
#### 方案 1使用 `llama-simple`(推荐,轻量问答)
bash
运行
```
./llama-simple -m ../../models/llama-3-8b-instruct-q4_0.gguf -c 2048 --color -i -p "
【参考文档】
这里放入你的本地文档内容
【用户问题】
这里放入你的具体问题
【回答要求】
仅基于参考文档回答,不使用外部知识。
"
```
#### 方案 2使用 `llama-cli`(功能更全)
bash
运行
```
./llama-cli -m ../../models/llama-3-8b-instruct-q4_0.gguf -c 2048 --color -i -p "你的提示词"
```
#### 方案 3使用 `llama-simple-chat`(对话模式更友好)
bash
运行
```
./llama-simple-chat -m ../../models/llama-3-8b-instruct-q4_0.gguf -c 2048
```
这个命令会直接进入交互式对话模式,不需要 `-p` 参数,输入问题即可。
---
### 💡 关键说明
- 新版本 `llama.cpp` 对工具做了重命名,`main` 被拆分成了更细分的工具:
- `llama-simple`:基础问答
- `llama-cli`:完整命令行接口
- `llama-simple-chat`:对话模式
- 所有工具的核心参数(`-m``-c``--color` 等)用法和之前完全一致,只是文件名变了。
现在用 `./llama-simple``./llama-cli` 就能正常运行模型了!
需要我帮你把之前的 Python 脚本也更新成新的可执行文件名吗?这样就能无缝适配新版本。