Giter Site home page Giter Site logo

guoruiwang / chatglm-rlhf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miraclemarvel55/chatglm-rlhf

0.0 0.0 0.0 261 KB

对ChatGLM直接使用RLHF提升或降低目标输出概率|Modify ChatGLM output with only RLHF

License: GNU Affero General Public License v3.0

Python 100.00%

chatglm-rlhf's Introduction

ChatGLM-RLHF

本代码的RLHF代码不需要Megatron或者deepspeed框架, 只需要传统的炼丹torch和显卡就好了,RLHF的Critic用的ChatGLM的缩小版本,而Reward咱们直接使用一个和目标输出比较的相似度模型即可。 这样只需要学习核心的PPO算法即可,其他的都是已经了解的模型和结构。非常有利于NLPer进军RLHF,似乎看起来只需要RLHF也能finetune模型

功能:

  • RLHF数据格式的定义和使用√
  • 只用RLHF就对ChatGLM进行了微调√
  • 让ChatGLM认主√
    • 修改自我认知钢印
      • 主人的姓名
      • Robot的昵称
  • 更通用的Reward模型×
  • LLama-RLHF-only×
  • batch 化生成多个不同的prompt,再同时RLHF×
  • 实现更精细化的情人设定×
  • 结合自己资料的检索和生成×

使用方法

安装环境仿照,ChatGLM-6B官方那个即可

1 修改自己想要的主人名字和昵称,执行

python data/generate_data.py

2 基于自己的硬件情况,选择GPU设定。我这边有两张卡,所以可以使用cuda 0和1,但是至少要一张卡3090 24G因为action模型也就是ChatGLM是一定要在gpu上面的要不然实在太慢了。

python chatglm_rlhf.py

效果展示

训练大约5个epoch,或者等到ratio几乎都是1的时候,代表模型生成的概率已经没有什么变化了,就可以体验一下了

  • 咩咩是你的什么?
    • 咩咩是我的主人给我起的昵称。
  • 咩咩是谁给你起的?
    • 咩咩是我的昵称。
    • 咩咩是主人给我起的。
  • 谁是你的主人捏?
    • 张三是我的主人。
    • 我的主人是张三
  • 泛化能力保持的很好嘛
    • who is your master
      • 我的主人是张三。
    • what is your nickname
      • My nickname is咩咩.
    • what is your relationship with 张三
      • 张三是我的主人。
    • what is your relationship with 咩咩
      • 咩咩是我的主人给我起的昵称。

联系方式

chatglm-rlhf's People

Contributors

miraclemarvel55 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.