开源项目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 小时前
Mesh AI 让每一位 3D 创作者和 3D 打印者都能轻松把想象变为现实。
aigc·unity3d
虎冯河14 小时前
图像,视频Lora模型训练的Timestep Type时间步类型
aigc·comfyui·模型训练·1024程序员节
墨风如雪15 小时前
AipexBase:AI时代,前端真的能“独立建国”了?
aigc
倔强的石头_17 小时前
2025长沙1024程序员日:为开发者职业发展插上腾飞之翼
aigc
扑克中的黑桃A18 小时前
2025长沙1024程序员日:为开发者职业发展插上腾飞之翼
aigc
咕咚-萌西20 小时前
When NOMA Meets AIGC: Enhanced WirelessFederated Learning
aigc
AAA阿giao1 天前
深入理解 OpenAI AIGC 模型与 Node.js 实战:从零构建歌词生成应用
aigc·openai
CaracalTiger1 天前
告别云端依赖!ComfyUI本地化视频生成实战教程+cpolar实战
python·gpt·开源·aigc·ai编程·1024程序员节·ai-native
Mintopia1 天前
🌐 数据合规框架下的 WebAIGC 训练数据处理技术规范
前端·javascript·aigc
DisonTangor1 天前
PaddleOCR-VL: 通过0.9B超紧凑视觉语言模型增强多语言文档解析
人工智能·计算机视觉·语言模型·自然语言处理·开源·aigc