Skip to content

大模型部署——ollama

第一次使用ollama我就被惊艳到了,惊掉了我的下巴。

开源大模型越来越多,大有百家争鸣之势。面对层出不穷的大模型,我们如何才能快速上手体验呢?答案就是:ollama。

什么是ollama

ollama

ollama可以帮助我们在本地启动并运行大语言模型。

我们不仅可以使用Llama 2、Code Llama等模型,还可以使用自己自定义创建的模型。

ollama支持的模型

以下是ollama已经支持的开源大模型,大家可以根据需要自行体验。

  • gemma
  • llama2
  • mistral
  • mixtral
  • command-r
  • llava
  • codellama
  • dolphin-mixtral
  • qwen
  • llama2-uncensored
  • mistral-openorca
  • deepseek-coder
  • phi
  • nous-hermes2
  • orca-mini
  • dolphin-mistral
  • wizard-vicuna-uncensored
  • vicuna
  • nomic-embed-text
  • tinydolphin
  • llama2-chinese
  • ...

太多了,就不再一一罗列了,几乎涵盖了所有的开源大模型

安装

ollama支持macOS、Linux和Windows

以Linux为例,在终端执行命令:

sh
curl -fsSL https://ollama.com/install.sh | sh

安装完成以后,验证是否安装成功:

sh
ollama -v

如图,则表示已经安装成功了。

快速开始

  • 查看本地模型列表
sh
ollama list

  • 拉取需要的模型
sh
ollama pull llama2

  • 再次查看本地模型列表

由图可知,llama2模型已经下载到本地了

注意,不知道大家有没有发现,整个过程是不是和使用docker有些像呢。

  • 运行模型
sh
ollama run llama2

当出现Send a message的提示时,说明模型已经成功启动了,我们就可以在终端使用大模型了。

  • 测试模型

要求大模型为爱人写一封信,看看效果吧

My dearest,

As I sit here thinking of you, my heart fills with joy and love. Every moment I spend away from you
feels like an eternity, and I can't wait to be reunited with you. Your touch, your smile, your
laughter - everything about you makes me feel alive and complete.

I dream of the day when we can hold each other close again, feel each other's warm embrace, and lose
ourselves in the depths of our love. Until then, know that you are always on my mind and in my heart,
and that I will love you forever and always.

Yours always,
[Your Name]

再让大模型翻译成中文

我的愛,

每次思考你时,我的心都会满满喜悦和爱。在与你分享的每一刹点时,我就会感到无比不可或缺。你的接觸、你的笑容、你的嘻唱──都能使我感到生命中的全新感受和完整。

我梦想在与你重返时,能够拥抱你,感受到你的温暖,并追逐在我们之间的爱心。 Until then, 知道你一直是我的心中的 主人,和我会永不离弃你的爱。

永远 yours,
[你的名字]

整个体验过程相当流畅,在此之前,我很难想象体验开源模型到底要经历什么(不堪回忆)。现在则只要大约十分钟就可以,关键是几十个开源大模型都可以畅玩。

需要注意,从安装到下载模型,速度都非常快,如果你在体验过程中发现非常慢,则不妨试试科学上网。

进阶

ollama带给我们的神奇之处还远不止上述内容,还有更多的能力需要大家去进一步探索学习。如果你已经被ollama深深吸引,可以到ollama官网学习。

关注:遇码,回复:ollama,获取ollama官方地址。

遇码MeetCoding 开源技术社区