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)
相关推荐
有梦想的攻城狮4 小时前
Java 11中的Collections类详解
java·windows·python·java11·collections
忒可君4 小时前
C# winform FTP功能
开发语言·windows·c#
十五年专注C++开发4 小时前
CMake进阶: CMake Modules---简化CMake配置的利器
linux·c++·windows·cmake·自动化构建
degree5205 小时前
全平台轻量浏览器推荐|支持Win/macOS/Linux,极速加载+隐私保护+扩展插件,告别广告与数据追踪!
windows·macos·电脑
许泽宇的技术分享1 天前
Windows桌面自动化的革命性突破:深度解析Windows-MCP.Net Desktop模块的技术奥秘
windows·自动化·.net
七仔的博客2 天前
【摸鱼办公神器】七仔的桌面工具超进化 -> 灵卡面板 v1.1.9
windows·神器·摸鱼
码农阿豪2 天前
Windows从零到一安装KingbaseES数据库及使用ksql工具连接全指南
数据库·windows
CC__xy2 天前
demo 通讯录 + 城市选择器 (字母索引左右联动 ListItemGroup+AlphabetIndexer)笔记
windows
LZQqqqqo2 天前
C# 中 ArrayList动态数组、List<T>列表与 Dictionary<T Key, T Value>字典的深度对比
windows·c#·list
季春二九2 天前
Windows 11 首次开机引导(OOBE 阶段)跳过登录微软账户,创建本地账户
windows·microsoft