AIGC之Ollama 本地大模型应用实战

Ollama 是一个开源项目,旨在简化在本地部署和运行大型语言模型(LLMs)的过程。它提供了一系列工具和功能,使得开发者和研究人员能够更容易地在自己的机器上利用这些先进的AI模型,而无需依赖云端服务。

官网:https://ollama.com

Github:https://github.com/ollama/ollama

一、运行环境准备

AIGC之Ollama 本地大模型应用实战

Ollama 官方提供了 Docker 镜像安装,可以在 Docker Hub 上获取:

Docker Hub :https://hub.docker.com/r/ollama/ollama

AIGC之Ollama 本地大模型应用实战

二、模型库提供商
提供商:https://ollama.com/library
AIGC之Ollama 本地大模型应用实战
运行 7B 模型需要至少 8GB 的 RAM,运行 13B 模型需要 16GB RAM,运行 33B 模型需要 32GB RAM。
三、运行本地大模型
运行并与 Llama 3 进行交流,可以使用以下命令:

AIGC之Ollama 本地大模型应用实战

四、命令行操作 CLI 参考

创建模型

ollama create selfModel -f ./Modelfile

更新模型

ollama pull llama3

删除模型

ollama rm llama3

复制模型

ollama cp llama3 self-llama3

多行输入

使用 """ 包裹文本
>>> """Hello,... world!... """I'm a basic program that prints the famous "Hello, world!" message to the console.多模态模型>>> What's in this image? /Users/aid/smile.pngThe image features a yellow smiley face, which is likely the central focus of the picture.

提示作为参数传入

$ ollama run llama2 "Summarize this file: $(cat README.md)" Ollama is a lightweight, extensible framework for building and running language models on the local machine. It provides a simple API for creating, running, and managing models, as well as a library of pre-built models that can be easily used in a variety of applications.

列出已安装模型列表

ollama list

启动 Ollama

ollama serve

五、源码构建Ollama

安装 cmakego
brew install cmake go

然后生成依赖项:
go generate ./...

然后构建二进制文件:
go build .

更详细的说明可以在开发者指南中找到。

运行本地构建

启动服务器:
./ollama serve
在shell 中,运行模型:
./ollama run llama2

六、REST API文档提供

详细信息查看文档

https://github.com/ollama/ollama/blob/main/docs/api.md

查看更多集成案例,可以查看github仓库文档

前沿技术开源大模型新闻资讯

告别复杂操作,免费ComfyUI网页让你轻松搭建AI工作流!

2026-2-4 16:51:12

前沿技术开源大模型新闻资讯

用ESP32,做了个siri?!开源了!

2026-2-4 18:36:56

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
购物车
优惠劵
搜索