Skip to main content

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"

Metadata

Release files for grpo-in-sandbox 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grpo-in-sandbox 1.0.0
File Size Uploaded Provenance Actions
grpo_in_sandbox-1.0.0.tar.gz 83.6 kB Without provenance Details for grpo_in_sandbox-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grpo-in-sandbox 1.0.0
File Interpreter ABI Platform Actions
grpo_in_sandbox-1.0.0-py3-none-any.whl Python 3 none any Details for grpo_in_sandbox-1.0.0-py3-none-any.whl

Total release size: 196.1 kB

Release files / grpo_in_sandbox-1.0.0.tar.gz

Download URL grpo_in_sandbox-1.0.0.tar.gz
Size 83.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ba1137f75b8d5afe5151dbc55717c7bad815ea6163651b409895f614fb43c412
BLAKE2b-256 checksum
How to use checksums
e94ba6feb070f096a17bb1021a755b61450174c17fa18e271e2fb5886ce805c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / grpo_in_sandbox-1.0.0-py3-none-any.whl

Download URL grpo_in_sandbox-1.0.0-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6006105db64611c783205b0864ad03f6fc75880bc6255354b80040915b3438bd
BLAKE2b-256 checksum
How to use checksums
8bfd970aa2296e00213faba78b6beafb022b0d765c47188be7b905b6d63237d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for grpo-in-sandbox 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page