docs(README): add quick start guide and update related documentation

- Add quick start guide for InternBootcamp in both English and Chinese
- Update README and README_zh to include new quick start links
- Create detailed documentation for using Xtuner with Bootcamp data
This commit is contained in:
chenyongkang 2025-06-12 21:26:49 +08:00
parent 467bf9359b
commit d2b7ff6d38
5 changed files with 208 additions and 0 deletions

74
examples/get_started.md Normal file
View file

@ -0,0 +1,74 @@
# Quick Start
**InternBootcamp** provides functionalities such as data generation, model training, and model evaluation. You can refer to the following guide to get started quickly.
To ensure successful execution of the following steps, please make sure **InternBootcamp is installed**, and **the project root directory is set as your working directory**.
## Data Generation
Run [**run\_pipeline.sh**](examples/pipelines/run_pipeline.sh) to generate training and testing data based on the [default configuration](examples/pipelines/data_configs).
For custom configurations, please refer to the [Pipeline Usage Guide](examples/pipelines/README.md) for personalized setup.
```bash
source examples/pipelines/run_pipeline.sh
```
The generated data will be saved in the [bootcamp\_generator\_outputs directory](examples/bootcamp_generator_outputs). Each data batch is timestamped, and the directory structure is as follows:
```
examples/
├── ...
└──bootcamp_generator_outputs/
├── ...
└── 2025-xx-xx-xx:xx:xx/
├── test/
│ ├── bootcamp_0.jsonl
│ ├── ...
│ └── bootcamp_n.jsonl
└── train/
├── bootcamp_0.jsonl
├── ...
└── bootcamp_n.jsonl
```
## Model Training(Reinforcement learning)
We provide support for two training frameworks: **Xpuyu** and **Verl**.
### Xpuyu
Refer to the [Xpuyu documentation](examples/xpuyu_usage/README.md) to get started with efficient training.
### Verl
To integrate Bootcamp tasks into the Verl framework for training, you need to embed the Bootcamp reward computation method into Verl.
See the [Verl documentation](examples/verl_usage/README.md) for detailed guidance.
## Model Evaluation
For Bootcamp tasks, we offer a customized evaluation service.
Once the model to be evaluated is deployed using frameworks like FastChat or Ollama, and you have the corresponding API URL and API Key, you can run the following command to evaluate your deployed model on the **InternBootcamp\_eval** dataset:
```bash
cd InternBootcamp
python examples/unittests/run_eval.py \
--url http://127.0.0.1:8000/v1 \
--api_key EMPTY \
--model_name r1_32B \
--api_mode completion \
--template r1 \
--max_tokens 32768 \
--temperature 0 \
--test_dir examples/data/InternBootcamp_eval \
--max_concurrent_requests 128 \
--timeout 6000 \
--max_retries 16 \
--max_retrying_delay 60
```
**Note:** When `api_mode` is set to `completion`, be sure to correctly specify the corresponding template (supported: `r1`, `qwen`, `internthinker`, `chatml` (with no system prompt)).
For more detailed instructions, refer to the [Evaluation Manual](examples/unittests/README.md).
---
Let me know if youd like a version with clearer formatting for publishing or documentation.

View file

