Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- openenv_CrisisWorldCortex.egg-info/PKG-INFO +2 -0
- openenv_CrisisWorldCortex.egg-info/SOURCES.txt +23 -1
- openenv_CrisisWorldCortex.egg-info/requires.txt +2 -0
- pyproject.toml +3 -0
- training/scripts/collect_sft_data.py +57 -48
- training/scripts/train_b1_grpo.py +25 -14
- training/scripts/train_cortex_multi_model.py +12 -3
- uv.lock +0 -0
openenv_CrisisWorldCortex.egg-info/PKG-INFO
CHANGED
|
@@ -5,6 +5,8 @@ Summary: Crisisworldcortex environment for OpenEnv
|
|
| 5 |
Requires-Python: >=3.10
|
| 6 |
Requires-Dist: openenv-core[core]==0.2.3
|
| 7 |
Requires-Dist: openai<3.0,>=2.0
|
|
|
|
|
|
|
| 8 |
Provides-Extra: dev
|
| 9 |
Requires-Dist: pre-commit>=4.0.0; extra == "dev"
|
| 10 |
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
|
|
| 5 |
Requires-Python: >=3.10
|
| 6 |
Requires-Dist: openenv-core[core]==0.2.3
|
| 7 |
Requires-Dist: openai<3.0,>=2.0
|
| 8 |
+
Requires-Dist: datasets>=4.0.0
|
| 9 |
+
Requires-Dist: huggingface-hub>=1.0.0
|
| 10 |
Provides-Extra: dev
|
| 11 |
Requires-Dist: pre-commit>=4.0.0; extra == "dev"
|
| 12 |
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
openenv_CrisisWorldCortex.egg-info/SOURCES.txt
CHANGED
|
@@ -7,6 +7,7 @@ pyproject.toml
|
|
| 7 |
./__init__.py
|
| 8 |
./client.py
|
| 9 |
./inference.py
|
|
|
|
| 10 |
./models.py
|
| 11 |
openenv_CrisisWorldCortex.egg-info/PKG-INFO
|
| 12 |
openenv_CrisisWorldCortex.egg-info/SOURCES.txt
|
|
@@ -19,9 +20,21 @@ server/__init__.py
|
|
| 19 |
server/app.py
|
| 20 |
tests/test_actions_round_trip.py
|
| 21 |
tests/test_baseline_b1.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
tests/test_env_reset_kwargs.py
|
| 23 |
tests/test_env_step_reward_wiring.py
|
| 24 |
tests/test_import_graph.py
|
|
|
|
| 25 |
tests/test_legal_constraint_enforcement.py
|
| 26 |
tests/test_llm_client.py
|
| 27 |
tests/test_observation_no_latent_leak.py
|
|
@@ -29,9 +42,18 @@ tests/test_outer_reward_in_range.py
|
|
| 29 |
tests/test_outer_reward_non_constancy.py
|
| 30 |
tests/test_outer_reward_terminal_bonus.py
|
| 31 |
tests/test_package_exports.py
|
|
|
|
| 32 |
tests/test_schemas_roundtrip.py
|
| 33 |
tests/test_simulator_determinism.py
|
| 34 |
tests/test_simulator_random_episode.py
|
| 35 |
tests/test_simulator_task_configs.py
|
| 36 |
tests/test_smoke_env.py
|
| 37 |
-
tests/test_stdout_format.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
./__init__.py
|
| 8 |
./client.py
|
| 9 |
./inference.py
|
| 10 |
+
./mm.py
|
| 11 |
./models.py
|
| 12 |
openenv_CrisisWorldCortex.egg-info/PKG-INFO
|
| 13 |
openenv_CrisisWorldCortex.egg-info/SOURCES.txt
|
|
|
|
| 20 |
server/app.py
|
| 21 |
tests/test_actions_round_trip.py
|
| 22 |
tests/test_baseline_b1.py
|
| 23 |
+
tests/test_baseline_b2.py
|
| 24 |
+
tests/test_baseline_b3.py
|
| 25 |
+
tests/test_cortex_brain_executive.py
|
| 26 |
+
tests/test_cortex_brain_smoke.py
|
| 27 |
+
tests/test_cortex_council.py
|
| 28 |
+
tests/test_cortex_council_smoke.py
|
| 29 |
+
tests/test_cortex_lenses.py
|
| 30 |
+
tests/test_cortex_metacognition.py
|
| 31 |
+
tests/test_cortex_perception.py
|
| 32 |
+
tests/test_cortex_routing_policy.py
|
| 33 |
+
tests/test_cortex_subagents.py
|
| 34 |
tests/test_env_reset_kwargs.py
|
| 35 |
tests/test_env_step_reward_wiring.py
|
| 36 |
tests/test_import_graph.py
|
| 37 |
+
tests/test_inference_agent_dispatch.py
|
| 38 |
tests/test_legal_constraint_enforcement.py
|
| 39 |
tests/test_llm_client.py
|
| 40 |
tests/test_observation_no_latent_leak.py
|
|
|
|
| 42 |
tests/test_outer_reward_non_constancy.py
|
| 43 |
tests/test_outer_reward_terminal_bonus.py
|
| 44 |
tests/test_package_exports.py
|
| 45 |
+
tests/test_reward_signal_quality.py
|
| 46 |
tests/test_schemas_roundtrip.py
|
| 47 |
tests/test_simulator_determinism.py
|
| 48 |
tests/test_simulator_random_episode.py
|
| 49 |
tests/test_simulator_task_configs.py
|
| 50 |
tests/test_smoke_env.py
|
| 51 |
+
tests/test_stdout_format.py
|
| 52 |
+
tests/test_synthetic_rejection_payload.py
|
| 53 |
+
tests/test_training_eval_metrics.py
|
| 54 |
+
tests/test_training_multi_model_skeleton.py
|
| 55 |
+
tests/test_training_reward_shaping.py
|
| 56 |
+
tests/test_training_rollout_buffer.py
|
| 57 |
+
tests/test_training_scripts_b1.py
|
| 58 |
+
tests/test_training_scripts_collect_sft.py
|
| 59 |
+
tests/test_training_scripts_sft.py
|
openenv_CrisisWorldCortex.egg-info/requires.txt
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
openenv-core[core]==0.2.3
|
| 2 |
openai<3.0,>=2.0
|
|
|
|
|
|
|
| 3 |
|
| 4 |
[dev]
|
| 5 |
pre-commit>=4.0.0
|
|
|
|
| 1 |
openenv-core[core]==0.2.3
|
| 2 |
openai<3.0,>=2.0
|
| 3 |
+
datasets>=4.0.0
|
| 4 |
+
huggingface-hub>=1.0.0
|
| 5 |
|
| 6 |
[dev]
|
| 7 |
pre-commit>=4.0.0
|
pyproject.toml
CHANGED
|
@@ -25,6 +25,9 @@ dependencies = [
|
|
| 25 |
# future uv sync from silently pulling 3.x. Bump explicitly when 3.0
|
| 26 |
# ships and we've verified compatibility.
|
| 27 |
"openai>=2.0,<3.0",
|
|
|
|
|
|
|
|
|
|
| 28 |
]
|
| 29 |
|
| 30 |
[project.optional-dependencies]
|
|
|
|
| 25 |
# future uv sync from silently pulling 3.x. Bump explicitly when 3.0
|
| 26 |
# ships and we've verified compatibility.
|
| 27 |
"openai>=2.0,<3.0",
|
| 28 |
+
# Training / data-collection scripts push trajectory datasets to HF.
|
| 29 |
+
"datasets>=4.0.0",
|
| 30 |
+
"huggingface-hub>=1.0.0",
|
| 31 |
]
|
| 32 |
|
| 33 |
[project.optional-dependencies]
|
training/scripts/collect_sft_data.py
CHANGED
|
@@ -273,59 +273,68 @@ def collect() -> int:
|
|
| 273 |
|
| 274 |
for task in tasks:
|
| 275 |
for ep in range(NUM_EPISODES):
|
|
|
|
| 276 |
try:
|
| 277 |
-
|
| 278 |
-
obs =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
except Exception as exc:
|
| 280 |
log(f"WARN env.reset failed task={task} ep={ep}: {exc}")
|
|
|
|
| 281 |
continue
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
if not accepted:
|
| 309 |
-
rejected_count += 1
|
| 310 |
-
elif reward < MIN_REWARD_THRESHOLD:
|
| 311 |
-
low_reward_count += 1
|
| 312 |
-
else:
|
| 313 |
-
rows.append(
|
| 314 |
-
{
|
| 315 |
-
"prompt": user_prompt,
|
| 316 |
-
"completion": json.dumps(action_dict, separators=(",", ":")),
|
| 317 |
-
"task": task,
|
| 318 |
-
"seed": ep,
|
| 319 |
-
"tick": tick,
|
| 320 |
-
"reward": float(reward),
|
| 321 |
-
"accepted": True,
|
| 322 |
-
}
|
| 323 |
)
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
if (ep + 1) % 5 == 0:
|
| 330 |
log(
|
| 331 |
f"[{task}] {ep + 1}/{NUM_EPISODES} kept={kept_count} "
|
|
|
|
| 273 |
|
| 274 |
for task in tasks:
|
| 275 |
for ep in range(NUM_EPISODES):
|
| 276 |
+
env = CrisisworldcortexEnv(base_url=ENV_URL).sync()
|
| 277 |
try:
|
| 278 |
+
reset_result = env.reset(task_name=task, seed=ep, max_ticks=EPISODE_TICKS)
|
| 279 |
+
obs = (
|
| 280 |
+
reset_result.observation
|
| 281 |
+
if hasattr(reset_result, "observation")
|
| 282 |
+
else reset_result
|
| 283 |
+
)
|
| 284 |
except Exception as exc:
|
| 285 |
log(f"WARN env.reset failed task={task} ep={ep}: {exc}")
|
| 286 |
+
env.close()
|
| 287 |
continue
|
| 288 |
+
try:
|
| 289 |
+
last_reward = 0.0
|
| 290 |
+
for tick in range(EPISODE_TICKS):
|
| 291 |
+
user_prompt = serialize_observation(obs, last_reward)
|
| 292 |
+
try:
|
| 293 |
+
completion = call_teacher(client, _SYSTEM_PROMPT_BODY, user_prompt)
|
| 294 |
+
except Exception as exc:
|
| 295 |
+
log(f"WARN teacher call failed task={task} ep={ep} tick={tick}: {exc}")
|
| 296 |
+
break
|
| 297 |
+
action_dict = parse_action_json(completion)
|
| 298 |
+
if action_dict is None:
|
| 299 |
+
parse_fail_count += 1
|
| 300 |
+
break
|
| 301 |
+
# Submit to env (Pydantic validates here).
|
| 302 |
+
try:
|
| 303 |
+
result = env.step(
|
| 304 |
+
CrisisworldcortexAction.model_validate({"action": action_dict})
|
| 305 |
+
)
|
| 306 |
+
except Exception as exc:
|
| 307 |
+
log(f"WARN env.step rejected task={task} ep={ep} tick={tick}: {exc}")
|
| 308 |
+
parse_fail_count += 1
|
| 309 |
+
break
|
| 310 |
+
next_obs = result.observation if hasattr(result, "observation") else result
|
| 311 |
+
reward = next_obs.reward if next_obs.reward is not None else 0.0
|
| 312 |
+
accepted = bool(
|
| 313 |
+
next_obs.recent_action_log and next_obs.recent_action_log[-1].accepted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
)
|
| 315 |
+
if not accepted:
|
| 316 |
+
rejected_count += 1
|
| 317 |
+
elif reward < MIN_REWARD_THRESHOLD:
|
| 318 |
+
low_reward_count += 1
|
| 319 |
+
else:
|
| 320 |
+
rows.append(
|
| 321 |
+
{
|
| 322 |
+
"prompt": user_prompt,
|
| 323 |
+
"completion": json.dumps(action_dict, separators=(",", ":")),
|
| 324 |
+
"task": task,
|
| 325 |
+
"seed": ep,
|
| 326 |
+
"tick": tick,
|
| 327 |
+
"reward": float(reward),
|
| 328 |
+
"accepted": True,
|
| 329 |
+
}
|
| 330 |
+
)
|
| 331 |
+
kept_count += 1
|
| 332 |
+
last_reward = float(reward)
|
| 333 |
+
obs = next_obs
|
| 334 |
+
if next_obs.done:
|
| 335 |
+
break
|
| 336 |
+
finally:
|
| 337 |
+
env.close()
|
| 338 |
if (ep + 1) % 5 == 0:
|
| 339 |
log(
|
| 340 |
f"[{task}] {ep + 1}/{NUM_EPISODES} kept={kept_count} "
|
training/scripts/train_b1_grpo.py
CHANGED
|
@@ -339,8 +339,8 @@ def main() -> int:
|
|
| 339 |
tasks = tuple(t.strip() for t in TASKS_CSV.split(",") if t.strip())
|
| 340 |
log(f"tasks={tasks}")
|
| 341 |
|
| 342 |
-
def make_env() ->
|
| 343 |
-
return CrisisworldcortexEnv(base_url=ENV_URL)
|
| 344 |
|
| 345 |
SYSTEM_PROMPT = build_system_prompt()
|
| 346 |
|
|
@@ -363,9 +363,17 @@ def main() -> int:
|
|
| 363 |
meta: list[dict] = []
|
| 364 |
for entry in seed_pool:
|
| 365 |
env = make_env()
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
|
| 370 |
train_dataset = Dataset.from_dict(
|
| 371 |
{
|
|
@@ -387,16 +395,19 @@ def main() -> int:
|
|
| 387 |
rewards: list[float] = []
|
| 388 |
for completion, t, s in zip(completions, task, seed):
|
| 389 |
env = make_env()
|
| 390 |
-
env.reset(task_name=t, seed=int(s), max_ticks=EPISODE_TICKS)
|
| 391 |
-
payload = parse_action(completion) or parse_failure_marker()
|
| 392 |
try:
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
return rewards
|
| 401 |
|
| 402 |
# ---- GRPO training ----
|
|
|
|
| 339 |
tasks = tuple(t.strip() for t in TASKS_CSV.split(",") if t.strip())
|
| 340 |
log(f"tasks={tasks}")
|
| 341 |
|
| 342 |
+
def make_env() -> Any:
|
| 343 |
+
return CrisisworldcortexEnv(base_url=ENV_URL).sync()
|
| 344 |
|
| 345 |
SYSTEM_PROMPT = build_system_prompt()
|
| 346 |
|
|
|
|
| 363 |
meta: list[dict] = []
|
| 364 |
for entry in seed_pool:
|
| 365 |
env = make_env()
|
| 366 |
+
try:
|
| 367 |
+
result = env.reset(
|
| 368 |
+
task_name=entry["task"],
|
| 369 |
+
seed=entry["seed"],
|
| 370 |
+
max_ticks=EPISODE_TICKS,
|
| 371 |
+
)
|
| 372 |
+
obs = result.observation if hasattr(result, "observation") else result
|
| 373 |
+
prompts.append(make_chat_prompt(obs))
|
| 374 |
+
meta.append(entry)
|
| 375 |
+
finally:
|
| 376 |
+
env.close()
|
| 377 |
|
| 378 |
train_dataset = Dataset.from_dict(
|
| 379 |
{
|
|
|
|
| 395 |
rewards: list[float] = []
|
| 396 |
for completion, t, s in zip(completions, task, seed):
|
| 397 |
env = make_env()
|
|
|
|
|
|
|
| 398 |
try:
|
| 399 |
+
env.reset(task_name=t, seed=int(s), max_ticks=EPISODE_TICKS)
|
| 400 |
+
payload = parse_action(completion) or parse_failure_marker()
|
| 401 |
+
try:
|
| 402 |
+
result = env.step(CrisisworldcortexAction(action=payload))
|
| 403 |
+
obs = result.observation if hasattr(result, "observation") else result
|
| 404 |
+
reward = obs.reward if obs.reward is not None else 0.0
|
| 405 |
+
rewards.append(float(reward))
|
| 406 |
+
except Exception as exc:
|
| 407 |
+
log(f"WARN env.step failed task={t} seed={s}: {exc}")
|
| 408 |
+
rewards.append(-1.0)
|
| 409 |
+
finally:
|
| 410 |
+
env.close()
|
| 411 |
return rewards
|
| 412 |
|
| 413 |
# ---- GRPO training ----
|
training/scripts/train_cortex_multi_model.py
CHANGED
|
@@ -398,8 +398,8 @@ def main() -> int:
|
|
| 398 |
tasks = tuple(t.strip() for t in TASKS_CSV.split(",") if t.strip())
|
| 399 |
log(f"tasks={tasks}")
|
| 400 |
|
| 401 |
-
def make_env() ->
|
| 402 |
-
return CrisisworldcortexEnv(base_url=ENV_URL)
|
| 403 |
|
| 404 |
train_dataset = Dataset.from_dict(
|
| 405 |
{
|
|
@@ -419,10 +419,16 @@ def main() -> int:
|
|
| 419 |
) -> list[float]:
|
| 420 |
rewards: list[float] = []
|
| 421 |
for _completion, t, s in zip(completions, task, seed):
|
|
|
|
| 422 |
try:
|
| 423 |
council = Council(brains=brains, routing_policy=router_policy)
|
| 424 |
env = make_env()
|
| 425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
cumulative = 0.0
|
| 427 |
last_reward = 0.0
|
| 428 |
for _ in range(EPISODE_TICKS):
|
|
@@ -438,6 +444,9 @@ def main() -> int:
|
|
| 438 |
except Exception as exc:
|
| 439 |
log(f"WARN rollout failed task={t} seed={s}: {exc}")
|
| 440 |
rewards.append(-1.0)
|
|
|
|
|
|
|
|
|
|
| 441 |
return rewards
|
| 442 |
|
| 443 |
# ---- GRPO config + trainer ----
|
|
|
|
| 398 |
tasks = tuple(t.strip() for t in TASKS_CSV.split(",") if t.strip())
|
| 399 |
log(f"tasks={tasks}")
|
| 400 |
|
| 401 |
+
def make_env() -> Any:
|
| 402 |
+
return CrisisworldcortexEnv(base_url=ENV_URL).sync()
|
| 403 |
|
| 404 |
train_dataset = Dataset.from_dict(
|
| 405 |
{
|
|
|
|
| 419 |
) -> list[float]:
|
| 420 |
rewards: list[float] = []
|
| 421 |
for _completion, t, s in zip(completions, task, seed):
|
| 422 |
+
env = None
|
| 423 |
try:
|
| 424 |
council = Council(brains=brains, routing_policy=router_policy)
|
| 425 |
env = make_env()
|
| 426 |
+
reset_result = env.reset(task_name=t, seed=int(s), max_ticks=EPISODE_TICKS)
|
| 427 |
+
obs = (
|
| 428 |
+
reset_result.observation
|
| 429 |
+
if hasattr(reset_result, "observation")
|
| 430 |
+
else reset_result
|
| 431 |
+
)
|
| 432 |
cumulative = 0.0
|
| 433 |
last_reward = 0.0
|
| 434 |
for _ in range(EPISODE_TICKS):
|
|
|
|
| 444 |
except Exception as exc:
|
| 445 |
log(f"WARN rollout failed task={t} seed={s}: {exc}")
|
| 446 |
rewards.append(-1.0)
|
| 447 |
+
finally:
|
| 448 |
+
if env is not None:
|
| 449 |
+
env.close()
|
| 450 |
return rewards
|
| 451 |
|
| 452 |
# ---- GRPO config + trainer ----
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|