重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
llama-cpp by orchestra-research/ai-research-skills
npx skills add https://github.com/orchestra-research/ai-research-skills --skill llama-cpp使用纯 C/C++ 进行 LLM 推理,依赖极少,针对 CPU 和非 NVIDIA 硬件进行了优化。
在以下情况使用 llama.cpp:
在以下情况改用 TensorRT-LLM:
在以下情况改用 vLLM:
# macOS/Linux
brew install llama.cpp
# 或从源代码构建
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# 使用 Metal (Apple Silicon)
make LLAMA_METAL=1
# 使用 CUDA (NVIDIA)
make LLAMA_CUDA=1
# 使用 ROCm (AMD)
make LLAMA_HIP=1
# 从 HuggingFace 下载 (GGUF 格式)
huggingface-cli download \
TheBloke/Llama-2-7B-Chat-GGUF \
llama-2-7b-chat.Q4_K_M.gguf \
--local-dir models/
# 或从 HuggingFace 转换
python convert_hf_to_gguf.py models/llama-2-7b-chat/
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 简单对话
./llama-cli \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
-p "解释量子计算" \
-n 256 # 最大令牌数
# 交互式对话
./llama-cli \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
--interactive
# 启动 OpenAI 兼容服务器
./llama-server \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
--host 0.0.0.0 \
--port 8080 \
-ngl 32 # 将 32 层卸载到 GPU
# 客户端请求
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama-2-7b-chat",
"messages": [{"role": "user", "content": "你好!"}],
"temperature": 0.7,
"max_tokens": 100
}'
| 格式 | 比特数 | 大小 (7B) | 速度 | 质量 | 使用场景 |
|---|---|---|---|---|---|
| Q4_K_M | 4.5 | 4.1 GB | 快 | 好 | 推荐默认值 |
| Q4_K_S | 4.3 | 3.9 GB | 更快 | 较低 | 速度优先 |
| Q5_K_M | 5.5 | 4.8 GB | 中等 | 更好 | 质量优先 |
| Q6_K | 6.5 | 5.5 GB | 较慢 | 最佳 | 最高质量 |
| Q8_0 | 8.0 | 7.0 GB | 慢 | 优秀 | 最小退化 |
| Q2_K | 2.5 | 2.7 GB | 最快 | 差 | 仅用于测试 |
# 通用(平衡)
Q4_K_M # 4 比特,中等质量
# 最大速度(退化更多)
Q2_K 或 Q3_K_M
# 最高质量(较慢)
Q6_K 或 Q8_0
# 非常大的模型 (70B, 405B)
Q3_K_M 或 Q4_K_S # 降低比特数以适配内存
# 使用 Metal 构建
make LLAMA_METAL=1
# 使用 GPU 加速运行(自动)
./llama-cli -m model.gguf -ngl 999 # 卸载所有层
# 性能:M3 Max 40-60 令牌/秒 (Llama 2-7B Q4_K_M)
# 使用 CUDA 构建
make LLAMA_CUDA=1
# 将层卸载到 GPU
./llama-cli -m model.gguf -ngl 35 # 卸载 35/40 层
# 大型模型的 CPU+GPU 混合模式
./llama-cli -m llama-70b.Q4_K_M.gguf -ngl 20 # GPU:20 层,CPU:其余层
# 使用 ROCm 构建
make LLAMA_HIP=1
# 使用 AMD GPU 运行
./llama-cli -m model.gguf -ngl 999
# 从文件处理多个提示
cat prompts.txt | ./llama-cli \
-m model.gguf \
--batch-size 512 \
-n 100
# 使用语法的 JSON 输出
./llama-cli \
-m model.gguf \
-p "生成一个人物:" \
--grammar-file grammars/json.gbnf
# 仅输出有效的 JSON
# 增加上下文(默认 512)
./llama-cli \
-m model.gguf \
-c 4096 # 4K 上下文窗口
# 超长上下文(如果模型支持)
./llama-cli -m model.gguf -c 32768 # 32K 上下文
| CPU | 线程数 | 速度 | 成本 |
|---|---|---|---|
| Apple M3 Max | 16 | 50 tok/s | $0 (本地) |
| AMD Ryzen 9 7950X | 32 | 35 tok/s | $0.50/小时 |
| Intel i9-13900K | 32 | 30 tok/s | $0.40/小时 |
| AWS c7i.16xlarge | 64 | 40 tok/s | $2.88/小时 |
| GPU | 速度 | 对比 CPU | 成本 |
|---|---|---|---|
| NVIDIA RTX 4090 | 120 tok/s | 3-4× | $0 (本地) |
| NVIDIA A10 | 80 tok/s | 2-3× | $1.00/小时 |
| AMD MI250 | 70 tok/s | 2× | $2.00/小时 |
| Apple M3 Max (Metal) | 50 tok/s | ~相同 | $0 (本地) |
LLaMA 系列 :
Mistral 系列 :
其他 :
每周安装数
62
代码仓库
GitHub 星标数
5.6K
首次出现
2026年2月7日
安全审计
已安装于
codex53
cursor53
opencode53
gemini-cli52
claude-code51
github-copilot51
Pure C/C++ LLM inference with minimal dependencies, optimized for CPUs and non-NVIDIA hardware.
Use llama.cpp when:
Use TensorRT-LLM instead when:
Use vLLM instead when:
# macOS/Linux
brew install llama.cpp
# Or build from source
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# With Metal (Apple Silicon)
make LLAMA_METAL=1
# With CUDA (NVIDIA)
make LLAMA_CUDA=1
# With ROCm (AMD)
make LLAMA_HIP=1
# Download from HuggingFace (GGUF format)
huggingface-cli download \
TheBloke/Llama-2-7B-Chat-GGUF \
llama-2-7b-chat.Q4_K_M.gguf \
--local-dir models/
# Or convert from HuggingFace
python convert_hf_to_gguf.py models/llama-2-7b-chat/
# Simple chat
./llama-cli \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
-p "Explain quantum computing" \
-n 256 # Max tokens
# Interactive chat
./llama-cli \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
--interactive
# Start OpenAI-compatible server
./llama-server \
-m models/llama-2-7b-chat.Q4_K_M.gguf \
--host 0.0.0.0 \
--port 8080 \
-ngl 32 # Offload 32 layers to GPU
# Client request
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama-2-7b-chat",
"messages": [{"role": "user", "content": "Hello!"}],
"temperature": 0.7,
"max_tokens": 100
}'
| Format | Bits | Size (7B) | Speed | Quality | Use Case |
|---|---|---|---|---|---|
| Q4_K_M | 4.5 | 4.1 GB | Fast | Good | Recommended default |
| Q4_K_S | 4.3 | 3.9 GB | Faster | Lower | Speed critical |
| Q5_K_M | 5.5 | 4.8 GB | Medium | Better | Quality critical |
| Q6_K | 6.5 | 5.5 GB | Slower | Best | Maximum quality |
| Q8_0 | 8.0 |
# General use (balanced)
Q4_K_M # 4-bit, medium quality
# Maximum speed (more degradation)
Q2_K or Q3_K_M
# Maximum quality (slower)
Q6_K or Q8_0
# Very large models (70B, 405B)
Q3_K_M or Q4_K_S # Lower bits to fit in memory
# Build with Metal
make LLAMA_METAL=1
# Run with GPU acceleration (automatic)
./llama-cli -m model.gguf -ngl 999 # Offload all layers
# Performance: M3 Max 40-60 tokens/sec (Llama 2-7B Q4_K_M)
# Build with CUDA
make LLAMA_CUDA=1
# Offload layers to GPU
./llama-cli -m model.gguf -ngl 35 # Offload 35/40 layers
# Hybrid CPU+GPU for large models
./llama-cli -m llama-70b.Q4_K_M.gguf -ngl 20 # GPU: 20 layers, CPU: rest
# Build with ROCm
make LLAMA_HIP=1
# Run with AMD GPU
./llama-cli -m model.gguf -ngl 999
# Process multiple prompts from file
cat prompts.txt | ./llama-cli \
-m model.gguf \
--batch-size 512 \
-n 100
# JSON output with grammar
./llama-cli \
-m model.gguf \
-p "Generate a person: " \
--grammar-file grammars/json.gbnf
# Outputs valid JSON only
# Increase context (default 512)
./llama-cli \
-m model.gguf \
-c 4096 # 4K context window
# Very long context (if model supports)
./llama-cli -m model.gguf -c 32768 # 32K context
| CPU | Threads | Speed | Cost |
|---|---|---|---|
| Apple M3 Max | 16 | 50 tok/s | $0 (local) |
| AMD Ryzen 9 7950X | 32 | 35 tok/s | $0.50/hour |
| Intel i9-13900K | 32 | 30 tok/s | $0.40/hour |
| AWS c7i.16xlarge | 64 | 40 tok/s | $2.88/hour |
| GPU | Speed | vs CPU | Cost |
|---|---|---|---|
| NVIDIA RTX 4090 | 120 tok/s | 3-4× | $0 (local) |
| NVIDIA A10 | 80 tok/s | 2-3× | $1.00/hour |
| AMD MI250 | 70 tok/s | 2× | $2.00/hour |
| Apple M3 Max (Metal) | 50 tok/s | ~Same | $0 (local) |
LLaMA family :
Mistral family :
Other :
Find models : https://huggingface.co/models?library=gguf
Weekly Installs
62
Repository
GitHub Stars
5.6K
First Seen
Feb 7, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
codex53
cursor53
opencode53
gemini-cli52
claude-code51
github-copilot51
超能力技能使用指南:AI助手技能调用优先级与工作流程详解
56,600 周安装
Twitter 搜索与分析工具:使用高级语法获取1000条推文并生成专业洞察报告
103 周安装
数据探索可视化工具 - 自动化EDA、医疗数据分析与专业报告生成
104 周安装
YouTube视频规划工具 - 自动生成优化标题、缩略图和开场钩子,提升点击率和留存率
103 周安装
Qodo PR Resolver:AI代码评审问题批量修复工具,支持GitHub/GitLab/Bitbucket/Azure DevOps
106 周安装
DOCX文档处理与自动化技能:专业格式创建、视觉审阅与Python编辑指南
103 周安装
nanoGPT极简GPT训练教程:从莎士比亚到GPT-2复现,快速上手PyTorch深度学习
106 周安装
| 7.0 GB |
| Slow |
| Excellent |
| Minimal degradation |
| Q2_K | 2.5 | 2.7 GB | Fastest | Poor | Testing only |