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)
相关推荐
爱编程的鱼6 小时前
C# 枚举(Enum)声明与使用详解
java·windows·c#
进取星辰11 小时前
Windows 10 上运行 Ollama 时遇到 llama runner process has terminated: exit status 2
windows·llama
sukalot11 小时前
Windows同步技术-使用命名对象
windows
快乐点吧13 小时前
【Flume 】Windows安装步骤、配置环境
大数据·windows·flume
Java手札14 小时前
Windows下Golang与Nuxt项目宝塔部署指南
开发语言·windows·golang
心灵宝贝14 小时前
Postman-win64-7.2.2 安装教程(Windows 64位详细步骤)
windows·测试工具·postman
快乐点吧17 小时前
【MongoDB】windows安装、配置、启动
数据库·windows·mongodb
Java-云海20 小时前
微软官网Win10镜像下载快速获取ISO文件
windows·microsoft·虚拟机·iso镜像·windows10系统
Clank的游戏栈1 天前
Unity多线程渲染指令队列设计与集成技术详解
windows·unity·游戏引擎
sukida1001 天前
BIOS主板(非UEFI)安装fedora42的方法
linux·windows·fedora