| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
🎉 InternAgentHarness technical report: InternAgentHarness: A Scalable Synthetic Environment for Enhancing LLM Agentic Abilities
🎉 InternBootcamp v1 的技术报告已被 WAICA 2026 接收!
📄 技术报告:InternBootcamp Technical Report: Boosting LLM Reasoning with Verifiable Task Scaling
📦 技术报告对应代码版本:InternBootcamp v1
InternAgentHarness (InternBootcamp) 是一个面向大语言模型智能体训练与评测的可扩展合成环境框架。
它并不只关注一次性的 benchmark 分数,而是为智能体构建可执行、可交互、可验证的任务环境。模型可以在真实的工具调用、状态反馈、多轮交互和奖励信号中持续学习与改进。
在 InternAgentHarness 中,不同类型的智能体任务会被统一封装为可训练的环境实例。每个任务由四个核心部分组成:
通过这套统一接口,科研工具调用、路径规划、金融推理、游戏决策、视觉任务等不同场景都可以在同一流程下完成运行、记录、训练和评测。
InternAgentHarness 同时提供 BootCampCLI,用于将任务配置自动转换为可运行的智能体交互流程。
用户可以先在本地调试单个任务,再将相同配置扩展到:
每次运行都会记录完整的交互轨迹,包括模型回复、工具调用、环境反馈、奖励结果和最终答案。这些记录便于后续复现、训练、调试和环境迭代。
InternAgentHarness 适用于希望进行以下工作的研究者和开发者:
它将“评测、数据生成、训练、再评测”连接成一个闭环,帮助用户更高效地提升大语言模型在复杂任务中的规划、工具使用、反馈修正和决策能力。
InternAgentHarness 提供了一组覆盖不同能力维度的智能体任务环境,用于评测和训练大语言模型在复杂场景中的规划、工具调用、反馈修正和决策能力。这些任务并不是简单的问答数据,而是可执行、可交互、可验证的智能体环境。模型需要根据任务目标调用相应工具,观察环境反馈,并在多轮交互中持续调整策略。 例如:
通过这些多样化任务,InternAgentHarness 能够系统评估模型是否真正具备面向智能体应用的核心能力,包括理解任务约束、正确使用工具、处理中间反馈、完成长程决策以及输出可验证结果。
用户也可以基于相同接口扩展新的任务环境,将自定义场景接入统一的训练、评测和轨迹采集流程。
这里是基于InternBootcampv1开发的InternAgentHarness,主要包含了针对具体专业性Bootcamp场景的multi-round toolcall的agentic RL 流程。
InternAgentHarness 深入绑定了verl的multi-round toolcall的流程,通过SGLANG-rollout的state control,实现对专业场景的toolcall调用、reward计算、模型训练及推理
为了支持更复杂的Bootcamp任务,我们需要多轮工具调用来处理。
基于多轮工具调用的复杂推理任务,通常有两种形式:
(1)LLM-based workflow
prompt --> LLM rollout(decision) --> tooluse response --> LLM rollout(decision) --> tooluse response ...
(2)environment-based workflow
prompt --> LLM rollout --> tooluse --> env decision --> LLM rollout --> tooluse --> env decision ...
即,一个Bootcamp任务存在两种LLM与环境的交互形式
为什么要multi-round toolcall & multi-round toolcall很复杂:
(1)single-round toolcall & 多轮对话,本质上都可以refine成single-round的交互
(2)multi-round toolcall 的调用在RL framework中,需要async的调用,导致rollout逻辑会更加复杂
一个需要多轮调用工具的Bootcamp流程:两种情况 toolcall or interaction-call ,以下统称toolcall
流程包含了:
(1)模型的prompt Design,workflow的整个流程;
prompt Design,在verl里体现为数据构造,对应包含data-source来明确task的类型,
生成这种数据的流程,在Bootcamp中,参考InternBootcampv1的对应思路;
(2)对应需要调用的tool的toollist tool的描述;
verl中, toollist,在toolconfig里填写,并且会在chat-template中基于对应mcp协议,拼接在chat-template里,
tool的config中,直接绑定了对应的tool的实现;
(3)调用的tool的实现逻辑,对应的io;
verl中,tool的调用,是通过执行execute,在SGLANG的rollout中对应调用的,
其中,SGLANG的rollout,会根据对应的state,对rollout过程进行控制,这些state包含了toolcall 和terminate等信号,
同时,在这里会计算每一轮的toolcall返回的中间过程reward;
SGLANG的rollout中,需要传入的参数包含了
(4)基于tool的io的返回,模型的multi-round rollout;
整体rollout结束后,会通过reward score 处计算最终的reward
(5)基于toolcall返回 or 基于模型判断 or 基于max-step 等条件,任务workflow的最终终止;
verl中,state中控制了流程的终止
git clone https://example.com/openinternbootcamp.git --recurse-submodules
cd openinternbootcamp
pip install -e ./
# verl install
pip install -e ./verl/
# openevolve install
pip install -e ./openevolve/
# 一键安装所有父和子仓库依赖
pip install -r requirements-editable.txt继承基类BaseInstructionGenerator
示例: example_instruction_generator.py
若需生成数据,须继承BaseInstructionGenerator基类,并实现以下两个抽象方法:(若无需生成数据则将数据规范为以下对应格式即可,无需实现InstructionGenerator)
from internbootcamp.src.base_instruction_generator import BaseInstructionGenerator
from typing import Dict, Any, Optional
import random
class CustomInstructionGenerator(BaseInstructionGenerator):
"""自定义指令生成器"""
def __init__(self, **kwargs):
super().__init__()
# 配置data_source,基类已如下实现,计算reward时会根据此信息匹配对应的RewardCalculator
self.data_source = f"bootcamp/{self.__class__.__name__.replace('InstructionGenerator', '').lower()}"
# 初始化自定义参数
for key, value in kwargs.items():
setattr(self, key, value)
def case_generator(self) -> Dict[str, Any]:
"""
生成任务案例,返回包含任务信息的字典
Returns:
Dict[str, Any]: 任务信息字典,包含ground_truth等关键信息;
这个任务信息字典将作为对应RewardCalculator的_verify_correction方法和对应Tool的create方法的identity参数传入
"""
# 实现任务生成逻辑
# 例如:生成数学题目、电路参数等
pass
def prompt_func(self, identity: Dict[str, Any]) -> str:
"""
根据任务信息生成提示语
Args:
identity (Dict[str, Any]): 任务信息字典
Returns:
str: 生成的提示词
"""
# 实现提示语生成逻辑
# 使用identity中的信息构建输入给语言模型的prompt
pass关键要点:
实践建议:
示例: example_instruction_config.yaml
使用YAML配置文件来管理数据生成的参数和行为:
# custom_instruction_config.yaml
instruction_generators:
# 基础配置组
basic_config:
config:
min_value: 1
max_value: 100
operation_type: "simple"
generation_ratio: 0.1 # 占总生成数据的40%,所有generation_ratio会自动归一化为比例(如0.4和0.6会分别分配40%和60%的样本数)
# 高级配置组
advanced_config:
config:
min_value: 50
max_value: 500
operation_type: "complex"
generation_ratio: 0.7 # 占总生成数据的60%,无需手动保证所有ratio之和为1,系统会自动归一化
# 带默认tool的配置组
basic_config_w_tool:
min_value: 1
max_value: 100
operation_type: "simple"
generation_ratio: 0.1
yaml_tool_path: "path/to/tool.yaml" # 工具配置文件路径
# 带默认interaction的配置组
basic_config_w_tool:
min_value: 1
max_value: 100
operation_type: "simple"
generation_ratio: 0.1
yaml_interaction_path: "path/to/interaction.yaml" # 交互配置文件路径
# 全局配置
global_config:
# 指令生成器类的完整路径
class_name: "internbootcamp.bootcamps.your_bootcamp.your_instruction_generator.CustomInstructionGenerator"
# 随机种子配置
enable_random_seed: true
default_seed: 999
# 数据集划分配置
default_split_samples:
train: 10000
test: 1000
# 是否启用数据打乱
shuffle: true
# 是否生成parquet文件
gen_parquet: false配置说明:
示例: example_multiturn_w_tool_grpo.sh
例如以下命令
# data_generate.sh
#!/bin/bash
python -m internbootcamp.utils.data_generation \
--instruction-config configs/your_instruction_config.yaml \
--output-dir data/your_bootcamp/ \
--tool-config configs/your_tool_config.yaml \ #全局配置,与单条配置合并
--interaction-config configs/your_interaction_config.yaml \ #全局配置,与单条配置合并
--split-samples train:10000,test:1000 \
--shuffle \
--global-config-overrides '{"gen_parquet": true}' \ #全局配置覆盖
--no-tool \ #开启则不使用任何工具配置
--no-interaction \ #开启则不使用任何交互配置参数列表
| 参数名称 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
| --instruction-config | str | ✓ | - | 指令管理器配置文件路径,定义数据生成的核心逻辑 |
| --output-dir | str | ✓ | - | 输出文件目录,生成的数据集将保存在此目录下 |
| --tool-config | str | ✗ | None | 工具配置文件路径,相当于全局配置,生成时与单条配置合并(冲突时优先使用单条配置) |
| --interaction-config | str | ✗ | None | 交互配置文件路径,相当于全局配置,生成时与单条配置合并(冲突时优先使用单条配置) |
| --split-samples | str | ✗ | None | 数据集划分和样本数,格式为 train:10000,test:1000,val:500 |
| --shuffle | flag | ✗ | False | 是否对生成的数据进行随机打乱 |
| --gen_parquet | flag | ✗ | True | 是否生成parquet格式文件(除jsonl外) |
| --global-config-overrides | str | ✗ | None | 全局配置覆盖参数,JSON字符串格式,如 '{"enable_random_seed": true}' |
| --no-tool | flag | ✗ | False | 开启则不使用任何工具配置 |
| --no-interaction | flag | ✗ | False | 开启则不使用任何交互配置 |
执行脚本后会以split为后缀生成多个jsonl数据文件
{
"data_source": "bootcamp/Example",
"prompt": [
{
"content": "你是一位数学专家,擅长进行算术运算。\n\n任务:计算表达式 88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020 的结果,误差范围为 1e-4\n\n最终答案格式:请以``json\n{\n \"result\": your_result\n}\n``格式返回结果,且在必要时使用科学计数法(如1e-4、2.5E+3)。\n\n计算建议:\n1. 请在合适的时机运用算术工具,如需要计算大数等自信程度不高计算时,以避免计算错误和无意义的工具调用。\n2. 若需要计算的表达式较长,请在实际计算开始前,先进行计算规划,以避免计算错误和无意义的工具调用。\n下面请开始计算。",
"role": "user"
}
],
"reward_model": {
"ground_truth": {
"expression": "88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020",
"expected_result": 2146993745.4955528,
"tolerance": "1e-4"
},
"style": "rule"
},
"extra_info": {
"tools_kwargs": {
},
"need_tools_kwargs": false,
"index": 102,
"split": "test",
"generator_name": "medium_arithmetic_w_interaction",
"interaction_kwargs": {
"name": "example_interaction",
"identity": {
"expression": "88086 ÷ 38856 - 34189 + 96429 ÷ 65083 × 2882 + 21625 × 99240 + 97985 × 61813 ÷ 6044 ÷ 79107 × 68650 + 89020",
"expected_result": 2146993745.4955528,
"tolerance": "1e-4"
}
}
}
}现支持批量并行数据生成:
# 批量数据生成
python -m internbootcamp.utils.batch_data_generation \
--bootcamp-registry configs/bootcamp_registry.jsonl \ # Bootcamp注册表
--max-workers 8 \ # 最大并行进程数
--output-dir data/batch_generated/ \
--split-samples train:1000,test:100 \ #每个Bootcamp配置生成1000个训练样本和100个测试样本
--concat-files \
--continue-on-errorbootcamp注册表作为批量生成配置文件(bootcamp_registry.jsonl): 单条注册表数据结构:
{"instruction_config_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_instruction_config.yaml", "data_source": "bootcamp/YourBootcamp", "yaml_tool_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_tool_config.yaml", "yaml_interaction_path": "internbootcamp/bootcamps/your_bootcamp/configs/your_interaction_config.yaml", "reward_calculator_class": "internbootcamp.bootcamps.your_bootcamp.your_reward_calculator.YourRewardCalculator"}
参数列表:
| 参数名称 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
| --bootcamp-registry | str | ✓ | - | Bootcamp注册表文件路径,jsonl格式,每条记录包含一个bootcamp的配置信息 |
| --max-workers | int | ✗ | min(16, CPU核心数) | 最大并行工作进程数,自动限制在CPU核心数范围内 |
| --continue-on-error | flag | ✗ | False | 遇到错误时继续执行其他配置,不中断整个批量生成流程 |
| --log-level | str | ✗ | INFO | 日志级别,可选值:DEBUG、INFO、WARNING、ERROR |
| --output-dir | str | ✗ | data/generated | 输出目录,所有生成的数据集将保存在此目录下 |
| --split-samples | str | ✗ | train:100,test:0 | 数据集划分和样本数,格式为 train:10000,test:1000,val:500 |
| --concat-files | flag | ✗ | False | 是否将所有生成的文件按split分别合并到文件中 |
| --no-tool | flag | ✗ | False | 是否不使用工具配置,开启则忽略所有工具相关配置 |
| --no-interaction | flag | ✗ | False | 是否不使用交互配置,开启则忽略所有交互相关配置 |
示例: example_tools.py
若自定义Bootcamp需支持工具训练,须继承BaseTool基类,并实现以下两个核心抽象方法:
# 示例代码结构
class CustomTool(BaseTool):
def __init__(self, config):
super().__init__(config)
async def create(self, instance_id: Optional[str] = None, identity: dict = None, **kwargs) -> str:
"""用于创建针对每条数据所需要的额外变量,在数据加载阶段被执行。
Args:
instance_id (Optional[str]): 针对每个instance的id,不指定时由类自动生成
identity (dict): 每条数据所需要的额外变量,data source应该有identity字段
Returns:
instance_id: str
"""
# 创建工具实例
pass
async def execute(self, instance_id: str, parameters: dict[str, Any], **kwargs) -> tuple[str, float, dict]:
"""工具的执行逻辑
Args:
instance_id (str):
parameters (dict[str, Any]): 执行工具所需的参数,parameters均有LLM的输出提供
Returns: tool_response, tool_reward_score, tool_metrics
tool_response (str): 工具的输出
tool_reward_score (float): 工具计算的reward结果,如有,否则返回0
tool_metrics (dict): 返回{}
"""
# 执行工具逻辑
pass关键要点:
# custom_tool_config.yaml
tools:
- class_name: "internbootcamp.bootcamps.your_bootcamp.your_tools.CustomTool"
config:
type: "native"
tool_schema: # tool_schema会作为prompt被输入LLM
type: "function"
function:
name: ""
description: ""
parameters:
type: "object"
properties:
param1:
type: ""
description: ""
param2:
type: ""
description: ""
required: [] # 哪些输入参数是强制需要的class BaseInteraction:
async def start_interaction(self, instance_id: Optional[str] = None, identity: dict[str, Any] = None, **kwargs) -> str: ...
async def generate_response(
self, instance_id: str, messages: list[dict[str, Any]], **kwargs
) -> tuple[bool, str, float, dict[str, Any]]:
"""
Returns:
- should_terminate_sequence: 是否终止该样本后续交互
- response_content: 返回给模型的反馈/追问内容(将以user角色注入下一轮)
- current_turn_score: 本回合得分
- additional_data: 额外元信息
"""
async def calculate_score(self, instance_id: str, **kwargs) -> float: ...
async def finalize_interaction(self, instance_id: str, **kwargs) -> bool: ...# example_interaction_config.yaml
interaction:
- name: "example_interaction"
class_name: "internbootcamp.bootcamps.example_bootcamp.example_interaction.ExampleInteraction"
config: {}{
"prompt": [{"role": "user", "content": "..."}],
"reward_model": {"ground_truth": {"identity": {"...": "..."}}, "style": "rule"},
"extra_info": {
"interaction_kwargs": {
"identity": {"...": "标准答案或判分所需信息 ..."}
}
}
}命令行评测时通过交互配置启用交互闭环:
python -m internbootcamp.utils.run_evaluation \
--dataset-path data/your_bootcamp/test.jsonl \
--output-dir outputs/ \
--api-key "$API_KEY" \
--api-url "$API_URL" \
--api-model "gpt-3.5-turbo" \
--reward-calculator-class "internbootcamp.bootcamps.example_bootcamp.example_reward_calculator.ExampleRewardCalculator" \
--tool-config configs/your_tool_config.yaml \
--interaction-config internbootcamp/bootcamps/example_bootcamp/configs/example_interaction_config.yaml \
--max-tool-turns-per-interaction 5 \
--max-interaction-turns 3示例: 分布式工具服务器文档 | DLC启动脚本
基于Master-Worker分布式架构的工具服务器,支持工具在多机器间分布式部署和执行,提供高并发处理能力和负载均衡。
启动Master服务器,等待Worker注册:
python -m internbootcamp.utils.tool_server.cli \
--mode master \
--tools_yaml_path config.yaml \
--port 8000 \
--output_dir outputs/在其他机器上启动Worker并注册到Master: 指定一个tools_config:
python -m internbootcamp.utils.tool_server.cli \
--mode worker \
--tools_yaml_path config.yaml \
--master_url http://master_ip:master_port \
--port 8001 \ # Worker服务器的起始端口号,系统会在端口的高位端口中为多个Worker智能分配可用端口
--num_workers 3 # Worker服务器数量指定一个bootcamp注册表:
python -m internbootcamp.utils.tool_server.cli \
--mode worker \
--bootcamp_registry configs/bootcamp_registry.jsonl \
--master_url http://master_ip:master_port \
--port 8001 \ # Worker服务器的起始端口号,系统会在端口的高位端口中为多个Worker智能分配可用端口
--num_workers 3 # Worker服务器数量在单机上同时启动Master和多个Worker:
python -m internbootcamp.utils.tool_server.cli \
--mode unified \
--tools_yaml_path config.yaml \
--port 8000 \
--num_workers 5 \
--keep_running \
--test_servers \
--log_dir ./logs/1. 动态Worker注册与负载均衡:
2. 健康监控与容错:
3. 批量工具配置支持:
# 使用bootcamp注册表批量加载所有工具
python -m internbootcamp.utils.tool_server.cli \
--mode unified \
--bootcamp_registry configs/bootcamp_registry.jsonl \
--port 8000 \
--num_workers 84. 配置自动生成:
5. 实时可视化监控仪表板:
| 参数名称 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
| --mode | str | ✓ | - | 运行模式:master/worker/unified |
| --tools_yaml_path | str | ✗ | - | 工具配置YAML文件路径 |
| --bootcamp_registry | str | ✗ | - | Bootcamp注册表文件路径,可批量加载所有工具 |
| --port | int | ✗ | 8000 | 服务器端口号或起始端口号 |
| --host | str | ✗ | 0.0.0.0 | 服务器主机地址 |
| --master_url | str | ✗ | - | Master服务器URL(Worker模式必需) |
| --worker_id | str | ✗ | 自动生成 | Worker ID标识 |
| --num_workers | int | ✗ | 3 | Worker服务器数量 |
| --output_dir | str | ✗ | 输入配置文件目录 | 配置文件输出目录 |
| --updated_tool_class | str | ✗ | BaseMCPTool | 更新后的工具类(不建议使用) |
| --timeout_per_query | int | ✗ | 60 | 单个查询超时时间(秒),影响训练、评测过程,建议设置得更宽容 |
| --keep_running | flag | ✗ | False | 保持服务器运行(unified模式) |
| --log_dir | str | ✗ | - | 日志目录路径(unified模式) |
| --test_servers | flag | ✗ | False | 启动后自动测试服务器(unified模式) |
| --test_timeout | int | ✗ | 10 | 测试超时时间(秒)(unified模式) |
| --connectivity_only | flag | ✗ | False | 仅测试连通性 (unified模式) |
原始工具配置:
tools:
- class_name: "internbootcamp.bootcamps.example_bootcamp.example_tools.ArithmeticTool"
config:
type: "native"
tool_schema:
# ... tool schema定义自动生成的工具配置: 使用该配置进行后续的训练与评测
tools:
- class_name: "internbootcamp.src.base_mcp_tool.BaseMCPTool"
config:
type: "native"
mcp_server_url: "http://IP:PORT/ArithmeticTool"
timeout_per_query: 60
tool_schema:
# ... 保持原有tool schema可视化仪表板:
Master服务器提供了一个实时监控仪表板,可通过浏览器访问Master服务器的根路径查看:
http://<master_ip>:<master_port>/
仪表板功能特性:
实时自动刷新:每3秒自动刷新一次,无需手动刷新页面
关键指标展示:
Worker详细信息:
工具可用性监控:
负载均衡可视化:
健康检查API:
除了可视化仪表板,还提供JSON格式的健康检查接口,便于程序化监控:
curl http://<master_ip>:<master_port>/health返回信息包括:
使用示例:
# 启动Master服务器后,在浏览器中访问
http://MASTER_IP:MASTER_PROT/
# 或通过API查询状态
curl http://MASTER_IP:MASTER_PROT/health | jq示例: example_reward_calculator.py
继承BaseRewardCalculator基类并实现两个核心抽象方法:
from internbootcamp.src.base_reward_calculator import BaseRewardCalculator
class CustomRewardCalculator(BaseRewardCalculator):
"""自定义奖励计算器"""
@staticmethod
def extract_output(output_str: str):
"""
从模型输出中提取关键信息用于奖励计算
Args:
output_str: 模型的最终响应字符串
Returns:
提取的信息,作为_verify_correction()的extract_solution参数
"""
# 实现输出解析逻辑,如正则表达式、JSON解析等
pass
@classmethod
def _verify_correction(cls, extract_solution, identity: dict, **kwargs) -> float:
"""
验证提取的解决方案并计算正确性分数
Args:
extract_solution: 从extract_output()提取的信息
identity: 任务标准答案信息(来自InstructionGenerator.case_generator())
kwargs: 额外关键字参数,可在评测和训练时传递,可用于控制reward计算逻辑
Returns:
float: 正确性分数(0-1之间)
"""
# 实现验证逻辑,对比提取结果与标准答案
pass示例: example_multiturn_w_tool_grpo.sh
使用统一的评估脚本对自定义Bootcamp进行API call形式的模型性能评估:
python -m internbootcamp.utils.run_evaluation \
--dataset-path "数据集路径(jsonl/parquet格式)" \
--output-dir "评估结果输出目录" \
--api-key "API密钥" \
--api-url "API地址" \
--api-model "模型名称" \
--api-extra-headers "Authorization:Bearer sk-xxx,Custom-Header:Value" \
--api-extra-params '{"temperature":0.7, "max_completion_tokens":65536, "extra_body": {"enable_thinking": true}}' \
--verify-correction-kwargs '{"strict":true}' \
--evaluator-class "评估器类路径,默认使用BaseEvaluator" \
--reward-calculator-class "奖励计算器类路径" \
--tool-config "工具配置文件路径" \
--interaction-config "交互配置文件路径" \
--max-assistant-turns "最大assistant消息数" \
--max-user-turns "最大user消息数" \
--max-concurrent "最大并发数量" \
--verbose \ # 详细输出
--dry-run \ # 干运行模式
--tokenizer-path "tokenizer路径" \
--bootcamp-registry "bootcamp注册表路径" \
--resume-from-result-path "断点重试文件路径"1. 断点重试机制:
# 从已有结果文件恢复评测
python -m internbootcamp.utils.run_evaluation \
--dataset-path data/test.jsonl \
--output-dir results/ \
--api-key sk-xxx \
--resume-from-result-path results/gpt-3.5-turbo/eval_results_20240315_143022.jsonl2. 多格式数据集支持:
3. 批量评测支持:
# 使用bootcamp注册表进行批量评测
python -m internbootcamp.utils.run_evaluation \
--bootcamp-registry configs/bootcamp_registry.jsonl \
--output-dir results/batch_evaluation/| 参数名称 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
| --dataset-path | str | ✓ | - | 数据集文件路径,支持.json、.jsonl、.parquet格式 |
| --output-dir | str | ✓ | - | 评测结果输出目录 |
| --api-key | str | ✓ | - | API密钥,用于模型调用认证 |
| --api-url | str | ✗ | - | API服务地址,不指定则使用默认OpenAI API |
| --api-model | str | ✗ | gpt-3.5-turbo | 模型名称 |
| --api-extra-headers | str | ✗ | - | 额外API头部,格式:"key1:value1,key2:value2" |
| --api-extra-params | str | ✗ | - | 额外模型参数;支持 JSON 字符串或 @文件(JSON)。示例:'{"temperature":0.7, "max_completion_tokens":65536, "extra_body": {"enable_thinking": true}}' 或 @/path/to/params.json;兼容旧格式 "temperature:0.7,max_tokens:2048" 作为回退解析 |
| --verify-correction-kwargs | str | ✗ | - | 传递给奖励计算器 verify_correction 的额外参数;支持格式同 --api-extra-params |
| --evaluator-class | str | ✗ | BaseEvaluator | 评测器类路径,用于自定义评测逻辑 |
| --reward-calculator-class | str | ✗ | - | 奖励计算器类路径,用于计算任务完成度 |
| --tool-config | str | ✗ | - | 工具配置YAML文件路径,支持原生工具和MCP工具 |
| --interaction-config | str | ✗ | - | 交互配置YAML文件路径,启用多轮交互功能 |
| --max-assistant-turns | int | ✗ | 5 | assistant 响应的最大轮次 |
| --max-user-turns | int | ✗ | 20 | user 输入的最大轮次(包括 tool response, interaction response) |
| --max-concurrent | int | ✗ | 1 | 最大并发数,控制并行评测样本数量 |
| --verbose | flag | ✗ | False | 输出详细信息,用于调试和监控 |
| --dry-run | flag | ✗ | False | 只验证配置不实际运行,用于配置测试 |
| --tokenizer-path | str | ✗ | - | tokenizer路径,用于apply template时的文本处理 |
| --bootcamp-registry | str | ✗ | - | bootcamp注册表路径,用于批量评测 |
| --resume-from-result-path | str | ✗ | - | 断点重试文件路径,从中断点恢复评测 |
评估完成后将在输出目录生成:
数据后处理工具用于对evaluator输出的jsonl文件进行灵活的过滤和转换,支持将评估结果转换为可用于训练的数据格式。
核心特性:
主要应用场景:
命令行方式(推荐快速使用):
# 方式1: 自动生成输出路径(添加_processed后缀)
python internbootcamp/utils/data_postprocess.py \
path/to/eval_results.jsonl \
--expand-messages-prefixes \
--extract-training \
--min-score 0.9 \
--max-score 1.0
# 方式2: 指定输出路径
python internbootcamp/utils/data_postprocess.py \
path/to/eval_results.jsonl \
path/to/output.jsonl \
--filter-success \
--min-score 0.9 \
--data-source bootcamp/example预定义过滤和转换功能:
| 参数名称 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
| input | str | ✓ | - | 输入jsonl文件路径 |
| output | str | ✗ | 自动生成 | 输出jsonl文件路径,不提供则自动生成为 {input}_processed.jsonl |
| --filter-success | flag | ✗ | False | 只保留success字段为True的样本 |
| --min-score | float | ✗ | 0.9 | 最小分数阈值(包含) |
| --max-score | float | ✗ | 1.0 | 最大分数阈值(包含) |
| --data-source | str | ✗ | - | 按指定数据源过滤 |
| --extract-training | flag | ✗ | False | 提取训练数据格式(包含data_source、prompt、messages、tools等字段) |
| --extract-messages | flag | ✗ | False | 只提取消息内容(messages、score、success字段) |
| --expand-messages-prefixes | flag | ✗ | False | 将多轮对话展开为前缀集,每个assistant消息生成一条样本 |
对于更复杂的数据处理需求,可以使用编程接口自定义过滤和转换逻辑:
from internbootcamp.utils.data_postprocess import (
DataPostProcessor,
filter_by_success,
filter_by_score,
extract_for_training,
expand_messages_prefixes
)
# 创建处理器
processor = DataPostProcessor()
# 添加过滤器
processor.add_filter(filter_by_success, name="success")
processor.add_filter(filter_by_score(min_score=0.9, max_score=1.0), name="score")
# 添加自定义过滤器
processor.add_filter(
lambda x: len(x.get("messages", [])) > 2,
name="min_messages"
)
# 添加转换器
processor.add_transformer(expand_messages_prefixes, name="expand")
processor.add_transformer(extract_for_training, name="training_format")
# 自定义转换器(一对一)
def add_metadata(data):
data["processed_at"] = "2024-01-01"
return data
processor.add_transformer(add_metadata, name="metadata")
# 自定义转换器(一对多)
def split_by_turns(data):
messages = data.get("messages", [])
return [{"turn": i, "msg": msg, "original_score": data.get("score")}
for i, msg in enumerate(messages)]
processor.add_transformer(split_by_turns, name="split")
# 执行处理
stats = processor.process(
input_path="eval_results.jsonl",
output_path="processed_results.jsonl",
verbose=True
)
print(f"处理完成: {stats}")高级功能:
# 创建字段提取器
from internbootcamp.utils.data_postprocess import create_field_extractor
extractor = create_field_extractor(
"input.data_source",
"score",
"messages",
"input.extra_info.generator_name"
)
processor.add_transformer(extractor)
# 创建自定义转换器(支持字段重命名和默认值)
from internbootcamp.utils.data_postprocess import create_custom_transformer
transformer = create_custom_transformer({
"text": "messages[-1].content", # 提取最后一条消息
"source": "input.data_source",
"score": ("score", 0.0), # 带默认值
"custom_field": lambda x: x.get("score", 0) * 100 # 自定义函数
})
processor.add_transformer(transformer)处理流程示例:
# 完整的数据处理流程:评估 → 后处理 → 训练
# 1. 运行评估
python -m internbootcamp.utils.run_evaluation \
--dataset-path data/test.jsonl \
--output-dir outputs/eval/
# 2. 后处理评估结果
python internbootcamp/utils/data_postprocess.py \
outputs/eval/gpt-3.5-turbo/eval_results_20240315.jsonl \
outputs/train_data/processed.jsonl \
--filter-success \
--min-score 0.9 \
--expand-messages-prefixes \
--extract-training
# 3. 使用处理后的数据进行训练
# (训练命令...)本手册提供了创建自定义Bootcamp的完整指导。通过遵循这些步骤和最佳实践,您将能够成功构建一个高质量的专业领域Bootcamp系统。
如有任何问题或建议,请参考项目文档或联系开发团队。
If you find this work helpful, please consider to star🌟 this repo and cite this paper. Thanks for your support!
@misc{li2026internbootcamptechnicalreportboosting,
title={InternBootcamp Technical Report: Boosting LLM Reasoning with Verifiable Task Scaling},
author={Peiji Li and Jiasheng Ye and Yongkang Chen and Yichuan Ma and Zijie Yu and Kedi Chen and Xiaozhe Li and Ganqu Cui and Haozhan Li and Jiacheng Chen and Chengqi Lyu and Wenwei Zhang and Linyang Li and Qipeng Guo and Dahua Lin and Bowen Zhou and Kai Chen},
year={2026},
eprint={2508.08636},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2508.08636},
}| Back | FazBrowse Home | New Git URL |