<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Inference Engine on Hypho - AI Agent 技术博客</title><link>https://blog.hypho.cn/tags/inference-engine/</link><description>Recent content in Inference Engine on Hypho - AI Agent 技术博客</description><image><title>Hypho - AI Agent 技术博客</title><url>https://blog.hypho.cn/papermod-cover.png</url><link>https://blog.hypho.cn/papermod-cover.png</link></image><generator>Hugo -- 0.148.2</generator><language>zh-cn</language><lastBuildDate>Sat, 18 Apr 2026 04:24:20 +0800</lastBuildDate><atom:link href="https://blog.hypho.cn/tags/inference-engine/index.xml" rel="self" type="application/rss+xml"/><item><title>本地 LLM 推理引擎之争：为什么 llama.cpp 远比 Ollama 值得选择</title><link>https://blog.hypho.cn/posts/local-llm-inference-engine-ollama-llama-cpp/</link><pubDate>Sat, 18 Apr 2026 04:24:20 +0800</pubDate><guid>https://blog.hypho.cn/posts/local-llm-inference-engine-ollama-llama-cpp/</guid><description>深入分析 Ollama 与 llama.cpp 的技术差异：Ollama 如何从首个便捷 llama.cpp 封装走向自研劣质后端、性能反不如原版，以及这场争议对本地大模型部署选型的启示。</description><content:encoded><![CDATA[<h2 id="真实案例引入一次生产事故揭开的盖子">真实案例引入：一次生产事故揭开的盖子</h2>
<p>2025 年中，某团队的 AI 编码助手在凌晨两点突然崩溃——他们在 Ollama 上跑的好好的 GPT-OSS 20B 模型突然报 GGML tensor type 不支持的错误。同一模型，在 llama.cpp 上运行完全正常。</p>
<p>这不是孤例。2025 年 GitHub 上关于 Ollama 的 issue 爆发式增长：<code>#3185</code>（许可证问题，400 天无回应）、结构化输出失效、视觉模型崩溃、多版本 GGML assertion crash。社区反复报告同一个事实：<strong>Ollama 自 2025 年中从 llama.cpp 后端切换到自研 ggml 分支后，引入了 llama.cpp 早已解决的 bug。</strong></p>
<p>这场崩溃的根源，要从 Ollama 的诞生说起。</p>
<h2 id="背景ollama-的起源与商业模式">背景：Ollama 的起源与商业模式</h2>
<p>Ollama 由 Jeffrey Morgan 和 Michael Chiang（曾主导 Docker GUI 工具 Kitematic）于 2021 年创办，入选 Y Combinator Winter 2021，2023 年正式公开。核心卖点是&quot;Docker for LLMs&quot;——一条命令下载运行模型。</p>
<p>然而，Ollama 的<strong>全部推理能力来自 llama.cpp</strong>：Georgi Gerganov 于 2023 年 3 月用一晚上 hack 出来的 C++ 推理引擎，让 LLaMA 模型首次能在消费级笔记本上运行。llama.cpp 如今 <a href="https://github.com/ggerganov/llama.cpp">GitHub 104,280 stars</a>，450+ 贡献者，是几乎所有 GGUF 工具的底层依赖。</p>
<p><strong>问题来了：</strong> 2023 年整年，Ollama 的 README、官网、营销材料中，<strong>从未提及 llama.cpp</strong>。他们甚至没有在二进制分发包中附带 llama.cpp 的 MIT 许可证声明——这在法律上是明确违规的。</p>
<h2 id="核心框架拆解llamacpp-vs-ollama-推理架构">核心框架拆解：llama.cpp vs Ollama 推理架构</h2>
<h3 id="1-后端演进路径">1. 后端演进路径</h3>
<pre tabindex="0"><code class="language-mermaid" data-lang="mermaid">graph TD
    A[llama.cpp / ggml 底层] --&gt; B[社区封装&lt;br/&gt;llama-cli, text-gen-webui]
    B --&gt; C[Ollama 2021-2025&lt;br/&gt;llama.cpp 封装层]
    C --&gt; D[Ollama 2025 中+&lt;br/&gt;自研 ggml 分支]
    
    style C fill:#4a90d9,color:#fff
    style D fill:#d94a4a,color:#fff
</code></pre><p><strong>Ollama 的核心问题：他们借用了 llama.cpp 的成果，却拒绝公开 credit。当他们终于&quot;独立&quot;时，做出来的是劣质版本。</strong></p>
<h3 id="2-性能数据对比">2. 性能数据对比</h3>
<p>社区多组基准测试一致显示相同结论：</p>
<table>
  <thead>
      <tr>
          <th>测试环境</th>
          <th>llama.cpp 吞吐量</th>
          <th>Ollama 吞吐量</th>
          <th>差距</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GPU 同硬件同模型</td>
          <td>161 tokens/s</td>
          <td>89 tokens/s</td>
          <td><strong>+81%</strong></td>
      </tr>
      <tr>
          <td>CPU</td>
          <td>基准（更快 30-50%）</td>
          <td>较慢</td>
          <td>—</td>
      </tr>
      <tr>
          <td>Qwen-3 Coder 32B</td>
          <td>基准</td>
          <td>低约 70%</td>
          <td><strong>-70%</strong></td>
      </tr>
  </tbody>
