Git Product home page Git Product logo

sapo's Introduction

Self-Augmented Preference Optimization: Off-Policy Paradigms for Language Model Alignment (SAPO)

teaser

This repository provides the official PyTorch implementation for the following paper:

Self-Augmented Preference Optimization: Off-Policy Paradigms for Language Model Alignment [Arxiv]
Yueqin Yin*, Zhendong Wang*, Yujia Xie, Weizhu Chen and Mingyuan Zhou
(* denotes equal contribution)
The University of Texas At Austin, Microsoft Azure AI

Abstract: Traditional language model alignment methods, such as Direct Preference Optimization (DPO), are limited by their dependence on static, pre-collected paired preference data, which hampers their adaptability and practical applicability. To overcome this limitation, we introduce Self-Augmented Preference Optimization (SAPO), an effective and scalable training paradigm that does not require existing paired data. Building on the self-play concept, which autonomously generates negative responses, we further incorporate an off-policy learning pipeline to enhance data exploration and exploitation. Specifically, we employ an Exponential Moving Average (EMA) model in conjunction with a replay buffer to enable dynamic updates of response segments, effectively integrating real-time feedback with insights from historical data. Our comprehensive evaluations of the LLaMA3-8B and Mistral-7B models across benchmarks, including the Open LLM Leaderboard, IFEval, AlpacaEval 2.0, and MT-Bench, demonstrate that SAPO matches or surpasses established offline contrastive baselines, such as DPO and Odds Ratio Preference Optimization, and outperforms offline self-play methods like SPIN.

Installation

  1. Clone this repo:
    git clone https://github.com/yinyueqin/SAPO.git
    cd SAPO
  2. Install dependent packages: A suitable Anaconda environment named sapo can be created and activated with:
    conda create -n sapo python=3.10
    conda activate sapo
    python -m pip install .
    python -m pip install flash-attn --no-build-isolation
    

Training

For detailed script commands, please refer to the scripts in scripts/sapo_dpo.sh and scripts/sapo_orpo.sh.

Citation

If you find this work useful for your research, please consider citing our paper:

@article{yin2024self,
  title={Self-Augmented Preference Optimization: Off-Policy Paradigms for Language Model Alignment},
  author={Yin, Yueqin and Wang, Zhendong and Xie, Yujia and Chen, Weizhu and Zhou, Mingyuan},
  journal={arXiv preprint arXiv:2405.20830},
  year={2024}
}

Acknowledgement

This repo is built upon SPIN and TRL. We thank the authors for their excellent work.

sapo's People

Contributors

yinyueqin avatar

Stargazers

Can Jin avatar Chaoshun avatar Fang Chang avatar Yuzhong Zhao avatar  avatar

Watchers

 avatar

sapo's Issues

Chat template to use in Fastchat when evaluating MT-Bench

Hi, nice work and well written paper !

I would like to ask that since you have used chatml template when training with orpo for llama3, I want to know what chat template to use hen evaluating model with MT-Bench with Fastchat library.

I have tried the following but it seems that it does not to work for me:

register_conv_template(
Conversation(
name="llava-chatml",
system_template="<|im_start|>system\n{system_message}",
system_message="Answer the questions.",
roles=("<|im_start|>user", "<|im_start|>assistant"),
sep_style=SeparatorStyle.CHATML,
sep="<|im_end|>",
stop_str="<|im_end|>",
)
)

Many thanks for the assistance.

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.