Ollama入门(windows版本)

一、简介

通过简单的安装指令,可以让用户执行一条命令就在本地运行开源大型语言模型,如gemma。

二、安装方式

1、访问官网,点击【Download】进行下载https://ollama.com/

2、目前支持Linux、Mac和windows

3、github链接:https://github.com/ollama/ollama

三、下载并运行模型(命令行方式)

1、点击【View logs】进入ollama目录

2、运行gemma:2b模型(如未下载,会自动下载)

3、提问

bash 复制代码
ollama run gemma:2b



四、webapi方式运行

1、webapi方式运行

bash 复制代码
./ollama serve

2、如需指定端口,可在环境变量中进行配置

3、安装openai工具包

bash 复制代码
pip install openai

4、openai格式调用ollama部署的接口

python 复制代码
import openai
# 设置api_base
openai.api_key = "111" #不可为空,为空会报错
openai.api_base = "http://127.0.0.1:8000/v1"
# 2. 设置提示词
prompt = """
你是谁?

"""

# 3.调用(可切换模型)
# resp = openai.ChatCompletion.create(model="llama2", messages=[{"role": "user", "content": prompt}], stream = False)
resp = openai.ChatCompletion.create(model="llama2-chinese", messages=[{"role": "user", "content": prompt}], stream = False)
# resp = openai.ChatCompletion.create(model="gemma:7b", messages=[{"role": "user", "content": prompt}], stream = False)

# 4.输出
print(resp.choices[0].message.content)
相关推荐
非凡ghost7 小时前
Wireshark中文版(网络抓包工具)
网络·windows·学习·测试工具·wireshark·软件需求
ID_180079054737 小时前
YouTube item_get_video接口认证方式:API密钥与OAuth2.0的选择与应用
服务器·windows·microsoft
yunianshu7 小时前
删除 Windows 保留名称文件指南
windows
zuozewei12 小时前
零基础 | AI编程工具 Claude Code 快速上手指南(Windows)
windows·ai编程
盘古工具13 小时前
创建分卷压缩文件:解决大文件传输难题
windows·winrar
玖釉-16 小时前
[Vulkan 学习之路] 16 - 最终章:渲染循环与同步 (Rendering & Presentation)
c++·windows·图形渲染
HelloRevit16 小时前
Windows Server SMB 共享文件 回收站
windows·c#
醇氧16 小时前
【Windows】安装mysql8
数据库·windows·mysql
十月不到底17 小时前
Windows 上安装 Volta
windows·npm
Merlyn1018 小时前
NVM介绍及Windows下的安装
windows·node.js·nvm