Stay Hungry,Stay Foolish!

Qwen Runner

本地测试

https://www.bingal.com/posts/Qwen-7b-usage/

通义千问-7B(Qwen-7b)是什么

通义千问(Qwen-7B)是阿里云最新发布的一系列超大规模语言模型,这个牛气十足的大模型令人惊叹。基于Transformer架构,Qwen-7B系列汇聚了70亿参数。废话不多说,让我们一起来看看Qwen-7B的强大之处吧!

安装虚拟环境

 
# 安装虚拟环境
conda create -n qwen-7b python=3.10 -y
# 激活虚拟环境
conda activate qwen-7b

安装 pytorch

参考 https://pytorch.org/get-started/locally/ 我本地安装的 cuda 是 11.8 版本,所以安装代码如下,如果是用 cpu 跑的话,则省略本步骤,下面的代码会自动下载 cpu 版本的 pytorch

 
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

拉取代码并安装依赖

 
# 拉取代码
git clone https://github.com/QwenLM/Qwen-7B.git
# 进入代码目录
cd Qwen-7B
# 安装依赖
pip install -r requirements.txt
# 安装 web_demo 依赖
pip install -r requirements_web_demo.txt

启动 web_demo 快速体验(自动下载模型)

 
# 通过参数 --server-port 指定端口号,默认为 8000
# 通过参数 --server-name 指定服务地址,默认为 127.0.0.1
# 如果是用 cpu 跑的话,可以加上参数 --cpu-only
# 如果想生成一个用于公网访问的 url,可以加上参数 --share
python web_demo.py --server-port 8087 --server-name "0.0.0.0"

web demo 界面 web demo 界面

启动类 openai api 形式的接口

有个必要的依赖库需要先安装 pip install sse_starlette ,然后就可以启动了

 
# 通过参数 --server-port 指定端口号,默认为 8000
# 通过参数 --server-name 指定服务地址,默认为 127.0.0.1
# 如果是用 cpu 跑的话,可以加上参数 --cpu-only
python openai_api.py --server-port 8086 --server-name "0.0.0.0"

服务启动正常之后,就可以使用 openai 的客户端使用了,比如 chatbox、opencat 等等,亲测可用。 设置 api 的时候选择 openapi api 接口,api-key 为空即可。 下面为 chatbox 设置方法: chatbox 设置方法 下面为 chatbox 对话效果 chatbox 对话效果

 

https://blog.csdn.net/qq_36344652/article/details/140361129

 

llama.cpp

https://qwen.readthedocs.io/en/latest/run_locally/llama.cpp.html

 

部署

vllm

https://qwen.readthedocs.io/zh-cn/latest/deployment/vllm.html

 

lmdeploy

https://lmdeploy.readthedocs.io/zh-cn/latest/serving/api_server.html

 

 

服务使用

https://help.aliyun.com/zh/dashscope/developer-reference/compatibility-of-openai-with-dashscope

https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api

https://help.aliyun.com/zh/dashscope/developer-reference/quick-start?spm=a2c4g.11186623.0.i3

 

posted @ 2024-07-27 12:01  lightsong  阅读(6)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel