GRPO-based agentic RL training library with code sandbox environment
Project description
GRPO-in-Sandbox Package
Agentic Reinforcement Learning Library.
Core API
from grpo_in_sandbox import (
train,
RLHFTrainingConfig,
create_runtime,
Agent,
AgentArgs,
RewardModel,
ProductManager,
BaseRuntime,
LocalRuntime,
DockerRuntime,
KaggleRuntime,
Trajectory,
TrajectoryStep,
AgentConfig,
load_config,
)
Module Structure
| Module | Description |
|---|---|
train.py |
GRPO training interface |
runtime.py |
Unified runtime abstraction |
config.py |
Configuration management |
agent.py |
Agent implementation |
trajectory.py |
Trajectory recording |
observation.py |
Action results |
action.py |
Action representation |
tools.py |
Tool definitions |
docker_runtime.py |
Docker backend |
Training Example
from grpo_in_sandbox import train, RLHFTrainingConfig
config = RLHFTrainingConfig(
model_name_or_path="Qwen/Qwen2.5-0.5B-Instruct",
num_train_epochs=3,
)
results = train(config)
AI Judge Self-Play Mode
Train models WITHOUT sandbox execution using AI-as-Judge for reward signals.
from grpo_in_sandbox import (
SelfPlayGRPO,
RLHFTrainingConfig,
AITrainerMode,
AIJudge,
ProductManager,
)
# Method 1: Using SelfPlayGRPO orchestrator
config = RLHFTrainingConfig(
mode=AITrainerMode.AI_JUDGE,
model_name_or_path="Qwen/Qwen2.5-0.5B-Instruct",
judge_llm_name="openai/gpt-4o-mini",
judge_criteria=["correctness", "clarity", "helpfulness"],
max_steps=50,
)
sp = SelfPlayGRPO(config)
sp.run()
# Method 2: Using train() with ai_judge parameter
judge = AIJudge(llm_name="openai/gpt-4o-mini")
results = train(config, ai_judge=judge)
For full API tutorial, see docs/AI_JUDGE_GRPO_TUTORIAL.md
Runtime Example
from grpo_in_sandbox import create_runtime
runtime = create_runtime(backend="docker")
output, exit_code = runtime.run("echo hello")
stdout, stderr, exit_code = runtime.demux_run("echo hello")
runtime.close()
Agent Example
from grpo_in_sandbox import Agent, AgentArgs, create_runtime
runtime = create_runtime(backend="docker")
args = AgentArgs(
system_prompt="You are a helpful assistant.",
instance_prompt="{problem_statement}",
llm_name="openai/gpt-4",
)
agent = Agent(args)
trajectory = agent.run(
runtime=runtime,
problem_statement="Solve 2+2",
)
#需要安装的依赖项 pip install "docker" "contextlib" "datetime" "dataclasses" "importlib" "pathlib" "fire" "yaml" "transformers" "torch" "tempfile"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grpo_in_sandbox-1.0.0.tar.gz.
File metadata
- Download URL: grpo_in_sandbox-1.0.0.tar.gz
- Upload date:
- Size: 83.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba1137f75b8d5afe5151dbc55717c7bad815ea6163651b409895f614fb43c412
|
|
| MD5 |
bd710f2dc6e1b4552120506b119c4bd2
|
|
| BLAKE2b-256 |
e94ba6feb070f096a17bb1021a755b61450174c17fa18e271e2fb5886ce805c3
|
File details
Details for the file grpo_in_sandbox-1.0.0-py3-none-any.whl.
File metadata
- Download URL: grpo_in_sandbox-1.0.0-py3-none-any.whl
- Upload date:
- Size: 112.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6006105db64611c783205b0864ad03f6fc75880bc6255354b80040915b3438bd
|
|
| MD5 |
702d1850e6be3c5b03ef5cc8863e81f2
|
|
| BLAKE2b-256 |
8bfd970aa2296e00213faba78b6beafb022b0d765c47188be7b905b6d63237d4
|