Git Product home page Git Product logo

rahf's Introduction

RAHF: Representation Alignment from Human Feedback

title

🌟News

  • We used RAHF to align the Mistral-7B model and uploaded the evaluation results on AlpacaEval to the AlpacaEval Leaderboard. We achieved the best results among all 7B models currently on the leaderboard.

    leaderboard

Intruduction

This repo includes a reference implementation of the RAHF for training language models from preference data, as described in the paperAligning Large Language Models with Human Preferences through Representation Engineering

The RAHF pipeline has three stages:

  • Step 0: Using the HH-RLHF dataset, perform Supervised Fine-Tuning (SFT) to enable the model with instruction following and conversational abilities.
  • Step 1: Fine-tune the model using the preference dataset Ultrafeedback, instructing the model to understand human preferences.
  • Step 2: Collecting activity patterns and constructing a model with LoRA to fit these patterns.

The files in this repo are:

  • code/step0/data_process.py:Split the dataset into PPO, RM, and test sets. For reproducibility, we have uploaded the split datasets used in our experiments to the data folder.
  • code/step1/DUAL_step1.py:Perform SFT on the model using the preference dataset. This part corresponds to the code implementation of part 3.1.2 in our paper.
  • code/step1/SCIT_step1.py:Perform Hindsight on the model using the preference dataset. This part corresponds to the code implementation of part 3.1.1 in our paper.
  • cde/step2/RAHF.py: This part corresponds to the code implementation of part 3.1.3 in our paper.

Quickstart

Install

pip install -r requirements.txt

Step0: Using the HH-RLHF dataset, perform Supervised Fine-Tuning (SFT)

cd code
bash bash/SFT-step0.sh

Step1: Instructing LLMs on Human Preferences

for SCIT

cd code
bash bash/SCIT-step1.sh

for DUAL

cd code
bash bash/DUAL-step1.sh

Step2: Constructing Final Models

for SCIT

cd code
bash bash/SCIT-step2.sh

for DUAL

cd code
bash bash/DUAL-step2.sh

Evaluation

for open llm Evaluation, we use lm-evaluation-harness.

for Alpaca-Eval, please see alpaca_eval.

for MT-Bench, please see FastChat.

rahf's People

Contributors

liuamber avatar

Stargazers

王政华 avatar Zhihao Xu avatar Aashiq Muhamed avatar Ben avatar XHWang avatar LingGod-23 avatar Tianlong Li avatar Yaojie Shen avatar

Watchers

 avatar

rahf's Issues

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.