开源项目Ollama让你的电脑也可以运行大模型

从OPEN AI推出大模型已经过去一年多了,想必大家已经感受到了AI对我们的影响。大型模型极具用途,其提升的准确性和处理更复杂任务的能力都令人赞叹。然而,本地运行这些模型却一直是一项艰巨的任务。运行这些模型需要大量的计算资源,而且数据存储需求往往超过了一般个人设备所能提供的。

此外,设置、配置和维护这些模型的过程可能复杂且耗时。同样,解决兼容性问题,排错和调试也会让用户在利用这些模型进行他们的研究或项目时望而却步。 虽然很早就有了开源大模型,我也一直跃跃欲试,但是苦于没有英伟达的显卡,所以一直没能本地运行。

但现在,有了一个解决方案 - 一项名为Ollama的开源项目。Ollama简化了实现大型模型的过程。借助Ollama,曾经令人畏惧的本地运行这些模型的任务变得轻而易举。它精简了整个过程,消除了与这些大型模型相关的设置和维护的复杂性。关键是不需要显卡,只使用CPU就可以运行。因此,有了Ollama,无论用户的技术栈或资源如何,大型模型的力量现在都已触手可及。

获取Ollama

Ollama下载地址,推荐第一个,一般都能下载。 ollama.com/download 如果你像研究源码,到下面的地址,部分人无法访问。 github.com/ollama/olla...

安装使用

下载window版安装后运行就可以打开命令行。

输入以下命令

arduino 复制代码
ollama run llama2

后就开始下载llama2模型,3.8G。 下载完成后就自动运行大模型了,你可以直接在命令行和它对话。

我的使用记录如下。

llama2模型使用日志

less 复制代码
Welcome to Ollama!

Run your first model:

        ollama run llama2

(base) PS C:\Windows\System32> ollama run llama2
pulling manifest
pulling 8934d96d3f08... 100% ▕████████████████████████████████████████████████████████▏ 3.8 GB
pulling 8c17c2ebb0ea... 100% ▕████████████████████████████████████████████████████████▏ 7.0 KB
pulling 7c23fb36d801... 100% ▕████████████████████████████████████████████████████████▏ 4.8 KB
pulling 2e0493f67d0c... 100% ▕████████████████████████████████████████████████████████▏   59 B
pulling fa304d675061... 100% ▕████████████████████████████████████████████████████████▏   91 B
pulling 42ba7f8a01dd... 100% ▕████████████████████████████████████████████████████████▏  557 B
verifying sha256 digest
writing manifest
removing any unused layers
success
>>> /?
Available Commands:
  /set            Set session variables
  /show           Show model information
  /load <model>   Load a session or model
  /save <model>   Save your current session
  /bye            Exit
  /?, /help       Help for a command
  /? shortcuts    Help for keyboard shortcuts

Use """ to begin a multi-line message.

>>> who are you
I'm just an AI assistant trained by Meta AI, my primary function is to assist users with their inquiries and
provide information on a wide range of topics. I'm here to help answer any questions you may have, so feel free to
ask me anything! Is there something specific you would like to know or discuss?

>>> /show
Available Commands:
  /show info         Show details for this model
  /show license      Show model license
  /show modelfile    Show Modelfile for this model
  /show parameters   Show parameters for this model
  /show system       Show system message
  /show template     Show prompt template

切换模型

还有其他可用模型,可以在github页面查看。 所有模型列表看这里 ollama.com/library

例如,我使用下面命令运行gemma模型:

arduino 复制代码
ollama run gemma

首次运行会先下载,模型,不过下载速度很快,几分钟。以后再运行就不用了。我的使用记录如下。

Gemma模型使用日志

sql 复制代码
C:\Users\weiyo>ollama
Usage:
  ollama [flags]
  ollama [command]

Available Commands:
  serve       Start ollama
  create      Create a model from a Modelfile
  show        Show information for a model
  run         Run a model
  pull        Pull a model from a registry
  push        Push a model to a registry
  list        List models
  cp          Copy a model
  rm          Remove a model
  help        Help about any command

Flags:
  -h, --help      help for ollama
  -v, --version   Show version information

Use "ollama [command] --help" for more information about a command.

C:\Users\weiyo>ollama run gemma
pulling manifest
pulling 456402914e83... 100% ▕████████████████████████████████████████████████████████▏ 5.2 GB
pulling 097a36493f71... 100% ▕████████████████████████████████████████████████████████▏ 8.4 KB
pulling 109037bec39c... 100% ▕████████████████████████████████████████████████████████▏  136 B
pulling 22a838ceb7fb... 100% ▕████████████████████████████████████████████████████████▏   84 B
pulling a443857c4317... 100% ▕████████████████████████████████████████████████████████▏  483 B
verifying sha256 digest
writing manifest
removing any unused layers
success
>>> how are you
I am an AI language model, so I don't have feelings or emotions. However, I am here to help you with your queries
and provide you with information. Is there anything I can assist you with today?

其他注意事项

安装程序把ollama安装在用户文件夹。安装后以后只需要运行程序,就可以在命令行使用ollama命令,启动模型使用了。

输入 /help可以获取帮助。使用Ctrl+D可以退出当前模型对话。

ollama支持本地restful api调用,以后可以研究以下。 github.com/ollama/olla...

每次下载的模型会默认保存到用户文件夹下,例如:

makefile 复制代码
C:\Users\用户文件夹\.ollama\models\blobs

ollama是命令行使用的。

这里推荐一些带界面的本地大模型

相关推荐
王莹月12 小时前
全店商品图风格怎么统一?生图API 用 nano banana pro 批量出同一套视觉
gpt·ai·chatgpt·ai作画·aigc·agi
DS随心转小程序1 天前
借助 AI 导出鸭简化各类办公场景下文心输出 word 文档全流程操作
人工智能·aigc·word·豆包·deepseek·ai导出鸭
m0_547486661 天前
《人工智能通识基础与AIGC应用》全套PPT课件2026
人工智能·aigc
wangruofeng1 天前
Deepseek harness 安装配置保姆教程
aigc·ai编程·deepseek
修远客1 天前
记忆模块:Agent的短期/中期/长期记忆 — 不是所有记忆都要放向量数据库
aigc·ai编程
DS随心转小程序1 天前
巧用 AI 导出鸭攻克各类难题完善 ChatGPT 输出 word 文档转化工作
人工智能·chatgpt·aigc·word·豆包·deepseek·ai导出鸭
咖啡星人k1 天前
AI编程Agent为何要配真服务器:拆解MonkeyCode云端沙箱
人工智能·aigc
AI创界者2 天前
最新 ComfyUI + LTX-2.5 本地一键整合包:文生视频/图生视频/数字人全流程指南
人工智能·aigc·音视频
xiezhr2 天前
DeepSeek 不能识图?装个开源 Skill,纯文本模型也能"睁眼"了
github·aigc·deepseek