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)
相关推荐
wuletaotao1 小时前
Windows 下 Redis 使用完整教程
数据库·windows·redis
渡我白衣3 小时前
并行的野心与现实——彻底拆解 C++ 标准并行算法(<execution>)的模型、陷阱与性能真相
java·开发语言·网络·c++·人工智能·windows·vscode
Jelly-小丑鱼3 小时前
windows的WFP过滤域名
windows·域名白名单·wfp
这儿有一堆花3 小时前
视频文件的技术逻辑解析
windows·macos
百事牛科技3 小时前
压缩包安全升级:分享WinRAR的两种加密功能
windows·winrar
欧恩意4 小时前
【Viusal Studio】关于增量链接机制
汇编·windows·bug
定_格4 小时前
windows本地启动项目并使用arthas调试
windows
ReaF_star5 小时前
【安防】Windows Server 2008虚拟机忘记密码的一时兴起
网络·windows·安全
山峰哥5 小时前
EcMenu:解锁 Windows 右键菜单的终极自由
windows·性能优化·软件工程·鼠标右键菜单工具
天魔老师6 小时前
WSL2 “system.vhd找不到” 错误修复教程(实测有效)
windows·wsl