@ -0,0 +1,52 @@
# 快速开始
InternBootcamp提供了数据生成、模型训练、模型评测等功能可参考如下指南快速入门。
为确保后续操作成功执行请确保您已经安装了InternBootcamp并将项目根目录设为工作目录。
## 数据生成
运行[**run_pipeline.sh**](examples/pipelines/run_pipeline.sh)即可根据[默认配置](examples/pipelines/data_configs)生成对应的测试与训练数据。若有自定义配置等需求可参考[Pipeline Usage](examples/pipelines/README_zh.md)进行个性化配置。
```bash
source examples/pipelines/run_pipeline.sh
```
生成的数据保存于[bootcamp_generator_outputs目录](examples/bootcamp_generator_outputs),数据批次以时间戳命名,具体目录结构如下
```
examples/
├── ...
└──bootcamp_generator_outputs/
├── ...
└── 2025-xx-xx-xx:xx:xx/
├── test/
│ ├── bootcamp_0.jsonl
│ ├── ...
│ └── bootcamp_n.jsonl
└── train/
├── bootcamp_0.jsonl
├── ...
└── bootcamp_n.jsonl
```
## 模型训练
我们提供了两种训练框架Xpuyu,Verl的支持体系。
### Xpuyu
可参考[Xpuyu说明文档](examples/xpuyu_usage/README_zh.md)快速进行高效训练。
### Verl
要在Verl框架下加入Bootcamp任务进行训练需要参考说明文档将bootcamp奖励计算方法嵌入verl框架具体参考[Verl说明文档](examples/verl_usage/README_zh.md)进行。
## 模型评测
我们针对bootcamp任务提供了个性化的评测服务在使用FastChat、Ollama等框架部署好待测模型并获取对应API Url 与API Key后,使用如下命令可快速评测已部署的模型在**InternBootcamp_eval**评测集上的性能:
```bash
cd InternBootcamp
python examples/unittests/run_eval.py \
--url http://127.0.0.1:8000/v1 \
--api_key EMPTY \
--model_name r1_32B \
--api_mode completion \
--template r1 \
--max_tokens 32768 \
--temperature 0 \
--test_dir examples/data/InternBootcamp_eval \
--max_concurrent_requests 128 \
--timeout 6000 \
--max_retries 16 \
--max_retrying_delay 60
```
注意当api_mode指定为completion时需正确设置对应的template支持r1、qwen、internthinker、chatmlwith no system prompt。更详细的内容参考[评测手册](examples/unittests/README_zh.md)。

View file

@ -0,0 +1,80 @@
# 使用 Xtuner 进行 Bootcamp 训练
## 🚄 训练教程
### 1. 安装依赖项
我们使用 [XTuner](https://github.com/InternLM/xtuner/tree/main) 作为训练引擎。
您需要确保 InternBootcamp 已成功安装。
```bash
pip install -e $InternBootcamp_path
```
然后安装 xtuner 及其依赖项。
```bash
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
pip install flash-attn --no-build-isolation
pip install xtuner[all]==0.2.0rc0
```
### 2. 准备数据
可以通过 `examples/xpuyu_usage/xpuyu_data_preprocess.py` 将 bootcamp 数据转换为训练格式。
**示例用法:**
```python
python examples/xpuyu_usage/xpuyu_preprocess.py --src examples/bootcamp_generator_outputs/{%Y-%m-%d-%H:%M:%S}
```
### 3. 准备您的训练配置
准备您的训练配置以开始 GRPO 训练。
一个示例配置文件位于:
```bash
examples/xpuyu_usage/bootcamp_rl/configs/example_training_config.py
```
### 4. 开始训练
```bash
cd examples/xpuyu_usage
GPUS_PER_NODE=$(python -c 'import torch; print(torch.cuda.device_count())')
# GPU 工作节点的数量,如果是单工作节点训练,请设置为 1
NNODES=${WORLD_SIZE:-1} # 修改以适应集群环境
# 当前工作节点的编号,应为 {0, ..., WORKER_CNT-1} 中的值,如果是单工作节点训练,请设置为 0
NODE_RANK=${RANK:-0} # 修改以适应集群环境
# Rank-0 工作节点的 IP 地址,如果是单工作节点训练,请设置为 localhost
MASTER_ADDR=${MASTER_ADDR:-localhost}
# 通信端口
MASTER_PORT=${MASTER_PORT:-6001}
DISTRIBUTED_ARGS="
--nproc_per_node $GPUS_PER_NODE \
--nnodes $NNODES \
--node_rank $NODE_RANK \
--master_addr $MASTER_ADDR \
--master_port $MASTER_PORT
"
echo $DISTRIBUTED_ARGS
torchrun $DISTRIBUTED_ARGS train_grpo.py ./bootcamp_rl/configs/example_training_config.py --work_dir examples/xpuyu_usage/ckpts/experiment_name
```
### 5. 训练曲线可视化
您可以使用 `examples/xpuyu_usage/report_to_wandb.py` 来可视化训练曲线。
```bash
python examples/xpuyu_usage/report_to_wandb.py examples/xpuyu_usage/ckpts/{experiment_name}/{timestamp}/rank0.log.jsonl {wandb_project_name}
```