当前位置: 首页 > news >正文

open-instruct - 训练开放式指令跟随语言模型

在这里插入图片描述

文章目录

    • 关于 open-instruct
    • 设置
    • 训练
      • 微调
      • 偏好调整
      • RLVR
    • 污染检查
      • 开发中
      • 仓库结构
    • 致谢


关于 open-instruct

  • github : https://github.com/allenai/open-instruct

这个仓库是我们对在公共数据集上对流行的预训练语言模型进行指令微调的开放努力。我们发布这个仓库,并将持续更新它,包括:

  1. 使用最新技术和指令数据集统一格式微调语言模型的代码。
  2. 在一系列基准上运行标准评估的代码,旨在针对这些语言模型的多种能力。
  3. 我们在探索中构建的检查点或其他有用的工件。

请参阅我们的第一篇论文
How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resources
关于这个项目背后的更多想法以及我们的初步发现,请参阅我们的第二篇论文。
Camels in a Changing Climate: Enhancing LM Adaptation with Tulu 2
关于使用Llama-2模型和直接偏好优化的结果。我们仍在开发更多模型。有关涉及PPO和DPO的更近期的结果,请参阅我们的第三篇论文
Unpacking DPO and PPO: Disentangling Best Practices for Learning from Preference Feedback


设置

我们的设置大部分遵循我们的
Dockerfile
, 使用 Python 3.10。注意,Open Instruct 是一个研究代码库,不保证向后兼容性。 我们提供两种安装策略:

  • 本地安装:这是推荐安装 Open Instruct 的方式。您可以通过运行以下命令安装依赖项:
pip install --upgrade pip "setuptools<70.0.0" wheel 
# TODO, unpin setuptools when this issue in flash attention is resolved
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121
pip install packaging
pip install flash-attn==2.6.3 --no-build-isolation
pip install -r requirements.txt
python -m nltk.downloader punkt
pip install -e .

  • Docker 安装: 您也可以使用 Dockerfile 来构建 Docker 镜像。您可以使用以下命令来构建镜像:
docker build --build-arg CUDA=12.1.0 --build-arg TARGET=cudnn8-devel --build-arg DIST=ubuntu20.04 . -t open_instruct_dev
# if you are interally at AI2, you can create an image like this:
beaker image delete $(whoami)/open_instruct_dev 
beaker image create open_instruct_dev -n open_instruct_dev -w ai2/$(whoami)

如果您在 AI2 内部,您可以使用我们始终最新的自动构建镜像来启动实验:nathanl/open_instruct_auto


训练

设置好环境后,您就可以开始一些实验了。我们在下面提供了一些示例。要了解有关如何重现Tulu 3模型的更多信息,请参阅Tulu 3自述文件。Tulu 1和Tulu 2的说明和文档在Tulu 1和2自述文件中。


微调

您可以使用以下命令开始:

# quick debugging run using 1 GPU
sh scripts/finetune_with_accelerate_config.sh 1 configs/train_configs/sft/mini.yaml
# train an 8B tulu3 model using 8 GPU
sh scripts/finetune_with_accelerate_config.sh 8 configs/train_configs/tulu3/tulu3_sft.yaml

偏好调整

# quick debugging run using 1 GPU
sh scripts/dpo_train_with_accelerate_config.sh 1 configs/train_configs/dpo/mini.yaml
# train an 8B tulu3 model using 8 GPU
sh scripts/finetune_with_accelerate_config.sh 8 configs/train_configs/tulu3/tulu3_dpo_8b.yaml

RLVR

# quick debugging run using 2 GPU (1 for inference, 1 for training)
# here we are using `HuggingFaceTB/SmolLM2-360M-Instruct`; it's prob not
# gonna work, but it's easy to test run and print stuff.
python open_instruct/ppo_vllm_thread_ray_gtrl.py \--dataset_mixer '{"ai2-adapt-dev/gsm8k_math_ifeval_ground_truth_mixed": 1.0}' \--dataset_train_splits train \--dataset_eval_mixer '{"ai2-adapt-dev/gsm8k_math_ground_truth": 1.0}' \--dataset_eval_splits test \--max_token_length 2048 \--max_prompt_token_length 2048 \--response_length 2048 \--model_name_or_path HuggingFaceTB/SmolLM2-360M-Instruct \--reward_model_path HuggingFaceTB/SmolLM2-360M-Instruct \--non_stop_penalty \--stop_token eos \--temperature 1.0 \--ground_truths_key ground_truth \--chat_template tulu \--sft_messages_key messages \--learning_rate 3e-7 \--total_episodes 10000 \--penalty_reward_value -10.0 \--deepspeed_stage 3 \--per_device_train_batch_size 2 \--local_rollout_forward_batch_size 2 \--local_mini_batch_size 32 \--local_rollout_batch_size 32 \--num_epochs 1 \--actor_num_gpus_per_node 1 \--vllm_tensor_parallel_size 1 \--beta 0.05 \--apply_verifiable_reward true \--output_dir output/rlvr_1b \--seed 3 \--num_evals 3 \--save_freq 100 \--reward_model_multiplier 0.0 \--gradient_checkpointing \--with_tracking# train an 8B tulu3 model using 8 GPU (1 for inference, 7 for training)
python open_instruct/ppo_vllm_thread_ray_gtrl.py \--dataset_mixer '{"ai2-adapt-dev/gsm8k_math_ifeval_ground_truth_mixed": 1.0}' \--dataset_train_splits train \--dataset_eval_mixer '{"ai2-adapt-dev/gsm8k_math_ground_truth": 1.0}' \--dataset_eval_splits test \--max_token_length 2048 \--max_prompt_token_length 2048 \--response_length 2048 \--model_name_or_path allenai/Llama-3.1-Tulu-3-8B-DPO \--reward_model_path allenai/Llama-3.1-Tulu-3-8B-RM \--non_stop_penalty \--stop_token eos \--temperature 1.0 \--ground_truths_key ground_truth \--chat_template tulu \--sft_messages_key messages \--learning_rate 3e-7 \--total_episodes 10000000 \--penalty_reward_value -10.0 \--deepspeed_stage 3 \--per_device_train_batch_size 2 \--local_rollout_forward_batch_size 2 \--local_mini_batch_size 32 \--local_rollout_batch_size 32 \--actor_num_gpus_per_node 7 \--vllm_tensor_parallel_size 1 \--beta 0.05 \--apply_verifiable_reward true \--output_dir output/rlvr_8b \--seed 3 \--num_evals 3 \--save_freq 100 \--reward_model_multiplier 0.0 \--gradient_checkpointing \--with_tracking

