[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-uclaml--SPPO":3,"tool-uclaml--SPPO":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":80,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":92,"forks":93,"last_commit_at":94,"license":95,"difficulty_score":10,"env_os":96,"env_gpu":97,"env_ram":98,"env_deps":99,"category_tags":105,"github_topics":106,"view_count":10,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":112,"updated_at":113,"faqs":114,"releases":144},905,"uclaml\u002FSPPO","SPPO","The official implementation of Self-Play Preference Optimization (SPPO)","SPPO是一个用于语言模型对齐的开源自我博弈偏好优化框架。它通过让模型与自身的历史版本进行博弈，学习优化响应偏好，从而提升模型在对话、指令跟随等方面的表现。该方法不需要依赖GPT-4等外部强信号的偏好数据，仅依靠模型自身生成的数据进行迭代优化。\n\n它主要解决了语言模型对齐过程中对高质量人类偏好数据依赖性强、成本高的问题，提供了一种更高效且理论上有收敛保证的优化途径。实验表明，基于SPPO微调的模型在AlpacaEval 2.0等基准上能显著超越原始基础模型以及使用DPO等方法训练的模型。\n\n该工具主要面向人工智能领域的研究人员和开发者，特别是那些从事大语言模型训练、对齐优化或强化学习应用的团队。它也适合对模型自我改进机制感兴趣的高级实践者进行实验和探索。\n\nSPPO的核心技术亮点在于其自我博弈框架和相应的SPPO损失函数，该框架理论上能确保模型在一般性（可能非传递性）的偏好设定下收敛至冯·诺依曼优胜者（即纳什均衡）。项目已提供了基于Mistral-7B和Llama-3-8B等模型的多轮迭代训练版本，方便社区直接使用或进一步研究。","\n# SPPO: Self-Play Preference Optimization for Language Model Alignment\n\n![Mistral-7B-Instruct](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel-Mistral--7B--Instruct--v0.2-green) ![Llama-3-8B-Instruct](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel-Llama--3--8B--Instruct-green) ![AlpacaEval 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-AlpacaEval_2.0-red\n) ![Open LLM](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-Open_LLM_Leaderboard-red) ![MT-Bench](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-MT--Bench-red)\n\nThis repository contains the official code and released models for the paper [Self-Play Preference Optimization for Language Model Alignment](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675).\n\nAuthors: [Yue Wu](https:\u002F\u002Fyuewu.us\u002F)\\*, [Zhiqing Sun](https:\u002F\u002Fwww.cs.cmu.edu\u002F~zhiqings\u002F)\\*, [Huizhuo Yuan](https:\u002F\u002Fscholar.google.com\u002Fcitations?user=8foZzX4AAAAJ)\\*, [Kaixuan Ji](https:\u002F\u002Fscholar.google.com\u002Fcitations?user=FOoKDukAAAAJ), [Yiming Yang](https:\u002F\u002Fwww.cs.cmu.edu\u002F~yiming\u002F), [Quanquan Gu](https:\u002F\u002Fweb.cs.ucla.edu\u002F~qgu\u002F)\n\n[[Webpage](https:\u002F\u002Fuclaml.github.io\u002FSPPO\u002F)] [[Huggingface](https:\u002F\u002Fhuggingface.co\u002Fpapers\u002F2405.00675)] [[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675)]\n\n\n## 🔔 News\n- **[01\u002F22\u002F2025]** SPPO has been accepted by ICLR2025!\n- **[06\u002F29\u002F2024]** We released [Gemma-2-9B-It-SPPO-Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3) trained upon [gemma-2-9b-it](https:\u002F\u002Fhuggingface.co\u002Fgoogle\u002Fgemma-2-9b-it), AlpacaEval 2.0 LC-win rate reached 53.27.\n- **[06\u002F25\u002F2024]** Our code is open-sourced!\n- **[05\u002F01\u002F2024]** Our paper is released on arXiv: https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675.\n\n## Table of Content\n\n- [About SPPO](#about-sppo)\n- [Released Models](#released-models)\n- [Environment Setup](#environment-setup)\n- [Training Scripts](#training-scripts)\n- [Evaluation](#evaluation)\n- [Troubleshoot](#troubleshoot)\n- [Citation](#citation)\n- [Acknowledgements](#acknowledgements)\n\n## About SPPO\nWe propose a new self-play framework dubbed SPPO for language model alignment and a new learning objective (called SPPO loss) derived from the self-play framework to fine-tune large language models efficiently.\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fuclaml_SPPO_readme_e55cf636fd41.png\" width=\"65%\"> \u003Cbr>\n  AlpacaEval 2.0 leaderboard results of normal and length-controlled (LC) win rates in percentage (\\%). Mistral-7B-SPPO can outperform larger models and Mistral-7B-SPPO (best-of-16) can outperform proprietary models such as GPT-4(6\u002F13). Llama-3-8B-SPPO exhibits even better performance.\n\u003C\u002Fp>\n\n\nSPPO can significantly enhance the performance of an LLM without strong external signals such as responses or preferences from GPT-4.  It can outperform the model trained with iterative direct preference optimization (DPO), among other methods. SPPO is theoretically grounded, ensuring that the LLM can converge to the von Neumann winner (i.e., Nash equilibrium) under general, potentially intransitive preference, and empirically validated through extensive evaluations on multiple datasets.\n\nFor more details, you can check our paper [here](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675).\n\n\n## Base Models and Released Models\n\n| Model  | AlpacaEval2.0 LC Win Rate | AlpacaEval2.0 Win Rate |\n| :--- | :---: | :---: |\n|🤗[Mistral-7B-Instruct-v0.2](https:\u002F\u002Fhuggingface.co\u002Fmistralai\u002FMistral-7B-Instruct-v0.2)  | 17.11 | 14.72 |\n|🤗[Mistral-7B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter1) |24.79 | 23.51|\n|🤗[Mistral-7B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter2) |26.89 |27.62 |\n|🤗[Mistral-7B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter3) |28.53 |31.02|\n|🤗[Llama-3-8B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3-8B-Instruct) |22.92 |22.57 |\n|🤗[Llama-3-8B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter1) |31.73 |31.74 |\n|🤗[Llama-3-8B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter2) |35.15 |35.98 |\n|🤗[Llama-3-8B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter3) |38.77 |39.85 |\n|🤗[Gemma-2-9B-It](https:\u002F\u002Fhuggingface.co\u002Fgoogle\u002Fgemma-2-9b-it) |45.08 |35.62 |\n|🤗[Gemma-2-9B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter1) |48.70 |40.76 |\n|🤗[Gemma-2-9B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter2) |50.93 | 44.64 |\n|🤗[Gemma-2-9B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3) |**53.27** |**47.74** |\n\n\n## Environment Setup\nOur training code is based on the alignment-handbook codebase. We utilize `vllm` for generation and `pairRM` for ranking. Follow the steps below to set up your environment:\n\n1. **Create a Virtual Environment:**\n\n   ```bash\n   conda create -n sppo python=3.10\n   conda activate sppo\n   ```\n\n2. **Install vllm for Generation:**\n   ```bash\n   pip install vllm\n   ```\n\n3. **Install PairRM:**\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fyuchenlin\u002FLLM-Blender.git\n   cd LLM-Blender\n   pip install -e .\n   ```\n\n4. **Download and Install Training Dependencies:**\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO.git\n   cd SPPO\n   pip install -e .\n   ```\n\n## Training Scripts\nExecute the training scripts based on the base model you choose:\n\n- For **Mistral-7B-Instruct-v0.2**:\n  ```bash\n  bash run_sppo_mistral.sh\n  ```\n\n- For **Llama-3-8B-Instruct**:\n  ```bash\n  bash run_sppo_llama-3.sh\n  ```\n\nThese scripts manage the training iterations, generation, and PairRM ranking processes. Note that some scripts may attempt to push datasets to the Hugging Face Hub under the UCLA-AGI organization. Ensure you have write access, or modify the organization name accordingly, or comment out any `push_to_hub` commands if necessary. Detailed scripts for each component are listed as follows:\n\n### Breakdown of Scripts:\n1. **Generation:**\n   ```bash\n   python scripts\u002Fgenerate.py --model $MODEL --maxlen 2048 --output_dir $OUTPUT_DIR --prompts $PROMPTS\n   ```\nMain parameters:\n- `model`: Specifies the model used for generation. In the first iteration, the model should be either `mistralai\u002FMistral-7B-Instruct-v0.2` or `meta-llama\u002FMeta-Llama-3-8B-Instruct`.\n- `maxlen`: Sets the token length for generation, defining the maximum number of tokens generated.\n- `pairs`: Determines the number of generated samples per prompt, with a default setting of 5. Please note that changing this number is not supported by the overall pipeline.\n- `output_dir`: Specifies the directory paths for saving intermediate results.\n- `prompts`: Defines the set of prompts used for generation.\n- `frac_len`: Enables the operation of vllm on multiple GPUs by dividing prompts into different fractions. `frac_len` defines the number of prompts in each fraction. For usage examples, see `generate.sh`.\n- `data_frac`: Used in conjunction with `frac_len` for multi-GPU setups, `data_frac` indicates which fraction of the data the current GPU is processing. Refer to `generate.sh` for more details.\n\n\n2. **Ranking:**\n   ```bash\n   python scripts\u002Frank.py --output_dir $OUTPUT_DIR --prompts $PROMPTS\n   ```\nMain Parameters:\n- `output_dir`: Specifies the directory paths where intermediate results are saved. Note that the default script attempts to push datasets to Hugging Face under the UCLA-AGI organization. You may need to adjust this to your organization, obtain write access for UCLA-AGI, or disable the `push_to_hub` command if necessary.\n- `pairs`: Sets the number of generated samples per prompt, with a default of 5. Please note that other numbers are not supported by the overall pipeline.\n- `frac_len`: This parameter is used to enable the use of PairRM on multiple GPUs by dividing prompts into different fractions. `frac_len` determines the number of prompts in each fraction. For usage examples, refer to `generate.sh`.\n- `data_frac`: Similar to `frac_len`, this option is used for running PairRM on multiple GPUs. It specifies which fraction of the data the current GPU is processing. See `generate.sh` for examples.\n- `prompts`: Defines the set of prompts used for generation.\n- `gpu`: Indicates the GPU index used for ranking; it should match the `data_frac` parameter.\n\n3. **Training:**\n   ```bash\n   bash scripts\u002Fpipeline.sh --model $MODEL --iter $ITER --dataset $DATASET --output_dir $OUTPUT_DIR --num 1\n   ```\nMain Parameters:\n- model: The base model for training.\n- dataset: The dataset used for training.\n- output_dir: The name of the output model.\n- num: The number of training epochs.\n\n## Evaluation\nWe adhere to the established guidelines for evaluation and utilize the following repositories:\n- [AlpacaEval 2](https:\u002F\u002Fgithub.com\u002Ftatsu-lab\u002Falpaca_eval)\n- [MT-Bench](https:\u002F\u002Fgithub.com\u002Flm-sys\u002FFastChat\u002Ftree\u002Fmain\u002Ffastchat\u002Fllm_judge)\n- [HuggingFace Open LLM Leaderboard](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fopen-llm-leaderboard\u002Fopen_llm_leaderboard)\n\nWe provide the model configurations used during AlpacaEval 2 in the `models_configs` directory. Please note that after the initial release of our model, we retrained it using a slightly modified prompt. The win rates observed post-retraining are comparable to the original results.\n\n\n## Troubleshoot\nFor questions related to the paper, please contact the authors via email. If you encounter any issues with the code or wish to report a bug, feel free to open an issue on our GitHub repository.\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fuclaml_SPPO_readme_2d5ea05abc16.png)](https:\u002F\u002Fstar-history.com\u002F#uclaml\u002FSPPO&Date)\n\n## Citation\n\n```\n@article{wu2024self,\n  title={Self-play preference optimization for language model alignment},\n  author={Wu, Yue and Sun, Zhiqing and Yuan, Huizhuo and Ji, Kaixuan and Yang, Yiming and Gu, Quanquan},\n  year={2024}\n}\n```\n\n## Acknowledgements\n\nWe thank the authors of [The Alignment Handbook](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Falignment-handbook) for their foundational contributions to the training code. We also acknowledge the use of [PairRM](https:\u002F\u002Fgithub.com\u002Fyuchenlin\u002FLLM-Blender) for ranking and [vllm](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm) for generation.\n","# SPPO：语言模型对齐的自博弈偏好优化\n\n![Mistral-7B-Instruct](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel-Mistral--7B--Instruct--v0.2-green) ![Llama-3-8B-Instruct](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel-Llama--3--8B--Instruct-green) ![AlpacaEval 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-AlpacaEval_2.0-red\n) ![Open LLM](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-Open_LLM_Leaderboard-red) ![MT-Bench](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTask-MT--Bench-red)\n\n本仓库包含论文 [Self-Play Preference Optimization for Language Model Alignment](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675) 的官方代码和已发布的模型。\n\n作者：[Yue Wu](https:\u002F\u002Fyuewu.us\u002F)\\*, [Zhiqing Sun](https:\u002F\u002Fwww.cs.cmu.edu\u002F~zhiqings\u002F)\\*, [Huizhuo Yuan](https:\u002F\u002Fscholar.google.com\u002Fcitations?user=8foZzX4AAAAJ)\\*, [Kaixuan Ji](https:\u002F\u002Fscholar.google.com\u002Fcitations?user=FOoKDukAAAAJ), [Yiming Yang](https:\u002F\u002Fwww.cs.cmu.edu\u002F~yiming\u002F), [Quanquan Gu](https:\u002F\u002Fweb.cs.ucla.edu\u002F~qgu\u002F)\n\n[[项目主页](https:\u002F\u002Fuclaml.github.io\u002FSPPO\u002F)] [[Huggingface](https:\u002F\u002Fhuggingface.co\u002Fpapers\u002F2405.00675)] [[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675)]\n\n## 🔔 新闻\n- **[2025年1月22日]** SPPO 已被 ICLR 2025 接收！\n- **[2024年6月29日]** 我们发布了基于 [gemma-2-9b-it](https:\u002F\u002Fhuggingface.co\u002Fgoogle\u002Fgemma-2-9b-it) 训练的 [Gemma-2-9B-It-SPPO-Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3)，其在 AlpacaEval 2.0 LC 上的胜率达到 53.27。\n- **[2024年6月25日]** 我们的代码已开源！\n- **[2024年5月1日]** 我们的论文已在 arXiv 上发布：https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675。\n\n## 目录\n\n- [关于 SPPO](#关于-sppo)\n- [已发布模型](#已发布模型)\n- [环境设置](#环境设置)\n- [训练脚本](#训练脚本)\n- [评估](#评估)\n- [故障排除](#故障排除)\n- [引用](#引用)\n- [致谢](#致谢)\n\n## 关于 SPPO\n我们提出了一个名为 SPPO 的新自博弈框架，用于语言模型对齐，以及一个从该自博弈框架推导出的新学习目标（称为 SPPO 损失），以高效微调大型语言模型。\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fuclaml_SPPO_readme_e55cf636fd41.png\" width=\"65%\"> \u003Cbr>\n  AlpacaEval 2.0 排行榜结果，展示了正常和长度控制（LC）胜率的百分比（%）。Mistral-7B-SPPO 可以超越更大的模型，而 Mistral-7B-SPPO（best-of-16）可以超越 GPT-4（6\u002F13）等专有模型。Llama-3-8B-SPPO 表现出更佳的性能。\n\u003C\u002Fp>\n\nSPPO 可以在没有强大外部信号（如来自 GPT-4 的响应或偏好）的情况下，显著提升 LLM 的性能。它能够超越使用迭代直接偏好优化（DPO）等方法训练的模型。SPPO 具有理论依据，确保 LLM 在一般的、可能非传递性的偏好下能够收敛到冯·诺依曼赢家（即纳什均衡），并通过在多个数据集上的广泛评估进行了实证验证。\n\n更多细节，请查看我们的[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.00675)。\n\n## 基础模型与已发布模型\n\n| 模型 | AlpacaEval2.0 LC 胜率 | AlpacaEval2.0 胜率 |\n| :--- | :---: | :---: |\n|🤗[Mistral-7B-Instruct-v0.2](https:\u002F\u002Fhuggingface.co\u002Fmistralai\u002FMistral-7B-Instruct-v0.2) | 17.11 | 14.72 |\n|🤗[Mistral-7B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter1) | 24.79 | 23.51 |\n|🤗[Mistral-7B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter2) | 26.89 | 27.62 |\n|🤗[Mistral-7B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FMistral7B-PairRM-SPPO-Iter3) | 28.53 | 31.02 |\n|🤗[Llama-3-8B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3-8B-Instruct) | 22.92 | 22.57 |\n|🤗[Llama-3-8B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter1) | 31.73 | 31.74 |\n|🤗[Llama-3-8B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter2) | 35.15 | 35.98 |\n|🤗[Llama-3-8B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FLlama-3-Instruct-8B-SPPO-Iter3) | 38.77 | 39.85 |\n|🤗[Gemma-2-9B-It](https:\u002F\u002Fhuggingface.co\u002Fgoogle\u002Fgemma-2-9b-it) | 45.08 | 35.62 |\n|🤗[Gemma-2-9B-SPPO Iter1](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter1) | 48.70 | 40.76 |\n|🤗[Gemma-2-9B-SPPO Iter2](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter2) | 50.93 | 44.64 |\n|🤗[Gemma-2-9B-SPPO Iter3](https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3) | **53.27** | **47.74** |\n\n## 环境设置\n我们的训练代码基于 alignment-handbook 代码库。我们使用 `vllm` 进行生成，使用 `pairRM` 进行排序。请按照以下步骤设置您的环境：\n\n1. **创建虚拟环境：**\n\n   ```bash\n   conda create -n sppo python=3.10\n   conda activate sppo\n   ```\n\n2. **安装用于生成的 vllm：**\n   ```bash\n   pip install vllm\n   ```\n\n3. **安装 PairRM：**\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fyuchenlin\u002FLLM-Blender.git\n   cd LLM-Blender\n   pip install -e .\n   ```\n\n4. **下载并安装训练依赖项：**\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO.git\n   cd SPPO\n   pip install -e .\n   ```\n\n## 训练脚本\n根据您选择的基础模型执行相应的训练脚本：\n\n- 对于 **Mistral-7B-Instruct-v0.2**：\n  ```bash\n  bash run_sppo_mistral.sh\n  ```\n\n- 对于 **Llama-3-8B-Instruct**：\n  ```bash\n  bash run_sppo_llama-3.sh\n  ```\n\n这些脚本管理训练迭代、生成和 PairRM 排序过程。请注意，某些脚本可能会尝试将数据集推送到 Hugging Face Hub 上的 UCLA-AGI 组织。请确保您有写入权限，或相应地修改组织名称，或者在必要时注释掉任何 `push_to_hub` 命令。每个组件的详细脚本如下：\n\n### 脚本功能分解：\n\n1. **生成（Generation）**：\n   ```bash\n   python scripts\u002Fgenerate.py --model $MODEL --maxlen 2048 --output_dir $OUTPUT_DIR --prompts $PROMPTS\n   ```\n   主要参数：\n   - `model`：指定用于生成的模型。在第一次迭代中，模型应为 `mistralai\u002FMistral-7B-Instruct-v0.2` 或 `meta-llama\u002FMeta-Llama-3-8B-Instruct`。\n   - `maxlen`：设置生成的最大令牌长度，定义了生成令牌的最大数量。\n   - `pairs`：决定每个提示（prompt）生成的样本数量，默认设置为 5。请注意，整个流程不支持更改此数字。\n   - `output_dir`：指定保存中间结果的目录路径。\n   - `prompts`：定义用于生成的提示集合。\n   - `frac_len`：通过将提示分成不同的部分，使 vllm 能够在多个 GPU 上运行。`frac_len` 定义了每个部分中的提示数量。使用示例请参见 `generate.sh`。\n   - `data_frac`：与 `frac_len` 配合用于多 GPU 设置，`data_frac` 表示当前 GPU 正在处理的数据部分。更多详情请参考 `generate.sh`。\n\n2. **排序（Ranking）**：\n   ```bash\n   python scripts\u002Frank.py --output_dir $OUTPUT_DIR --prompts $PROMPTS\n   ```\n   主要参数：\n   - `output_dir`：指定保存中间结果的目录路径。请注意，默认脚本会尝试将数据集推送到 Hugging Face 的 UCLA-AGI 组织下。您可能需要将其调整为您自己的组织、获取 UCLA-AGI 的写入权限，或在必要时禁用 `push_to_hub` 命令。\n   - `pairs`：设置每个提示生成的样本数量，默认为 5。请注意，整个流程不支持其他数字。\n   - `frac_len`：此参数用于通过将提示分成不同的部分，使 PairRM 能够在多个 GPU 上运行。`frac_len` 决定了每个部分中的提示数量。使用示例请参考 `generate.sh`。\n   - `data_frac`：与 `frac_len` 类似，此选项用于在多个 GPU 上运行 PairRM。它指定当前 GPU 正在处理的数据部分。示例请参见 `generate.sh`。\n   - `prompts`：定义用于生成的提示集合。\n   - `gpu`：指示用于排序的 GPU 索引；它应与 `data_frac` 参数匹配。\n\n3. **训练（Training）**：\n   ```bash\n   bash scripts\u002Fpipeline.sh --model $MODEL --iter $ITER --dataset $DATASET --output_dir $OUTPUT_DIR --num 1\n   ```\n   主要参数：\n   - model：用于训练的基础模型。\n   - dataset：用于训练的数据集。\n   - output_dir：输出模型的名称。\n   - num：训练的轮数（epochs）。\n\n## 评估（Evaluation）\n我们遵循既定的评估指南，并使用了以下代码库：\n- [AlpacaEval 2](https:\u002F\u002Fgithub.com\u002Ftatsu-lab\u002Falpaca_eval)\n- [MT-Bench](https:\u002F\u002Fgithub.com\u002Flm-sys\u002FFastChat\u002Ftree\u002Fmain\u002Ffastchat\u002Fllm_judge)\n- [HuggingFace Open LLM 排行榜](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fopen-llm-leaderboard\u002Fopen_llm_leaderboard)\n\n我们在 `models_configs` 目录中提供了在 AlpacaEval 2 期间使用的模型配置。请注意，在我们的模型首次发布后，我们使用略微修改的提示对其进行了重新训练。重新训练后观察到的胜率与原始结果相当。\n\n## 故障排除（Troubleshoot）\n有关论文的问题，请通过电子邮件联系作者。如果您在代码中遇到任何问题或希望报告错误，请随时在我们的 GitHub 仓库中提交问题（issue）。\n\n## 星标历史（Star History）\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fuclaml_SPPO_readme_2d5ea05abc16.png)](https:\u002F\u002Fstar-history.com\u002F#uclaml\u002FSPPO&Date)\n\n## 引用（Citation）\n\n```\n@article{wu2024self,\n  title={Self-play preference optimization for language model alignment},\n  author={Wu, Yue and Sun, Zhiqing and Yuan, Huizhuo and Ji, Kaixuan and Yang, Yiming and Gu, Quanquan},\n  year={2024}\n}\n```\n\n## 致谢（Acknowledgements）\n\n我们感谢 [The Alignment Handbook](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Falignment-handbook) 的作者对训练代码的基础性贡献。我们也感谢使用 [PairRM](https:\u002F\u002Fgithub.com\u002Fyuchenlin\u002FLLM-Blender) 进行排序以及使用 [vllm](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm) 进行生成。","# SPPO 快速上手指南\n\nSPPO（Self-Play Preference Optimization）是一种用于语言模型对齐的自博弈偏好优化方法。本指南将帮助您快速搭建环境并运行 SPPO。\n\n## 环境准备\n\n- **操作系统**: Linux (推荐 Ubuntu 20.04 或更高版本)\n- **Python**: 3.10\n- **包管理器**: pip, conda (可选，用于创建虚拟环境)\n- **硬件**: 支持 CUDA 的 NVIDIA GPU (建议显存 >= 24GB 以运行 7B\u002F8B 模型)\n- **网络**: 可访问 Hugging Face 和 GitHub (建议配置国内镜像源以加速下载)\n\n## 安装步骤\n\n1.  **创建并激活虚拟环境 (推荐使用 conda):**\n    ```bash\n    conda create -n sppo python=3.10\n    conda activate sppo\n    ```\n\n2.  **安装 vLLM (用于高效推理生成):**\n    ```bash\n    pip install vllm\n    ```\n\n3.  **安装 PairRM (用于响应排序):**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fyuchenlin\u002FLLM-Blender.git\n    cd LLM-Blender\n    pip install -e .\n    cd ..\n    ```\n\n4.  **下载 SPPO 代码库并安装训练依赖:**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO.git\n    cd SPPO\n    pip install -e .\n    ```\n\n**国内加速建议**:\n- 在运行 `pip install` 前，可设置 PyPI 镜像源，例如：\n  ```bash\n  pip config set global.index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n  ```\n- 如需加速 `git clone`，可使用 `ghproxy.com` 等代理服务。\n\n## 基本使用\n\n以下以使用 **Mistral-7B-Instruct-v0.2** 作为基础模型为例，展示如何启动一轮完整的 SPPO 训练流程。\n\n1.  **进入项目目录:**\n    ```bash\n    cd SPPO\n    ```\n\n2.  **运行训练脚本:**\n    执行以下命令将自动进行数据生成、PairRM 排序和模型训练：\n    ```bash\n    bash run_sppo_mistral.sh\n    ```\n    *注意：首次运行会下载基础模型和数据集，请确保网络通畅。脚本默认配置可能尝试将数据推送至 Hugging Face Hub，如无权限可注释掉相关 `push_to_hub` 命令。*\n\n3.  **（可选）分步执行:**\n    您也可以手动执行核心步骤：\n    - **生成响应**:\n      ```bash\n      python scripts\u002Fgenerate.py --model mistralai\u002FMistral-7B-Instruct-v0.2 --maxlen 2048 --output_dir .\u002Foutput --prompts .\u002Fdata\u002Fprompts.jsonl\n      ```\n    - **使用 PairRM 排序**:\n      ```bash\n      python scripts\u002Frank.py --output_dir .\u002Foutput --prompts .\u002Fdata\u002Fprompts.jsonl\n      ```\n    - **训练模型**:\n      ```bash\n      bash scripts\u002Fpipeline.sh --model mistralai\u002FMistral-7B-Instruct-v0.2 --iter 1 --dataset .\u002Foutput\u002Franked_data --output_dir .\u002Fsppo_model --num 1\n      ```\n\n训练完成后，模型将保存在指定的 `output_dir` 中，您可以使用类似 `transformers` 库的方式加载和使用它。","一家AI创业公司的算法团队正在开发一款智能客服助手，他们基于开源的Llama-3-8B-Instruct模型进行微调，希望它能更流畅、更贴切地处理用户的开放式咨询，从而替代部分人工客服。\n\n### 没有 SPPO 时\n- **回复质量不稳定**：模型有时能给出专业回答，但有时又会生成冗长、重复或略微偏离核心问题的内容，需要人工设定大量规则和后处理逻辑来“兜底”。\n- **难以把握“贴心”与“专业”的度**：对于用户情绪化的问题（如投诉），模型的回复要么过于机械冰冷，要么过度共情而显得不专业，调整提示词（Prompt）的效果时好时坏。\n- **依赖外部强反馈信号，成本高昂**：为了优化模型，团队考虑使用基于GPT-4等强大模型的反馈或人工标注偏好数据来训练，但这过程昂贵、耗时，且引入了对闭源模型的依赖。\n- **对齐优化过程复杂**：尝试使用类似DPO（直接偏好优化）的方法进行迭代时，需要精心构建成对的偏好数据，训练过程不稳定，效果提升遇到瓶颈。\n\n### 使用 SPPO 后\n- **回复质量显著且稳定提升**：经过SPPO迭代训练后，模型在AlpacaEval 2.0等基准测试上的胜率大幅提升（例如从22.92%提升至38.77%），生成的回复更一致地做到直接、准确、有用，减少了不可预测的“胡言乱语”。\n- **自主学会平衡语气与专业性**：在SPPO的自对弈框架下，模型通过自我博弈不断探索和改进策略，能够自动学习到在安抚用户情绪与提供实质性解决方案之间取得更好平衡的回应方式。\n- **摆脱对昂贵外部反馈的依赖**：SPPO的核心优势在于其自对弈机制，模型通过与自身的历史版本进行博弈来优化，无需依赖GPT-4等外部强模型的偏好数据或昂贵的人工标注，实现了更高效、低成本的对齐。\n- **提供理论保证且易于实施的优化路径**：SPPO提供了收敛性理论保证，并且其开源代码和脚本让团队能够基于已有模型（如Llama-3-8B-Instruct）直接启动迭代训练，流程清晰，效果随着迭代次数增加而稳步提升。\n\nSPPO使得该团队能够利用开源模型，以较低成本训练出一个在对话质量上接近甚至超越某些更大规模或闭源模型的智能客服核心引擎。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fuclaml_SPPO_2bce9ef6.png","uclaml","UCLA Artificial General Intelligence Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fuclaml_9c96392c.png","The artificial general intelligence lab (formerly known as statistical machine learning lab) at UCLA is led by Prof. Quanquan Gu in the computer science dept.","Department of Computer Science, UCLA",null,"http:\u002F\u002Fweb.cs.ucla.edu\u002F~qgu","https:\u002F\u002Fgithub.com\u002Fuclaml",[84,88],{"name":85,"color":86,"percentage":87},"Python","#3572A5",91.8,{"name":89,"color":90,"percentage":91},"Shell","#89e051",8.2,585,47,"2026-04-03T02:03:45","Apache-2.0","Linux","需要 NVIDIA GPU，显存未明确说明，CUDA 版本未明确说明","未说明",{"notes":100,"python":101,"dependencies":102},"1. 基于 alignment-handbook 代码库。2. 使用 vllm 进行生成，使用 PairRM 进行排序。3. 训练脚本可能尝试将数据集推送到 Hugging Face Hub，需注意权限或修改脚本。4. 支持多 GPU 运行（通过 frac_len 和 data_frac 参数）。5. 首次运行需要下载基础模型（如 Mistral-7B-Instruct-v0.2 或 Llama-3-8B-Instruct）。","3.10",[103,104],"vllm","llm-blender",[13,26],[107,108,109,110,111],"deep-learning","fine-tuning","large-language-models","rlhf","self-play","2026-03-27T02:49:30.150509","2026-04-06T05:16:57.754879",[115,120,124,129,134,139],{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},3951,"Gemma-2-9B 在安装最新 vLLM 后停止工作，如何解决？","当安装最新 vLLM 后 Gemma-2-9B 可能无法工作时，可以尝试启用 flashinfer（通过 export 设置环境变量）并安装 flashinfer 库。但请注意，启用 flashinfer 后可能会遇到并行处理失败（内存一致性错误）的问题。","https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO\u002Fissues\u002F12",{"id":121,"question_zh":122,"answer_zh":123,"source_url":119},3946,"Gemma-2-9B 的结果与论文不符，请问使用了什么数据集？","我们使用了基于 UltraFeedback 的数据集。具体来说，是 UCLA-AGI\u002Fdata-mistral-7b-instruct-sppo-iter[x] 系列。最新的 Gemma-2-9B 模型（Gemma-2-9B-It-SPPO-Iter3）已发布在 Hugging Face，LC-win 率达到 53.27。您可以在此查看：https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3。",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},3947,"SPPO 代码可以在家庭实验室（例如 2 张 RTX 4090）上运行吗？","生成（generation）阶段可以运行，但完整训练可能会失败。解决方案是使用 4-bit 量化或 QLoRA 来减少显存占用，使其能够在家庭实验室环境中运行。","https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO\u002Fissues\u002F13",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},3948,"是否有适用于 Gemma 2 9B 和 27B 的 SPPO 代码或模型？","是的，我们已发布 Gemma-2-9B 的 SPPO 微调模型。您可以在 Hugging Face 上找到：https:\u002F\u002Fhuggingface.co\u002FUCLA-AGI\u002FGemma-2-9B-It-SPPO-Iter3。该模型在 LC-win 率上达到了 53.27。","https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO\u002Fissues\u002F3",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},3949,"如何为家庭实验室（2张家用GPU）适配4-bit量化训练\u002F响应生成？","有社区成员正在为此进行适配工作。您可以关注其代码分支以获取进展和测试：https:\u002F\u002Fgithub.com\u002Fkaykyr\u002FSPPO。初步尝试显示训练已能启动（损失值有输出），这表明量化适配是可行的。","https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO\u002Fissues\u002F16",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},3950,"为什么训练代码中仍在使用 DPO Trainer，而不是论文中的 SPPO？","我们没有重命名 Trainer，因为我们代码的一个版本已经集成到 trl 库的 DPOTrainer 中，并通过指定 `loss_type` 为 `\"sppo\"` 来使用 SPPO 损失函数。因此，代码在功能上实现了 SPPO，只是沿用了 DPO Trainer 的名称。","https:\u002F\u002Fgithub.com\u002Fuclaml\u002FSPPO\u002Fissues\u002F6",[]]