llama3仿openai api实验(本地服务器) #173
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#173
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
本文默认您在操作系统的用户名为:ganjialing,如果您使用的是其他用户名,请更改涉及到用户名的地址。
环境准备
源码下载
安装miniconda
创建并激活虚拟环境
下载模型
查看模型存储位置
开源版openai接口启动
中文llama3的开源版本实现在以下目录:/home/ganjialing/Chinese-LLaMA-Alpaca-3-3.0/scripts/oai_api_demo,下面分别是GPU和CPU版本的启动流程。
脚本bug修复
打开/home/llm_course/Chinese-LLaMA-Alpaca-3-3.0/scripts/oai_api_demo/openai_api_server.py文件,找到如下内容:
将generation_kwargs改为如下值:
加入上面的参数主要是为了兼容llama3特有的停止token,不然流式接口返回的内容会不断的自动重复,不停止。
GPU版本接口启动
备份脚本
使用如下命令备份/home/ganjialing/Chinese-LLaMA-Alpaca-3-3.0/requirements.txt文件:
安装依赖
通过如下命令创建新的requirements.txt:
安装依赖:
启动大模型模型
测试效果
安装ChatNextWeb
我们使用ChatGPTNextWeb工具测试我们的接口,下载:
Windows:https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/releases/download/v2.14.2/NextChat_2.14.2_x64-setup.exe
接入大模型
设置
设置接口地址,若为本地则为localhost+端口号,服务器则需要替换;
API_KEY随便设置就好。
这里把ChatGPT提示信息去掉;
设置完后点这里关闭;
点这里选择模型;
选择llama-chinese;
测试可通。
CPU版本接口启动
创建CPU版本专用的虚拟环境
创造并启动conda环境:
安装依赖:
利用CPU启动大模型服务
测试效果
与CPU版本相同。
cpu还是慢一些的。
实验中遇到的问题:
TypeError:
dumps_kwargs
keyword arguments are no longer supported1.问题描述:
启动私有大语言模型,通过一些 UI 工具进行访问时,报以下错误。

2.解决方法:
通过网上搜索,原因是 pydabtic 包升级带来的问题,需要安装指定的版本。
pip install pydantic==1.10.11