{"id":30957283,"url":"https://github.com/cyberagentailab/annotation-efficient-po","last_synced_at":"2025-09-11T13:45:18.241Z","repository":{"id":241067003,"uuid":"799728774","full_name":"CyberAgentAILab/annotation-efficient-po","owner":"CyberAgentAILab","description":"Code of \"Annotation-Efficient Preference Optimization for Language Model Alignment\"","archived":false,"fork":false,"pushed_at":"2024-05-29T12:58:36.000Z","size":20412,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-10T07:42:49.348Z","etag":null,"topics":["alignment","llm","rlhf"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2405.13541","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberAgentAILab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-13T01:20:05.000Z","updated_at":"2025-08-23T23:00:46.000Z","dependencies_parsed_at":"2024-05-29T15:00:14.063Z","dependency_job_id":null,"html_url":"https://github.com/CyberAgentAILab/annotation-efficient-po","commit_stats":null,"previous_names":["cyberagentailab/annotation-efficient-po"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CyberAgentAILab/annotation-efficient-po","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Fannotation-efficient-po","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Fannotation-efficient-po/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Fannotation-efficient-po/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Fannotation-efficient-po/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberAgentAILab","download_url":"https://codeload.github.com/CyberAgentAILab/annotation-efficient-po/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Fannotation-efficient-po/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274496660,"owners_count":25296427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","llm","rlhf"],"created_at":"2025-09-11T13:45:15.172Z","updated_at":"2025-09-11T13:45:18.233Z","avatar_url":"https://github.com/CyberAgentAILab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Annotation-Efficient Preference Optimization\n\n![illustration](https://github.com/CyberAgentAILab/annotation-efficient-po/raw/master/aepo.png)\n\nThis repository implements the [Annotation-Efficient Preference Optimization (AEPO) algorithm](https://arxiv.org/abs/2405.13541).\n\nThe code is tested on Ubuntu 20.04 using Python 3.9 and CUDA 11.0 (Docker image nvidia/cuda:11.0.3-cudnn8-devel-ubuntu20.04).\n\n## Install\n\nYou can install aepo via pip.\n```\npip install aepo\n```\n\nSource install is available too. Clone this repository and run `pip install .`.\n```\ngit clone git@github.com:CyberAgentAILab/annotation-efficient-po.git\ncd annotation-efficient-po\npip install .\n```\n\n\n## Usage\n\nThe command line interface is available.\nThe input dataset can be csv file or a dataset uploaded to Huggingface Hub.\nThe dataset should have a column named *prompt* or *instruction*. aepo recognize it as the user prompt given to the system and the rest of the columns to be the responses generated by the system.\n\nI prepared an example dataset in `dataset/alpaca_samples.csv`.\nThe csv file includes 128 responses generated by [HuggingFaceH4/mistral-7b-sft-beta](https://huggingface.co/HuggingFaceH4/mistral-7b-sft-beta) for each instruction of the `alpaca_human_preference` split of [tatsu-lab/alpaca_farm](https://huggingface.co/datasets/tatsu-lab/alpaca_eval).\nYou can try aepo using this dataset with the following command:\n\n```\naepo dataset/alpaca_samples.csv --num_responses 8 --num_annotations 2 --num_instructions 10\n```\n\n`--num_responses` is the number of input responses you use. The dataset has to have responses larger than or equal to `--num_responses`. `--num_annotations` is the number of responses after the subsampling process. It is also the number of times the reward model is queried per instruction.\n\n### Example: Running AEPO\n\nYou can generate a pair of responses for each instruction using aepo using the following command.\n\n```\naepo dataset/alpaca_samples.csv --num_responses 8 --num_annotations 2 --num_instructions 10\n```\n\nTo subsample four responses for e.g., [LiPO](https://arxiv.org/abs/2402.01878v1), set `--num_annotations` to four.\n\n```\naepo dataset/alpaca_samples.csv --num_responses 8 --num_annotations 4 --num_instructions 10\n```\n\n### Example: Running West-of-N over 8 samples\n[West-of-N](https://arxiv.org/abs/2401.12086) is a strategy to pick the Best-of-N as the chosen response, and Worst-of-N as a rejected response. It is shown to be effective for DPO and reward modeling.\nYou can run West-of-N using this package by setting `--num_annotations` == `--num_responses`.\n\n```\naepo dataset/alpaca_samples.csv --num_responses 8 --num_annotations 8 --num_instructions 10\n```\n\nThis command will generate a dataset with 8 responses, ranked by their rewards. If you only need the best and worst of the N samples, then use `--west_of_n` option.\n\n```\naepo dataset/alpaca_samples.csv --num_responses 8 --num_annotations 8 --num_instructions 10 --west_of_n\n```\n\nThis will pick the best and worst responses as the chosen and rejected. The rest of the responses are discarded.\nIt would be useful to construct a pairwise preference dataset.\n\n## Reference\n\n[Jinnai, Y., Honda, U. (2024). Annotation-Efficient Preference Optimization for Language Model Alignment. arXiv preprint arXiv:2405.13541.](https://arxiv.org/abs/2405.13541)\n\n\nBibtex:\n\n```\n@misc{jinnai2024annotationefficient,\n      title={Annotation-Efficient Preference Optimization for Language Model Alignment}, \n      author={Yuu Jinnai and Ukyo Honda},\n      year={2024},\n      eprint={2405.13541},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n## Contact\nFor any questions, feel free to raise an issue or contact me at jinnai_yu@cyberagent.co.jp.\n\n## Acknowledgements\n[AlpacaFarm dataset](https://github.com/tatsu-lab/alpaca_farm) is licensed under [Attribution-NonCommercial 4.0 International](https://github.com/tatsu-lab/alpaca_farm/blob/main/DATA_LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberagentailab%2Fannotation-efficient-po","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberagentailab%2Fannotation-efficient-po","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberagentailab%2Fannotation-efficient-po/lists"}