首页
/ Roleplay-with-XiYou 的安装和配置教程

Roleplay-with-XiYou 的安装和配置教程

2025-05-20 12:19:09作者:温玫谨Lighthearted

1、项目的基础介绍和主要的编程语言

Roleplay-with-XiYou 是一个基于《西游记》原文、白话文、ChatGPT生成数据制作的角色扮演多LLM聊天室。该项目通过InternLM2微调,实现了对《西游记》中四位主要角色的模拟,包括唐僧、孙悟空、猪八戒和沙悟净。用户可以通过简单的聊天室界面与这些角色进行交流,体验原著中的趣味对话。

项目主要使用 Python 编程语言,并结合了XTuner、LMDeploy等工具和框架。

2、项目使用的关键技术和框架

  • Python: 作为项目的主要编程语言,Python 提供了丰富的库和工具,使得项目开发更加高效和便捷。

  • XTuner: 一个基于 Transformer 的文本微调工具,用于对预训练模型进行微调,以适应特定的任务和数据集。在Roleplay-with-XiYou项目中,XTuner被用来微调预训练模型,使其能够更好地理解《西游记》中的对话场景。

  • LMDeploy: 一个模型部署工具,用于将训练好的模型转换为可部署的形式,并支持多种部署方式,如本地部署、云服务器部署等。在Roleplay-with-XiYou项目中,LMDeploy被用来将微调后的模型转换为可部署的形式,并通过简单的聊天室界面供用户使用。

3、项目安装和配置的准备工作和详细的安装步骤

准备工作:

  • 安装 Python 3.8 或更高版本
  • 安装 git 和 git-lfs
  • 准备 OpenAI API 的 API Key 和 API Base URL

安装步骤:

  1. 克隆项目仓库:
git clone --recurse-submodules https://github.com/JimmyMa99/Roleplay-with-XiYou.git
  1. 进入项目目录:
cd Roleplay-with-XiYou
  1. 创建 Python 虚拟环境并激活:
conda create -n chatXY python=3.10 -y
conda activate chatXY
  1. 安装 LMDeploy:
pip install lmdeploy
  1. 安装 XTuner:
cd train/Xtuner
pip install -e '.[all]'
  1. 安装其他依赖:
pip install -r requirements.txt
  1. 从模型scope下载权重:
# 三藏-Chat
git clone https://www.modelscope.cn/JimmyMa99/SanZang-Chat.git

# 悟空-Chat
git clone https://www.modelscope.cn/JimmyMa99/WuKong-Chat.git

# 八戒-Chat
git clone https://www.modelscope.cn/JimmyMa99/BaJie-Chat.git

# 悟净-Chat
git clone https://www.modelscope.cn/JimmyMa99/WuJing-Chat.git
  1. 离线转换模型:
# 转换三藏-Chat模型
lmdeploy convert internlm2-chat-7b ./SanZang-Chat

# 转换悟空-Chat模型
lmdeploy convert internlm2-chat-7b ./WuKong-Chat

# 转换八戒-Chat模型
lmdeploy convert internlm2-chat-7b ./BaJie-Chat

# 转换悟净-Chat模型
lmdeploy convert internlm2-chat-7b ./WuJing-Chat
  1. 启动模型服务:
# 启动悟空-Chat服务
lmdeploy serve api_server swk_workspace --server-name ${gradio_ui_ip} --server-port ${gradio_ui_port}

# 启动八戒-Chat服务
lmdeploy serve api_server zbj_workspace --server-name ${gradio_ui_ip} --server-port ${gradio_ui_port}
  1. 下载简易聊天室:
git clone https://github.com/JimmyMa99/Easy-Chatroom.git
  1. 启动聊天室服务端:
cd Easy-Chatroom
python server_start.py
  1. 启动聊天室客户端:
cd Easy-Chatroom
# 第一个bot
python bot_start.py
# 第二个bot
python bot_start.py
# 开启观察客户端(人提问)
python client_start.py

完成以上步骤后,即可通过聊天室界面与Roleplay-with-XiYou中的角色进行交流。

登录后查看全文
热门项目推荐