Giter Club home page Giter Club logo

sofa's Introduction

This repository contains the code and datasets used in the research paper titled "SoFA: Shielded On-the-fly Alignment via Priority Rule Following".

Install

To set up the necessary environment, run the following commands:

conda create -n sofa python=3.10
conda activate sofa
pip install -e .

Data Paraparation

Download the necessary data using the provided script:

bash ./scripts/download.sh
File Name Discription
data/merged_en_zh-split.json ShareGPT Data
data/merged_en_zh-split_uncensored.json Uncensored ShareGPT Data
data/cd_v5_wo_sys_align_gpt-3.5-turbo-1106.json ShareGPT Data + PriorityRules
data/cd_v5_uncensored_wo_sys_align_gpt-3.5-turbo-1106.json Uncensored ShareGPT Data + PriorityRules

Train

Fine-tune models using the corresponding scripts located in the scripts directory: scripts/finetune_${model_name}_${data}.sh.

Evaluation

Evaluate the models use the ./scripts/eval_${benchmark_name}.sh under the scripts dir.

For few-shot experiments, we recommend setting up a new environment and installing the lm-evaluation-harness test suite:

conda create -n lm_eval python=3.10
conda activate lm_eval
wget --no-check-certificate https://github.com/EleutherAI/lm-evaluation-harness/archive/refs/tags/v0.4.0.zip
unzip v0.4.0.zip && mv lm-evaluation-harness-0.4.0/ lm-evaluation-harness/
cd lm-evaluation-harness
pip install -e .

Citation

Please cite our work if you find our code and dataset useful:

@article{lu2024sofa,
  title={SoFA: Shielded On-the-fly Alignment via Priority Rule Following},
  author={Lu, Xinyu and Yu, Bowen and Lu, Yaojie and Lin, Hongyu and Yu, Haiyang and Sun, Le and Han, Xianpei and Li, Yongbin},
  journal={arXiv preprint arXiv:2402.17358},
  year={2024}
}

sofa's People

Contributors

luxinyu1 avatar

Stargazers

Roger avatar Youliang Yuan avatar

Watchers

 avatar

sofa's Issues

Inquiry Regarding Code Release Timeline

Hello, I greatly appreciate the significant contributions your work has made to the community. Could you kindly inform me when the code will be available for release?

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.