{"id":53814,"date":"2025-02-16T10:05:57","date_gmt":"2025-02-16T02:05:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53814\/"},"modified":"2025-02-16T10:05:57","modified_gmt":"2025-02-16T02:05:57","slug":"vllm-vs-ollama","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53814\/","title":{"rendered":"VLLM vs. Ollama"},"content":{"rendered":"<p>\u5927\u578b\u8bed\u8a00\u6a21\u578b (LLM) \u7684\u5174\u8d77\u6539\u53d8\u4e86 AI \u9a71\u52a8\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b9e\u73b0\u4e86\u4ece\u804a\u5929\u673a\u5668\u4eba\u5230\u81ea\u52a8\u4ee3\u7801\u751f\u6210\u7684\u4e00\u5207\u3002\u7136\u800c\uff0c\u9ad8\u6548\u8fd0\u884c\u8fd9\u4e9b\u6a21\u578b\u4ecd\u7136\u662f\u4e00\u4e2a\u6311\u6218\uff0c\u56e0\u4e3a\u5b83\u4eec\u901a\u5e38\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5f00\u53d1\u4eba\u5458\u4f9d\u8d56\u4e8e\u4f18\u5316\u7684\u63a8\u7406\u6846\u67b6\uff0c\u65e8\u5728\u6700\u5927\u9650\u5ea6\u5730\u63d0\u9ad8\u901f\u5ea6\u3001\u6700\u5927\u9650\u5ea6\u5730\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u91cf\u5e76\u65e0\u7f1d\u96c6\u6210\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u4e2a\u9886\u57df\u7684\u4e24\u4e2a\u6770\u51fa\u89e3\u51b3\u65b9\u6848\u662f VLLM \u548c Ollama\u2014\u2014\u6bcf\u4e2a\u89e3\u51b3\u65b9\u6848\u90fd\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002<\/p>\n<ul>\n<li>VLLM \u662f\u4e00\u4e2a\u4f18\u5316\u7684\u63a8\u7406\u5f15\u64ce\uff0c\u53ef\u63d0\u4f9b\u9ad8\u901f\u4ee4\u724c\u751f\u6210\u548c\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\uff0c\u4f7f\u5176\u6210\u4e3a\u5927\u578b AI \u5e94\u7528\u7a0b\u5e8f\u7684\u7406\u60f3\u9009\u62e9\u3002<\/li>\n<li>Ollama \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4e14\u7528\u6237\u53cb\u597d\u7684\u6846\u67b6\uff0c\u53ef\u7b80\u5316\u5728\u672c\u5730\u673a\u5668\u4e0a\u8fd0\u884c\u5f00\u6e90 LLM \u7684\u8fc7\u7a0b\u3002<\/li>\n<\/ul>\n<p>\u90a3\u4e48\uff0c\u4f60\u5e94\u8be5\u9009\u62e9\u54ea\u4e00\u4e2a\u5462\uff1f\u5728\u8fd9\u6b21\u5168\u9762\u7684\u6bd4\u8f83\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u89e3\u5b83\u4eec\u7684\u6027\u80fd\u3001\u6613\u7528\u6027\u3001\u7528\u4f8b\u3001\u66ff\u4ee3\u65b9\u6848\u548c\u5206\u6b65\u8bbe\u7f6e\uff0c\u4ee5\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u51b3\u5b9a\u3002<\/p>\n<h2>1\u3001VLLM \u548c Ollama\u6982\u8ff0<\/h2>\n<p>\u5728\u6df1\u5165\u4e86\u89e3\u7ec6\u8282\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5148\u4e86\u89e3\u8fd9\u4e24\u4e2a\u6846\u67b6\u7684\u6838\u5fc3\u76ee\u7684\u3002<\/p>\n<p>VLLM\uff08\u8d85\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u662f\u7531 SKYPILOT \u6784\u5efa\u7684\u63a8\u7406\u4f18\u5316\u6846\u67b6\uff0c\u65e8\u5728\u63d0\u9ad8\u5728 GPU \u4e0a\u8fd0\u884c\u7684 LLM \u7684\u6548\u7387\u3002\u5b83\u4e13\u6ce8\u4e8e\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u8fde\u7eed\u6279\u5904\u7406\u5feb\u901f\u751f\u6210\u4ee4\u724c\u3002<\/li>\n<li>\u901a\u8fc7 PagedAttention \u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u4f7f\u7528\uff0c\u5141\u8bb8\u5904\u7406\u5927\u578b\u4e0a\u4e0b\u6587\u7a97\u53e3\u800c\u4e0d\u4f1a\u6d88\u8017\u8fc7\u591a\u7684 GPU \u5185\u5b58\u3002<\/li>\n<li>\u65e0\u7f1d\u96c6\u6210\u5230 AI \u5de5\u4f5c\u6d41\u4e2d\uff0c\u517c\u5bb9 PyTorch \u548c TensorFlow \u7b49\u4e3b\u8981\u6df1\u5ea6\u5b66\u4e60\u5e73\u53f0\u3002<\/li>\n<\/ul>\n<p>VLLM \u88ab\u9700\u8981\u5927\u89c4\u6a21\u9ad8\u6027\u80fd\u63a8\u7406\u7684 AI \u7814\u7a76\u4eba\u5458\u548c\u4f01\u4e1a\u5e7f\u6cdb\u4f7f\u7528\u3002<\/p>\n<p>Ollama \u662f\u4e00\u4e2a\u672c\u5730 LLM \u8fd0\u884c\u65f6\uff0c\u53ef\u7b80\u5316\u90e8\u7f72\u548c\u4f7f\u7528\u5f00\u6e90 AI \u6a21\u578b\u3002\u5b83\u63d0\u4f9b\uff1a<\/p>\n<ul>\n<li>\u9884\u6253\u5305\u6a21\u578b\uff0c\u4f8b\u5982 LLaMA\u3001Mistral \u548c Falcon\u3002<\/li>\n<li>\u4f18\u5316\u7684 CPU \u548c GPU \u63a8\u7406\uff0c\u7528\u4e8e\u5728\u65e5\u5e38\u786c\u4ef6\u4e0a\u8fd0\u884c AI \u6a21\u578b\u3002<\/li>\n<li>\u4e00\u4e2a\u7b80\u5355\u7684 API \u548c CLI\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u4ee5\u6700\u5c11\u7684\u914d\u7f6e\u542f\u52a8 LLM\u3002<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u5e0c\u671b\u5728\u4e2a\u4eba\u673a\u5668\u4e0a\u8bd5\u9a8c AI \u6a21\u578b\u7684\u5f00\u53d1\u4eba\u5458\u548c AI \u7231\u597d\u8005\u6765\u8bf4\uff0cOllama \u662f\u4e00\u4e2a\u7edd\u4f73\u7684\u9009\u62e9\u3002<\/p>\n<h2>2\u3001\u6027\u80fd\uff1a\u901f\u5ea6\u3001\u5185\u5b58\u548c\u53ef\u6269\u5c55\u6027<\/h2>\n<p>\u6027\u80fd\u662f\u9009\u62e9\u63a8\u7406\u6846\u67b6\u7684\u5173\u952e\u56e0\u7d20\u3002\u8ba9\u6211\u4eec\u5728\u901f\u5ea6\u3001\u5185\u5b58\u6548\u7387\u548c\u53ef\u6269\u5c55\u6027\u65b9\u9762\u6bd4\u8f83\u4e00\u4e0b VLLM \u548c Ollama\u3002<\/p>\n<p>\u5173\u952e\u6027\u80fd\u6307\u6807\uff1a<\/p>\n<p>VLLM \u5229\u7528 PagedAttention \u6765\u6700\u5927\u5316\u63a8\u7406\u901f\u5ea6\u5e76\u6709\u6548\u5904\u7406\u5927\u578b\u4e0a\u4e0b\u6587\u7a97\u53e3\u3002\u8fd9\u4f7f\u5f97\u5b83\u6210\u4e3a\u804a\u5929\u673a\u5668\u4eba\u3001\u641c\u7d22\u5f15\u64ce\u548c AI \u5199\u4f5c\u52a9\u624b\u7b49\u9ad8\u6027\u80fd AI \u5e94\u7528\u7a0b\u5e8f\u7684\u9996\u9009\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>Ollama \u63d0\u4f9b\u4e86\u4e0d\u9519\u7684\u901f\u5ea6\uff0c\u4f46\u53d7\u5230\u672c\u5730\u786c\u4ef6\u7684\u9650\u5236\u3002\u5b83\u975e\u5e38\u9002\u5408\u5728 MacBook\u3001PC \u548c\u8fb9\u7f18\u8bbe\u5907\u4e0a\u8fd0\u884c\u8f83\u5c0f\u7684\u6a21\u578b\uff0c\u4f46\u5728\u5904\u7406\u975e\u5e38\u5927\u7684\u6a21\u578b\u65f6\u4f1a\u9047\u5230\u56f0\u96be\u3002<\/p>\n<blockquote><p>\n  \u7ed3\u8bba\uff1aOllama \u66f4\u9002\u5408\u521d\u5b66\u8005\uff0c\u800c VLLM \u662f\u9700\u8981\u6df1\u5ea6\u5b9a\u5236\u7684\u5f00\u53d1\u4eba\u5458\u7684\u9009\u62e9\u3002\n<\/p><\/blockquote>\n<h2>3\u3001\u7528\u4f8b\uff1a\u4f55\u65f6\u4f7f\u7528 VLLM \u800c\u4e0d\u662f Ollama\uff1f<\/h2>\n<p>VLLM \u7684\u6700\u4f73\u7528\u4f8b<\/p>\n<ul>\n<li>\u4f01\u4e1a AI \u5e94\u7528\u7a0b\u5e8f\uff08\u4f8b\u5982\u5ba2\u6237\u670d\u52a1\u673a\u5668\u4eba\u3001AI \u9a71\u52a8\u7684\u641c\u7d22\u5f15\u64ce\uff09<\/li>\n<li>\u5728\u9ad8\u7aef GPU\uff08A100\u3001H100\u3001RTX 4090 \u7b49\uff09\u4e0a\u90e8\u7f72\u57fa\u4e8e\u4e91\u7684 LLM<\/li>\n<li>\u5fae\u8c03\u548c\u8fd0\u884c\u81ea\u5b9a\u4e49\u6a21\u578b<\/li>\n<li>\u9700\u8981\u5927\u578b\u4e0a\u4e0b\u6587\u7a97\u53e3\u7684\u5e94\u7528\u7a0b\u5e8f<\/li>\n<\/ul>\n<p>\u4e0d\u9002\u5408\uff1a\u4e2a\u4eba\u7b14\u8bb0\u672c\u7535\u8111\u3001\u4f11\u95f2 AI \u5b9e\u9a8c<\/p>\n<p>Ollama \u7684\u6700\u4f73\u7528\u4f8b<\/p>\n<ul>\n<li>\u5728\u6ca1\u6709\u4e91\u8d44\u6e90\u7684\u60c5\u51b5\u4e0b\u5728 Mac\u3001Windows \u6216 Linux \u4e0a\u8fd0\u884c LLM<\/li>\n<li>\u65e0\u9700\u590d\u6742\u8bbe\u7f6e\u5373\u53ef\u5728\u672c\u5730\u8bd5\u9a8c\u6a21\u578b<\/li>\n<li>\u60f3\u8981\u4f7f\u7528\u7b80\u5355 API \u5c06 AI \u96c6\u6210\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u5f00\u53d1\u4eba\u5458<\/li>\n<li>\u8fb9\u7f18\u8ba1\u7b97\u5e94\u7528\u7a0b\u5e8f<\/li>\n<\/ul>\n<p>\u4e0d\u9002\u5408\uff1a\u5927\u89c4\u6a21 AI \u90e8\u7f72\u3001\u7e41\u91cd\u7684 GPU \u5de5\u4f5c\u8d1f\u8f7d<\/p>\n<blockquote><p>\n  \u7ed3\u8bba\uff1aVLLM \u9002\u7528\u4e8e AI \u5de5\u7a0b\u5e08\uff0c\u800c Ollama \u9002\u7528\u4e8e\u5f00\u53d1\u4eba\u5458\u548c\u4e1a\u4f59\u7231\u597d\u8005\u3002\n<\/p><\/blockquote>\n<h2>4\u3001\u5feb\u901f\u4e0a\u624b<\/h2>\n<p>VLLM\u8981\u9996\u5148\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a<\/p>\n<pre><code>pip install vllm<\/code><\/pre>\n<p>\u5728 LLaMA \u6a21\u578b\u4e0a\u8fd0\u884c\u63a8\u7406\uff1a<\/p>\n<pre><code>from vllm import LLM\nllm = LLM(model=\"meta-llama\/Llama-2-7b\")\noutput = llm.generate(\"What is VLLM?\")<\/code><\/pre>\n<p>Ollama\u8981\u5b89\u88c5 Ollama (Mac\/Linux)\uff1a<\/p>\n<pre><code>brew install ollama<\/code><\/pre>\n<p>\u7136\u540e\u4e0b\u8f7d\u5e76\u8fd0\u884c\u6a21\u578b\uff1a<\/p>\n<pre><code>ollama run mistral<\/code><\/pre>\n<p>\u8c03\u7528 Ollama \u7684 API\uff1a<\/p>\n<pre><code>import requests\nresponse = requests.post(\"http:\/\/localhost:11434\/api\/generate\", json={\"model\": \"mistral\", \"prompt\": \"Tell me a joke\"})\nprint(response.json())<\/code><\/pre>\n<blockquote><p>\n  \u7ed3\u8bba\uff1aOllama \u66f4\u6613\u4e8e\u5b89\u88c5\uff0c\u800cVLLM \u63d0\u4f9b\u66f4\u591a\u5b9a\u5236\u3002\n<\/p><\/blockquote>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u578b\u8bed\u8a00\u6a21\u578b (LLM) \u7684\u5174\u8d77\u6539\u53d8\u4e86 AI \u9a71\u52a8\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b9e\u73b0\u4e86\u4ece\u804a\u5929\u673a\u5668\u4eba\u5230\u81ea\u52a8\u4ee3\u7801\u751f\u6210\u7684\u4e00\u5207\u3002\u7136\u800c\uff0c\u9ad8\u6548\u8fd0\u884c\u8fd9\u4e9b\u6a21\u578b\u4ecd\u7136\u662f\u4e00\u4e2a\u6311\u6218\uff0c\u56e0\u4e3a\u5b83\u4eec\u901a\u5e38\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u3002 \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5f00\u53d1\u4eba\u5458\u4f9d\u8d56\u4e8e\u4f18\u5316\u7684\u63a8\u7406\u6846\u67b6\uff0c\u65e8\u5728\u6700\u5927\u9650\u5ea6\u5730\u63d0\u9ad8\u901f\u5ea6\u3001\u6700\u5927\u9650\u5ea6\u5730\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u91cf\u5e76\u65e0\u7f1d\u96c6\u6210\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u4e2a\u9886\u57df\u7684\u4e24\u4e2a\u6770\u51fa\u89e3\u51b3\u65b9\u6848\u662f VLLM \u548c Ollama\u2014\u2014\u6bcf\u4e2a\u89e3\u51b3\u65b9\u6848\u90fd\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002 VLLM \u662f\u4e00\u4e2a\u4f18\u5316\u7684\u63a8\u7406\u5f15\u64ce\uff0c\u53ef\u63d0\u4f9b\u9ad8\u901f\u4ee4\u724c\u751f\u6210\u548c\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\uff0c\u4f7f\u5176\u6210\u4e3a\u5927\u578b AI \u5e94\u7528\u7a0b\u5e8f\u7684\u7406\u60f3\u9009\u62e9\u3002 Ollama \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4e14\u7528\u6237\u53cb\u597d\u7684\u6846\u67b6\uff0c\u53ef\u7b80\u5316\u5728\u672c\u5730\u673a\u5668\u4e0a\u8fd0\u884c\u5f00\u6e90 LLM \u7684\u8fc7\u7a0b\u3002 \u90a3\u4e48\uff0c\u4f60\u5e94\u8be5\u9009\u62e9\u54ea\u4e00\u4e2a\u5462\uff1f\u5728\u8fd9\u6b21\u5168\u9762\u7684\u6bd4\u8f83\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u89e3\u5b83\u4eec\u7684\u6027\u80fd\u3001\u6613\u7528\u6027\u3001\u7528\u4f8b\u3001\u66ff\u4ee3\u65b9\u6848\u548c\u5206\u6b65\u8bbe\u7f6e\uff0c\u4ee5\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u51b3\u5b9a\u3002 1\u3001VLLM \u548c Ollama\u6982\u8ff0 \u5728\u6df1\u5165\u4e86\u89e3\u7ec6\u8282\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5148\u4e86\u89e3\u8fd9\u4e24\u4e2a\u6846\u67b6\u7684\u6838\u5fc3\u76ee\u7684\u3002 VLLM\uff08\u8d85\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u662f\u7531 SKYPILOT \u6784\u5efa\u7684\u63a8\u7406\u4f18\u5316\u6846\u67b6\uff0c\u65e8\u5728\u63d0\u9ad8\u5728 GPU \u4e0a\u8fd0\u884c\u7684 LLM \u7684\u6548\u7387\u3002\u5b83\u4e13\u6ce8\u4e8e\uff1a \u4f7f\u7528\u8fde\u7eed\u6279\u5904\u7406\u5feb\u901f\u751f\u6210\u4ee4\u724c\u3002 \u901a\u8fc7 PagedAttention \u5b9e\u73b0\u9ad8\u6548\u7684\u5185\u5b58\u4f7f\u7528\uff0c\u5141\u8bb8\u5904\u7406\u5927\u578b\u4e0a\u4e0b\u6587\u7a97\u53e3\u800c\u4e0d\u4f1a\u6d88\u8017\u8fc7\u591a\u7684 GPU \u5185\u5b58\u3002 \u65e0\u7f1d\u96c6\u6210\u5230 AI \u5de5\u4f5c\u6d41\u4e2d\uff0c\u517c\u5bb9 PyTorch \u548c TensorFlow \u7b49\u4e3b\u8981\u6df1\u5ea6\u5b66\u4e60\u5e73\u53f0\u3002 VLLM \u88ab\u9700\u8981\u5927\u89c4\u6a21\u9ad8\u6027\u80fd\u63a8\u7406\u7684 AI \u7814\u7a76\u4eba\u5458\u548c\u4f01\u4e1a\u5e7f\u6cdb\u4f7f\u7528\u3002 Ollama \u662f\u4e00\u4e2a\u672c\u5730 LLM \u8fd0\u884c\u65f6\uff0c\u53ef\u7b80\u5316\u90e8\u7f72\u548c\u4f7f\u7528\u5f00\u6e90 AI \u6a21\u578b\u3002\u5b83\u63d0\u4f9b\uff1a \u9884\u6253\u5305\u6a21\u578b\uff0c\u4f8b\u5982 LLaMA\u3001Mistral \u548c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-53814","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53814"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53814\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}