</table>
<p><strong>性能差距来源：</strong></p>
<ul>
<li>Ollama daemon 进程层增加不必要开销</li>
<li>GPU 卸载启发式算法粗糙</li>
<li>vendored 后端落后上游数月</li>
</ul>
<h3 id="3-模型命名误导">3. 模型命名误导</h3>
<p>2025 年 1 月 DeepSeek R1 发布后，Ollama 将 DeepSeek-R1-Distill-Qwen-32B（Qwen 微调版，行为与 671B R1 完全不同）在库和 CLI 中直接标注为 &ldquo;DeepSeek-R1&rdquo;。用户 <code>ollama run deepseek-r1</code> 实际跑的是一个小得多的蒸馏模型——DeepSeek 官方已正确标注 &ldquo;R1-Distill&rdquo; 前缀，Ollama 选择忽略。</p>
<h3 id="4-许可证合规问题">4. 许可证合规问题</h3>
<p>llama.cpp 采用 MIT 许可证，核心要求只有一条：<strong>附带版权声明</strong>。Ollama 最初违反了这一点。经社区长期推动后，最终只在 README 底部加了一行小字。Ollama 联创 Michael Chiang 对社区 PR 的回应耐人寻味：</p>
<blockquote>
<p>&ldquo;We will be transitioning to more systematically built engines.&rdquo;
（我们将过渡到更系统化构建的引擎。）</p></blockquote>
<h2 id="关键工程洞察">关键工程洞察</h2>
<h3 id="洞察-1选推理引擎优先看-upstream-活跃度">洞察 1：选推理引擎，优先看 upstream 活跃度</h3>
<p>llama.cpp 目前保持日更（最近 push: 2026-04-17），Ollama 的自研 ggml 分支则存在已知 bug 且长期不修复。如果你需要运行新模型（如 Qwen3、Gemma3、GLM-5），llama.cpp 是唯一靠谱的选择。</p>
<h3 id="洞察-2别被易用性欺骗易用性不等于可靠性">洞察 2：别被&quot;易用性&quot;欺骗——易用性不等于可靠性</h3>
<p>Ollama 的 <code>ollama run</code> 确实比手动编译 llama.cpp 容易，但生产环境的代价是：</p>
<ul>
<li>性能损失 30-80%</li>
<li>新模型支持滞后</li>
<li>上游 bug 移植后变成自己的 bug</li>
</ul>
<h3 id="洞察-3开源不等于免疫攘功看代码贡献历史">洞察 3：开源不等于免疫&quot;攘功&quot;——看代码贡献历史</h3>
<p>llama.cpp commits 绝大多数来自 Georgi Gerganov 本人，加上 450+ 贡献者。Ollama 的代码贡献者虽不少，但其核心推理能力实际上是 llama.cpp 贡献者的成果。引用开源项目不是软弱，是基本的工程诚信。</p>
<h2 id="替代方案推荐">替代方案推荐</h2>
<table>
  <thead>
      <tr>
          <th>工具</th>
          <th>适用场景</th>
          <th>特点</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>llama.cpp</strong> (原生)</td>
          <td>需要极致性能和新模型支持</td>
          <td>最高性能，最快模型支持，CLI 有学习曲线</td>
      </tr>
      <tr>
          <td><strong>text-generation-webui</strong> (oobabooga)</td>
          <td>需要 Web UI</td>
          <td>丰富的 UI 扩展，底层仍是 llama.cpp</td>
      </tr>
      <tr>
          <td><strong>vllm</strong></td>
          <td>需要 GPU 高吞吐服务</td>
          <td>PagedAttention，continuous batching</td>
      </tr>
      <tr>
          <td><strong>llama-cli</strong> (llama.cpp 内置)</td>
          <td>轻量级单文件推理</td>
          <td>零依赖，直接跑 GGUF</td>
      </tr>
  </tbody>
</table>
<h2 id="总结">总结</h2>
<p>Ollama 的故事是一个关于技术诚信和工程选型的反面教材。它以&quot;首个 easy llama.cpp wrapper&quot;起步，积累了数百万用户，却花了多年时间回避 credit 其真正的技术来源。当它最终试图&quot;独立&quot;时，产出的是一个性能更差、bug 更多的后端。</p>
<p>对于本地 LLM 推理，<strong>llama.cpp 仍然是王者</strong>——它是整个本地大模型运动的底层引擎，100,000+ stars，活跃开发，几乎所有主流工具都在其上构建。选择基于它的工具，而不是选择试图取代它却不成功的封装。</p>
<blockquote>
<p>引用来源：<a href="https://sleepingrobots.com/dreams/stop-using-ollama/">Friends Don&rsquo;t Let Friends Use Ollama - Sleeping Robots</a>，<a href="https://github.com/ggerganov/llama.cpp">llama.cpp GitHub</a>，<a href="https://github.com/ollama/ollama">Ollama GitHub</a></p></blockquote>
]]></content:encoded></item></channel></rss>