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

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

相关推荐
cxyxiaokui0015 小时前
检索增强生成(RAG):打破模型知识壁垒的革命性架构
java·aigc
产品研究员6 小时前
AI内容创作APP原型设计详解:案例拆解与高效搭建技巧
app·aigc
用户5191495848458 小时前
使用Amazon Verified Permissions快速为Express应用API添加安全防护
人工智能·aigc
Mintopia11 小时前
🏛️ 从“像”到“优”:AIGC 质量评估与 BS 架构的奇幻之旅
前端·javascript·aigc
安思派Anspire11 小时前
我测试了所有AI Code Generator——这是最终赢家(二)
aigc·openai·agent
r0ad12 小时前
从0到6.75亿:非科班创业者的AI法律破局
aigc
墨风如雪1 天前
告别AI视频“幻觉”:群核SpatialGen,3D生成驶入“真空间”时代!
aigc
闲不住的李先森1 天前
AI 应用演进:从基础调用到自主智能体
人工智能·llm·aigc
DisonTangor1 天前
【字节拥抱开源】字节豆包团队开源豆包OSS大模型
人工智能·开源·aigc
尘叶心简1 天前
从零开发一个Agent
aigc·openai