Skip to content

基于ChatGLM-6B,低成本实现类Instruction效果的角色扮演

License

Notifications You must be signed in to change notification settings

vissurra/RolePlayGLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f557d35 · May 15, 2023

History

9 Commits
Apr 28, 2023
Apr 28, 2023
May 15, 2023
May 15, 2023
May 15, 2023
Apr 27, 2023
Apr 28, 2023
Apr 27, 2023
May 15, 2023
Apr 27, 2023
Apr 28, 2023
May 15, 2023
May 15, 2023
May 15, 2023
Apr 28, 2023

Repository files navigation

RolePlayGLM

基于ChatGLM-6B使用ptuning进行微调,实现类instruction的效果

介绍

由于ChatGLM-6B 不支持instruction,所以在进行角色扮演任务时具有不稳定性。本项目通过模板生成超小语料数据集,使用ptuning 进行微调,实现角色扮演的效果。
📜 通过外挂知识库的方式进行角色背景设定。

  • Python 3.10

示例

基本信息问答

demo

知识库配置

demo_knowledge

TODOs

  • 基本信息
  • 背景设定
  • 性格、情绪

使用

  1. 安装依赖

    # 安装ChatGLM-6B所需依赖
    $ pip install -r chatglm_6b/requirements.txt
    # 安装ptuning依赖
    $ pip install rouge_chinese nltk jieba datasets
    # 安装本项目所需依赖
    $ pip install -r requirements.txt
  2. 训练模型

    可以删除 train_instruction.sh 中的--quantization_bit参数,不使用量化。

    # 构造数据集
    $ python dataset.py
    # 训练
    $ bash train_instruction.sh

    Google Drive 下载已经训练的权重文件,放在 ckpt 目录下,跳过此步骤。

  3. 运行

    $ bash web_demo.sh
  4. 访问
    浏览器直接打开 http://127.0.0.1:7860

硬件

推理

量化 显存(GB)
FP16(无量化) 14
INT4 6

训练

量化 显存(GB) 速度(s/it) loss
FP16(无量化) 15 6.28 0.0021
INT4 7 8.95 0.0012
  • 以上数据为单张RTX 3090显卡的测试结果
  • epoch: 50

感谢

About

基于ChatGLM-6B,低成本实现类Instruction效果的角色扮演

Topics

Resources

License

Stars

Watchers

Forks