污染检查

我们发布了用于测量指令调整数据集和评估数据集之间重叠的脚本./decontamination。有关更多详细信息,请参阅自述文件。


开发中

当向此仓库提交PR时,我们使用以下方式检查open_instruct/中的核心代码样式:

make style
make quality

仓库结构

├── assets/                     <- Images, licenses, etc.
├── configs/                    
| ├── beaker_configs/       <- AI2 Beaker configs
| ├── ds_configs/           <- DeepSpeed configs
| └── train_configs/        <- Training configs
├── decontamination/            <- Scripts for measuring train-eval overlap
├── eval/                       <- Evaluation suite for fine-tuned models
├── human_eval/                 <- Human evaluation interface (not maintained)
├── open_instruct/              <- Source code (flat)
├── quantize/                   <- Scripts for quantization
├── scripts/                    <- Core training and evaluation scripts
└── Dockerfile                  <- Dockerfile

致谢

Open Instruct 是一个受益于许多开源项目和库的项目。我们特别感谢以下项目:

  • HuggingFace Transformers : 我们为微调脚本适配了 Hugging Face 的 Trainer。
  • HuggingFace TRL 和 eric-mitchell/direct-preference-optimization : 我们的偏好调整代码改编自 TRL 和 Eric Mitchell 的 DPO 代码。
  • OpenAI 的 lm-human-preferences, summarize-from-feedback, 和vwxyzjn/summarize_from_feedback_details : 我们的核心PPO代码是从OpenAI的原始RLHF代码改编而来。
    Huang et al (2024)'s reproduction work 关于OpenAI的基于反馈的总结工作的内容。
  • OpenRLHF : 我们将 OpenRLHF 的 Ray + vLLM 分布式代码进行了适配,以扩展 PPO RLVR 训练至 70B 规模。

http://www.lryc.cn/news/493437.html

相关文章:

  • DI依赖注入详解
  • TDengine在debian安装
  • 【C#设计模式(15)——命令模式(Command Pattern)】
  • XGBoost库介绍:提升机器学习模型的性能
  • 网络安全构成要素
  • SpringMVC——SSM整合
  • Windows系统电脑安装TightVNC服务端结合内网穿透实现异地远程桌面
  • 【ubuntu24.04】GTX4700 配置安装cuda
  • Spring Boot 动态数据源切换
  • MySQL技巧之跨服务器数据查询:进阶篇-从A服务器的MySQ数据库复制到B服务器的SQL Server数据库的表中
  • 大语言模型LLM的微调中 QA 转换的小工具 xlsx2json.py
  • CFD 在生物反应器放大过程中的作用
  • Axios与FastAPI结合:构建并请求用户增删改查接口
  • 美畅物联丨如何通过ffmpeg排查视频问题
  • 基于OpenCV视觉库让机械手根据视觉判断物体有无和分类抓取的例程
  • QChart数据可视化
  • 转换的艺术:如何在JavaScript中序列化Set为Array、Object及逆向操作
  • 万能门店小程序管理系统存在前台任意文件上传漏洞
  • 详解Rust泛型用法
  • 移远通信携手紫光展锐,以“5G+算力”共绘万物智联新蓝图
  • Mybatis:Mybatis快速入门
  • 微信小程序用户登录页面制作教程
  • python+django自动化平台(一键执行sql) 前端vue-element展示
  • JavaScript学习总结
  • Python 3 教程第22篇(数据结构)
  • AI时代的软件工程:迎接LLM-DevOps的新纪元
  • linux安全管理-系统环境安全
  • MindAgent部署(进行中.....)
  • 【JavaEE初阶 — 网络编程】TCP流套接字编程
  • 《气候变化研究进展》