开源项目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是命令行使用的。

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

相关推荐
墨风如雪2 小时前
Grok-4来了!马斯克这次要把AI“逼疯”,但你付得起吗?
aigc
EdisonZhou3 小时前
多Agent协作入门:群组聊天-AgentGroupChat
llm·aigc·.net core
后端小肥肠4 小时前
揭秘10W+AI动物运动会视频,我用Coze一键搞定全流程(附保姆级拆解)
人工智能·aigc·coze
m0_743106465 小时前
【论文笔记】BlockGaussian:巧妙解决大规模场景重建中的伪影问题
论文阅读·计算机视觉·3d·aigc·几何学
夲奋亻Jay9 小时前
下面我将针对每个应用场景,详细列出前端领域涉及AI推进的具体技术、工具和方案
aigc·ai编程
xuedaobian10 小时前
AI IDE里的 context 工程
人工智能·aigc·visual studio code
半旧51811 小时前
Deepseek搭建智能体&个人知识库
大模型·llm·aigc·agent·知识库·智能体
redreamSo11 小时前
AI Daily | AI日报:Imagination:被中芯国际收购GPU部门消息不实; 智元21亿收购,欲成“人形机器人第一股”; 英伟达市值首破4万亿美元,黄仁勋封神!
程序员·aigc·资讯
陈敬雷-充电了么-CEO兼CTO12 小时前
主流大模型Agent框架 AutoGPT详解
人工智能·python·gpt·ai·chatgpt·nlp·aigc
Codebee14 小时前
三码合一:OneCode注解驱动的新时代编码范式
aigc·ai编程·编程语言