Giter VIP home page Giter VIP logo

slic-hf's Introduction

Reproducing results of paper - "Beyond Reverse KL: Generalizing Direct Preference Optimization with Diverse Divergence Constraints"

The paper compares different divergence functions for direct preference optimization (DPO).

Results notebook on nbviewer - results.ipynb

Setup

  1. Install poetry
  2. Then run:
git clone https://github.com/somvy/slic-hf && cd slic-hf
poetry install && poetry shell
wandb login
huggingface-cli login
  1. Specify your HuggingFace username, desired SFT model in config.py

Dataset

Prompts - first sentences from movie reviews. Used some hacks to generate answers with positive bias (see dataset/generation_config.py) Used diverse beam search decoding with diversity penalty 50 to generate 6 answers per prompt. Then scored them with reward model. Used pairs of (top1, top4\5\6) and (top1\2\3, top6) as chosen and rejected answers (total 6 pairs from generation). Final dataset - 3600 pairs, test size 0.2.

hf link

Also randomly selected 50 prompts for eval generation - hf link

Use this dataset, or generate your own by

set -a && source .env && poetry run python dataset/main.py

after generation change datasets paths in config.py

Train

  1. Specify training arguments, DPOTrainer params and run_name in train_dpo/train.py
  2. Run
set -a && source .env && poetry run python train_dpo/train.py
  1. (Optional) Generate answers from eval dataset. Specify generation params and desired run_name in train_dpo/generate.py
set -a && source .env && poetry run python train_dpo/generate.py

Experiments setup

Trained GPT2 finetuned on IMDB reviews.
3 epochs, batch size 4, lr 1e-4 for sigmoid and hinge, 1e-5 for others.

Weights and logs

Loss Weights Wandb Report
Hinge link
$\beta = 10$ link
$\beta = 1$ link
$\beta = 0.5$ link
$\beta = 0.1$ link
Sigmoid link
$\beta = 10$ link
$\beta = 1$ link
$\beta = 0.5$ link
$\beta = 0.1$ link
JS divergence link
$\beta = 1$ link
$\beta = 0.1 $ link
Forward KL link
$\beta=0.1$ link
$\beta = 1$ link
$\alpha$-divergence link
$\alpha = 0.3, \beta = 1$ link
$\alpha = 0.3, \beta = 0.1$ link
$\alpha = 0.5, \beta = 1$ link
$\alpha = 0.5, \beta = 0.1$ link
$\alpha = 0.7, \beta = 1$ link
$\alpha = 0.7, \beta = 0.1$ link

slic-hf's People

Contributors

somvy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.