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)
相关推荐
夏日米米茶3 小时前
Windows系统下npm报错node-gyp configure got “gyp ERR“解决方法
前端·windows·npm
虾球xz4 小时前
CppCon 2015 学习:CLANG/C2 for Windows
开发语言·c++·windows·学习
码上库利南5 小时前
Windows开机自动启动中间件
windows
nenchoumi311911 小时前
AirSim/Cosys-AirSim 游戏开发(一)XBox 手柄 Windows + python 连接与读取
windows·python·xbox
love530love12 小时前
【PyCharm必会基础】正确移除解释器及虚拟环境(以 Poetry 为例 )
开发语言·ide·windows·笔记·python·pycharm
黄交大彭于晏14 小时前
发送文件脚本源码版本
java·linux·windows
vfvfb1 天前
bat批量去掉本文件夹中的文件扩展名
服务器·windows·批处理·删除扩展名·bat技巧
我命由我123451 天前
VSCode - VSCode 放大与缩小代码
前端·ide·windows·vscode·前端框架·编辑器·软件工具
PT_silver1 天前
tryhackme——Abusing Windows Internals(进程注入)
windows·microsoft
爱炸薯条的小朋友1 天前
C#由于获取WPF窗口名称造成的异常报错问题
windows·c#·wpf