llama.cpp + Ertas
从 Ertas 导出 GGUF 模型,使用 llama.cpp 在 CPU、GPU 或 Apple Silicon 上运行高性能推理,无需沉重的框架依赖。
Overview
llama.cpp 是纯 C/C++ 实现的高效 LLM 推理参考实现,支持从消费级笔记本电脑到多 GPU 服务器的各种硬件。通过消除对 Python 运行时和沉重 ML 框架的需求,llama.cpp 提供了本地推理中最快的 token/秒速率之一。它支持高级量化方案(从 2 位到 8 位)、KV 缓存优化、推测解码和批量推理,使其成为许多生产级本地 AI 部署的骨干。
对于使用 Ertas 微调领域特定模型的团队,llama.cpp 提供了将训练权重转化为生产就绪推理端点的性能层。无论您是将模型嵌入桌面应用、在边缘设备上运行推理,还是构建高吞吐量 API 服务器,llama.cpp 都能提供托管运行时无法匹配的对内存使用、线程和 GPU 卸载的精细控制。
How Ertas Integrates
在 Ertas Studio 中微调后,您可以直接以 llama.cpp 使用的 GGUF 格式下载模型。下载时,您可以从十多种量化选项中选择,Ertas 会显示针对您验证集的困惑度基准测试,帮助您在模型大小和输出质量之间选择正确的权衡。下载的 GGUF 文件包含嵌入的聊天模板、分词器配置和元数据,因此 llama.cpp 可以在无需额外配置文件的情况下加载和提供模型服务。
Ertas Studio 还会在您下载时提供推荐的 llama-server 启动参数,基于您选择的模型大小和量化级别。这些建议涵盖上下文大小、批量大小和层卸载策略,消除了性能调优的猜测工作,帮助您的微调模型在特定硬件上以最佳效率运行。
Getting Started
- 1
在 Ertas Studio 中完成微调
在 Ertas Studio 中使用 LoRA 或全参数方法训练模型。在导出前针对测试集验证以确认质量。
- 2
选择量化策略
根据您的部署约束选择 GGUF 量化级别。Ertas 显示每个选项的估计文件大小和困惑度影响。
- 3
下载 GGUF 模型
从 Ertas Studio 以 GGUF 格式下载微调模型,包含嵌入的分词器、聊天模板和元数据。文件是自包含的,可直接用于 llama.cpp。
- 4
查看推荐的服务器设置
Ertas Studio 在您下载时显示推荐的 llama-server 启动参数,包括上下文大小、GPU 层卸载和线程数。
- 5
启动 llama-server
使用导出的模型启动 llama.cpp HTTP 服务器。服务器提供兼容 OpenAI 的 API 端点,用于聊天补全和嵌入。
- 6
基准测试并迭代
运行内置基准测试套件,衡量每秒 token 数、首个 token 时间和内存使用。将结果反馈到 Ertas 用于下一次训练迭代。
# After downloading the Q4_K_M GGUF file from Ertas Studio,
# launch llama-server with the recommended settings
llama-server \
--model ./models/my-model.gguf \
--ctx-size 4096 \
--n-gpu-layers 35 \
--threads 8 \
--port 8080
# Test the endpoint
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello"}]}'Benefits
- 推理无需 Python 运行时或 ML 框架依赖
- 在 CPU、GPU 和 Apple Silicon 上实现业界领先的推理 速度
- 十多种量化选项并提供困惑度影响预览
- 自包含的 GGUF 文件,内嵌分词器和聊天模板
- 在 GGUF 下载旁提供推荐的服务器设置
- 适用于边缘部署、桌面应用和高吞吐量服务器
Related Resources
Fine-Tuning
GGUF
Inference
LoRA
Getting Started with Ertas: Fine-Tune and Deploy Custom AI Models
Privacy-Conscious AI Development: Fine-Tune in the Cloud, Run on Your Terms
Running AI Models Locally: The Complete Guide to Local LLM Inference
Fine-Tuning Llama 3: A Practical Guide for Your Use Case
Self-Hosted AI for Indie Apps: Replace GPT-4 with Your Own Model
Cheapest AI API Pricing in 2026: Indie Dev Guide
Hugging Face
KoboldCpp
LM Studio
Ollama
vLLM
Ertas for Healthcare
Ertas for SaaS Product Teams
Ertas for Customer Support
Ertas for E-Commerce
Ertas for Indie Developers & Vibe-Coded Apps
Ship AI that runs on your users' devices.
Free plan with 30 credits/mo, no card required. Paid plans from $10/mo USD.