Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b5636994d6 | |||
| 9fda7311ea |
@@ -1,29 +0,0 @@
|
||||
# SkillOpt Environment Variables
|
||||
# Copy this file to .env and fill in your values.
|
||||
# Usage: set -a; source .env; set +a
|
||||
|
||||
# ── Azure OpenAI (required for openai_chat backend) ──────────────────
|
||||
export AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
||||
export AZURE_OPENAI_API_VERSION=2024-12-01-preview
|
||||
# Authentication: choose one method
|
||||
# Option 1: API Key
|
||||
export AZURE_OPENAI_API_KEY=
|
||||
# Option 2: Azure CLI (no API key needed, recommended on Azure VMs)
|
||||
# export AZURE_OPENAI_AUTH_MODE=azure_cli
|
||||
# Option 3: Managed Identity
|
||||
# export AZURE_OPENAI_AUTH_MODE=managed_identity
|
||||
# export AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID=your-client-id
|
||||
|
||||
# ── OpenAI-compatible endpoints ──────────────────────────────────────
|
||||
# Set AUTH_MODE to openai_compatible and reuse AZURE_OPENAI_ENDPOINT / _API_KEY.
|
||||
# The plain OpenAI client is used; no Azure auth, no api-version header.
|
||||
# export AZURE_OPENAI_ENDPOINT=https://api.openai.com/v1
|
||||
# export AZURE_OPENAI_API_KEY=sk-...
|
||||
# export AZURE_OPENAI_AUTH_MODE=openai_compatible
|
||||
|
||||
# ── Anthropic / Claude (for claude_chat backend) ─────────────────────
|
||||
# export ANTHROPIC_API_KEY=sk-ant-...
|
||||
|
||||
# ── Qwen Local Model (for qwen_chat backend) ────────────────────────
|
||||
# export QWEN_CHAT_BASE_URL=http://localhost:8000/v1
|
||||
# export QWEN_CHAT_MODEL=Qwen/Qwen3.5-4B
|
||||
-27
@@ -1,42 +1,15 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.egg-info/
|
||||
build/
|
||||
dist/
|
||||
site/
|
||||
|
||||
data/
|
||||
outputs/
|
||||
logs/
|
||||
external/
|
||||
|
||||
/BabyVision/
|
||||
/MMRB/
|
||||
/SpreadsheetBench/
|
||||
/dl4ir-searchQA/
|
||||
|
||||
configs/local/
|
||||
configs/**/*.local.yaml
|
||||
*.local.md
|
||||
*.secret.md
|
||||
*.bak
|
||||
|
||||
.env
|
||||
.secrets/
|
||||
.codex_azure*/
|
||||
|
||||
# Internal docs (not for open-source release)
|
||||
docs/ablation_plan.md
|
||||
docs/ablation_paper_tables.md
|
||||
docs/ablation_paper_tables.html
|
||||
docs/experiment_commands.md
|
||||
docs/slow_update_flowchart.md
|
||||
docs/session_memory.md
|
||||
docs/harness_fresh_machine_handoff.md
|
||||
docs/harness_monitoring_memory.md
|
||||
docs/harness_reproduction_secrets.secret.md
|
||||
docs/reflact_conda_env_export.yml
|
||||
docs/reflact_overview.html
|
||||
docs/render_ablation_paper_tables.py
|
||||
docs/让*
|
||||
.gradio/
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# Contributing to SkillOpt
|
||||
|
||||
Thank you for your interest in contributing! SkillOpt welcomes contributions of all kinds.
|
||||
|
||||
## Getting Started
|
||||
|
||||
```bash
|
||||
git clone https://github.com/microsoft/SkillOpt.git
|
||||
cd SkillOpt
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
## How to Contribute
|
||||
|
||||
### 🐛 Bug Reports
|
||||
Open a GitHub issue with reproduction steps, expected/actual behavior, and your config file (remove API keys).
|
||||
|
||||
### 🔧 Add a Benchmark
|
||||
See the [guide](docs/guide/new-benchmark.md) and use the scaffold at `skillopt/envs/_template/`.
|
||||
|
||||
### 🤖 Add a Model Backend
|
||||
See the [guide](docs/guide/new-backend.md).
|
||||
|
||||
### 📝 Improve Documentation
|
||||
```bash
|
||||
pip install -e ".[docs]"
|
||||
mkdocs serve # Preview at http://localhost:8000
|
||||
```
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. Fork the repo and create a feature branch
|
||||
2. Make changes and test with an existing benchmark
|
||||
3. Submit a PR with a clear description
|
||||
4. Ensure CI passes
|
||||
|
||||
## Code Style
|
||||
- Follow existing patterns in the codebase
|
||||
- Use type hints for function signatures
|
||||
- Keep docstrings concise
|
||||
|
||||
## License
|
||||
By contributing, you agree your contributions are licensed under the [MIT License](LICENSE).
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,288 +1,557 @@
|
||||
# SkillOpt: Executive Strategy for Self-Evolving Agent Skills
|
||||
# ReflACT: Reflective Agent Tuning
|
||||
|
||||
*Train agent skills like you train neural networks — with epochs, (mini-)batchsize, learning rates, and validation gates — but without touching model weights.*
|
||||
ReflACT is a framework for optimizing an external skill document through iterative rollout, reflection, editing, and gated validation.
|
||||
|
||||
[](https://microsoft.github.io/SkillOpt/) [](https://arxiv.org/abs/2605.23904) [](https://youtu.be/JUBMDTCiM0M) [](https://www.python.org/) [](LICENSE)
|
||||
It does **not** fine-tune model weights. Instead, it treats the skill document as the optimization target:
|
||||
|
||||
## 🎬 SkillOpt Demo Video
|
||||
- the **student** model executes tasks with the current skill
|
||||
- the **teacher** model analyzes trajectories and proposes edits
|
||||
- the framework merges, ranks, applies, and validates those edits
|
||||
- only validated skill updates are kept
|
||||
|
||||
https://github.com/user-attachments/assets/eb12d3bc-371c-467f-904d-91b61f339ed7
|
||||
This branch implements a full training loop with step-level skill optimization and optional epoch-level memory mechanisms (`slow_update`, `meta_skill`, `meta_reflect`).
|
||||
|
||||
<p align="center">
|
||||
<a href="https://youtu.be/JUBMDTCiM0M"><b>▶ Watch the full demo on YouTube</b></a>
|
||||
</p>
|
||||
## Method Overview
|
||||
|
||||
---
|
||||
### Optimization Target
|
||||
|
||||
## Documentation
|
||||
Each run maintains a mutable markdown skill document. The framework repeatedly improves that document instead of changing model parameters.
|
||||
|
||||
A complete, self-contained **Documentation & Reproduction Guide** lives at
|
||||
[`docs/guideline.html`](docs/guideline.html). It covers installation, data
|
||||
preparation, training/eval commands, the full configuration reference, the
|
||||
framework internals (training loop, validation gate, slow update, meta skill),
|
||||
and an API/function reference — all in a single page with a left navigation
|
||||
sidebar.
|
||||
This gives a training-style loop for prompt / policy optimization:
|
||||
|
||||
Because GitHub shows raw source for `.html` files instead of rendering them,
|
||||
open the guide one of these ways:
|
||||
1. Roll out the current skill on a batch of tasks.
|
||||
2. Reflect on failures and successes.
|
||||
3. Merge patch proposals into a coherent candidate update.
|
||||
4. Rank and select a bounded number of edits.
|
||||
5. Apply those edits to produce a candidate skill.
|
||||
6. Validate the candidate skill on a held-out selection split.
|
||||
7. Keep the update only if the gate accepts it.
|
||||
|
||||
- **Locally** — clone the repo and open `docs/guideline.html` in any browser
|
||||
(no build step required).
|
||||
- **Rendered online (no setup)** — via the htmlpreview proxy:
|
||||
[`htmlpreview.github.io/?…/docs/guideline.html`](https://htmlpreview.github.io/?https://github.com/microsoft/SkillOpt/blob/main/docs/guideline.html)
|
||||
- **GitHub Pages** — the repository's GitHub Pages site already serves the
|
||||
project homepage from the repo root, so the guide is reachable alongside it at
|
||||
`https://microsoft.github.io/SkillOpt/docs/guideline.html` (the homepage at
|
||||
`https://microsoft.github.io/SkillOpt/` is unaffected).
|
||||
### Per-Step Pipeline
|
||||
|
||||
---
|
||||
Every training step executes the following pipeline in `skillopt/engine/trainer.py`:
|
||||
|
||||
## Install
|
||||
1. **Rollout**
|
||||
The student model runs a batch of tasks using the current skill.
|
||||
|
||||
**Requirements:** Python 3.10+
|
||||
2. **Reflect**
|
||||
The teacher analyzes minibatches of trajectories and emits raw patches.
|
||||
Failure-driven and success-driven patches are tracked separately.
|
||||
|
||||
3. **Aggregate**
|
||||
Raw patches are merged hierarchically. Metadata such as `support_count` and `source_type` is carried into the merged patch so later ranking can use it.
|
||||
|
||||
4. **Select**
|
||||
The teacher ranks the merged edit pool and keeps up to `edit_budget` edits.
|
||||
|
||||
5. **Update**
|
||||
The selected edits are applied to the skill document. The framework records an `edit_apply_report.json` so you can see which edits actually landed, which were skipped, and why.
|
||||
|
||||
6. **Evaluate / Gate**
|
||||
The candidate skill is evaluated on the selection split. Gate validation is mandatory in this branch. A candidate update is accepted only if it improves over the current selection score; a new global best is tracked separately.
|
||||
|
||||
### Within-Epoch Memory
|
||||
|
||||
Inside an epoch, the trainer maintains a step buffer containing:
|
||||
|
||||
- compact failure-pattern summaries from previous steps
|
||||
- rejected edits and their score deltas
|
||||
|
||||
That context is fed back into later reflection calls so the teacher can avoid repeating ineffective edits and can focus on unsolved error patterns.
|
||||
|
||||
### Epoch-Level Mechanisms
|
||||
|
||||
This branch supports three optional epoch-level mechanisms.
|
||||
|
||||
#### Slow Update
|
||||
|
||||
At the end of each epoch, `slow_update` compares the previous epoch’s terminal skill and current epoch’s terminal skill on a sampled train subset. It then writes longitudinal guidance into a protected slow-update region inside the skill document.
|
||||
|
||||
Importantly, this guidance is **not** blindly written through. It is converted into a candidate skill and sent through the same selection gate as step-level updates.
|
||||
|
||||
#### Meta Skill
|
||||
|
||||
`meta_skill` is teacher-side cross-epoch memory. It does not directly edit the current skill. Instead, it writes a compact memory artifact describing longer-term patterns across adjacent epochs. That memory is loaded into later reflection / merge / ranking calls as extra context.
|
||||
|
||||
#### Meta Reflect
|
||||
|
||||
`meta_reflect` runs at epoch end over the step history of the current epoch. It looks at accepted and rejected directions from the whole epoch, proposes higher-level patch edits, applies them to a meta candidate, and then sends that candidate through the same selection gate.
|
||||
|
||||
## What This Branch Guarantees
|
||||
|
||||
The current implementation assumes the following as the mainline method contract:
|
||||
|
||||
- gate validation is always on
|
||||
- the current skill, current score, best skill, and best score stay aligned
|
||||
- `slow_update` is gated before being committed
|
||||
- patch provenance (`source_type`, `support_count`) reaches selection
|
||||
- patch application is observable through per-edit reports
|
||||
- resume state is restored from `runtime_state.json` rather than inferred only from history
|
||||
- all benchmark model calls go through the unified backend router
|
||||
|
||||
## Model Backends
|
||||
|
||||
All model access now goes through the split teacher/student model layer in `skillopt.model`.
|
||||
|
||||
Supported teacher backends:
|
||||
|
||||
- `openai_chat`
|
||||
- `claude_chat`
|
||||
|
||||
Supported student backends:
|
||||
|
||||
- `openai_chat`
|
||||
- `claude_chat`
|
||||
- `codex_exec`
|
||||
- `claude_code_exec`
|
||||
|
||||
Recommended config shape:
|
||||
|
||||
```yaml
|
||||
model:
|
||||
teacher_backend: openai_chat
|
||||
student_backend: codex_exec
|
||||
teacher: gpt-5.4
|
||||
student: gpt-5.4-codex
|
||||
reasoning_effort: medium
|
||||
```
|
||||
|
||||
Legacy `model.backend` and CLI flags like `--backend codex` still work. They are mapped onto the split backend model for backward compatibility.
|
||||
|
||||
The same routing is used by:
|
||||
|
||||
- training (`scripts/train.py`)
|
||||
- eval-only runs (`scripts/eval_only.py`)
|
||||
- SpreadsheetBench standalone prompt eval scripts
|
||||
- LiveMathematicianBench baseline eval script
|
||||
- benchmark rollout code inside the main framework
|
||||
|
||||
### Azure OpenAI
|
||||
|
||||
If you use `openai_chat`, configure either environment variables or config values:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/microsoft/SkillOpt.git
|
||||
cd SkillOpt
|
||||
pip install -e .
|
||||
|
||||
# For ALFWorld benchmark (optional):
|
||||
pip install -e ".[alfworld]"
|
||||
alfworld-download
|
||||
export AZURE_OPENAI_ENDPOINT="https://your-endpoint.openai.azure.com/"
|
||||
export AZURE_OPENAI_API_KEY="your-api-key"
|
||||
export AZURE_OPENAI_API_VERSION="2025-04-01-preview"
|
||||
```
|
||||
|
||||
### Configure API Credentials
|
||||
The config supports both the old keys and the new explicit names:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# Edit .env with your API credentials, then:
|
||||
source .env
|
||||
```yaml
|
||||
model:
|
||||
azure_openai_endpoint: "..."
|
||||
azure_openai_api_version: "..."
|
||||
azure_openai_api_key: ""
|
||||
azure_openai_auth_mode: api_key
|
||||
azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
azure_openai_managed_identity_client_id: ""
|
||||
```
|
||||
|
||||
**Azure OpenAI** (recommended):
|
||||
```bash
|
||||
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
|
||||
# Option 1: API key auth
|
||||
export AZURE_OPENAI_API_KEY="your-key"
|
||||
# Option 2: Azure CLI auth (no API key needed)
|
||||
export AZURE_OPENAI_AUTH_MODE="azure_cli"
|
||||
`azure_openai_auth_mode` can be used for API-key auth or Azure AD / managed identity flows.
|
||||
|
||||
### Exec Harness
|
||||
|
||||
`codex_exec` and `claude_code_exec` run the student inside a workspace harness instead of a plain chat call. The harness writes task files, renders a dynamic `SKILL.md`, runs the student CLI, and saves raw execution artifacts such as:
|
||||
|
||||
- `codex_raw.txt`
|
||||
- `codex_trace_summary.txt`
|
||||
- workspace-local task / skill files
|
||||
|
||||
This branch keeps `meta_skill` and `apply_patch_with_report`, while upgrading the student path to the more realistic workspace-exec setup.
|
||||
|
||||
### Trace-Aware Deep Reflect
|
||||
|
||||
When `student_backend=codex_exec` and `gradient.use_deep_reflect=true`, deep reflection can probe a specific earlier Codex attempt:
|
||||
|
||||
- the teacher sees a compact Codex trace summary
|
||||
- deep probe can target `probe_target_id`
|
||||
- the follow-up rollout can resume from `probe_after_step`
|
||||
|
||||
This is wired for the dataset-backed environments in this branch.
|
||||
|
||||
### Rewrite Mode
|
||||
|
||||
Skill updates support two modes:
|
||||
|
||||
- `optimizer.skill_update_mode=patch`
|
||||
- `optimizer.skill_update_mode=rewrite_from_suggestions`
|
||||
|
||||
`patch` keeps the existing fine-grained edit application path and still records `edit_apply_report.json`.
|
||||
|
||||
`rewrite_from_suggestions` asks the teacher to emit higher-level rewrite suggestions, then rewrites the whole skill in one pass. This is useful when patch edits become too fragmented.
|
||||
|
||||
## Repository Layout
|
||||
|
||||
```text
|
||||
skillopt/
|
||||
engine/
|
||||
trainer.py main training loop
|
||||
gradient/
|
||||
reflect.py minibatch reflection
|
||||
aggregate.py hierarchical patch merge
|
||||
deep_probe.py diagnostic probing for deep reflect
|
||||
optimizer/
|
||||
clip.py edit ranking / selection
|
||||
skill.py patch application + apply report
|
||||
slow_update.py epoch-level longitudinal guidance
|
||||
meta_skill.py teacher-side cross-epoch memory
|
||||
meta_reflect.py epoch-level macro editing
|
||||
evaluation/
|
||||
gate.py pure gate decision logic
|
||||
model/
|
||||
backend_config.py teacher/student backend routing
|
||||
azure_openai.py Azure backend
|
||||
codex_harness.py workspace exec harness + Codex trace parsing
|
||||
claude_backend.py Claude backend
|
||||
envs/
|
||||
... environment adapters and rollout logic
|
||||
scripts/
|
||||
train.py unified training entry
|
||||
eval_only.py evaluate one skill without training
|
||||
configs/
|
||||
_base_/default.yaml shared defaults
|
||||
<env>/default.yaml environment-specific configs
|
||||
```
|
||||
|
||||
> **Note:** `AZURE_OPENAI_ENDPOINT` is required for all three modes (`api_key`, `azure_cli`,
|
||||
> `openai_compatible`). Without it, all LLM calls will fail.
|
||||
## Configuration
|
||||
|
||||
**OpenAI-compatible endpoints**:
|
||||
```bash
|
||||
export AZURE_OPENAI_ENDPOINT="https://api.openai.com/v1"
|
||||
export AZURE_OPENAI_API_KEY="sk-..."
|
||||
export AZURE_OPENAI_AUTH_MODE="openai_compatible"
|
||||
Configs use structured YAML with `_base_` inheritance.
|
||||
|
||||
The base config is `configs/_base_/default.yaml`. Key defaults in this branch are:
|
||||
|
||||
- `model.teacher_backend = openai_chat`
|
||||
- `model.student_backend = openai_chat`
|
||||
- `model.reasoning_effort = medium`
|
||||
- `optimizer.use_slow_update = true`
|
||||
- `optimizer.use_meta_skill = true`
|
||||
- `optimizer.use_meta_reflect = false`
|
||||
- `gradient.use_deep_reflect = false`
|
||||
- `optimizer.skill_update_mode = patch`
|
||||
|
||||
Default setting snapshot:
|
||||
|
||||
```yaml
|
||||
model:
|
||||
backend: azure_openai
|
||||
teacher: gpt-5.4
|
||||
student: gpt-5.4
|
||||
teacher_backend: openai_chat
|
||||
student_backend: openai_chat
|
||||
reasoning_effort: medium
|
||||
rewrite_reasoning_effort: ""
|
||||
rewrite_max_completion_tokens: 64000
|
||||
codex_exec_path: codex
|
||||
codex_exec_sandbox: workspace-write
|
||||
codex_exec_profile: ""
|
||||
codex_exec_full_auto: false
|
||||
codex_exec_reasoning_effort: none
|
||||
claude_code_exec_path: claude
|
||||
claude_code_exec_profile: ""
|
||||
codex_trace_to_teacher: true
|
||||
|
||||
train:
|
||||
num_epochs: 4
|
||||
train_size: 0
|
||||
batch_size: 80
|
||||
accumulation: 1
|
||||
seed: 42
|
||||
|
||||
gradient:
|
||||
minibatch_size: 16
|
||||
merge_batch_size: 16
|
||||
analyst_workers: 16
|
||||
max_analyst_rounds: 3
|
||||
failure_only: false
|
||||
use_deep_reflect: false
|
||||
deep_reflect_failures: 4
|
||||
deep_reflect_successes: 2
|
||||
|
||||
optimizer:
|
||||
learning_rate: 8
|
||||
min_learning_rate: 2
|
||||
lr_scheduler: cosine
|
||||
skill_update_mode: patch
|
||||
use_meta_reflect: false
|
||||
meta_learning_rate: 8
|
||||
use_slow_update: true
|
||||
slow_update_samples: 20
|
||||
use_meta_skill: true
|
||||
|
||||
evaluation:
|
||||
use_gate: true
|
||||
sel_env_num: 0
|
||||
test_env_num: 0
|
||||
eval_test: true
|
||||
|
||||
env:
|
||||
split_mode: ratio
|
||||
split_ratio: "2:1:7"
|
||||
split_seed: 42
|
||||
```
|
||||
|
||||
This routes all calls through the plain OpenAI Python client (no Azure auth, no `api-version`
|
||||
header).
|
||||
For the full source of truth, see [configs/_base_/default.yaml](/home/azureuser/workspace-yqh/skillopt_final/configs/_base_/default.yaml).
|
||||
|
||||
> **Note:** SkillOpt reuses the `AZURE_OPENAI_*` env var names even in this mode — there is no
|
||||
> separate `OPENAI_API_KEY` knob.
|
||||
Selected fields:
|
||||
|
||||
**Anthropic Claude**:
|
||||
```bash
|
||||
export ANTHROPIC_API_KEY="sk-ant-..."
|
||||
```
|
||||
|
||||
**Qwen (local vLLM)**:
|
||||
```bash
|
||||
export QWEN_CHAT_BASE_URL="http://localhost:8000/v1"
|
||||
export QWEN_CHAT_MODEL="Qwen/Qwen3.5-4B"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Data Preparation
|
||||
|
||||
SkillOpt expects data in a **split directory** with `train/`, `val/`, `test/` subdirectories, each containing a JSON file (e.g., `items.json`).
|
||||
|
||||
```
|
||||
data/my_split/
|
||||
├── train/items.json
|
||||
├── val/items.json
|
||||
└── test/items.json
|
||||
```
|
||||
|
||||
Each JSON file is an array of task items. The required fields depend on the benchmark. For example, SearchQA items look like:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "unique_item_id",
|
||||
"question": "Who wrote the novel ...",
|
||||
"context": "[DOC] relevant passage text ...",
|
||||
"answers": ["expected answer"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
See `skillopt/envs/<benchmark>/dataloader.py` for the exact format each benchmark expects.
|
||||
|
||||
> **Note:** Benchmark datasets are not included in this repository. Prepare your own data following the format above.
|
||||
|
||||
### Supported Benchmarks
|
||||
|
||||
| Benchmark | Type | Config |
|
||||
| Section | Key | Meaning |
|
||||
|---|---|---|
|
||||
| SearchQA | QA | `configs/searchqa/default.yaml` |
|
||||
| ALFWorld | Embodied agent | `configs/alfworld/default.yaml` |
|
||||
| DocVQA | Document QA | `configs/docvqa/default.yaml` |
|
||||
| LiveMathematicianBench | Math | `configs/livemathematicianbench/default.yaml` |
|
||||
| SpreadsheetBench | Code generation | `configs/spreadsheetbench/default.yaml` |
|
||||
| OfficeQA | Tool-augmented QA | `configs/officeqa/default.yaml` |
|
||||
| `model` | `teacher_backend` | teacher backend: `openai_chat` or `claude_chat` |
|
||||
| `model` | `student_backend` | student backend: chat backend or exec backend |
|
||||
| `model` | `teacher` | teacher model / deployment |
|
||||
| `model` | `student` | student model / deployment |
|
||||
| `model` | `reasoning_effort` | reasoning budget passed to the backend when supported |
|
||||
| `model` | `codex_trace_to_teacher` | include Codex trace summaries in teacher reflection context |
|
||||
| `train` | `num_epochs` | number of epochs |
|
||||
| `train` | `train_size` | expected train split size, or `0` to infer |
|
||||
| `train` | `batch_size` | tasks per rollout batch |
|
||||
| `train` | `accumulation` | number of rollout/reflect minibatches per step |
|
||||
| `gradient` | `minibatch_size` | trajectories per analyst minibatch |
|
||||
| `gradient` | `merge_batch_size` | patches per aggregate batch |
|
||||
| `gradient` | `use_deep_reflect` | enable diagnostic probe rollouts |
|
||||
| `gradient` | `max_analyst_rounds` | teacher reflection retries / refinement budget |
|
||||
| `optimizer` | `learning_rate` | max edits kept after selection |
|
||||
| `optimizer` | `lr_scheduler` | edit-budget scheduler |
|
||||
| `optimizer` | `use_slow_update` | epoch-level longitudinal guidance |
|
||||
| `optimizer` | `use_meta_skill` | teacher-side epoch memory |
|
||||
| `optimizer` | `use_meta_reflect` | epoch-level macro editing |
|
||||
| `optimizer` | `skill_update_mode` | `patch` or `rewrite_from_suggestions` |
|
||||
| `evaluation` | `sel_env_num` | selection set size (`0` means full split) |
|
||||
| `evaluation` | `test_env_num` | test set size (`0` means full split) |
|
||||
|
||||
---
|
||||
### Important Branch Rule
|
||||
|
||||
## Quick Start
|
||||
`use_gate=false` is intentionally not supported in this branch. Gate validation is part of the method contract here.
|
||||
|
||||
### Training
|
||||
If an old config still contains `evaluation.use_gate: false`, the loader / trainer will raise instead of silently continuing.
|
||||
|
||||
```bash
|
||||
# Minimal example — train on SearchQA:
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--split_dir /path/to/your/searchqa_split \
|
||||
--azure_openai_endpoint https://your-resource.openai.azure.com/ \
|
||||
--optimizer_model gpt-5.5 \
|
||||
--target_model gpt-5.5
|
||||
## Supported Environments
|
||||
|
||||
# Train on LiveMathematicianBench:
|
||||
python scripts/train.py \
|
||||
--config configs/livemathematicianbench/default.yaml \
|
||||
--split_dir /path/to/your/livemath_split \
|
||||
--azure_openai_endpoint https://your-resource.openai.azure.com/ \
|
||||
--optimizer_model gpt-5.5 \
|
||||
--target_model gpt-5.5
|
||||
The main training entry and eval-only entry now register 11 environments:
|
||||
|
||||
# Train on ALFWorld:
|
||||
python scripts/train.py \
|
||||
--config configs/alfworld/default.yaml \
|
||||
--split_dir /path/to/your/alfworld_split \
|
||||
--azure_openai_endpoint https://your-resource.openai.azure.com/ \
|
||||
--optimizer_model gpt-5.5 \
|
||||
--target_model gpt-5.5
|
||||
```
|
||||
| Env | Default rollout shape | Current default split / data setting | Branch alignment |
|
||||
|---|---|---|---|
|
||||
| `alfworld` | environment-backed episodic rollout | native ALFWorld train/eval splits | in `skillopt_new_zzw` |
|
||||
| `babyvision` | single-round multimodal QA | `split_mode=ratio` from raw metadata/images, or prepared `split_dir` | in `skillopt_new_zzw` |
|
||||
| `docvqa` | single-round multimodal QA | `split_dir: data/docvqa_split` | in `skillopt_new_zzw` |
|
||||
| `livemathematicianbench` | single-round QA | `split_mode=ratio` or prepared `split_dir` | in `skillopt_new_zzw` |
|
||||
| `mathverse` | single-round multimodal math QA | `data_root: data/MathVerse`, split files loaded from `split_dir` when provided | in `skillopt_new_zzw` |
|
||||
| `mmrb` | single-round multimodal reasoning QA | `split_mode=ratio` or prepared `split_dir` | in `skillopt_new_zzw` |
|
||||
| `officeqa` | multi-turn tool loop | `split_dir: data/officeqa_split` plus `data_dirs: [data/officeqa_docs_official]` | in `skillopt_new_zzw` |
|
||||
| `sealqa` | multi-turn tool loop | `split_dir: data/sealqa_split` | in `skillopt_new_zzw` |
|
||||
| `searchqa` | single-round QA (`max_turns=1`) | `split_dir: data/searchqa_split` | in `skillopt_new_zzw` |
|
||||
| `spreadsheetbench` | codegen loop, default `mode=multi`, `max_turns=30` | `split_dir: data/spreadsheetbench_split`, `data_root: data/spreadsheetbench_verified_400` | in `skillopt_new_zzw`, default adjusted here to multi-round |
|
||||
| `swebench` | mini-swe-agent multi-step bug-fixing rollout | `split_mode=ratio`, `dataset_name=lite`, repo-stratified `2:1:7` split materialized under `out_root/_generated_splits/...` unless `split_dir` is provided | added here, aligned to `swe-bench-old` |
|
||||
|
||||
Key CLI arguments:
|
||||
## Data Expectations
|
||||
|
||||
| Argument | Description | Example |
|
||||
|---|---|---|
|
||||
| `--config` | Benchmark config YAML | `configs/searchqa/default.yaml` |
|
||||
| `--split_dir` | Path to data split directory | `/path/to/split` |
|
||||
| `--azure_openai_endpoint` | Azure OpenAI endpoint URL | `https://your-resource.openai.azure.com/` |
|
||||
| `--optimizer_model` | Optimizer model deployment name | `gpt-5.5` |
|
||||
| `--target_model` | Target model deployment name | `gpt-5.5` |
|
||||
| `--num_epochs` | Number of training epochs | `4` |
|
||||
| `--batch_size` | Batch size per step | `40` |
|
||||
| `--workers` | Parallel rollout workers | `8` |
|
||||
| `--out_root` | Output directory | `outputs/my_run` |
|
||||
The standard two-mode dataset entry path is:
|
||||
|
||||
### Eval Only
|
||||
- `split_mode: ratio`
|
||||
- load raw data from `env.data_path`
|
||||
- build a deterministic `train/`, `val/`, `test/` split under `env.split_output_dir` (or under `out_root/_generated_splits/` if unset)
|
||||
- default ratio is explicitly `2:1:7`
|
||||
- `split_mode: split_dir`
|
||||
- load an existing `env.split_dir` with `train/`, `val/`, `test/` subdirectories
|
||||
|
||||
Evaluate a trained skill on specific data splits without training:
|
||||
This currently applies to:
|
||||
|
||||
```bash
|
||||
# Evaluate the packaged GPT-5.5 SearchQA skill on the test split:
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill ckpt/searchqa/gpt5.5_skill.md \
|
||||
--split valid_unseen \
|
||||
--split_dir /path/to/searchqa_split \
|
||||
--azure_openai_endpoint https://your-resource.openai.azure.com/
|
||||
- `searchqa`
|
||||
- `spreadsheetbench`
|
||||
- `babyvision`
|
||||
- `livemathematicianbench`
|
||||
- `mmrb`
|
||||
- `swebench`
|
||||
|
||||
# Evaluate on all splits (train + val + test):
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill ckpt/searchqa/gpt5.5_skill.md \
|
||||
--split all \
|
||||
--split_dir /path/to/searchqa_split \
|
||||
--azure_openai_endpoint https://your-resource.openai.azure.com/
|
||||
```
|
||||
`ALFWorld` is the exception: it is environment-backed rather than JSON split-backed.
|
||||
|
||||
To evaluate a skill produced by a training run, replace `--skill` with that
|
||||
run's best-skill path, for example `outputs/my_run/best_skill.md`.
|
||||
The following environments currently expect prepared split directories or extra rooted assets rather than the generic ratio-split path:
|
||||
|
||||
| Split | Description |
|
||||
- `docvqa`
|
||||
- `mathverse`
|
||||
- `officeqa`
|
||||
- `sealqa`
|
||||
|
||||
At a high level:
|
||||
|
||||
- `SearchQA`: raw QA json / jsonl or pre-split QA json files
|
||||
- `SpreadsheetBench`: raw task manifest json plus spreadsheet task directory, or a pre-split task manifest
|
||||
- `ALFWorld`: installed game environment and configured eval/train splits
|
||||
- `BabyVision`: raw `meta_data.jsonl` plus images, or a pre-split directory
|
||||
- `DocVQA`: pre-split CSV / JSON data under `split_dir`
|
||||
- `LiveMathematicianBench`: raw monthly QA json files, or a pre-split directory
|
||||
- `MathVerse`: split files plus `data_root` image assets
|
||||
- `MMRB`: raw extracted dataset json files, or a pre-split directory
|
||||
- `OfficeQA`: pre-split metadata plus resolved office document directories
|
||||
- `SealQA`: pre-split metadata for tool-augmented QA tasks
|
||||
- `SWEBench`: HuggingFace SWE-bench dataset alias (`lite` / `verified` / `full`) or a prepared split directory
|
||||
|
||||
### Split References Across Branches
|
||||
|
||||
The split-related defaults are not identical across `skillopt-final`, `skillopt_new_zzw`, `gepa`, and `swe-bench-old`. The practical reference points are:
|
||||
|
||||
| Source branch | Explicit split settings / dirs |
|
||||
|---|---|
|
||||
| `valid_unseen` | Test set |
|
||||
| `valid_seen` | Validation set |
|
||||
| `train` | Training set |
|
||||
| `all` | All splits combined (default) |
|
||||
| `skillopt-final` | `searchqa -> data/searchqa_split`; `spreadsheetbench -> data/spreadsheetbench_split`; `docvqa -> data/docvqa_split`; `officeqa -> data/officeqa_split`; `sealqa -> data/sealqa_split`; `swebench -> ratio split 2:1:7 over the default lite dataset, materialized under out_root/_generated_splits/...` |
|
||||
| `skillopt_new_zzw` | Same 10-benchmark env set as above except no `swebench`; explicit split dirs are `data/searchqa_split`, `data/spreadsheetbench_split`, `data/docvqa_split`, `data/officeqa_split`, `data/sealqa_split`; `spreadsheetbench` there defaults to `mode=single`; `officeqa` uses `max_tool_turns=24`; `sealqa` uses `max_tool_turns=12` |
|
||||
| `gepa` | `configs/spreadsheetbench.yaml` uses `data.splits_dir = data/spreadsheetbench/splits`, `eval.mode = react`, `eval.max_turns = 20`; `configs/swebench.yaml` uses `dataset = SWE-bench/SWE-bench_Verified` with `train_size = 100`, `val_size = 50`, `test_size = 350` |
|
||||
| `swe-bench-old` | Repo-stratified `2:1:7` split over `SWE-Bench_Lite`, persisted as `outputs/.../split/train.json`, `selection.json`, `test.json`; the example split in that branch is `train=60`, `selection=33`, `test=207` |
|
||||
|
||||
### Output Structure
|
||||
For the 10 benches shared with `skillopt_new_zzw`, the current branch is now aligned on env coverage. The main intentional delta is `spreadsheetbench`: this branch defaults to multi-round codegen, while `skillopt_new_zzw` kept `mode=single` by default.
|
||||
|
||||
Each run writes to a structured output directory:
|
||||
## Running Training
|
||||
|
||||
```
|
||||
outputs/<run_name>/
|
||||
├── config.json # Flattened runtime config
|
||||
├── history.json # Per-step training history
|
||||
├── runtime_state.json # Resume checkpoint
|
||||
├── best_skill.md # Best validated skill document
|
||||
├── skills/skill_vXXXX.md # Skill snapshot per step
|
||||
├── steps/step_XXXX/ # Per-step artifacts (patches, evals)
|
||||
├── slow_update/epoch_XX/ # Slow update logs
|
||||
└── meta_skill/epoch_XX/ # Meta skill logs
|
||||
```
|
||||
|
||||
Re-running the same command auto-resumes from the last completed step.
|
||||
|
||||
---
|
||||
|
||||
## Community-contributed configs
|
||||
|
||||
These are **not** default SkillOpt settings — they are reference configs
|
||||
contributed by users for specific scenarios. The paper-reported numbers
|
||||
were obtained with the default settings, not these.
|
||||
|
||||
- **`configs/examples/soft_gate.yaml`** *(PR #25, contributed by
|
||||
[@lvbaocheng](https://github.com/lvbaocheng))* — switches the
|
||||
validation gate from exact-match (`hard`) to soft / partial-credit
|
||||
(`soft` or `mixed`). Useful when the held-out **selection split is
|
||||
small** (e.g. ≤ ~10 items) and the **reward is continuous**, where the
|
||||
discrete hard gate often rejects every candidate and training stalls.
|
||||
See the comment at the top of the file for details and when not to use
|
||||
it.
|
||||
|
||||
---
|
||||
|
||||
## WebUI
|
||||
|
||||
Launch the monitoring dashboard (optional):
|
||||
Example:
|
||||
|
||||
```bash
|
||||
pip install -e ".[webui]"
|
||||
python -m skillopt_webui.app
|
||||
python scripts/train.py --config configs/searchqa/default.yaml
|
||||
```
|
||||
|
||||
| Flag | Default | Description |
|
||||
|---|---|---|
|
||||
| `--port` | 7860 | Server port |
|
||||
| `--host` | `0.0.0.0` | Bind address |
|
||||
| `--share` | off | Create a public Gradio share link |
|
||||
Explicit 2:1:7 split from raw data:
|
||||
|
||||
```bash
|
||||
# With public share link (useful for remote servers)
|
||||
python -m skillopt_webui.app --share
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--split_mode ratio \
|
||||
--data_path /path/to/searchqa_train_2000.json
|
||||
```
|
||||
|
||||
---
|
||||
Directly consume a prepared split directory:
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@misc{yang2026skilloptexecutivestrategyselfevolving,
|
||||
title={SkillOpt: Executive Strategy for Self-Evolving Agent Skills},
|
||||
author={Yifan Yang and Ziyang Gong and Weiquan Huang and Qihao Yang and Ziwei Zhou and Zisu Huang and Yan Li and Xuemei Gao and Qi Dai and Bei Liu and Kai Qiu and Yuqing Yang and Dongdong Chen and Xue Yang and Chong Luo},
|
||||
year={2026},
|
||||
eprint={2605.23904},
|
||||
archivePrefix={arXiv},
|
||||
primaryClass={cs.AI},
|
||||
url={https://arxiv.org/abs/2605.23904}
|
||||
}
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--split_mode split_dir \
|
||||
--split_dir /path/to/searchqa_split
|
||||
```
|
||||
|
||||
You can override structured config keys from the CLI:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/spreadsheetbench/default.yaml \
|
||||
--cfg-options model.teacher_backend=openai_chat model.student_backend=codex_exec train.batch_size=40 optimizer.learning_rate=4
|
||||
```
|
||||
|
||||
Legacy flat overrides still work for common keys:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--backend azure_openai \
|
||||
--teacher_model gpt-5.4 \
|
||||
--student_model gpt-5.4 \
|
||||
--reasoning_effort medium
|
||||
```
|
||||
|
||||
Exec harness example:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--teacher_backend openai_chat \
|
||||
--student_backend codex_exec \
|
||||
--teacher_model gpt-5.4 \
|
||||
--student_model gpt-5.4-codex \
|
||||
--use_deep_reflect true \
|
||||
--skill_update_mode rewrite_from_suggestions
|
||||
```
|
||||
|
||||
SWEBench example:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/swebench/default.yaml \
|
||||
--cfg-options env.dataset_name=lite env.split_ratio=2:1:7
|
||||
```
|
||||
|
||||
## Eval-Only and Standalone Evaluation
|
||||
|
||||
Evaluate a specific skill without training:
|
||||
|
||||
```bash
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill skillopt/envs/searchqa/skills/initial.md
|
||||
```
|
||||
|
||||
The same dataset entry modes apply in eval-only runs:
|
||||
|
||||
- `--split_mode ratio --data_path ...`
|
||||
- `--split_mode split_dir --split_dir ...`
|
||||
|
||||
Standalone scripts also exist for benchmark-specific comparisons, including:
|
||||
|
||||
- `scripts/eval_prompt_custom.py`
|
||||
- `scripts/eval_prompt_official.py`
|
||||
- `scripts/eval_livemathematicianbench_baseline.py`
|
||||
|
||||
These scripts now also support backend selection through the unified model layer.
|
||||
|
||||
## Output Structure
|
||||
|
||||
Each run writes a structured output directory under `out_root`.
|
||||
|
||||
Important top-level artifacts:
|
||||
|
||||
- `config.json` — flattened runtime config
|
||||
- `history.json` — per-step history records
|
||||
- `runtime_state.json` — resume state for current/best skill tracking
|
||||
- `best_skill.md` — current best validated skill
|
||||
- `skills/skill_vXXXX.md` — persisted skill snapshot per step
|
||||
|
||||
Per-step artifacts live under `steps/step_XXXX/`, including:
|
||||
|
||||
- `merged_patch.json`
|
||||
- `ranked_edits.json`
|
||||
- `candidate_skill.md`
|
||||
- `edit_apply_report.json`
|
||||
- `rewrite_result.json` when rewrite mode is enabled
|
||||
- `selection_eval/`
|
||||
- `trajectory_digest.json`
|
||||
- rollout and patch subdirectories
|
||||
|
||||
Epoch-level artifacts live under:
|
||||
|
||||
- `slow_update/epoch_XX/`
|
||||
- `meta_skill/epoch_XX/`
|
||||
- `meta_reflect/epoch_XX/`
|
||||
|
||||
## Resume Behavior
|
||||
|
||||
The trainer resumes from `runtime_state.json` when present. That state tracks:
|
||||
|
||||
- last completed step
|
||||
- current skill path
|
||||
- current score
|
||||
- best skill path
|
||||
- best score
|
||||
- origin tags for current and best skill
|
||||
|
||||
This is important because skill state can change at both step level and epoch level; resuming only from `history.json` is not sufficient for this branch’s method logic.
|
||||
|
||||
## Notes
|
||||
|
||||
- This repository focuses on skill optimization logic; datasets are not included.
|
||||
- Patch application is intentionally observable. Inspect `edit_apply_report.json` when candidate skills do not behave as expected.
|
||||
- `SpreadsheetBench` now defaults to `mode=multi`. If you run an exec student backend there, override back to `env.mode=single` because exec backends are still only wired for SpreadsheetBench single-mode rollout.
|
||||
- `SWEBench` follows the older mini-swe-agent + `swebench.harness.run_evaluation` path, so it requires the SWE-bench / Docker toolchain rather than the generic chat-only stack.
|
||||
- `slow_update` writes into a protected skill region and normal edits are prevented from overwriting that region directly.
|
||||
- `meta_skill` is context memory, not a direct skill edit.
|
||||
- `meta_reflect` is a gated skill edit stage, not just logging.
|
||||
|
||||
## Minimal Setup
|
||||
|
||||
```bash
|
||||
conda create -n skillopt python=3.11
|
||||
conda activate skillopt
|
||||
pip install openai pyyaml openpyxl
|
||||
```
|
||||
|
||||
Depending on the environment, you may also need:
|
||||
|
||||
```bash
|
||||
pip install datasets gymnasium numpy ray regex
|
||||
```
|
||||
|
||||
For `SWEBench`, you also need a working Docker environment plus the SWE-bench / mini-swe-agent dependencies used in `swe-bench-old`.
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
# ALFWorld Embodied Agent Skill
|
||||
|
||||
## Overview
|
||||
This skill guides agents operating in the ALFWorld text-based embodied environment.
|
||||
The agent must complete household tasks by navigating rooms, interacting with objects,
|
||||
and using appliances. Actions must be chosen from the admissible action list provided
|
||||
at each step.
|
||||
|
||||
**Output format**: Always output `<think>...</think>` for reasoning, then `<action>...</action>` for the chosen action.
|
||||
|
||||
---
|
||||
|
||||
## Task Types
|
||||
|
||||
| Type | Goal | Key Steps |
|
||||
|------|------|-----------|
|
||||
| Pick & Place | Put object X in/on receptacle Y | Find X -> take X -> go to Y -> put X in/on Y |
|
||||
| Pick Two & Place | Put two instances of X in/on Y | Find X1 -> take -> place -> find X2 -> take -> place |
|
||||
|
||||
### Pick Two Object Bookkeeping
|
||||
For `pick_two_obj_and_place`, choose one destination receptacle instance once it is opened/usable, and remember it as the target. Both object instances should be placed into that same remembered receptacle. After placing the first object, do not remove it again; if the second object was already seen, return directly to its remembered location rather than searching randomly. If the two objects are accidentally split across different receptacles, consolidate them into the chosen target receptacle.
|
||||
| Examine in Light | Examine object X under desklamp | Find X -> take X -> find desklamp -> use desklamp |
|
||||
|
||||
| Examine in Light detail | Final interaction | While holding X where a desklamp is visible, use the desklamp; do not try to place X on the lamp first. |
|
||||
| Clean & Place | Clean object X and put in/on Y | Find X -> take X -> go to sink -> clean X -> go to Y -> put X |
|
||||
| Heat & Place | Heat object X and put in/on Y | Find X -> take X -> go to microwave -> heat X -> go to Y -> put X |
|
||||
| Cool & Place | Cool object X and put in/on Y | Find X -> take X -> go to fridge -> cool X -> go to Y -> put X |
|
||||
|
||||
---
|
||||
|
||||
## General Principles
|
||||
|
||||
1. **Decompose the task**: Parse the goal into ordered sub-goals (locate, acquire, transform, deliver). Complete each before moving to the next.
|
||||
2. **Systematic exploration**: Search each surface and container exactly once before revisiting. Open closed containers (drawers, cabinets, fridge) before judging them empty.
|
||||
|
||||
- Prioritize semantically likely locations first, then broaden systematically: food in fridges/on countertops or dining tables; dishes/utensils/cookware on countertops, dining tables, stoveburners, cabinets, or drawers; office/bedroom items on desks, shelves, dressers, sidetables, or in drawers; newspapers on coffeetables, sidetables, sofas, or tvstands; toiletries/cleaning items near sinks, bathroom counters, shelves, carts, or cabinets.
|
||||
|
||||
- For portable kitchen targets such as bread, mugs, cups, plates, bowls, and utensils, check broad exposed surfaces early: after one or two empty countertops, try dining tables or other open surfaces before opening many cabinets/drawers. For small office/bedroom targets, alternate drawers with exposed desks, shelves, sidetables, and dressers rather than exhausting drawers first.
|
||||
|
||||
- Keep a persistent **searched set** of receptacle instances, e.g. `drawer 1`, `shelf 3`, `countertop 2`. Once an observation shows no needed target object there, mark it searched and do not call it “unexplored” later.
|
||||
- If all locations in the current preferred class are searched, **broaden to any unvisited admissible `go to ...` location** instead of restarting the same sequence. Search broadly across surfaces, furniture, containers, and appliances when relevant.
|
||||
- If a visible object is itself an openable/container-like object, such as a box, and opening/examining it is admissible, inspect it before leaving the area.
|
||||
3. **Grab immediately**: When a required object is visible and reachable, take it right away before moving elsewhere.
|
||||
|
||||
- Pick up only the exact requested object type. Similar or related objects, such as a cup when the task asks for a mug, a spoon when it asks for a knife, or a pot when it asks for a pan, are distractors; leave them in place and mark that location searched for the target.
|
||||
4. **Transform before placing**: If the task requires cleaning, heating, or cooling, perform the state change at the appropriate appliance before heading to the final destination.
|
||||
|
||||
- Do not repeatedly revisit the sink, microwave, fridge, or final destination before holding the target object. If you find the appliance early, remember its location, then resume searching unvisited object locations until the target object is acquired.
|
||||
|
||||
- Use direct admissible appliance/tool commands immediately when available, such as `clean X with sinkbasin`, `heat X with microwave`, `cool X with fridge`, or `use desklamp`. Do not waste steps opening, closing, toggling, or examining the appliance unless the needed action is unavailable or opening is required for searching/placing.
|
||||
5. **Direct delivery**: Once holding the transformed (or untransformed) goal object, navigate straight to the target receptacle and place it.
|
||||
|
||||
- Remember known destination receptacles and return directly to the same instance after pickup/transformation. If the destination is also a semantically likely source location, check/open it early rather than only after exhaustive search: food may already be in the fridge, utensils may be on the diningtable, newspapers may be on/near the sofa, and a target drawer can be opened early for pick-two tasks. If the object starts at the destination but needs cleaning/heating/cooling, take it out, transform it, then return to that same instance and place it back.
|
||||
6. **Track progress**: Maintain an internal count of how many objects still need to be found and placed. Only stop searching when the count reaches zero.
|
||||
7. **Avoid loops**: Never repeat the same action more than twice in a row. If stuck, move to a different unexplored location.
|
||||
8. **Only choose admissible actions**: Always pick an action from the admissible action list. Do not invent actions.
|
||||
|
||||
---
|
||||
|
||||
## Common Mistakes to Avoid
|
||||
|
||||
- **Revisiting searched locations**: Keep track of which surfaces/containers have been checked; do not re-examine them.
|
||||
- **Ignoring visible objects**: If the target object appears in the observation, pick it up immediately.
|
||||
- **Skipping state changes**: Do not place an object at the destination without first cleaning/heating/cooling it when required.
|
||||
- **Premature termination**: Do not stop the episode until all goal conditions are verified as met.
|
||||
- **Action loops**: Repeatedly toggling or examining the same object wastes steps. Move on to new locations instead.
|
||||
|
||||
### Hard Search-Loop Recovery
|
||||
|
||||
- **Exact-instance lockout before pickup**: once a receptacle/surface instance has been observed and does not contain the target object, do not go back to that exact instance while still searching for the object. A phase change, such as holding the object or needing final delivery, is the only reason to return.
|
||||
- **Fast broadening threshold**: after 3-4 misses in the same receptacle class, switch to a different likely class or any unvisited admissible location instead of continuing or restarting that class, unless the target has already been seen there.
|
||||
- **No search reset by recency**: do not say a location is "unsearched" merely because it was not in the last few observations. The searched set is global for the whole episode.
|
||||
- **Finite-class exhaustion**: if all visible instances of a small class have been checked once, such as all stoveburners, diningtables, countertops, or shelves, mark that class exhausted for object search and do not start a second pass. Remember a usable destination instance, then search different receptacle classes.
|
||||
- **Unvisited beats likely-but-searched**: after several misses, prefer any admissible unvisited `go to`, `open`, or `examine` target over revisiting a semantically likely but already-searched location.
|
||||
- **Destination surfaces before pickup**: if the destination receptacle is also a likely object location, inspect each instance at most once before pickup. If it lacks the object, remember it as the final destination but stop using it as a search target until the object has been transformed and is ready to place.
|
||||
- **Kitchen item fallback**: for cookware and dishware, after checking obvious burners/tables/counters once, broaden to unsearched cabinets, drawers, shelves, sinkbasins, and other kitchen storage/surfaces rather than cycling among the obvious locations.
|
||||
|
||||
### Strict Search Ledger Action Filter
|
||||
|
||||
Before every empty-handed search action, apply this hard filter:
|
||||
|
||||
1. If a required target object is visible, take it immediately.
|
||||
2. Otherwise choose an exact receptacle/surface/container instance whose contents have not yet been observed in the current object-search phase.
|
||||
3. Reject any `go to`, `examine`, or `open` action for an exact instance already observed to lack the target, even if it is semantically likely, nearby, recently mentioned, or the final destination type.
|
||||
4. If all likely instances are rejected by the ledger, broaden to any unvisited admissible location/class instead of restarting from instance 1 of a searched class.
|
||||
|
||||
The searched ledger survives inventory checks, appliance visits, placing the first object in a pick-two task, and putting down an irrelevant inspected object/container. These events are not permission to rescan shelves, drawers, cabinets, tables, counters, or destination receptacles from the beginning.
|
||||
|
||||
### Destination-as-Source Lockout
|
||||
|
||||
When the final receptacle type is also a plausible source location, inspect each visible destination instance at most once before pickup. After it lacks the target, remember a usable destination instance and lock that exact instance out of object search until you are holding the required object ready for delivery. Do not alternate between destination instances and other searched source instances while still empty-handed.
|
||||
|
||||
### Pick-Two Phase Memory
|
||||
|
||||
After placing the first object in a pick-two task, do not begin a fresh room/class search. If another required instance was previously seen, return directly to that remembered source location for the second pickup. If no second instance is remembered, continue from the existing unsearched-location ledger rather than revisiting locations already checked before the first placement.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
Preserve the successful pattern: when the exact requested object is visible, take it immediately; perform the required clean/heat/cool/use action as soon as the correct command is admissible; then deliver directly to the remembered destination.
|
||||
|
||||
Treat tool locations as tools, not repeated search targets. If a sinkbasin, fridge, microwave, desklamp, or destination receptacle has already been checked and does not contain the target while you are empty-handed, remember it for later but do not revisit it until you are holding the required object or ready to place/use it.
|
||||
|
||||
Use a next-unsearched-instance pointer for every numbered class. If you leave cabinets, drawers, shelves, countertops, or stoveburners and later return to that class, resume at the lowest exact instance not yet observed; never restart at instance 1 and never revisit an instance already observed to lack the target.
|
||||
|
||||
For pan-to-stoveburner tasks, search in a step-efficient order: make one quick pass over stoveburners only to find a pan or remember an empty destination, then leave stoveburners until delivery. Next check countertops/islands and sinkbasins. Then prioritize cabinets in numeric order, opening each closed cabinet and observing its contents, before low-yield drawers. Do not abandon cabinet search to revisit searched stoveburners, countertops, or drawers.
|
||||
|
||||
For kettle/teapot clean-and-place tasks, after checking obvious countertops/islands, check stoveburners and sinkbasins once, then cabinets in numeric order. If several cabinets are empty, continue to the next unsearched cabinet or broaden to unvisited shelves/carts/dining tables; do not return to already searched countertops. Remember one open/empty cabinet as the final destination, but do not keep using searched cabinets as search targets.
|
||||
|
||||
For dishsponge clean-and-place tasks, check sinkbasin and nearby countertops once, then search unvisited cabinets, drawers, shelves, carts, and other storage/surfaces. Because the sink is needed for cleaning, remember it after the first visit; do not go back to the sink while empty-handed just because the sponge is likely near it. Because shelf is the destination, remember a usable shelf after inspecting it once; after a shelf lacks the sponge, search only unvisited shelves or other unvisited locations until the sponge is found.
|
||||
|
||||
When the step budget is running and you are still empty-handed, prefer any unvisited admissible location over any searched likely location. A location being semantically likely, useful later, or recently mentioned is never a reason to rescan it before acquisition.
|
||||
|
||||
Do not let the broadening threshold cause class restarts. Broadening means move to a different unvisited class or continue at the next unsearched instance of a promising storage class; it never means cycling back through exact instances already observed.
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
@@ -1,26 +0,0 @@
|
||||
# DocVQA Skill
|
||||
|
||||
## Visual Evidence Discipline
|
||||
- Read the document carefully before answering.
|
||||
- Prefer the smallest exact text span that answers the question.
|
||||
|
||||
- For questions asking for a value, count, page number, date, or graph reading, return only the requested value span; omit nearby labels, category names, units, or explanatory words unless the question explicitly asks for them.
|
||||
- When several nearby strings look similar, choose the one whose surrounding labels or layout best match the question.
|
||||
|
||||
## Exact Answer Discipline
|
||||
- Copy names, numbers, and dates exactly from the document whenever possible.
|
||||
|
||||
- Preserve the document's exact spelling and punctuation for names and quoted phrases; do not substitute similar letters or change straight/curly quotes, spacing, or parentheses when the visible text provides them.
|
||||
- Prefer direct extraction over paraphrase.
|
||||
- Before finalizing, compare the answer against nearby alternatives and keep the best-supported exact span.
|
||||
|
||||
## Structured Layout Lookup
|
||||
- For tables, first find the row or entry named in the question, then read the value under the requested column, header, date, or category; answer with that cell only.
|
||||
- For forms, receipts, or labeled fields, locate the exact role, party, or field label mentioned in the question, then copy the filled-in value from the same line, box, block, or immediately adjacent field.
|
||||
- For table-of-contents, indexed, numbered, or bulleted lists, match the requested title, entry, or point number, then follow the same line or list item to the associated value; do not take a nearby value from another item.
|
||||
|
||||
## Anchored Handwriting / Nearby Text
|
||||
- For handwritten or list/table questions with an anchor term, first locate the anchor, then inspect the immediately adjacent text in the same row, column, or nearby margin. If legible, provide the best-supported nearby span rather than leaving the answer blank.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
@@ -1,35 +0,0 @@
|
||||
# Live Mathematical MCQ Heuristics
|
||||
|
||||
## Option Comparison
|
||||
|
||||
### Meta-Options About Stronger Results
|
||||
- Treat options of the form “one of the remaining options is correct, but a stronger result can be proven” as serious candidates, especially when the question asks for the strongest statement.
|
||||
- If a concrete option is true but your theorem or derivation gives a strictly stronger conclusion not exactly listed, choose the meta-option rather than the weaker concrete statement.
|
||||
- When options are nested by strength, rank them explicitly before answering: e.g. finite-time blowup is stronger than merely “not globally bounded”; positive stable growth is stronger than ordinary unboundedness; sharper constants, rates, exceptional-set bounds, endpoint inclusion, or full equivalences are stronger than weaker asymptotic versions.
|
||||
- Compare all options before committing. The correct choice is often the strongest statement justified by the question, while nearby distractors are weaker, overstrong, or miss an equality case.
|
||||
- Track exact quantifiers such as "there exists", "for every", "if and only if", and "exactly when".
|
||||
|
||||
## Theorem-Level Precision
|
||||
|
||||
- Do not add converse, realization, or classification claims unless the theorem explicitly proves them. Phrases such as “conversely,” “every such parameter occurs,” “if and only if,” or “exactly all” add strength beyond a one-way implication.
|
||||
- Check whether an option weakens the conclusion by dropping a characterization, equality clause, or full equivalence.
|
||||
- Check whether an option overstates the theorem by upgrading regularity, removing scale restrictions, or changing an existential statement into a universal one.
|
||||
|
||||
## Hypotheses
|
||||
|
||||
### Exact Conditions and Thresholds
|
||||
- For biconditional/equivalence questions, reject conditions that are merely necessary or merely sufficient. A broader condition, such as congruence modulo a divisor instead of modulo the full modulus, is usually weaker and not equivalent unless the domain collapses the extra cases.
|
||||
- For threshold conditions, verify the exact sign and endpoint: distinguish \(\mu_0\) from \(-\mu_0\), \(<\) from \(\le\), and whether the equality case belongs to the positive, zero, or negative parameter regime.
|
||||
- When options differ by “for every” vs “for sufficiently large,” local vs global domains, strict vs non-strict inequalities, or dependence of constants, rank them by logical strength and match the sharpest justified version.
|
||||
- Verify the hypotheses and domain carefully. Distractors often keep the theorem shape but alter the required assumptions.
|
||||
- Pay close attention to equality cases, extremal conditions, and whether a result applies to the full family or only a restricted subfamily.
|
||||
|
||||
## Final Answer
|
||||
- Output the final answer as the single option label only.
|
||||
|
||||
## Exact Scope and Quantitative Wording
|
||||
- Distinguish global conclusions from localized or completed ones. Equivalence after localization, completion, or at each prime/scale is usually weaker than an unqualified equivalence.
|
||||
- In estimate-heavy options, compare every quantitative detail: exponent, derivative index range, constants and their parameter dependence, log factors, additive terms, one-sided vs two-sided notation, and pointwise vs uniform convergence.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
@@ -1,50 +0,0 @@
|
||||
# OfficeQA Skill
|
||||
|
||||
## Retrieval Discipline
|
||||
|
||||
- When an external official time-series observation is needed, prefer the source's series/data-download/table page once identified. If exact-date or guessed-value searches return empty results, stop repeating them; broaden to the official series name/code plus `data` or `download` and use the table values.
|
||||
|
||||
- Treat provided/oracle parsed pages as primary evidence: if they contain the relevant table and period, extract directly from them before searching elsewhere; search only for missing continuation pages, missing periods, or an official actual value not present.
|
||||
- Start by narrowing to the most likely candidate file before reading long passages.
|
||||
- Prefer targeted search terms that name the exact entity, period, measure, or table concept from the question.
|
||||
- After a promising match, read only a small surrounding span and verify it matches the requested year, basis, and unit.
|
||||
|
||||
- If the requested date range extends beyond the provided/oracle page, first enumerate the required periods and verify that every period is present in evidence. Do not compute from a partial ledger or fill missing periods from memory; retrieve continuation pages, adjacent issues, or a later issue of the same table that contains the missing dates/revisions.
|
||||
|
||||
## Evidence Discipline
|
||||
- Extract the exact value from the retrieved text before doing any arithmetic.
|
||||
- Keep track of each operand's period, unit, and semantic role so nearby proxy values are not mixed in.
|
||||
|
||||
- For Treasury financing narratives, label each amount by transaction role before calculating: offered amount, tenders/subscriptions received, tenders accepted, competitive/noncompetitive accepted, foreign or Government-account exchange tenders, refunding, and **new cash** are not interchangeable.
|
||||
- When converting currencies or scales, make a direction ledger first: source table unit, source currency, exchange-rate orientation (foreign currency per U.S. dollar means divide by the rate; U.S. dollars per foreign unit means multiply), and requested final unit.
|
||||
|
||||
- For tables, align values by row label and exact column header, not proximity alone; watch for continued or unlabeled columns, footnotes, adjacent amount-versus-percent columns, fiscal-year versus calendar-year sections, and repeated month rows under different year blocks.
|
||||
- If the question asks for a transformed or derived quantity, compute only after confirming every operand.
|
||||
|
||||
- For derived comparisons, preserve the direction and sign implied by the wording: “change from A to B” means B minus A; “former than latter” means former minus latter; “share accounted for by X” means X divided by the stated total; paired “gap” questions require computing each within-row difference before ranking.
|
||||
- For statistical, regression, correlation, and growth-rate questions, write a formula ledger before calculating: confirm the exact series/endpoints, ordered vector, elapsed intervals, and requested convention such as continuously compounded rate, CAGR, Pearson correlation, or OLS index/year choice.
|
||||
- For multi-stage questions where one table determines the period/entity used in another lookup, freeze that derived key with evidence first, then retrieve the second measure only for that exact month/year/reporting date/entity.
|
||||
|
||||
- For inclusive time-series ranges, make a period-by-period ledger covering every requested month/year exactly once, preserving calendar versus fiscal basis, end-of-month or end-of-fiscal-month status, source units, and any specified adjustments.
|
||||
|
||||
- For statistical transforms over time-series windows, confirm endpoint inclusion/exclusion exactly as worded, use consecutive time indices for trend regressions when appropriate, sort values before medians, and for logarithmic growth use ln(final/initial) before converting to the requested percentage format.
|
||||
|
||||
## Final Answer Discipline
|
||||
|
||||
- Before finalizing, enforce the requested unit and format: convert thousands/millions/billions or full nominal dollars as needed, then apply no-comma, fixed-decimal, whole-number, or nearest-tenth/thousandth formatting exactly as asked.
|
||||
- Return the final answer only after one last consistency check against the retrieved evidence.
|
||||
- Copy the final answer from a checked value, not from an unverified intermediate guess.
|
||||
|
||||
## Statistical and Time-Series Calculation Checks
|
||||
|
||||
- Before computing any statistic, write the intended formula and denominator convention. If the prompt explicitly says **population standard deviation**, divide by `n`; if it says **sample**, divide by `n-1`; for a z-score comparing one observation against a small set of comparison months/periods and no population convention is stated, estimate dispersion with the **sample** standard deviation of the comparison set. Do not round intermediate operands, weighted averages, logs, exchange-rate conversions, or standard deviations before the final requested rounding.
|
||||
- For long inclusive ranges, first enumerate the expected count of observations and the first/last period, then verify the ledger has exactly that count. Exclude totals, cumulative-to-date columns, comparable-period columns, estimates, and extra latest-month columns outside the requested calendar or fiscal range.
|
||||
- When a page contains multiple nearby sections with similar labels, use only the section whose title and row label match the requested measure exactly; do not compute from the first visible table if the requested measure/table title is absent or only partially shown.
|
||||
- For Treasury security quotations, obey the table's quote basis. If the table states that price decimals are 32nds, convert quotes such as `99.27` as `99 + 27/32`, not as decimal `99.27`. If a task asks for smoothing, averaging, or forecasting in a target currency using period-specific exchange rates, convert each period's observation to the target currency first unless the prompt explicitly says to compute in the source currency and convert only the final result.
|
||||
|
||||
## Stricter Final Formatting
|
||||
|
||||
- Match any requested output template exactly. Unless the prompt explicitly asks for unit words or explanatory text, return only the numeric value or requested list; do not append words such as `million`, `dollars`, `percent`, or `percentage points`. Include symbols/commas only when the prompt requests currency-formatted output or the answer format clearly requires them.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
@@ -1,71 +0,0 @@
|
||||
# Question Answering Skill
|
||||
|
||||
(No learned rules yet. Rules will be added through the reflection process.)
|
||||
|
||||
## Concise Answer Normalization
|
||||
- Prefer the shortest unambiguous answer that directly satisfies the question. Do not include generic descriptors, legal suffixes, or expanded formal names unless the question specifically asks for the full official name or the descriptor is necessary to identify the entity.
|
||||
|
||||
- If the answer appears inside a longer descriptive phrase, strip words that merely repeat the clue's requested type or modifiers already stated in the clue. For short-answer trivia, return the distinctive core entity or headword rather than role titles, product flavor adjectives, or place/facility designators, even when those words are part of a fuller official phrase, unless the full official name is explicitly requested.
|
||||
- For place/name-etymology questions asking for “the name” or “the word” that means something, answer the distinctive name/word itself rather than a larger phrase with a generic type label.
|
||||
|
||||
- For natural geographic features, preserve conventional feature designators such as “Lake,” “River,” “Bay,” “Gorge,” “Mount,” or “Island” when they are part of the proper name or match the requested feature type. Do not shorten “Lake Okeechobee,” “Tampa Bay,” or “Olduvai Gorge” to an ambiguous base name merely to be concise.
|
||||
- For companies, brands, and organizations, answer the common distinctive name when sufficient; omit additions such as “Company,” “Corporation,” “Inc.,” etc. unless explicitly required.
|
||||
|
||||
- Preserve the answer surface form supported by the strongest evidence when exact variants differ: spelling, capitalization, punctuation, and word order can matter. Do not substitute an equivalent official/common variant such as an alternate spelling or inverted institution name if a direct title/snippet/answer field gives the expected form.
|
||||
|
||||
- When copying titles or quoted names, preserve ordinary ASCII punctuation from the evidence, especially straight apostrophes (`'`). Do not replace them with typographic curly quotes/apostrophes unless that exact stylized form is explicitly shown as the supported answer.
|
||||
|
||||
- For nicknames, epithets, saints, and quoted titles, copy the supported surface form exactly, including spacing, capitalization, and conventional abbreviations such as “St.” Do not normalize a stylized or quoted form into a lowercase dictionary word or an expanded spelling when the clue/evidence points to the stylized answer.
|
||||
|
||||
- For person answers in trivia or crossword-style clues, prefer the conventional supported name. Use just a surname, first name, or saint/regnal name only when the clue/source clearly expects that short form; otherwise use the canonical full personal name from the strongest evidence or answer field, especially when a lone given name would be ambiguous.
|
||||
- Return the grammatical base form expected by the clue. Do not add a plural `s` merely because a crossword source pluralizes a shared name or category; if the clue lists people sharing a first name, answer the singular given name.
|
||||
|
||||
- For common-noun category answers, default to the singular dictionary headword in trivia/crossword-style clues, even if the clue uses plural words like “these,” “those,” “places,” or “items” for grammar. Use a plural only when the term is inherently plural or an answer field/source clearly gives a plural phrase.
|
||||
|
||||
- For common-noun clues about things being replaced, used in place of, or substituted by another system/item, answer the broad headword for the thing replaced unless a narrowing modifier is required by the clue or answer field. Do not add adjectives such as “letter,” “regular,” or “standard” merely because they appear in explanatory context.
|
||||
- For fill-in-the-blank or definitional clues using words like “this” or “that,” provide a standalone noun phrase. Avoid context-dependent pronouns or possessives from the source text; use a natural article such as “the” when needed (e.g., answer “the highest point,” not “its highest point”).
|
||||
|
||||
## Context-Grounded Evidence Matching
|
||||
- Start by identifying the most distinctive terms in the question: proper names, dates, titles, quoted phrases, unusual words, roles, relationships, and category descriptors.
|
||||
- Prioritize passages or document titles where several distinctive clue terms occur together, especially if the wording directly repeats or closely paraphrases the question.
|
||||
- Treat document titles as useful evidence: the answer is often named in a title while the snippet confirms the clue facts.
|
||||
|
||||
- Do not assume the document title itself is the answer. If the requested type differs from the title entity, use the title as context and extract the matching typed entity from the snippet or clue relationship.
|
||||
|
||||
- For “known as,” “called,” “defined as,” or category/type clues, choose the canonical term explicitly used in the strongest matching title/snippet or scraped answer field rather than inventing a related derivative or near-synonym from the clue wording. When multiple plausible candidates appear, prefer the candidate whose evidence directly states the requested relationship and repeats the most distinctive clue facts.
|
||||
- Ignore noisy results that only match generic words; prefer evidence that directly connects the clue facts to one specific entity.
|
||||
|
||||
## Clue Interpretation and Answer Type
|
||||
- For Jeopardy-style wording such as “this man,” “this group,” “this film,” “this country,” “this system,” “he,” or “his wife,” infer the expected answer type before choosing the answer.
|
||||
- Use that expected type to validate candidates: answer with the concise person, place, title, organization, object, term, or phrase requested by the clue.
|
||||
|
||||
- Treat modifiers attached to the requested type as hard filters, not background flavor: constraints like dates, “largest,” “2-letter-named,” “1978 remake,” “hot dog brand,” “dual throne,” or “on this company’s board” must all fit the candidate before you answer.
|
||||
- For clues centered on creative works such as books, films, plays, songs, poems, or other media, first determine whether the clue asks for the work itself, its creator, a performer or cast member, a character, a quotation source, or a setting. Verbs such as “wrote,” “directed,” “stars,” “played,” and “set in,” plus pronouns like “he” or “her,” usually determine the target.
|
||||
|
||||
- For fill-in-style clues with placeholders such as “this,” “these,” or “one of these,” substitute each candidate back into the clue and choose the concise answer that makes the full phrase, title, or fact read correctly.
|
||||
- For terse clues that are just examples or names separated by commas, slashes, or “or,” infer the shared category, class, or synonym that links them, then answer with that concise common term.
|
||||
|
||||
- For crossword-style clues, treat parenthetical numbers or stated letter counts as hard constraints on the answer length, and omit generic labels that would violate them. In dual-definition clues using wording like “X, or what Y does,” choose the single word that satisfies both senses and preserve the required inflected form.
|
||||
- If the clue references an unavailable image or link with wording like “seen here,” “pictured,” or parenthetical visual hints, rely on the textual clues and context to infer the answer; do not treat the missing image as necessary evidence.
|
||||
- If multiple snippets support the same entity, use that corroboration to choose the canonical/common form of the answer.
|
||||
|
||||
## Trivia / Jeopardy Snippet Formats
|
||||
- Retrieved trivia snippets may contain the clue and answer in scraped formats such as `CATEGORY | clue | answer`, `clue. ANSWER`, or labels like `right:`.
|
||||
- When the question text matches the clue in such a snippet, extract the answer field or adjacent answer name, not the category or the whole clue sentence.
|
||||
|
||||
## Common Clue Traps
|
||||
- Watch for inverse relationships: if the clue says “His third wife was Jiang Qing,” the requested answer is the husband, not Jiang Qing.
|
||||
|
||||
- More generally, preserve relation direction in clues: “A is evidence of this B,” “A is related to this language,” or “home to these characters” asks for the target of the relationship, not the entity already named in the clue.
|
||||
|
||||
- When a clue says examples, models, breeds, members, or items “include,” “like,” or “such as” named entities, treat those names as evidence for the requested parent class or entity. Answer the encompassing brand, animal, category, place, or term requested by “this,” not one of the examples already given.
|
||||
- If the question gives the start of a quotation or phrase, answer with the exact missing continuation from the context.
|
||||
|
||||
- For song, poem, nursery-rhyme, or quotation clues, first decide whether the question asks for a missing word or phrase from the quote or for the associated creator, performer, or work; use pronouns and answer-type signals to choose the right target.
|
||||
- When a clue asks for a constrained form such as a first name, abbreviation, acronym, or lyric word, return that exact form rather than the fuller person, title, or explanation; preserve conventional punctuation or spelling when it is part of the requested form.
|
||||
- If the clue contains wordplay, quotation marks, or puns, treat them as hints, but answer with the real entity supported by the evidence.
|
||||
|
||||
- If a clue includes a quoted title, quoted narration or lyric, named event, slogan, or other distinctive phrase but asks for an associated “this” entity, treat the quote or name as evidence to identify the requested person, work, place, group, category, source, or term; do not return the quoted anchor unless the clue explicitly asks for it.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
@@ -1,133 +0,0 @@
|
||||
# Spreadsheet Manipulation Skill (xlsx)
|
||||
|
||||
## Overview
|
||||
This skill guides agents in manipulating Excel (.xlsx) spreadsheets using Python.
|
||||
|
||||
**Primary libraries**: `openpyxl` (structure-preserving read/write), `pandas` (data transformation).
|
||||
Never use any other third-party libraries.
|
||||
|
||||
---
|
||||
|
||||
## Common Workflow
|
||||
|
||||
1. **Explore** the input file: list sheets, inspect headers, check dimensions.
|
||||
|
||||
- Inspect actual workbook data beyond the preview, including nearby rows/columns, sample outputs, formulas, labels, headers, and any reference/example sheets such as `Output`, `Manual Result`, or `Desired...` tabs.
|
||||
|
||||
- Treat existing filled cells in the requested output area or adjacent example tables as semantic examples for edge cases and expected formats, but still recompute and write the complete requested target range.
|
||||
- Scan the used range for complete header groups, not just row 1. Tables may start in later rows/columns, have title rows above them, or have multiple source/result tables on the same sheet; use nearby labels and the requested output range to distinguish sources from destinations.
|
||||
- Locate tables, fields, and target ranges by header text, nearby labels, and surrounding nonblank structure rather than fixed coordinates. Build header maps from actual cells when useful, e.g. `{str(cell.value).strip(): cell.column}`.
|
||||
2. **Write `solution.py`** with `INPUT_PATH` and `OUTPUT_PATH` defined at the top.
|
||||
3. **Execute** `python solution.py` and verify the output file was created.
|
||||
4. **Confirm** the target cells/range contain the expected values.
|
||||
|
||||
---
|
||||
|
||||
## Library Selection
|
||||
|
||||
| Use case | Library |
|
||||
|----------|---------|
|
||||
| Preserve formulas, formatting, named ranges | `openpyxl` |
|
||||
| Bulk data transformation, aggregation, sorting | `pandas` → write back with `openpyxl` |
|
||||
| Simple cell read/write | `openpyxl` |
|
||||
|
||||
**Warning**: `pandas.to_excel()` silently destroys existing formulas and named ranges.
|
||||
When writing back to a spreadsheet that contains formulas, always use `openpyxl.save()`.
|
||||
|
||||
**Formula evaluation caution**: `openpyxl` can write formulas but does **not** calculate them or update cached results. If the requested output will be checked as cell values, compute the result in Python and write literal values unless the user explicitly requires live formulas. When existing formulas are inputs to your logic, load a second workbook with `data_only=True` to read cached values while saving changes through the normal workbook:
|
||||
|
||||
```python
|
||||
wb = openpyxl.load_workbook(INPUT_PATH)
|
||||
wb_values = openpyxl.load_workbook(INPUT_PATH, data_only=True)
|
||||
ws = wb["Sheet1"]
|
||||
ws_values = wb_values["Sheet1"]
|
||||
```
|
||||
|
||||
Treat wording such as “write/fix a formula,” “SUMIFS/COUNTIFS,” “VBA,” or “macro” as a description of the spreadsheet logic unless the deliverable explicitly requires live formula text, an `.xlsm`, or a preserved VBA project. For normal `.xlsx` outputs, implement the equivalent logic in Python/openpyxl and write the computed final values to the requested cells so verification does not depend on Excel recalculation or macros.
|
||||
|
||||
When the user provides an existing or broken formula, use it as a semantic specification: honor its referenced lookup ranges, criteria ranges, return ranges, aggregation intent, and error-handling behavior, then write the resulting values rather than guessing different source columns or leaving unevaluated formulas.
|
||||
|
||||
---
|
||||
|
||||
## solution.py Template
|
||||
|
||||
```python
|
||||
import openpyxl
|
||||
import pandas as pd
|
||||
|
||||
INPUT_PATH = "..." # set to the actual input path
|
||||
OUTPUT_PATH = "..." # set to the actual output path
|
||||
|
||||
wb = openpyxl.load_workbook(INPUT_PATH)
|
||||
ws = wb.active # or wb["SheetName"]
|
||||
|
||||
# --- perform manipulation ---
|
||||
|
||||
wb.save(OUTPUT_PATH)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Requirements
|
||||
|
||||
- Save the result to `OUTPUT_PATH`.
|
||||
- Do not hardcode row counts or column letters — iterate over actual rows in the workbook.
|
||||
- Preserve sheets and cells not mentioned in the instruction.
|
||||
|
||||
## Matching and Target Range Hygiene
|
||||
|
||||
- Choose the comparison operator from the instruction and examples: use `startswith` for “begins with”, substring search for “contains/search/occurrence”, and exact normalized equality only when a whole-cell match is implied.
|
||||
- Create small helper functions for comparisons and numeric parsing. Normalize text by trimming, collapsing repeated spaces/NBSPs, and casefolding; when names or labels have punctuation/spacing inconsistencies, consider punctuation-insensitive keys. Parse numeric text after removing commas/currency symbols while preserving signs and decimal points; skip `None`/blank and booleans for numeric tests, and handle placeholders such as `"-"`, `"$"`, `"$0"`, blanks, and numeric zero deliberately.
|
||||
- Normalize date keys deliberately: handle `datetime`/`date` objects, Excel serial numbers, and date-like strings, then compare at the granularity implied by the task, such as exact date, month, month/year, fiscal period, or year. For workday/date-window logic, compute the range in Python and exclude weekends/holidays as specified.
|
||||
|
||||
- For monthly or period summary grids, canonicalize period labels from all sources: sheet names, title text, row/column headers, text months such as `March`, and actual date cells. Match summaries by normalized period plus the other stated criteria rather than by fixed month offsets or existing formulas.
|
||||
- For date ranges and rolling windows, infer endpoint inclusivity from wording and examples. Phrases like `X to Y`, `through`, and `up to`, or examples such as `2 to 5` meaning `4 days`, usually require inclusive boundary handling.
|
||||
- For time extraction or time-threshold logic, parse `datetime`, `time`, Excel serial/fractional times, and time-like strings into real Python `time`/`datetime` values. Write real time values with an Excel `number_format` such as `hh:mm:ss AM/PM`; do not write text substrings when the result should behave as a time.
|
||||
- For joins, deduplication, grouping, interval lookups, lookup grids, and ordered outputs, build explicit normalized keys, including composite keys when the task refers to multiple fields. Preserve original source order within each group unless sorting is explicitly requested.
|
||||
- For outputs that depend on other rows or lookup grids, make a first pass to build normalized dictionaries/groups/range structures, then a second pass to write results. Avoid nested full-sheet scans per row; split delimited tokens and ignore empty tokens, and treat error literals such as `#N/A` as meaningful sentinel values when the task refers to them.
|
||||
|
||||
- For lookups, filters, joins, and label/header matching, normalize comparison keys consistently: trim whitespace, skip blanks explicitly, use case-insensitive text matching when appropriate, and treat numeric-looking IDs consistently (`330`, `330.0`, and `"330"`). Keep numeric outputs numeric; use `number_format` for display formatting instead of converting numbers to strings unless text is explicitly required.
|
||||
- When replacing a generated output area, clear only the instructed target range before writing new results so stale values/formulas do not remain. Preserve formatting, column widths, borders, formulas, and unrelated cells unless the instruction explicitly asks to change them.
|
||||
|
||||
- If the instruction includes formatting changes, apply them exactly after writing values and only to the requested cells/range. Use `openpyxl` styles for fills, alignment, fonts, borders, and number formats; convert hex colors to ARGB when needed, for example `#FFC000` → `FFFFC000`. For “format as text,” set `number_format = '@'` and write string values when the expected cell values are text.
|
||||
|
||||
- When the instruction names a destination range or columns, write derived results directly there. Do not insert rows/columns, relocate the source table, or sort/delete source records unless that structural change is explicitly requested.
|
||||
- For filtered lists, summaries, and aggregations, first collect all source records/results in memory, preserving the required order, then write from the first output row and clear leftover cells below the new results in the target columns. When adding rows, copy style/alignment/number format from an existing template row when appropriate; when deleting rows, delete from bottom to top to avoid row-index shifts.
|
||||
- Preserve intended blanks as empty cells (`None`) rather than placeholder text or `0` unless the task specifies otherwise.
|
||||
|
||||
- For numeric aggregation, crosstab, SUMIFS-like, and INDEX/MATCH-style summary outputs, infer missing-match behavior from table semantics and examples: numeric summary grids usually require literal `0` for no matching records, while filtered lists or “show only once” outputs usually require blanks (`None`).
|
||||
- For blank-sensitive logic such as “if input is blank, output blank,” evaluate the driving input with `data_only=True` when it may itself be a formula, and write `None` for truly blank outputs rather than relying on a new formula returning `""`.
|
||||
|
||||
## Robustness for Simple Fill Tasks
|
||||
|
||||
- Prefer simple, auditable row/column loops over complex workbook XML parsing unless the task truly requires unsupported workbook internals. Before returning, run the script once to catch syntax/indentation errors and verify that representative target rows were actually written.
|
||||
|
||||
<!-- SLOW_UPDATE_START -->
|
||||
When the user asks for a formula, macro, VBA code, or a fix to an Excel formula, still deliver the completed workbook state: compute the intended results in Python and write literal final values into the requested cells. Do not write formula strings unless the task explicitly says the output must contain live formulas.
|
||||
|
||||
After writing, reload or inspect the saved workbook and verify that every requested/evaluated target cell contains a non-formula literal where a value is expected. If a target cell is still `None` unexpectedly, fix the script before finishing.
|
||||
|
||||
Use existing formulas in the workbook as examples/specifications, not as output. If a cell contains a reference formula such as `=A25` or an INDEX/MATCH/SUMIFS pattern, parse what source cells/ranges/criteria it refers to, compute those results yourself, and overwrite the destination with the referenced or calculated value.
|
||||
|
||||
For blank-sensitive formula tasks, compute the branch explicitly: if the driving source cell is truly blank, write `None`; otherwise write the actual result such as `0`, `1`, a category label, or a lookup value. Never rely on `IF(...,"",...)` formulas to be recalculated later.
|
||||
|
||||
For lookup/category tasks, locate both the input rows and the lookup table by headers and nearby labels. Support exact keys, numeric-looking keys, and interval/range tables; then fill every destination row that has a driving input, not just the first visible example.
|
||||
|
||||
For “every nth row” or OFFSET-style tasks, infer the source column, first source row, and step from the provided examples or formulas, then copy the actual source values into the requested output range as literals.
|
||||
|
||||
For schedule/calendar fill tasks, build a cycle-day-to-periods mapping from the schedule/template area first, then fill the daily rows across all requested class columns based on each row’s cycle day. Preserve repeated/double periods exactly as shown by the template; do not leave formulas in the schedule cells.
|
||||
|
||||
For INDEX/MATCH problems where the first row works but subsequent rows fail, treat row labels, column/year headers, region/type criteria, and expense/category labels as a multi-key lookup. Fill the whole result matrix with values from the source data table, using cached `data_only` values when source cells are formulas.
|
||||
|
||||
For multi-step macro/VBA-style requests, implement every stated operation in the workbook, not just the first deletion/filtering step. Re-read the numbered requirements before saving and verify later computed columns, totals, and derived fields as well as the obvious filtered rows.
|
||||
|
||||
When a target range includes special rows such as `Total`, `Grand Total`, `min`, `max`, constraints, headers, or blank separators, do not apply ordinary row logic blindly to those rows. Compute totals as aggregates when indicated, and leave constraint/header/blank cells untouched unless explicitly requested.
|
||||
|
||||
For residual-balancing tasks, identify data rows separately from min/max constraint rows. Add positive residuals from unit 1 toward unit 5 without exceeding max values; subtract negative residuals from unit 5 toward unit 1 without going below min values; update only the unit cells in actual data rows.
|
||||
|
||||
For time-threshold rows, decide per row whether it is a normal data row or a summary row. Normal rows use the before/after threshold rule; summary rows should aggregate the computed normal-row results if the workbook labels or examples indicate a total.
|
||||
|
||||
Keep scripts simple enough to run cleanly. Avoid unnecessary dynamic code generation and fragile f-strings with regex expressions inside them. Always execute the final `solution.py`; fix any syntax, indentation, or runtime error, then verify representative target cells.
|
||||
|
||||
If workbook cells contain arbitrary sample text that could be sensitive or trigger content filters, do not quote large raw cell contents in your response. Process them locally in Python with neutral variable names and output only the completed script/workbook changes.
|
||||
<!-- SLOW_UPDATE_END -->
|
||||
+27
-22
@@ -1,12 +1,12 @@
|
||||
# SkillOpt default configuration — base for all environments.
|
||||
# ReflACT default configuration — base for all environments.
|
||||
# Environment configs should inherit via: _base_: default.yaml
|
||||
|
||||
model:
|
||||
backend: azure_openai
|
||||
optimizer: gpt-5.5
|
||||
target: gpt-5.5
|
||||
optimizer_backend: openai_chat
|
||||
target_backend: openai_chat
|
||||
teacher: gpt-5.5
|
||||
student: gpt-5.5
|
||||
teacher_backend: openai_chat
|
||||
student_backend: openai_chat
|
||||
reasoning_effort: medium
|
||||
rewrite_reasoning_effort: ""
|
||||
rewrite_max_completion_tokens: 64000
|
||||
@@ -24,25 +24,25 @@ model:
|
||||
claude_code_exec_use_sdk: auto
|
||||
claude_code_exec_effort: medium
|
||||
claude_code_exec_max_thinking_tokens: 16384
|
||||
codex_trace_to_optimizer: true
|
||||
azure_openai_endpoint: "" # e.g. "https://your-resource.openai.azure.com/"
|
||||
codex_trace_to_teacher: true
|
||||
azure_openai_endpoint: "https://t2vgoaigpt4o3.openai.azure.com/"
|
||||
azure_openai_api_version: "2024-12-01-preview"
|
||||
azure_openai_api_key: "" # Fill locally if you do not export AZURE_OPENAI_API_KEY
|
||||
azure_openai_auth_mode: "" # empty → fall back to AZURE_OPENAI_AUTH_MODE env (default "azure_cli")
|
||||
azure_openai_auth_mode: azure_cli
|
||||
azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
azure_openai_managed_identity_client_id: ""
|
||||
optimizer_azure_openai_endpoint: "" # e.g. "https://your-resource.openai.azure.com/"
|
||||
optimizer_azure_openai_api_version: "2024-12-01-preview"
|
||||
optimizer_azure_openai_api_key: ""
|
||||
optimizer_azure_openai_auth_mode: "" # empty → fall back to OPTIMIZER_AZURE_OPENAI_AUTH_MODE env, then shared
|
||||
optimizer_azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
optimizer_azure_openai_managed_identity_client_id: ""
|
||||
target_azure_openai_endpoint: "" # e.g. "https://your-resource.openai.azure.com/"
|
||||
target_azure_openai_api_version: "2024-12-01-preview"
|
||||
target_azure_openai_api_key: ""
|
||||
target_azure_openai_auth_mode: "" # empty → fall back to TARGET_AZURE_OPENAI_AUTH_MODE env, then shared
|
||||
target_azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
target_azure_openai_managed_identity_client_id: ""
|
||||
teacher_azure_openai_endpoint: "https://t2vgoaigpt4o3.openai.azure.com/"
|
||||
teacher_azure_openai_api_version: "2024-12-01-preview"
|
||||
teacher_azure_openai_api_key: ""
|
||||
teacher_azure_openai_auth_mode: azure_cli
|
||||
teacher_azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
teacher_azure_openai_managed_identity_client_id: ""
|
||||
student_azure_openai_endpoint: "https://t2vgoaigpt4o3.openai.azure.com/"
|
||||
student_azure_openai_api_version: "2024-12-01-preview"
|
||||
student_azure_openai_api_key: ""
|
||||
student_azure_openai_auth_mode: azure_cli
|
||||
student_azure_openai_ad_scope: "https://cognitiveservices.azure.com/.default"
|
||||
student_azure_openai_managed_identity_client_id: ""
|
||||
|
||||
train:
|
||||
num_epochs: 4
|
||||
@@ -57,6 +57,9 @@ gradient:
|
||||
analyst_workers: 16
|
||||
max_analyst_rounds: 3
|
||||
failure_only: false
|
||||
use_deep_reflect: false
|
||||
deep_reflect_failures: 4
|
||||
deep_reflect_successes: 2
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4 # max edits per step (edit_budget)
|
||||
@@ -64,9 +67,10 @@ optimizer:
|
||||
lr_scheduler: cosine # constant / linear / cosine / autonomous
|
||||
lr_control_mode: fixed # fixed / autonomous / none
|
||||
skill_update_mode: patch # patch / rewrite_from_suggestions / full_rewrite_minibatch
|
||||
use_meta_reflect: false
|
||||
meta_learning_rate: 4 # max edits per epoch-level meta-reflect
|
||||
use_slow_update: true
|
||||
slow_update_samples: 20
|
||||
slow_update_gate_with_selection: false
|
||||
longitudinal_pair_policy: mixed # mixed / changed / unchanged
|
||||
use_meta_skill: true
|
||||
|
||||
@@ -80,9 +84,10 @@ env:
|
||||
name: ""
|
||||
skill_init: ""
|
||||
split_mode: ratio # ratio = build deterministic split from data_path; split_dir = use pre-split train/val/test
|
||||
split_ratio: "2:1:7" # explicit default for dataset-backed benchmarks: train:val:test
|
||||
split_seed: 42
|
||||
split_dir: ""
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
exec_timeout: 120 # per target model/code-agent call timeout in seconds
|
||||
exec_timeout: 120 # per student model/code-agent call timeout in seconds
|
||||
out_root: ""
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
# Ablation Study Configuration Manifest
|
||||
|
||||
This folder records the final, reproducible settings for the ablation runs used
|
||||
in `docs/ablation_paper_tables.md`.
|
||||
|
||||
It is intentionally separate from the benchmark default configs. The benchmark
|
||||
configs under `configs/<benchmark>/default.yaml` remain the source task configs;
|
||||
this folder records the exact matrix-level overrides, run roots, launch commands,
|
||||
and validation rules used for the paper ablations.
|
||||
|
||||
## Files
|
||||
|
||||
- `matrix.yaml`: canonical ablation matrix, common overrides, benchmark splits,
|
||||
token/output caps, and invalid-run rules.
|
||||
- `launch_commands.sh`: exact launcher commands for the valid run roots.
|
||||
- `validation.md`: monitoring, result extraction, and invalidation checklist.
|
||||
|
||||
## Source Of Truth
|
||||
|
||||
Use the matrix launcher:
|
||||
|
||||
```bash
|
||||
/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python scripts/run_ablation_matrix.py
|
||||
```
|
||||
|
||||
The launcher builds runs from the same defaults and values recorded in
|
||||
`matrix.yaml`. It skips completed runs by checking `summary.json` and skips
|
||||
active runs by checking `env.out_root` in active `scripts/train.py` processes.
|
||||
|
||||
Do not manually rerun a completed run into the same `env.out_root`. If a run is
|
||||
invalid, archive or remove its output directory first, then let the launcher
|
||||
start it cleanly.
|
||||
|
||||
## Current Correct Run Roots
|
||||
|
||||
- SearchQA / SpreadsheetBench original ablations:
|
||||
`outputs/ablation_20260502_040604_unique48`
|
||||
- SearchQA / SpreadsheetBench batch-size ablations:
|
||||
`outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run`
|
||||
- LiveMathBench / ALFWorld clean ablations:
|
||||
`outputs/ablation_livemath_alfworld_clean_20260503_155155_run`
|
||||
- DocVQA ablations:
|
||||
`outputs/ablation_docvqa_20260503_160225_run`
|
||||
|
||||
Archived, superseded, misaligned, dry-run, or pre-fix directories must not be
|
||||
used for paper tables.
|
||||
|
||||
## End-To-End Runbook
|
||||
|
||||
### Environment
|
||||
|
||||
Run from the repository root:
|
||||
|
||||
```bash
|
||||
cd /home/azureuser/workspace-gzy/SkillReflection
|
||||
```
|
||||
|
||||
Always use:
|
||||
|
||||
```bash
|
||||
PY=/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python
|
||||
export ALFWORLD_DATA=/home/azureuser/.cache/alfworld
|
||||
```
|
||||
|
||||
Default model/auth settings are generated by `scripts/run_ablation_matrix.py`:
|
||||
|
||||
```text
|
||||
teacher=gpt-5.5
|
||||
student=gpt-5.5
|
||||
teacher_backend=openai_chat
|
||||
student_backend=openai_chat
|
||||
reasoning_effort=medium
|
||||
teacher/student endpoint=https://t2vgoaigpt4o3.openai.azure.com/
|
||||
teacher/student api_version=2024-12-01-preview
|
||||
teacher/student auth_mode=azure_cli
|
||||
```
|
||||
|
||||
Core training settings:
|
||||
|
||||
```text
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_scheduler=cosine
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
optimizer.longitudinal_pair_policy=mixed
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
```
|
||||
|
||||
`train.train_size=0` is intentional. The dataloader derives the train size from
|
||||
the fixed split. Batch-size ablations rely on the default `ceil(train_size /
|
||||
batch_size)` behavior; the last batch can be smaller than `train.batch_size`.
|
||||
|
||||
### Fixed Splits
|
||||
|
||||
Default split directories:
|
||||
|
||||
```text
|
||||
searchqa: data/ablation_splits/searchqa/2-1-7_seed42
|
||||
spreadsheetbench: data/ablation_splits/spreadsheetbench/2-1-7_seed42
|
||||
livemathematicianbench: data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
alfworld: data/ablation_splits/alfworld/2-1-7_seed42
|
||||
docvqa: /home/azureuser/zisu/SkillReflection/data/docvqa/splits
|
||||
```
|
||||
|
||||
Default train/val/test sizes:
|
||||
|
||||
| Benchmark | Train | Val | Test |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| SearchQA | 400 | 200 | 1400 |
|
||||
| SpreadsheetBench | 80 | 40 | 280 |
|
||||
| LiveMathBench | 35 | 18 | 124 |
|
||||
| ALFWorld | 39 | 18 | 134 |
|
||||
| DocVQA | 1070 | 535 | 3744 |
|
||||
|
||||
DocVQA images are not copied. The valid setup uses:
|
||||
|
||||
```text
|
||||
data/docvqa_images -> /home/azureuser/zisu/SkillReflection/data/docvqa_images
|
||||
```
|
||||
|
||||
2026-05-05 DocVQA data correction: all DocVQA final reruns should use the zisu
|
||||
10% split above and a fresh output root such as
|
||||
`outputs/ablation_docvqa_zisu10pct_20260505_run`. The older local
|
||||
`data/ablation_splits/docvqa/2-1-7_seed42` contains the same 5349 questionId
|
||||
pool but a different train/val/test assignment, so its completed summaries are
|
||||
historical only.
|
||||
|
||||
### Matrix Groups
|
||||
|
||||
Use these group names with `scripts/run_ablation_matrix.py`:
|
||||
|
||||
```text
|
||||
default split batch mbs lr sched slown mod smodel longpair lrctrl
|
||||
```
|
||||
|
||||
`longpair` is the slow-update/meta-skill comparison-example ablation. It keeps
|
||||
all prompts and training settings unchanged and only overrides:
|
||||
|
||||
```text
|
||||
optimizer.longitudinal_pair_policy=changed
|
||||
optimizer.longitudinal_pair_policy=unchanged
|
||||
```
|
||||
|
||||
The default paper setting remains `mixed`.
|
||||
|
||||
`lrctrl` contains the two learning-rate-control baselines:
|
||||
|
||||
```text
|
||||
optimizer.lr_control_mode=autonomous
|
||||
optimizer.lr_control_mode=none + optimizer.skill_update_mode=full_rewrite_minibatch
|
||||
```
|
||||
|
||||
The autonomous run logs the chosen integer per step in `lr_decision.json` and
|
||||
`lr_history.jsonl`. The full-rewrite run removes the LR/edit-selection concept:
|
||||
each minibatch analyst produces a complete skill candidate, and aggregate/merge
|
||||
produces the candidate skill directly.
|
||||
|
||||
Batch-size values are:
|
||||
|
||||
```text
|
||||
8 / 24 / 40 / 56 / full
|
||||
```
|
||||
|
||||
`40` is the default point. `full` expands to the benchmark train size.
|
||||
|
||||
### Launch Commands Used In This Session
|
||||
|
||||
The exact commands are recorded in `launch_commands.sh` and in
|
||||
`docs/ablation_plan.md`. The important current policy is:
|
||||
|
||||
- SearchQA / SpreadsheetBench batch-only matrix can run at `--max-parallel 8`.
|
||||
- DocVQA matrix can run with its launcher at `--max-parallel 8`; later top-up used `--max-parallel 16` only because completed runs were skipped and active roots were checked.
|
||||
- LiveMathBench is safe as API-only benchmark after the token cap fix.
|
||||
- ALFWorld must not be mixed into a 24-way run on this shared machine. Use `--bench alfworld --max-parallel 1` only after memory is available.
|
||||
|
||||
### Token And Timeout Fixes
|
||||
|
||||
LiveMathBench must use a large student completion cap:
|
||||
|
||||
```text
|
||||
max_completion_tokens=16384
|
||||
timeout=300
|
||||
```
|
||||
|
||||
The old 768/512 cap produced many empty visible responses because hidden
|
||||
reasoning consumed the budget.
|
||||
|
||||
ALFWorld must use:
|
||||
|
||||
```text
|
||||
max_completion_tokens=2048
|
||||
empty response fallback -> <action>look</action>
|
||||
missing action fallback -> <action>look</action>
|
||||
```
|
||||
|
||||
### Invalid Runs
|
||||
|
||||
Never fill paper tables from these archive directories:
|
||||
|
||||
```text
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_livemath_token768_20260504_022258/
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_token512_20260504_021417/
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_empty_action_20260504_025311/
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_prefallback_20260504_025402/
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_oom_partial_20260504_050517/
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_serial_lowmem_20260504_1300/
|
||||
```
|
||||
|
||||
### Current Resource Notes
|
||||
|
||||
ALFWorld model calls are API calls. The ablation branch now creates local
|
||||
ALFWorld/TextWorld environments through multiprocessing workers ported from
|
||||
`skillopt_final_zzw`, not through Ray actors. Old Ray-based archived runs are
|
||||
not valid for table fill. The observed historical failure mode in this session
|
||||
was system RAM pressure and Ray OOM prevention, not model GPU memory.
|
||||
|
||||
GPU memory currently shown by `nvidia-smi` came from unrelated Ray Serve visual
|
||||
models under:
|
||||
|
||||
```text
|
||||
/home/azureuser/workspace-gzy/zyf/gca-skill
|
||||
```
|
||||
|
||||
Those processes are `GroundingDINOModel` / `DA3Model`, not the
|
||||
SkillReflection ablation ALFWorld run.
|
||||
|
||||
There are also unrelated ALFWorld jobs under:
|
||||
|
||||
```text
|
||||
/home/azureuser/zisu/skill_distill
|
||||
```
|
||||
|
||||
Do not confuse those with this repository's ablation outputs.
|
||||
|
||||
### Monitoring
|
||||
|
||||
Active run and duplicate output-root check:
|
||||
|
||||
```bash
|
||||
$PY - <<'PY'
|
||||
import subprocess, re, collections, time
|
||||
try:
|
||||
raw = subprocess.check_output(["pgrep", "-af", "scripts/train.py"], text=True)
|
||||
except subprocess.CalledProcessError:
|
||||
raw = ""
|
||||
roots = []
|
||||
for line in raw.splitlines():
|
||||
m = re.search(r"env\.out_root=([^\s]+)", line)
|
||||
if m:
|
||||
roots.append(m.group(1))
|
||||
ctr = collections.Counter(roots)
|
||||
print("time", time.strftime("%F %T"))
|
||||
print("active_count", len(roots))
|
||||
print("duplicates", [r.rsplit("/", 1)[-1] for r, c in ctr.items() if c > 1])
|
||||
for root in sorted(roots):
|
||||
print(root.rsplit("/", 1)[-1])
|
||||
PY
|
||||
```
|
||||
|
||||
Error scan:
|
||||
|
||||
```bash
|
||||
rg -n "Traceback|ERROR|Error code|AuthenticationError|BadRequest|RateLimit|content_filter|Killed|OutOfMemory|CUDA out of memory|\\[FAIL\\]|LLM call failed" \
|
||||
outputs/ablation_docvqa_20260503_160225_run/logs \
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/logs \
|
||||
outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run/logs \
|
||||
-g '*.log' | tail -100 || true
|
||||
```
|
||||
|
||||
Resource checks:
|
||||
|
||||
```bash
|
||||
free -h | sed -n '1,3p'
|
||||
df -h /tmp
|
||||
du -sh /tmp/ray 2>/dev/null || true
|
||||
nvidia-smi
|
||||
```
|
||||
|
||||
### Filling Tables
|
||||
|
||||
Only use top-level `summary.json` from valid run roots. Fill
|
||||
`docs/ablation_paper_tables.md` from:
|
||||
|
||||
```text
|
||||
best_selection_hard
|
||||
baseline_test_hard
|
||||
test_hard
|
||||
test_delta_hard
|
||||
token_summary._total.total_tokens
|
||||
```
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd /home/azureuser/workspace-gzy/SkillReflection
|
||||
|
||||
PY=/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python
|
||||
export ALFWORLD_DATA=/home/azureuser/.cache/alfworld
|
||||
|
||||
# Original SearchQA / SpreadsheetBench full matrix reproduction command.
|
||||
# Do not run this into the existing root unless intentionally reproducing from
|
||||
# scratch; the current valid root is already populated:
|
||||
# outputs/ablation_20260502_040604_unique48
|
||||
#
|
||||
# setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
# --groups default split mbs lr sched slown mod smodel \
|
||||
# --bench searchqa spreadsheetbench \
|
||||
# --run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_20260502_040604_unique48 \
|
||||
# --max-parallel 24 \
|
||||
# --execute \
|
||||
# > /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_20260502_040604_unique48/launcher_reproduce_full_matrix.log 2>&1 < /dev/null &
|
||||
#
|
||||
# SearchQA / SpreadsheetBench batch-size ablations only.
|
||||
# Original non-batch SearchQA/SpreadsheetBench ablations live in:
|
||||
# outputs/ablation_20260502_040604_unique48
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups batch \
|
||||
--bench searchqa spreadsheetbench \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run \
|
||||
--max-parallel 8 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run/launcher_parallel8.log 2>&1 < /dev/null &
|
||||
|
||||
# DocVQA full matrix.
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups default split batch mbs lr sched slown mod smodel \
|
||||
--bench docvqa \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_docvqa_20260503_160225_run \
|
||||
--max-parallel 8 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_docvqa_20260503_160225_run/launcher_parallel8.log 2>&1 < /dev/null &
|
||||
|
||||
# LiveMathBench clean matrix. ALFWorld should be launched separately at lower
|
||||
# concurrency because Ray OOM occurred when many ALFWorld runs were mixed into a
|
||||
# 24-way run.
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups default split batch mbs lr sched slown mod smodel \
|
||||
--bench livemathematicianbench \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_livemath_alfworld_clean_20260503_155155_run \
|
||||
--max-parallel 8 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_livemath_alfworld_clean_20260503_155155_run/launcher_livemath_parallel8.log 2>&1 < /dev/null &
|
||||
|
||||
# ALFWorld clean matrix. Increase to 2 only after checking memory, /tmp/ray,
|
||||
# and that no other ALFWorld run is active. Do not use 8/16/24 for ALFWorld on
|
||||
# the current shared machine unless resources are explicitly reserved.
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups default split batch mbs lr sched slown mod smodel \
|
||||
--bench alfworld \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_livemath_alfworld_clean_20260503_155155_run \
|
||||
--max-parallel 1 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_livemath_alfworld_clean_20260503_155155_run/launcher_alfworld_parallel1.log 2>&1 < /dev/null &
|
||||
|
||||
# Longitudinal comparison-example policy ablations. This intentionally excludes
|
||||
# ALFWorld. The only varied setting is optimizer.longitudinal_pair_policy.
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups longpair \
|
||||
--bench searchqa spreadsheetbench livemathematicianbench docvqa \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_longpair_20260504_run \
|
||||
--max-parallel 8 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_longpair_20260504_run/launcher_longpair_parallel8.log 2>&1 < /dev/null &
|
||||
|
||||
# Learning-rate-control baselines. This intentionally excludes ALFWorld.
|
||||
setsid "$PY" scripts/run_ablation_matrix.py \
|
||||
--groups lrctrl \
|
||||
--bench searchqa spreadsheetbench livemathematicianbench docvqa \
|
||||
--run-root /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_lrctrl_20260504_run \
|
||||
--max-parallel 8 \
|
||||
--execute \
|
||||
> /home/azureuser/workspace-gzy/SkillReflection/outputs/ablation_lrctrl_20260504_run/launcher_lrctrl_parallel8.log 2>&1 < /dev/null &
|
||||
@@ -0,0 +1,257 @@
|
||||
version: 2026-05-04
|
||||
purpose: "Canonical paper ablation settings matching the valid current runs."
|
||||
|
||||
launcher:
|
||||
script: scripts/run_ablation_matrix.py
|
||||
python: /home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python
|
||||
skip_completed_by: summary.json
|
||||
skip_active_by: "active scripts/train.py env.out_root"
|
||||
|
||||
environment:
|
||||
working_directory: /home/azureuser/workspace-gzy/SkillReflection
|
||||
required_env:
|
||||
ALFWORLD_DATA: /home/azureuser/.cache/alfworld
|
||||
docvqa_images_symlink: "data/docvqa_images -> /home/azureuser/zisu/SkillReflection/data/docvqa_images"
|
||||
|
||||
common_overrides:
|
||||
model.teacher_backend: openai_chat
|
||||
model.student_backend: openai_chat
|
||||
model.teacher: gpt-5.5
|
||||
model.student: gpt-5.5
|
||||
model.teacher_azure_openai_endpoint: https://t2vgoaigpt4o3.openai.azure.com/
|
||||
model.teacher_azure_openai_api_version: 2024-12-01-preview
|
||||
model.teacher_azure_openai_auth_mode: azure_cli
|
||||
model.student_azure_openai_endpoint: https://t2vgoaigpt4o3.openai.azure.com/
|
||||
model.student_azure_openai_api_version: 2024-12-01-preview
|
||||
model.student_azure_openai_auth_mode: azure_cli
|
||||
model.reasoning_effort: medium
|
||||
train.num_epochs: 4
|
||||
train.train_size: 0
|
||||
train.batch_size: 40
|
||||
train.accumulation: 1
|
||||
train.seed: 42
|
||||
gradient.minibatch_size: 8
|
||||
gradient.merge_batch_size: 8
|
||||
gradient.analyst_workers: 16
|
||||
gradient.use_deep_reflect: false
|
||||
optimizer.learning_rate: 4
|
||||
optimizer.min_learning_rate: 2
|
||||
optimizer.lr_scheduler: cosine
|
||||
optimizer.skill_update_mode: patch
|
||||
optimizer.use_slow_update: true
|
||||
optimizer.slow_update_samples: 20
|
||||
optimizer.use_meta_skill: true
|
||||
optimizer.use_meta_reflect: false
|
||||
evaluation.use_gate: true
|
||||
evaluation.eval_test: true
|
||||
env.split_mode: split_dir
|
||||
|
||||
benchmarks:
|
||||
searchqa:
|
||||
config: configs/searchqa/default.yaml
|
||||
run_roots:
|
||||
original_matrix: outputs/ablation_20260502_040604_unique48
|
||||
batch_matrix: outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run
|
||||
default_split: data/ablation_splits/searchqa/2-1-7_seed42
|
||||
train: 400
|
||||
val: 200
|
||||
test: 1400
|
||||
student_rollout:
|
||||
function: skillopt/envs/searchqa/rollout.py::chat_student
|
||||
max_completion_tokens:
|
||||
first_turn: 512
|
||||
refinement: 512
|
||||
rationale: "Short-answer QA; sampled empties are low and not LiveMath-like."
|
||||
|
||||
spreadsheetbench:
|
||||
config: configs/spreadsheetbench/default.yaml
|
||||
run_roots:
|
||||
original_matrix: outputs/ablation_20260502_040604_unique48
|
||||
batch_matrix: outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run
|
||||
default_split: data/ablation_splits/spreadsheetbench/2-1-7_seed42
|
||||
train: 80
|
||||
val: 40
|
||||
test: 280
|
||||
student_rollout:
|
||||
function: skillopt/envs/spreadsheetbench/codegen_agent.py::run_multi
|
||||
max_output_tokens: 16384
|
||||
result_note: "results.jsonl stores execution fields, not a response field."
|
||||
|
||||
livemathematicianbench:
|
||||
config: configs/livemathematicianbench/default.yaml
|
||||
run_roots:
|
||||
clean_matrix: outputs/ablation_livemath_alfworld_clean_20260503_155155_run
|
||||
default_split: data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
train: 35
|
||||
val: 18
|
||||
test: 124
|
||||
student_rollout:
|
||||
function: skillopt/envs/livemathematicianbench/rollout.py::chat_student
|
||||
max_completion_tokens:
|
||||
first_turn: 16384
|
||||
refinement: 16384
|
||||
timeout_seconds: 300
|
||||
invalid_old_caps:
|
||||
first_turn: 768
|
||||
refinement: 512
|
||||
invalid_archive: outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_livemath_token768_20260504_022258
|
||||
rationale: "GPT-5 reasoning consumed small budgets and produced many empty visible responses."
|
||||
|
||||
alfworld:
|
||||
config: configs/alfworld/default.yaml
|
||||
run_roots:
|
||||
clean_matrix: outputs/ablation_livemath_alfworld_clean_20260503_155155_run
|
||||
default_split: data/ablation_splits/alfworld/2-1-7_seed42
|
||||
train: 39
|
||||
val: 18
|
||||
test: 134
|
||||
student_rollout:
|
||||
function: skillopt/envs/alfworld/rollout.py::chat_student
|
||||
max_completion_tokens: 2048
|
||||
timeout_seconds: 120
|
||||
max_steps: 50
|
||||
fallback_action: look
|
||||
invalid_old_cap: 512
|
||||
invalid_archives:
|
||||
- outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_token512_20260504_021417
|
||||
- outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_empty_action_20260504_025311
|
||||
- outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_prefallback_20260504_025402
|
||||
- outputs/ablation_livemath_alfworld_clean_20260503_155155_run/archive_alfworld_oom_partial_20260504_050517
|
||||
concurrency_note: "Do not mix many ALFWorld runs into 24-way total concurrency; Ray OOM occurred. Prefer 1-2 ALFWorld runs at a time unless resources are clearly free."
|
||||
|
||||
docvqa:
|
||||
config: configs/docvqa/default.yaml
|
||||
run_roots:
|
||||
matrix: outputs/ablation_docvqa_zisu10pct_20260505_run
|
||||
default_split: /home/azureuser/zisu/SkillReflection/data/docvqa/splits
|
||||
train: 1070
|
||||
val: 535
|
||||
test: 3744
|
||||
data_note: "2026-05-05: use zisu-provided 5349-item DocVQA split directly; previous local 2-1-7_seed42 used the same item pool but a different train/val/test assignment and must not be used for final DocVQA reruns."
|
||||
student_rollout:
|
||||
function: skillopt/envs/docvqa/rollout.py::chat_student_messages
|
||||
max_completion_tokens:
|
||||
first_turn: 768
|
||||
refinement: 512
|
||||
rationale: "Short-answer VQA output; preserve current setting for alignment unless explicitly rerunning all affected DocVQA."
|
||||
|
||||
splits:
|
||||
tags:
|
||||
1shot:
|
||||
extra_overrides:
|
||||
optimizer.slow_update_samples: 1
|
||||
1-1-8: {}
|
||||
2-1-7:
|
||||
default: true
|
||||
4-1-5: {}
|
||||
paths:
|
||||
searchqa:
|
||||
1shot: data/ablation_splits/searchqa/1shot_seed42
|
||||
1-1-8: data/ablation_splits/searchqa/1-1-8_seed42
|
||||
2-1-7: data/ablation_splits/searchqa/2-1-7_seed42
|
||||
4-1-5: data/ablation_splits/searchqa/4-1-5_seed42
|
||||
spreadsheetbench:
|
||||
1shot: data/ablation_splits/spreadsheetbench/1shot_seed42
|
||||
1-1-8: data/ablation_splits/spreadsheetbench/1-1-8_seed42
|
||||
2-1-7: data/ablation_splits/spreadsheetbench/2-1-7_seed42
|
||||
4-1-5: data/ablation_splits/spreadsheetbench/4-1-5_seed42
|
||||
livemathematicianbench:
|
||||
1shot: data/ablation_splits/livemathematicianbench/1shot_seed42
|
||||
1-1-8: data/ablation_splits/livemathematicianbench/1-1-8_seed42
|
||||
2-1-7: data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
4-1-5: data/ablation_splits/livemathematicianbench/4-1-5_seed42
|
||||
alfworld:
|
||||
1shot: data/ablation_splits/alfworld/1shot_seed42
|
||||
1-1-8: data/ablation_splits/alfworld/1-1-8_seed42
|
||||
2-1-7: data/ablation_splits/alfworld/2-1-7_seed42
|
||||
4-1-5: data/ablation_splits/alfworld/4-1-5_seed42
|
||||
docvqa:
|
||||
1shot: data/ablation_splits/docvqa/1shot_seed42
|
||||
1-1-8: data/ablation_splits/docvqa/1-1-8_seed42
|
||||
2-1-7: /home/azureuser/zisu/SkillReflection/data/docvqa/splits
|
||||
4-1-5: data/ablation_splits/docvqa/4-1-5_seed42
|
||||
|
||||
groups:
|
||||
default:
|
||||
run_id: "DEFAULT-{benchmark}-5.5"
|
||||
overrides: {}
|
||||
split:
|
||||
values: [1shot, 1-1-8, 4-1-5]
|
||||
skip_default_2_1_7: true
|
||||
override_template: "env.split_dir={split_path}"
|
||||
batch:
|
||||
values: [8, 24, 56, full]
|
||||
default_value_reused: 40
|
||||
full_values:
|
||||
searchqa: 400
|
||||
spreadsheetbench: 80
|
||||
livemathematicianbench: 35
|
||||
alfworld: 39
|
||||
docvqa: 1070
|
||||
fixed_overrides:
|
||||
gradient.minibatch_size: 8
|
||||
mbs:
|
||||
values: [1, 2, 4, 16, 32]
|
||||
default_value_reused: 8
|
||||
override_template: "gradient.minibatch_size={value}"
|
||||
lr:
|
||||
values: [1, 2, 4, 8, 16]
|
||||
fixed_overrides:
|
||||
optimizer.lr_scheduler: constant
|
||||
optimizer.min_learning_rate: 1
|
||||
override_template: "optimizer.learning_rate={value}"
|
||||
sched:
|
||||
values: [constant, linear]
|
||||
default_value_reused: cosine
|
||||
override_template: "optimizer.lr_scheduler={value}"
|
||||
slown:
|
||||
values: [5, 10, 40]
|
||||
default_value_reused: 20
|
||||
override_template: "optimizer.slow_update_samples={value}"
|
||||
mod:
|
||||
values:
|
||||
slow-only:
|
||||
optimizer.use_slow_update: true
|
||||
optimizer.use_meta_skill: false
|
||||
meta-only:
|
||||
optimizer.use_slow_update: false
|
||||
optimizer.use_meta_skill: true
|
||||
none:
|
||||
optimizer.use_slow_update: false
|
||||
optimizer.use_meta_skill: false
|
||||
default_value_reused: slow-meta
|
||||
longpair:
|
||||
values: [changed, unchanged]
|
||||
default_value_reused: mixed
|
||||
override_template: "optimizer.longitudinal_pair_policy={value}"
|
||||
note: "Only changes slow-update/meta-skill comparison examples; prompts and other settings remain unchanged."
|
||||
lrctrl:
|
||||
values:
|
||||
autonomous:
|
||||
optimizer.lr_control_mode: autonomous
|
||||
full-rewrite:
|
||||
optimizer.lr_control_mode: none
|
||||
optimizer.skill_update_mode: full_rewrite_minibatch
|
||||
default_value_reused: "fixed patch learning_rate=4"
|
||||
note: "autonomous records lr_decision.json/lr_history.jsonl; full-rewrite removes LR/select/apply-edit and uses full skill candidates."
|
||||
smodel:
|
||||
values:
|
||||
"5.4":
|
||||
model.student: gpt-5.4-pro
|
||||
model.student_azure_openai_endpoint: https://t2vgoaigpt4o3.openai.azure.com/
|
||||
model.student_azure_openai_api_version: 2025-03-01-preview
|
||||
model.student_azure_openai_auth_mode: azure_cli
|
||||
"5.4-mini":
|
||||
model.student: gpt-5.4-mini
|
||||
model.student_azure_openai_endpoint: https://searchagent5.cognitiveservices.azure.com/
|
||||
model.student_azure_openai_api_version: 2024-12-01-preview
|
||||
model.student_azure_openai_auth_mode: azure_cli
|
||||
default_value_reused: "5.5"
|
||||
|
||||
validity_rules:
|
||||
use_for_tables:
|
||||
- "Only runs with summary.json in valid run roots."
|
||||
- "Do not use archive, archived, MISALIGNED, SUPERSEDED, dryrun, smoke, or debug directories."
|
||||
- "Do not use ALFWorld runs started before empty/missing-action fallback."
|
||||
- "Do not use old LiveMath runs with 768/512 token caps."
|
||||
rerun_rule: "Archive or remove invalid out_root before relaunch; never write a rerun into a polluted output directory."
|
||||
@@ -0,0 +1,141 @@
|
||||
# Ablation Validation Checklist
|
||||
|
||||
Use this checklist before launch, during monitoring, and before filling
|
||||
`docs/ablation_paper_tables.md`.
|
||||
|
||||
## Before Launch
|
||||
|
||||
Run from repo root:
|
||||
|
||||
```bash
|
||||
cd /home/azureuser/workspace-gzy/SkillReflection
|
||||
export ALFWORLD_DATA=/home/azureuser/.cache/alfworld
|
||||
```
|
||||
|
||||
Verify syntax for edited files:
|
||||
|
||||
```bash
|
||||
/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python -m py_compile \
|
||||
scripts/run_ablation_matrix.py \
|
||||
scripts/train.py \
|
||||
skillopt/model/azure_openai.py \
|
||||
skillopt/envs/searchqa/rollout.py \
|
||||
skillopt/envs/spreadsheetbench/rollout.py \
|
||||
skillopt/envs/livemathematicianbench/rollout.py \
|
||||
skillopt/envs/alfworld/rollout.py \
|
||||
skillopt/envs/docvqa/rollout.py
|
||||
```
|
||||
|
||||
Check active runs and duplicate `env.out_root` before starting more:
|
||||
|
||||
```bash
|
||||
/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python - <<'PY'
|
||||
import subprocess, re, collections
|
||||
try:
|
||||
raw = subprocess.check_output(["pgrep", "-af", "scripts/train.py"], text=True)
|
||||
except subprocess.CalledProcessError:
|
||||
raw = ""
|
||||
roots = []
|
||||
for line in raw.splitlines():
|
||||
m = re.search(r"env\.out_root=([^\s]+)", line)
|
||||
if m:
|
||||
roots.append(m.group(1))
|
||||
ctr = collections.Counter(roots)
|
||||
print("train_count", len(roots))
|
||||
print("duplicate_roots", [r.rsplit("/", 1)[-1] for r, c in ctr.items() if c > 1])
|
||||
for root in sorted(roots):
|
||||
print(root.rsplit("/", 1)[-1])
|
||||
PY
|
||||
```
|
||||
|
||||
## During Monitoring
|
||||
|
||||
Check launchers:
|
||||
|
||||
```bash
|
||||
pgrep -af 'scripts/run_ablation_matrix.py' || true
|
||||
tail -80 outputs/ablation_docvqa_20260503_160225_run/launcher_parallel8.log 2>/dev/null || true
|
||||
tail -80 outputs/ablation_livemath_alfworld_clean_20260503_155155_run/launcher_livemath_parallel8.log 2>/dev/null || true
|
||||
tail -80 outputs/ablation_livemath_alfworld_clean_20260503_155155_run/launcher_alfworld_parallel1.log 2>/dev/null || true
|
||||
```
|
||||
|
||||
Scan current logs for new hard failures:
|
||||
|
||||
```bash
|
||||
rg -n "Traceback|ERROR|Error code|AuthenticationError|BadRequest|RateLimit|content_filter|Killed|OutOfMemory|\\[FAIL\\]|\\[RETRY\\]" \
|
||||
outputs/ablation_docvqa_20260503_160225_run/logs \
|
||||
outputs/ablation_livemath_alfworld_clean_20260503_155155_run/logs \
|
||||
outputs/ablation_batch_searchqa_spreadsheet_20260503_153902_run/logs \
|
||||
-g '*.log' | tail -160 || true
|
||||
```
|
||||
|
||||
Check resource pressure:
|
||||
|
||||
```bash
|
||||
df -h /tmp
|
||||
du -sh /tmp/ray 2>/dev/null || true
|
||||
free -h | sed -n '1,3p'
|
||||
```
|
||||
|
||||
## Quality Checks
|
||||
|
||||
LiveMathBench current valid runs should not look like old 768/512 runs:
|
||||
|
||||
```bash
|
||||
/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python - <<'PY'
|
||||
import json, pathlib
|
||||
root = pathlib.Path("outputs/ablation_livemath_alfworld_clean_20260503_155155_run")
|
||||
for run in sorted(root.glob("*livemathematicianbench*")):
|
||||
if not run.is_dir() or "archive" in str(run):
|
||||
continue
|
||||
for rel in ["test_eval_baseline/results.jsonl", "test_eval/results.jsonl"]:
|
||||
p = run / rel
|
||||
if not p.exists():
|
||||
continue
|
||||
rows = [json.loads(l) for l in p.open(errors="ignore") if l.strip()]
|
||||
empty = sum(1 for r in rows if not str(r.get("response", "")).strip())
|
||||
answer = sum(1 for r in rows if "<answer>" in str(r.get("response", "")).lower())
|
||||
if empty:
|
||||
print(run.name, rel, "empty", empty, "answer", answer, "n", len(rows))
|
||||
PY
|
||||
```
|
||||
|
||||
ALFWorld valid runs must not contain empty action or missing action:
|
||||
|
||||
```bash
|
||||
/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python - <<'PY'
|
||||
import json, pathlib
|
||||
root = pathlib.Path("outputs/ablation_livemath_alfworld_clean_20260503_155155_run")
|
||||
for run in sorted(root.glob("*alfworld*")):
|
||||
if not run.is_dir() or "archive" in str(run):
|
||||
continue
|
||||
bad = []
|
||||
fallback = 0
|
||||
for c in run.glob("**/conversation.json"):
|
||||
data = json.load(c.open(errors="ignore"))
|
||||
for step in data:
|
||||
if step.get("step") is None:
|
||||
continue
|
||||
if not step.get("action"):
|
||||
bad.append(str(c.relative_to(run)))
|
||||
break
|
||||
mr = str(step.get("model_response", ""))
|
||||
if "empty model response" in mr or "missing action tag" in mr:
|
||||
fallback += 1
|
||||
print(run.name, "bad_action_files", len(bad), "fallback", fallback)
|
||||
PY
|
||||
```
|
||||
|
||||
## Filling Tables
|
||||
|
||||
Use only `summary.json` fields:
|
||||
|
||||
- `best_selection_hard` -> Best Sel
|
||||
- `baseline_test_hard` -> Base Test
|
||||
- `test_hard` -> Best Test
|
||||
- `test_delta_hard` -> Delta
|
||||
- `total_accepts` -> Accept
|
||||
- `total_rejects` -> Reject
|
||||
- `token_summary._total.total_tokens` -> Tokens
|
||||
|
||||
Do not fill table rows from logs alone.
|
||||
@@ -10,6 +10,7 @@ gradient:
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4
|
||||
use_meta_reflect: false
|
||||
|
||||
evaluation:
|
||||
sel_env_num: 0
|
||||
@@ -19,11 +20,11 @@ env:
|
||||
name: alfworld
|
||||
skill_init: skillopt/envs/alfworld/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: data/ablation_splits/alfworld/2-1-7_seed42
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_steps: 50
|
||||
max_completion_tokens: 16384
|
||||
workers: 8
|
||||
max_api_workers: 8
|
||||
limit: 0
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
_base_: default.yaml
|
||||
|
||||
optimizer:
|
||||
use_meta_reflect: true
|
||||
@@ -0,0 +1,21 @@
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
train:
|
||||
batch_size: 64
|
||||
accumulation: 1
|
||||
|
||||
env:
|
||||
name: babyvision
|
||||
skill_init: skillopt/envs/babyvision/skills/initial.md
|
||||
split_mode: ratio
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: ""
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_turns: 1
|
||||
workers: 16
|
||||
limit: 0
|
||||
image_detail: auto
|
||||
judge_model: gpt-5.4
|
||||
judge_max_completion_tokens: 256
|
||||
judge_retries: 5
|
||||
@@ -18,11 +18,11 @@ env:
|
||||
name: docvqa
|
||||
skill_init: skillopt/envs/docvqa/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_dir: data/docvqa/splits
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: /home/azureuser/zisu/SkillReflection/data/docvqa/splits
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_turns: 1
|
||||
max_completion_tokens: 16384
|
||||
workers: 16
|
||||
image_detail: auto
|
||||
limit: 0
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Example: soft / mixed validation-gate metric (community-contributed, PR #25)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
#
|
||||
# This is NOT a default SkillOpt setting and was NOT used to produce the
|
||||
# numbers reported in the paper. It is provided as a reference for users
|
||||
# who encounter a specific scenario where the default `hard` gate is too
|
||||
# coarse to drive training.
|
||||
#
|
||||
# When to consider this:
|
||||
# - You are running on a custom environment.
|
||||
# - Your held-out *selection* split has very few items (e.g. ≤ ~10).
|
||||
# - Your reward function is continuous / partial-credit (e.g. F1, BLEU,
|
||||
# soft match) rather than purely binary 0/1.
|
||||
#
|
||||
# Symptom this addresses:
|
||||
# With a small selection split + continuous rewards, candidate skills
|
||||
# often improve per-item soft scores (e.g. 0.06 → 0.26 on one item) but
|
||||
# never flip the discrete hard outcome. The default `hard` gate then
|
||||
# rejects every candidate and training stalls. Switching the gate to
|
||||
# `soft` or `mixed` lets these partial improvements be accepted.
|
||||
#
|
||||
# When NOT to use this:
|
||||
# - When reproducing the paper. The paper-reported numbers were obtained
|
||||
# under the default `hard` gate.
|
||||
# - When your selection split is large (dozens+ items) and / or your
|
||||
# reward is already binary — `hard` is the more conservative choice
|
||||
# and matches the design described in the paper.
|
||||
#
|
||||
# To use: inherit your env config from this file, e.g.
|
||||
# _base_: ../examples/soft_gate.yaml
|
||||
# or copy the `evaluation:` block below into your config.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
evaluation:
|
||||
# Three options:
|
||||
# 'hard' — default; exact-match accuracy. Use this to reproduce the paper.
|
||||
# 'soft' — per-item soft / partial-credit score (recommended for the
|
||||
# small-split + continuous-reward scenario described above).
|
||||
# 'mixed' — weighted average: (1 - w) * hard + w * soft, with `w` set by
|
||||
# `gate_mixed_weight` below.
|
||||
gate_metric: soft
|
||||
|
||||
# Only used when gate_metric == 'mixed'. Ignored otherwise.
|
||||
gate_mixed_weight: 0.5
|
||||
@@ -9,11 +9,11 @@ env:
|
||||
name: livemathematicianbench
|
||||
skill_init: skillopt/envs/livemathematicianbench/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_turns: 1
|
||||
max_completion_tokens: 16384
|
||||
exec_timeout: 300
|
||||
workers: 64
|
||||
limit: 0
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
model:
|
||||
codex_exec_sandbox: danger-full-access
|
||||
|
||||
train:
|
||||
batch_size: 64
|
||||
accumulation: 1
|
||||
|
||||
env:
|
||||
name: mathverse
|
||||
skill_init: skillopt/envs/mathverse/skills/initial.md
|
||||
split_dir: ""
|
||||
data_root: data/MathVerse
|
||||
problem_version: Text Lite
|
||||
use_text_dominant_reference: false
|
||||
max_turns: 1
|
||||
workers: 16
|
||||
limit: 0
|
||||
image_detail: auto
|
||||
judge_model: gpt-5.4
|
||||
judge_max_completion_tokens: 256
|
||||
judge_retries: 5
|
||||
@@ -0,0 +1,18 @@
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
train:
|
||||
batch_size: 128
|
||||
accumulation: 1
|
||||
|
||||
env:
|
||||
name: mmrb
|
||||
skill_init: skillopt/envs/mmrb/skills/initial.md
|
||||
split_mode: ratio
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: ""
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_turns: 1
|
||||
workers: 16
|
||||
limit: 0
|
||||
image_detail: auto
|
||||
@@ -17,18 +17,9 @@ optimizer:
|
||||
env:
|
||||
name: officeqa
|
||||
skill_init: skillopt/envs/officeqa/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_dir: data/officeqa_split
|
||||
data_dirs:
|
||||
- data/officeqa_docs_official
|
||||
workers: 4
|
||||
max_tool_turns: 24
|
||||
max_completion_tokens: 16384
|
||||
search_mode: offline
|
||||
max_queries_per_turn: 4
|
||||
search_api_url: http://apisix.westus2.cloudapp.azure.com/search_tool/search
|
||||
search_auth_env: OFFICEQA_CUSTOM_SEARCH_AUTH
|
||||
search_provider: duckduckgo
|
||||
search_max_num_results: 4
|
||||
search_timeout_seconds: 20
|
||||
limit: 0
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
model:
|
||||
reasoning_effort: medium
|
||||
|
||||
train:
|
||||
batch_size: 10
|
||||
accumulation: 1
|
||||
|
||||
gradient:
|
||||
minibatch_size: 8
|
||||
merge_batch_size: 8
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4
|
||||
|
||||
env:
|
||||
name: sealqa
|
||||
skill_init: skillopt/envs/sealqa/skills/initial.md
|
||||
split_dir: data/sealqa_split
|
||||
workers: 4
|
||||
max_tool_turns: 12
|
||||
limit: 0
|
||||
@@ -23,10 +23,10 @@ env:
|
||||
name: searchqa
|
||||
skill_init: skillopt/envs/searchqa/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: data/searchqa_split
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
max_turns: 1
|
||||
max_completion_tokens: 16384
|
||||
workers: 24
|
||||
limit: 0
|
||||
|
||||
@@ -23,12 +23,12 @@ env:
|
||||
name: spreadsheetbench
|
||||
skill_init: skillopt/envs/spreadsheetbench/skills/initial.md
|
||||
split_mode: split_dir
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: data/spreadsheetbench_split
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
data_root: data/spreadsheetbench_verified_400
|
||||
mode: multi
|
||||
max_turns: 30
|
||||
max_completion_tokens: 16384
|
||||
exec_timeout: 600
|
||||
workers: 24
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
_base_: ../_base_/default.yaml
|
||||
|
||||
model:
|
||||
reasoning_effort: medium
|
||||
|
||||
train:
|
||||
batch_size: 20
|
||||
accumulation: 1
|
||||
|
||||
gradient:
|
||||
minibatch_size: 4
|
||||
merge_batch_size: 8
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4
|
||||
|
||||
evaluation:
|
||||
sel_env_num: 0
|
||||
test_env_num: 0
|
||||
|
||||
env:
|
||||
name: swebench
|
||||
skill_init: skillopt/envs/swebench/skills/initial.md
|
||||
split_mode: ratio
|
||||
split_ratio: "2:1:7"
|
||||
split_dir: ""
|
||||
data_path: ""
|
||||
split_output_dir: ""
|
||||
dataset_name: lite
|
||||
hf_split: test
|
||||
workers: 8
|
||||
eval_workers: 8
|
||||
step_limit: 50
|
||||
cost_limit: 3.0
|
||||
timeout_per_instance: 600
|
||||
limit: 0
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,602 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": "1758dc50625e46ee814e44a6061f091d"
|
||||
},
|
||||
{
|
||||
"id": "52967b20d9564d5b94756bc0b3d113d6"
|
||||
},
|
||||
{
|
||||
"id": "e77dbfc0d45e476b9ed5b2204b6d9fc8"
|
||||
},
|
||||
{
|
||||
"id": "675f01b5343e46599626104968c0f45a"
|
||||
},
|
||||
{
|
||||
"id": "dccd0f04cd3b41bc8c4182e41a413b3e"
|
||||
},
|
||||
{
|
||||
"id": "efde5820a29949488feaa18ce7e429f9"
|
||||
},
|
||||
{
|
||||
"id": "98773558971e490d8de41088e41a3207"
|
||||
},
|
||||
{
|
||||
"id": "70e3e1e1d41f4795ba45678d5f4b6524"
|
||||
},
|
||||
{
|
||||
"id": "206a9ffb8ed24686a24db1492c9f10dc"
|
||||
},
|
||||
{
|
||||
"id": "e91f1225cdb84ee7a2d773b5177945c1"
|
||||
},
|
||||
{
|
||||
"id": "b68a14a7b43842a0a50a3965d3bbffbb"
|
||||
},
|
||||
{
|
||||
"id": "e2e679989b544e94bf8dbc3466e49003"
|
||||
},
|
||||
{
|
||||
"id": "c51c26c07b384bbe865976b81a86736d"
|
||||
},
|
||||
{
|
||||
"id": "83928d21f3504843aa6294ce9d9c8da1"
|
||||
},
|
||||
{
|
||||
"id": "f822cde36d864c508b426f3e2b5245b2"
|
||||
},
|
||||
{
|
||||
"id": "f03757766e034c539bf2595428c03626"
|
||||
},
|
||||
{
|
||||
"id": "349be67be2e141438287d21cb6a94131"
|
||||
},
|
||||
{
|
||||
"id": "7f3e18272c6d43dd8c6385c4758b685e"
|
||||
},
|
||||
{
|
||||
"id": "66dc8aee931142b1834da63363511491"
|
||||
},
|
||||
{
|
||||
"id": "52ac78645e144b4598958d67920617dc"
|
||||
},
|
||||
{
|
||||
"id": "32a66c67a8d7490b8572387d8f1d762a"
|
||||
},
|
||||
{
|
||||
"id": "b028bea99d2641268532cd2a32d4ad2d"
|
||||
},
|
||||
{
|
||||
"id": "c9f3a971abe64853aca3e0bb1fea6962"
|
||||
},
|
||||
{
|
||||
"id": "5324041c25d04316a800ccba2d79a2c7"
|
||||
},
|
||||
{
|
||||
"id": "9960a3f1ac954282a7ea1d7f7c8a86f9"
|
||||
},
|
||||
{
|
||||
"id": "03bd8fc86a9d465e9370dcdaedb3c422"
|
||||
},
|
||||
{
|
||||
"id": "a1d0d03fcac54483a1e88542b767afd5"
|
||||
},
|
||||
{
|
||||
"id": "c21a41745ab9402da8b1deea67055a8d"
|
||||
},
|
||||
{
|
||||
"id": "d5c48bd600824c8a9328df80a8baf964"
|
||||
},
|
||||
{
|
||||
"id": "746806ac0b1c48cb80d7ab5ad0a63517"
|
||||
},
|
||||
{
|
||||
"id": "e3b96fc1b99247ebada09a84fa5fd205"
|
||||
},
|
||||
{
|
||||
"id": "bbeeec20466a4dab9e4d73d86c964cba"
|
||||
},
|
||||
{
|
||||
"id": "2b85b097d130404daeb26a3349bdc297"
|
||||
},
|
||||
{
|
||||
"id": "fbaae95260474ed58ccbb05ac482089b"
|
||||
},
|
||||
{
|
||||
"id": "28b837ac304845bd961a46cedc9246af"
|
||||
},
|
||||
{
|
||||
"id": "691e3a24e5994c749ff11c6bc43b2d1c"
|
||||
},
|
||||
{
|
||||
"id": "12d5b51c793a43b1aa3b7e1bf5f4bc73"
|
||||
},
|
||||
{
|
||||
"id": "a3a3892296c74fc4b23b2475156901b1"
|
||||
},
|
||||
{
|
||||
"id": "8065f2e8639848f5b2f16a4f2877b7c2"
|
||||
},
|
||||
{
|
||||
"id": "b06e0d2be0a5465ea12ff2bf2b27d387"
|
||||
},
|
||||
{
|
||||
"id": "e50328dc70634863ac39580ef6f8dd5a"
|
||||
},
|
||||
{
|
||||
"id": "17b441db9b444435951d859e6e081f3b"
|
||||
},
|
||||
{
|
||||
"id": "0fc37a4bd8424ecf8eede56e956edb3a"
|
||||
},
|
||||
{
|
||||
"id": "09c769c7262e43eb95a52e874042c02a"
|
||||
},
|
||||
{
|
||||
"id": "2417ce75564b4b8eab1ddd755b10d962"
|
||||
},
|
||||
{
|
||||
"id": "8f4beaa8a7704eba93f753a0e7040165"
|
||||
},
|
||||
{
|
||||
"id": "6d8e99531264435badb67bf6ac209075"
|
||||
},
|
||||
{
|
||||
"id": "940ddc06648f4c9bac6b3bf5df402e5a"
|
||||
},
|
||||
{
|
||||
"id": "fa0fcf36e99644d0b51be95869d87adc"
|
||||
},
|
||||
{
|
||||
"id": "1882f20b777146608474ac0056d54a5e"
|
||||
},
|
||||
{
|
||||
"id": "439e908aa7c7422daf5632af7e0440ec"
|
||||
},
|
||||
{
|
||||
"id": "2d90c36ab1dd4724b1c108b2507316e4"
|
||||
},
|
||||
{
|
||||
"id": "efa5cc2f750c421a807bc4315db0dc1e"
|
||||
},
|
||||
{
|
||||
"id": "3b1c596e1720499ebe790d14f34a67af"
|
||||
},
|
||||
{
|
||||
"id": "c87234a3a1074b5ea5500114ad9aa16d"
|
||||
},
|
||||
{
|
||||
"id": "9d08ada791844519b7a4bb247d50c89c"
|
||||
},
|
||||
{
|
||||
"id": "74c45e35e5a740798fbd528ff08a70e3"
|
||||
},
|
||||
{
|
||||
"id": "650b683d39dd45c99ad7435fc7d33fe3"
|
||||
},
|
||||
{
|
||||
"id": "191ce59c97e143f7b4c33400913d3570"
|
||||
},
|
||||
{
|
||||
"id": "74441a0f7dae42ca9ee19d8be8c9b318"
|
||||
},
|
||||
{
|
||||
"id": "baef3cef84f14ed98655ac73293a56db"
|
||||
},
|
||||
{
|
||||
"id": "099a1ae148184bd5a93c9bc9889306e7"
|
||||
},
|
||||
{
|
||||
"id": "4fb4332a7a0e44e4b5655de1d7c2e5ac"
|
||||
},
|
||||
{
|
||||
"id": "cdf86d1982f64cb49d6595680b1c53b8"
|
||||
},
|
||||
{
|
||||
"id": "fa4cbba4ffed4f4e8ed4c148711cbc78"
|
||||
},
|
||||
{
|
||||
"id": "41c691d3b7e94ffd993647c7e531e94e"
|
||||
},
|
||||
{
|
||||
"id": "df43ea868a6d409ea67eb632fc9f285c"
|
||||
},
|
||||
{
|
||||
"id": "746448dcf441410db997a59f7137a2c8"
|
||||
},
|
||||
{
|
||||
"id": "3d0cad58c3c145f3b98d51c06a65a0c9"
|
||||
},
|
||||
{
|
||||
"id": "9cb4317831024d589622e2a3cf544360"
|
||||
},
|
||||
{
|
||||
"id": "802015dbc9f5406d8df3b468497f6553"
|
||||
},
|
||||
{
|
||||
"id": "5463f1d3fc124cadb2ad016076a699f5"
|
||||
},
|
||||
{
|
||||
"id": "8c77419b4e864778b965753f411bb469"
|
||||
},
|
||||
{
|
||||
"id": "2e112a7c9d97482fa0deb079c6c09172"
|
||||
},
|
||||
{
|
||||
"id": "f0c26f4f2e9f4d1d84b4f13cb201cbeb"
|
||||
},
|
||||
{
|
||||
"id": "231d7d9955d54f60a1f1ff4f0bf1c5b6"
|
||||
},
|
||||
{
|
||||
"id": "9b56a920d67a48e8b33932802d17d374"
|
||||
},
|
||||
{
|
||||
"id": "092a8aab433c4184bde9c8aa08789464"
|
||||
},
|
||||
{
|
||||
"id": "266a4337fa5742c8bbcc5aa79e571e85"
|
||||
},
|
||||
{
|
||||
"id": "d67cecf38f954800a7c651cca70bdc66"
|
||||
},
|
||||
{
|
||||
"id": "e634fa14bd4941ef96e1d21e796a9cd3"
|
||||
},
|
||||
{
|
||||
"id": "dbc29aef324e4c4f9f19082dcb1b5cb1"
|
||||
},
|
||||
{
|
||||
"id": "e688c5081a84488694b111a11a50ef7e"
|
||||
},
|
||||
{
|
||||
"id": "80b114d03dbb4598b5da648bbe174d0f"
|
||||
},
|
||||
{
|
||||
"id": "ce42d55ff5874c6380e018896b16e128"
|
||||
},
|
||||
{
|
||||
"id": "ef2b37212c98453390c9dca445d69de1"
|
||||
},
|
||||
{
|
||||
"id": "a66639dbb5ed4dfb9e65fe359ed8dc03"
|
||||
},
|
||||
{
|
||||
"id": "10eacaf72a4e4ad49cc43d3a710ee24a"
|
||||
},
|
||||
{
|
||||
"id": "b7e3d45f77bd4a4db768505fc4726592"
|
||||
},
|
||||
{
|
||||
"id": "0d1592f640f04ecb9c7add7164f87c5a"
|
||||
},
|
||||
{
|
||||
"id": "296a678ada814b09bdd0a53629f7f3f9"
|
||||
},
|
||||
{
|
||||
"id": "6e6fd6d62ce54031a4e36f88c2d5b63d"
|
||||
},
|
||||
{
|
||||
"id": "8d0dd71f94cc4abba255f3cdd6c2d940"
|
||||
},
|
||||
{
|
||||
"id": "7c26258ff99c4adeb4b9b35001005453"
|
||||
},
|
||||
{
|
||||
"id": "d13c24c99c704e31bbb3aaa585884d56"
|
||||
},
|
||||
{
|
||||
"id": "dbfb81f100dc474f8267e6f9ab0ae51c"
|
||||
},
|
||||
{
|
||||
"id": "3b4a5a2f617b43c8aa37b0890f576749"
|
||||
},
|
||||
{
|
||||
"id": "c49a8bf2d0ad4afd9b0bb0d03c1b9d96"
|
||||
},
|
||||
{
|
||||
"id": "fbfb4851dd494e44b9a21475d7e6dbaa"
|
||||
},
|
||||
{
|
||||
"id": "e0ba941f8e2c4fa6a0dea2b562b0e4be"
|
||||
},
|
||||
{
|
||||
"id": "7c9ec2b1cd8d4a8eaa6e1154e6fb40c4"
|
||||
},
|
||||
{
|
||||
"id": "4ae645d2721c4751b1e71c83870bbe16"
|
||||
},
|
||||
{
|
||||
"id": "c7bd32aee95f485d85d0b6749d542c51"
|
||||
},
|
||||
{
|
||||
"id": "20e140b44e0f4a6484e9cf776b09679b"
|
||||
},
|
||||
{
|
||||
"id": "5deb6bfcdd8c486d9f5f630309968763"
|
||||
},
|
||||
{
|
||||
"id": "18d1fcc3ed394b23ada799aad3beca90"
|
||||
},
|
||||
{
|
||||
"id": "74a655bcaead4857b92a49ec5f93ee23"
|
||||
},
|
||||
{
|
||||
"id": "bfec094ae9da4aaebd91713b39d3008e"
|
||||
},
|
||||
{
|
||||
"id": "80ebe13e36eb413a9acaace84648b36d"
|
||||
},
|
||||
{
|
||||
"id": "982e414b371248788c72732975949957"
|
||||
},
|
||||
{
|
||||
"id": "963ad06f3e314d3b99e0b6b9eaeaf2d8"
|
||||
},
|
||||
{
|
||||
"id": "90b6478bd7ae4145976c474dc42da80f"
|
||||
},
|
||||
{
|
||||
"id": "ea475dcd08d54da6896f56e330fa2a1c"
|
||||
},
|
||||
{
|
||||
"id": "64899cac91e5423fa3617bf576e6df4d"
|
||||
},
|
||||
{
|
||||
"id": "6231d57d040143e3bc56cafaabaa0975"
|
||||
},
|
||||
{
|
||||
"id": "3fdb66ab2b0a49318b053edda6633237"
|
||||
},
|
||||
{
|
||||
"id": "7dff080db1b8438e9ed737df1d7c32e3"
|
||||
},
|
||||
{
|
||||
"id": "878108ec7e9742a090175bd33390e2c5"
|
||||
},
|
||||
{
|
||||
"id": "3b2acfd62bdf4361aa4e51895d12df8b"
|
||||
},
|
||||
{
|
||||
"id": "0335847f4a44451db5a1b775cc019765"
|
||||
},
|
||||
{
|
||||
"id": "b6bfa34339c649398ae3b4540ed95fcf"
|
||||
},
|
||||
{
|
||||
"id": "82fd2c61b9a64b5f8971b28a1cfd8c1b"
|
||||
},
|
||||
{
|
||||
"id": "a9385b35a3a5492283aa461b93fdb361"
|
||||
},
|
||||
{
|
||||
"id": "847f117d4638487d92539d52eb07a999"
|
||||
},
|
||||
{
|
||||
"id": "de103586389245e7858b26b9b9a1ba57"
|
||||
},
|
||||
{
|
||||
"id": "82d95f6b3df64bb48668f7e98ddf5b9c"
|
||||
},
|
||||
{
|
||||
"id": "b1f6907b8f0f41ec82dc2eae7f84666b"
|
||||
},
|
||||
{
|
||||
"id": "1f232b1de1f34793b6557c8688bf4d9c"
|
||||
},
|
||||
{
|
||||
"id": "c16f718bd6554e998a95fe1d07623a13"
|
||||
},
|
||||
{
|
||||
"id": "dc2add9004fd40e69fcbd2eea80c513c"
|
||||
},
|
||||
{
|
||||
"id": "464e204e258340b69eca2b90451f06b8"
|
||||
},
|
||||
{
|
||||
"id": "c12fd75ea3db450bbfcabeb4f62f7e8f"
|
||||
},
|
||||
{
|
||||
"id": "5dbcadd728fa4956a4f739c1168fbf18"
|
||||
},
|
||||
{
|
||||
"id": "1730220302104d54ba2bb781ca219e52"
|
||||
},
|
||||
{
|
||||
"id": "ffcf25fe8cce4198bd483f2faaa17889"
|
||||
},
|
||||
{
|
||||
"id": "98ed5d627d0746e0aecb42eae39c14dc"
|
||||
},
|
||||
{
|
||||
"id": "30718db44c7f44a5b4b0c68842b1053b"
|
||||
},
|
||||
{
|
||||
"id": "4e90a93f4548458bb5d35ac9c767233b"
|
||||
},
|
||||
{
|
||||
"id": "dabccc32402a43a7ab9c82408f3603a1"
|
||||
},
|
||||
{
|
||||
"id": "80a8a1ea275944228e71fd0dfc74fb74"
|
||||
},
|
||||
{
|
||||
"id": "687434d75186430896ea636fec156e6d"
|
||||
},
|
||||
{
|
||||
"id": "28e5233352ba44ea9f7a8d4cf7f6b86a"
|
||||
},
|
||||
{
|
||||
"id": "b11499ee2a1f4a2b8fa8c9f561136430"
|
||||
},
|
||||
{
|
||||
"id": "6efcba5974464dcbaf5d9c5e9322bd9c"
|
||||
},
|
||||
{
|
||||
"id": "a1d460152c3840d98ed3bc45bf80d5c1"
|
||||
},
|
||||
{
|
||||
"id": "0d482f0e297544dcb2ce1e87e4c3b4b4"
|
||||
},
|
||||
{
|
||||
"id": "1a5baeb7a51d453d892ba70a9de2146d"
|
||||
},
|
||||
{
|
||||
"id": "ab84169c66b2415180563269295f53be"
|
||||
},
|
||||
{
|
||||
"id": "08c0e9678f1548aebeada27ab7b954e1"
|
||||
},
|
||||
{
|
||||
"id": "efd2d367aeec4cc4ae72cd3eaa040a0f"
|
||||
},
|
||||
{
|
||||
"id": "ae54626131ed42eaa55755f10ee64a76"
|
||||
},
|
||||
{
|
||||
"id": "1787cbe3e160427ca4e61931daf66e51"
|
||||
},
|
||||
{
|
||||
"id": "24143f01e7dd455e86c34a4a6f4ed3b9"
|
||||
},
|
||||
{
|
||||
"id": "5e92b869dd0b4ecbaf8694041891eb75"
|
||||
},
|
||||
{
|
||||
"id": "8d130f744b214055ad0c4cdce459a4b9"
|
||||
},
|
||||
{
|
||||
"id": "87913f6be2004e938ba60cda550bc675"
|
||||
},
|
||||
{
|
||||
"id": "68c7f892cbd94fc59ebe4ef1e1ad0c89"
|
||||
},
|
||||
{
|
||||
"id": "f7bf36628c7540da907dda84b48aac82"
|
||||
},
|
||||
{
|
||||
"id": "357af030b55046fc856e03fdac36032a"
|
||||
},
|
||||
{
|
||||
"id": "3a90f09909344dfdbb1a73f80c983a87"
|
||||
},
|
||||
{
|
||||
"id": "44fd76ce5f864cc2aef99c75cfd4904e"
|
||||
},
|
||||
{
|
||||
"id": "95e54b962ce1420d82c716ff428d84fe"
|
||||
},
|
||||
{
|
||||
"id": "8e22ba3b6fc34886a86d60dd1a1db025"
|
||||
},
|
||||
{
|
||||
"id": "162917ea12b24d0e874540feecf9b445"
|
||||
},
|
||||
{
|
||||
"id": "c8e87f5da41c47c7a3116bd1ed0cc34d"
|
||||
},
|
||||
{
|
||||
"id": "a3458bd73564491585df515468475a66"
|
||||
},
|
||||
{
|
||||
"id": "e27a4c1fb25c48809feb3cc438b5eb3c"
|
||||
},
|
||||
{
|
||||
"id": "f36338c39e2846959491ea48cbce07f6"
|
||||
},
|
||||
{
|
||||
"id": "eae01f064523415c95e57ff1e8dadc43"
|
||||
},
|
||||
{
|
||||
"id": "8b845d50f998467a898367107377c64b"
|
||||
},
|
||||
{
|
||||
"id": "a50ae9e7cb6a4f1e8dad07a9bbace810"
|
||||
},
|
||||
{
|
||||
"id": "5c2009e4f1384b27b4b4fe9422f048ed"
|
||||
},
|
||||
{
|
||||
"id": "0baaa0fe4fde4bae99bc6d2be230d525"
|
||||
},
|
||||
{
|
||||
"id": "d2563a0ca702457497995a6959ff1c61"
|
||||
},
|
||||
{
|
||||
"id": "b07871d2991d47e899cfa68a91f16b52"
|
||||
},
|
||||
{
|
||||
"id": "b745738e5b3c482aa2ae94ad5688246b"
|
||||
},
|
||||
{
|
||||
"id": "d66f1f0158054f638ff1b8acf3e18a8a"
|
||||
},
|
||||
{
|
||||
"id": "ede0705d606d4435a300e06beab2322f"
|
||||
},
|
||||
{
|
||||
"id": "e9d415f928644b59b5ed19b7011f627d"
|
||||
},
|
||||
{
|
||||
"id": "1a78a8cf476c4a0dbf551558da1d879b"
|
||||
},
|
||||
{
|
||||
"id": "ea7c66d5dae241eda155763541749cd1"
|
||||
},
|
||||
{
|
||||
"id": "78ae271549144680a42139693d1117e9"
|
||||
},
|
||||
{
|
||||
"id": "7eb9a69a23b8469b9f20f1915abff3be"
|
||||
},
|
||||
{
|
||||
"id": "db73ca2786684b9e92deb1fcc796effd"
|
||||
},
|
||||
{
|
||||
"id": "a876fb1accf64f4eb1b20b4a0ee089db"
|
||||
},
|
||||
{
|
||||
"id": "71d6dabd553c471b98debe941341a4c0"
|
||||
},
|
||||
{
|
||||
"id": "1c6add1cbd464f34b6e90485780f1c3e"
|
||||
},
|
||||
{
|
||||
"id": "5e9b0b44825e44d89ba0501c3b819685"
|
||||
},
|
||||
{
|
||||
"id": "4cfc841cb81e4c90822cfb7c0ec9f86e"
|
||||
},
|
||||
{
|
||||
"id": "2933df89dd6146c791eac1a85f0d02c8"
|
||||
},
|
||||
{
|
||||
"id": "5af06dca120a46889964109e94fff0a0"
|
||||
},
|
||||
{
|
||||
"id": "77970683cb6444388e5cfdd743784db6"
|
||||
},
|
||||
{
|
||||
"id": "3e40d5d91615427d976a56932be3c955"
|
||||
},
|
||||
{
|
||||
"id": "70bc65e0c17041729a4eabe86ff36d53"
|
||||
},
|
||||
{
|
||||
"id": "b913e55670474b69a70736d314822155"
|
||||
},
|
||||
{
|
||||
"id": "ada9cbe2dd8e48deb55171645e47a24a"
|
||||
},
|
||||
{
|
||||
"id": "fba813b8837249cbb39a1996dc657ef0"
|
||||
},
|
||||
{
|
||||
"id": "f7ecc32a212e4c3b8471ce26c32f3135"
|
||||
},
|
||||
{
|
||||
"id": "015641bf588b43aebba1aee07a8afde0"
|
||||
},
|
||||
{
|
||||
"id": "bcecb67a14f34fc6896bc5d65c58405a"
|
||||
}
|
||||
]
|
||||
@@ -1,69 +0,0 @@
|
||||
# Contributing to SkillOpt
|
||||
|
||||
Thank you for your interest in contributing to SkillOpt! This guide covers how to get started.
|
||||
|
||||
## Development Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/microsoft/SkillOpt.git
|
||||
cd SkillOpt
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
## Ways to Contribute
|
||||
|
||||
### 🐛 Bug Reports
|
||||
|
||||
Open an issue with:
|
||||
- Steps to reproduce
|
||||
- Expected vs actual behavior
|
||||
- Config file used (sanitize API keys)
|
||||
- Python version and OS
|
||||
|
||||
### 🔧 New Benchmark
|
||||
|
||||
See [Add a New Benchmark](guide/new-benchmark.md) for the implementation guide.
|
||||
|
||||
**Checklist:**
|
||||
- [ ] Data loader in `skillopt/envs/<benchmark>/loader.py`
|
||||
- [ ] Environment adapter in `skillopt/envs/<benchmark>/env.py`
|
||||
- [ ] Config file in `configs/<benchmark>/default.yaml`
|
||||
- [ ] Registration in `skillopt/envs/__init__.py`
|
||||
- [ ] Documentation page in `docs/`
|
||||
|
||||
### 🤖 New Model Backend
|
||||
|
||||
See [Add a New Model Backend](guide/new-backend.md) for the implementation guide.
|
||||
|
||||
**Checklist:**
|
||||
- [ ] Backend in `skillopt/model/<backend>.py`
|
||||
- [ ] Registration in `skillopt/model/__init__.py`
|
||||
- [ ] API key entry in `.env.example`
|
||||
- [ ] Documentation update
|
||||
|
||||
### 📝 Documentation
|
||||
|
||||
Documentation is built with MkDocs Material:
|
||||
|
||||
```bash
|
||||
pip install -e ".[docs]"
|
||||
mkdocs serve # Preview at http://localhost:8000
|
||||
```
|
||||
|
||||
## Code Style
|
||||
|
||||
- Follow existing patterns in the codebase
|
||||
- Use type hints for function signatures
|
||||
- Keep docstrings concise
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch: `git checkout -b feature/my-benchmark`
|
||||
3. Make your changes
|
||||
4. Test with an existing benchmark config
|
||||
5. Submit a PR with a clear description
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the MIT License.
|
||||
@@ -1,109 +0,0 @@
|
||||
# Configuration Guide
|
||||
|
||||
SkillOpt uses YAML configuration files with a hierarchical override system.
|
||||
|
||||
## Config Structure
|
||||
|
||||
```
|
||||
configs/
|
||||
├── _base_/
|
||||
│ └── default.yaml # Global defaults
|
||||
├── searchqa/
|
||||
│ └── default.yaml # SearchQA overrides
|
||||
├── docvqa/
|
||||
│ └── default.yaml # DocVQA overrides
|
||||
└── alfworld/
|
||||
└── default.yaml # ALFWorld overrides
|
||||
```
|
||||
|
||||
Benchmark configs inherit from `_base_/default.yaml` and override specific values.
|
||||
|
||||
## Key Parameters
|
||||
|
||||
### Model
|
||||
|
||||
```yaml
|
||||
model:
|
||||
backend: azure_openai # azure_openai | openai_chat | claude_code_exec | qwen
|
||||
optimizer: gpt-5.5 # Optimizer model (for reflection)
|
||||
target: gpt-5.5 # Target model (for rollout)
|
||||
```
|
||||
|
||||
### Training
|
||||
|
||||
```yaml
|
||||
train:
|
||||
num_epochs: 4 # Number of training epochs
|
||||
batch_size: 40 # Tasks per step (batch size)
|
||||
accumulation: 1 # Gradient accumulation
|
||||
seed: 42
|
||||
```
|
||||
|
||||
### Gradient (Reflection)
|
||||
|
||||
```yaml
|
||||
gradient:
|
||||
minibatch_size: 8 # Reflect minibatch size
|
||||
analyst_workers: 16 # Parallel reflection workers
|
||||
max_analyst_rounds: 3 # Max rounds of analyst reflection
|
||||
failure_only: false # Only reflect on failures
|
||||
```
|
||||
|
||||
### Optimizer
|
||||
|
||||
```yaml
|
||||
optimizer:
|
||||
learning_rate: 4 # Max edits per step (edit budget)
|
||||
min_learning_rate: 2 # Min edits for decay schedulers
|
||||
lr_scheduler: cosine # constant | linear | cosine | autonomous
|
||||
use_slow_update: true # Momentum-like blending at epoch boundary
|
||||
slow_update_samples: 20 # Samples for slow update evaluation
|
||||
use_meta_skill: true # Cross-epoch strategy memory
|
||||
```
|
||||
|
||||
### Evaluation
|
||||
|
||||
```yaml
|
||||
evaluation:
|
||||
use_gate: true # Validation gating (accept/reject updates)
|
||||
eval_test: true # Run test evaluation after training
|
||||
```
|
||||
|
||||
### Environment (Data)
|
||||
|
||||
```yaml
|
||||
env:
|
||||
name: searchqa # Benchmark name
|
||||
split_mode: ratio # ratio | split_dir
|
||||
split_ratio: "2:1:7" # train:val:test ratio
|
||||
data_path: "" # Path to dataset
|
||||
exec_timeout: 120 # Per-task timeout (seconds)
|
||||
```
|
||||
|
||||
## CLI Overrides
|
||||
|
||||
Override any config value from the command line:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
optimizer.learning_rate=16 \
|
||||
optimizer.lr_scheduler=linear \
|
||||
gradient.analyst_workers=8
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Model credentials are loaded from environment variables:
|
||||
|
||||
| Variable | Backend | Description |
|
||||
|---|---|---|
|
||||
| `AZURE_OPENAI_ENDPOINT` | azure_openai | Azure resource endpoint |
|
||||
| `AZURE_OPENAI_API_KEY` | azure_openai | Azure API key |
|
||||
| `OPENAI_API_KEY` | openai | OpenAI API key |
|
||||
| `ANTHROPIC_API_KEY` | claude | Anthropic API key |
|
||||
| `QWEN_API_BASE` | qwen | Local Qwen vLLM endpoint |
|
||||
|
||||
## Full Reference
|
||||
|
||||
See [Configuration Reference](../reference/config.md) for the complete parameter list.
|
||||
@@ -1,51 +0,0 @@
|
||||
# Deep Learning ↔ SkillOpt Analogy
|
||||
|
||||
SkillOpt is designed around a core insight: **optimizing natural-language prompts follows the same structure as training neural networks**. This page maps every DL concept to its SkillOpt counterpart.
|
||||
|
||||
## Complete Mapping
|
||||
|
||||
| Deep Learning | SkillOpt | Description |
|
||||
|---|---|---|
|
||||
| **Model weights** | Skill document (Markdown) | The thing being optimized |
|
||||
| **Forward pass** | Rollout | Target executes tasks using current skill |
|
||||
| **Loss function** | Task evaluator | Scores task execution quality |
|
||||
| **Backpropagation** | Reflect | Optimizer analyzes failures → edit patches |
|
||||
| **Gradients** | Edit patches | Proposed changes to the skill |
|
||||
| **Gradient aggregation** | Patch aggregation | Merge similar edits |
|
||||
| **Gradient clipping** | Edit selection | Cap max edits per step |
|
||||
| **Learning rate** | `learning_rate` | Max number of edits applied per step |
|
||||
| **LR scheduler** | `lr_scheduler` | Decay schedule: cosine, linear, constant |
|
||||
| **SGD step** | Skill update | Apply selected patches to document |
|
||||
| **Validation set** | Selection split | Gate checks improvement before accepting |
|
||||
| **Early stopping** | Gate patience | Reject updates that don't improve |
|
||||
| **Training step** | Step | One rollout → reflect → update cycle |
|
||||
| **Epoch** | Epoch | Full pass with slow update + meta memory |
|
||||
| **Momentum** | Slow update | Longitudinal comparison at epoch boundary |
|
||||
| **Meta-learning** | Meta skill | Cross-epoch optimizer strategy memory |
|
||||
| **Batch size** | `batch_size` | Tasks sampled per rollout |
|
||||
| **Data parallelism** | `analyst_workers` | Parallel reflection workers |
|
||||
| **Training set** | Train split | Items used for rollout |
|
||||
| **Test set** | Test split | Held-out final evaluation |
|
||||
| **Warm-up** | (implicit) | High LR early steps explore broadly |
|
||||
| **Checkpointing** | Skill snapshots | Saved after each accepted step |
|
||||
| **Transfer learning** | Seed skill / cross-benchmark init | Start from pre-trained skill |
|
||||
|
||||
## Why This Analogy Matters
|
||||
|
||||
1. **Familiar mental model**: ML practitioners immediately understand how to tune SkillOpt
|
||||
2. **Principled hyperparameter search**: Grid search over `learning_rate` × `lr_scheduler` works just like in DL
|
||||
3. **Proven mechanisms**: Gating ≈ validation-based selection, patience ≈ early stopping, slow update ≈ momentum — all with strong theoretical motivation
|
||||
|
||||
## Hyperparameter Transfer Rules
|
||||
|
||||
From our experiments, these DL intuitions transfer well:
|
||||
|
||||
!!! success "What transfers"
|
||||
- **Cosine schedule > constant** — same as in DL, cosine annealing helps convergence
|
||||
- **Moderate LR (4-16) > very high/low** — too few edits = slow learning, too many = noisy
|
||||
- **Slow update helps** — longitudinal comparison prevents catastrophic forgetting across epochs
|
||||
- **Meta skill memory improves reflection** — optimizer benefits from cross-epoch strategy notes
|
||||
|
||||
!!! warning "What doesn't transfer"
|
||||
- **Batch size ≠ better** — larger rollout batches have diminishing returns due to API costs
|
||||
- **More epochs ≠ better** — skills converge faster than neural networks (2-4 epochs usually enough)
|
||||
@@ -1,110 +0,0 @@
|
||||
# Your First Experiment
|
||||
|
||||
This guide walks through running a complete SkillOpt training on SearchQA.
|
||||
|
||||
## 1. Choose a Benchmark
|
||||
|
||||
SkillOpt includes ready-to-use configs for several benchmarks:
|
||||
|
||||
| Benchmark | Difficulty | Typical Runtime |
|
||||
|---|---|---|
|
||||
| SearchQA | ⭐ Easy | ~30 min |
|
||||
| DocVQA | ⭐⭐ Medium | ~2 hours |
|
||||
| ALFWorld | ⭐⭐⭐ Hard | ~3 hours |
|
||||
|
||||
We'll use **SearchQA** as it's the fastest to complete.
|
||||
|
||||
## 2. Configure
|
||||
|
||||
Review the config file:
|
||||
|
||||
```bash
|
||||
cat configs/searchqa/default.yaml
|
||||
```
|
||||
|
||||
Key parameters (deep learning analogy in parentheses):
|
||||
|
||||
```yaml
|
||||
train:
|
||||
num_epochs: 4 # (epochs)
|
||||
batch_size: 40 # (batch size)
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4 # (max edits per step)
|
||||
lr_scheduler: cosine # (learning rate schedule)
|
||||
use_slow_update: true # (momentum at epoch boundary)
|
||||
use_meta_skill: true # (cross-epoch optimizer memory)
|
||||
|
||||
gradient:
|
||||
analyst_workers: 16 # (parallel reflection workers)
|
||||
|
||||
evaluation:
|
||||
use_gate: true # (validation gating)
|
||||
```
|
||||
|
||||
## 3. Train
|
||||
|
||||
```bash
|
||||
python scripts/train.py --config configs/searchqa/default.yaml
|
||||
```
|
||||
|
||||
You'll see output like:
|
||||
|
||||
```
|
||||
[Step 1/8] Rollout: 20 items, 4 workers...
|
||||
[Step 1/8] Score: 0.65 → Reflect...
|
||||
[Step 1/8] 6 edit patches generated
|
||||
[Step 1/8] Selected 4 edits (lr=8, cosine → 7.7)
|
||||
[Step 1/8] Gate: val score 0.68 > 0.65 ✓ ACCEPT
|
||||
[Step 2/8] ...
|
||||
```
|
||||
|
||||
## 4. Monitor
|
||||
|
||||
Training outputs are saved to `outputs/<benchmark>/<run_id>/`:
|
||||
|
||||
```
|
||||
outputs/searchqa/2024-01-15_10-30-00/
|
||||
├── steps/
|
||||
│ ├── step_0001/
|
||||
│ │ ├── candidate_skill.md
|
||||
│ │ ├── step_record.json
|
||||
│ │ └── trajectory_digest.json
|
||||
│ └── step_0002/
|
||||
├── slow_update/
|
||||
│ └── epoch_02/
|
||||
├── meta_skill/
|
||||
│ └── epoch_02/
|
||||
├── skills/
|
||||
│ └── step_0001.md
|
||||
├── best_skill.md
|
||||
├── history.json
|
||||
└── config.yaml
|
||||
```
|
||||
|
||||
## 5. Evaluate
|
||||
|
||||
Evaluate the best skill on the test split:
|
||||
|
||||
```bash
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill outputs/searchqa/<run_id>/skills/best_skill.md
|
||||
```
|
||||
|
||||
## WebUI
|
||||
|
||||
Prefer a graphical interface? Launch the WebUI:
|
||||
|
||||
```bash
|
||||
pip install -e ".[webui]"
|
||||
python -m skillopt_webui.app
|
||||
```
|
||||
|
||||
Then open `http://localhost:7860` in your browser to configure parameters and launch training.
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Understand the training loop](training-loop.md)
|
||||
- [Configuration reference](../reference/config.md)
|
||||
- [Add a new benchmark](new-benchmark.md)
|
||||
@@ -1,89 +0,0 @@
|
||||
# Installation
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python ≥ 3.10
|
||||
- At least one model API key (Azure OpenAI, OpenAI, Anthropic, or local Qwen)
|
||||
|
||||
## Quick Install
|
||||
|
||||
```bash
|
||||
git clone https://github.com/microsoft/SkillOpt.git
|
||||
cd SkillOpt
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
## Optional Dependencies
|
||||
|
||||
Install extras for specific benchmarks or backends:
|
||||
|
||||
=== "ALFWorld"
|
||||
|
||||
```bash
|
||||
pip install -e ".[alfworld]"
|
||||
```
|
||||
|
||||
=== "Claude Backend"
|
||||
|
||||
```bash
|
||||
pip install -e ".[claude]"
|
||||
```
|
||||
|
||||
=== "Qwen (Local)"
|
||||
|
||||
```bash
|
||||
pip install -e ".[qwen]"
|
||||
```
|
||||
|
||||
=== "WebUI"
|
||||
|
||||
```bash
|
||||
pip install -e ".[webui]"
|
||||
```
|
||||
|
||||
=== "Development"
|
||||
|
||||
```bash
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
=== "All"
|
||||
|
||||
```bash
|
||||
pip install -e ".[alfworld,claude,qwen,webui,dev]"
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Copy the example `.env` file and fill in your credentials:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Edit `.env` with your API keys:
|
||||
|
||||
```ini
|
||||
# Azure OpenAI (default backend)
|
||||
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
||||
AZURE_OPENAI_API_KEY=your-key
|
||||
|
||||
# Or use OpenAI directly
|
||||
OPENAI_API_KEY=sk-...
|
||||
|
||||
# Or Anthropic Claude
|
||||
ANTHROPIC_API_KEY=sk-ant-...
|
||||
```
|
||||
|
||||
!!! tip
|
||||
You only need credentials for the backend you plan to use. Azure OpenAI is the default.
|
||||
|
||||
## Verify Installation
|
||||
|
||||
```bash
|
||||
python -c "import skillopt; print('SkillOpt ready!')"
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
→ [Run your first experiment](first-experiment.md)
|
||||
@@ -1,143 +0,0 @@
|
||||
# Local Environment Smoke Tests
|
||||
|
||||
This guide describes a lightweight pattern for testing a custom SkillOpt environment before connecting it to expensive model calls or a full benchmark dataset.
|
||||
|
||||
The goal is to validate the training loop plumbing first:
|
||||
|
||||
- config loading
|
||||
- adapter construction
|
||||
- dataloader splits
|
||||
- rollout output shape
|
||||
- reflection patch shape
|
||||
- merge/rank/update control flow
|
||||
- artifact creation under `out_root`
|
||||
|
||||
Once those are stable, you can switch the same environment to real model calls and larger evaluation splits.
|
||||
|
||||
## 1. Add a tiny fixture split
|
||||
|
||||
Start with a handful of deterministic examples that cover the expected pass/fail cases for your environment. Keep them small enough that a single training step can run locally.
|
||||
|
||||
A minimal fixture item usually needs:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "example-1",
|
||||
"split": "train",
|
||||
"question": "...",
|
||||
"expected": "..."
|
||||
}
|
||||
```
|
||||
|
||||
Use the split names your adapter maps to SkillOpt phases:
|
||||
|
||||
- `train` for optimization rollouts
|
||||
- `val` or `valid_seen` for selection/gating
|
||||
- `test` or `valid_unseen` for final evaluation
|
||||
|
||||
## 2. Support an offline mock mode
|
||||
|
||||
Add a configuration flag such as `mock: true` to your adapter. In mock mode, `rollout()` should return deterministic responses without calling external model APIs.
|
||||
|
||||
This lets you verify the SkillOpt loop with a fast command such as:
|
||||
|
||||
```bash
|
||||
python scripts/train.py \
|
||||
--config configs/myenv/tiny_mock.yaml
|
||||
```
|
||||
|
||||
Mock mode should still write the same artifacts as a real run, for example:
|
||||
|
||||
- `responses.json`
|
||||
- `rollout_results.json`
|
||||
- `ranked_edits.json`
|
||||
- `candidate_skill.md`
|
||||
- `summary.json`
|
||||
|
||||
## 3. Keep the smoke config tiny
|
||||
|
||||
A CI-friendly smoke config should run a single small step:
|
||||
|
||||
```yaml
|
||||
train:
|
||||
num_epochs: 1
|
||||
train_size: 3
|
||||
batch_size: 3
|
||||
|
||||
gradient:
|
||||
minibatch_size: 1
|
||||
merge_batch_size: 2
|
||||
analyst_workers: 1
|
||||
max_analyst_rounds: 1
|
||||
|
||||
optimizer:
|
||||
learning_rate: 1
|
||||
min_learning_rate: 1
|
||||
lr_scheduler: constant
|
||||
skill_update_mode: patch
|
||||
use_slow_update: false
|
||||
|
||||
evaluation:
|
||||
use_gate: true
|
||||
sel_env_num: 2
|
||||
test_env_num: 2
|
||||
eval_test: false
|
||||
|
||||
env:
|
||||
name: myenv
|
||||
out_root: outputs/myenv_tiny_mock
|
||||
mock: true
|
||||
```
|
||||
|
||||
Prefer a mock config that runs without credentials. That makes it useful for contributors and CI.
|
||||
|
||||
## 4. Validate optimizer JSON before returning it
|
||||
|
||||
If your environment or extension asks an LLM to merge or rank skill edits, validate the returned JSON before passing it back into SkillOpt. This avoids silent fallbacks from empty, malformed, or out-of-range responses.
|
||||
|
||||
Useful checks for edit payloads:
|
||||
|
||||
- response is a JSON object
|
||||
- `edits` is a non-empty list
|
||||
- every edit is an object
|
||||
- every edit has an allowed operation
|
||||
- required fields such as `content` or `target` are present for that operation
|
||||
|
||||
Useful checks for ranking payloads:
|
||||
|
||||
- `selected_indices` exists
|
||||
- indices are integers
|
||||
- indices are unique
|
||||
- indices are within the candidate edit range
|
||||
- selected count does not exceed the edit budget
|
||||
|
||||
On failure, retry with a compact prompt that includes the schema error. If retries fail, raise an explicit error instead of silently accepting malformed output.
|
||||
|
||||
## 5. Run progressively stronger checks
|
||||
|
||||
A good development sequence is:
|
||||
|
||||
```bash
|
||||
python -m py_compile scripts/train.py skillopt/envs/myenv/adapter.py
|
||||
python scripts/train.py --config configs/myenv/tiny_mock.yaml
|
||||
python scripts/train.py --config configs/myenv/tiny.yaml
|
||||
```
|
||||
|
||||
For the real tiny run, verify that:
|
||||
|
||||
- the run completes
|
||||
- `summary.json` is written
|
||||
- `ranked_edits.json` contains the expected ranking metadata
|
||||
- any optimizer bridge log marks the response schema as valid
|
||||
- no generated files are written outside `out_root`
|
||||
|
||||
## 6. Keep custom environments isolated
|
||||
|
||||
When adding a custom environment to the registry, avoid side effects for existing benchmarks:
|
||||
|
||||
- lazy-import optional dependencies
|
||||
- install environment-specific hooks only when `cfg["env"]` matches your environment
|
||||
- keep mock behavior behind an explicit config flag
|
||||
- write generated artifacts only under `out_root`
|
||||
|
||||
This makes it easier to review and test a custom integration without affecting the built-in benchmarks.
|
||||
@@ -1,130 +0,0 @@
|
||||
# Add a New Model Backend
|
||||
|
||||
SkillOpt supports multiple LLM backends. This guide shows how to add your own.
|
||||
|
||||
## Backend Architecture
|
||||
|
||||
```
|
||||
skillopt/model/
|
||||
├── base.py # Abstract base class
|
||||
├── azure_openai.py # Azure OpenAI backend
|
||||
├── openai_model.py # Direct OpenAI backend
|
||||
├── claude.py # Anthropic Claude backend
|
||||
├── qwen.py # Local Qwen (vLLM) backend
|
||||
└── your_backend.py # Your new backend
|
||||
```
|
||||
|
||||
## Step 1: Create the Backend
|
||||
|
||||
Create `skillopt/model/your_backend.py`:
|
||||
|
||||
```python
|
||||
from skillopt.model.base import ModelBackend, ModelResponse
|
||||
|
||||
class YourBackend(ModelBackend):
|
||||
"""Your custom model backend."""
|
||||
|
||||
def __init__(self, cfg: dict):
|
||||
super().__init__(cfg)
|
||||
self.model_name = cfg.get('model_name', 'your-default-model')
|
||||
self.api_key = os.environ.get('YOUR_API_KEY', '')
|
||||
self.client = self._init_client()
|
||||
|
||||
def _init_client(self):
|
||||
"""Initialize API client."""
|
||||
# TODO: Set up your API client
|
||||
pass
|
||||
|
||||
async def generate(
|
||||
self,
|
||||
messages: list[dict],
|
||||
temperature: float = 0.7,
|
||||
max_tokens: int = 4096,
|
||||
**kwargs
|
||||
) -> ModelResponse:
|
||||
"""
|
||||
Generate a completion.
|
||||
|
||||
Args:
|
||||
messages: Chat messages [{"role": "...", "content": "..."}]
|
||||
temperature: Sampling temperature
|
||||
max_tokens: Maximum tokens in response
|
||||
|
||||
Returns:
|
||||
ModelResponse with content, usage, and metadata
|
||||
"""
|
||||
response = await self.client.chat(
|
||||
model=self.model_name,
|
||||
messages=messages,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
|
||||
return ModelResponse(
|
||||
content=response.text,
|
||||
usage={
|
||||
'prompt_tokens': response.usage.input,
|
||||
'completion_tokens': response.usage.output,
|
||||
},
|
||||
model=self.model_name,
|
||||
)
|
||||
|
||||
async def generate_with_tools(
|
||||
self,
|
||||
messages: list[dict],
|
||||
tools: list[dict],
|
||||
**kwargs
|
||||
) -> ModelResponse:
|
||||
"""Generate with tool/function calling support."""
|
||||
# Optional: implement if your model supports tool use
|
||||
raise NotImplementedError("Tool use not supported")
|
||||
```
|
||||
|
||||
## Step 2: Register the Backend
|
||||
|
||||
Add to `skillopt/model/__init__.py`:
|
||||
|
||||
```python
|
||||
from .your_backend import YourBackend
|
||||
|
||||
BACKEND_REGISTRY = {
|
||||
# ... existing backends ...
|
||||
'your_backend': YourBackend,
|
||||
}
|
||||
```
|
||||
|
||||
## Step 3: Configure
|
||||
|
||||
Use your backend in any config:
|
||||
|
||||
```yaml
|
||||
model:
|
||||
backend: your_backend
|
||||
model_name: your-model-id
|
||||
temperature: 0.7
|
||||
max_tokens: 4096
|
||||
```
|
||||
|
||||
Set credentials via environment variable:
|
||||
|
||||
```bash
|
||||
export YOUR_API_KEY="your-key"
|
||||
```
|
||||
|
||||
## Required Interface
|
||||
|
||||
Your backend must implement these methods:
|
||||
|
||||
| Method | Required | Description |
|
||||
|---|---|---|
|
||||
| `generate()` | ✅ | Basic text generation |
|
||||
| `generate_with_tools()` | Optional | Tool/function calling |
|
||||
| `count_tokens()` | Optional | Token counting for context management |
|
||||
|
||||
## Tips
|
||||
|
||||
!!! tip
|
||||
- Test your backend with `python -c "from skillopt.model.your_backend import YourBackend"` first
|
||||
- Use `async` methods for all API calls — SkillOpt uses asyncio throughout
|
||||
- Implement retry logic with exponential backoff for production use
|
||||
- Add your API key to `.env.example` when submitting a PR
|
||||
@@ -1,181 +0,0 @@
|
||||
# Add a New Benchmark
|
||||
|
||||
Extend SkillOpt with your own benchmark in ~100 lines of code.
|
||||
|
||||
## Overview
|
||||
|
||||
To add a benchmark, you need:
|
||||
|
||||
1. **Data Loader** — Loads and splits your dataset
|
||||
2. **Environment Adapter** — Executes tasks and returns scores
|
||||
3. **Config** — YAML configuration file
|
||||
|
||||
## Step 1: Create the Benchmark Package
|
||||
|
||||
```bash
|
||||
mkdir -p skillopt/envs/my_benchmark
|
||||
touch skillopt/envs/my_benchmark/__init__.py
|
||||
```
|
||||
|
||||
## Step 2: Implement the Data Loader
|
||||
|
||||
Create `skillopt/envs/my_benchmark/loader.py`:
|
||||
|
||||
```python
|
||||
from skillopt.data.base import DataLoader, DataItem
|
||||
|
||||
class MyBenchmarkDataLoader(DataLoader):
|
||||
"""Load and split your benchmark data."""
|
||||
|
||||
def __init__(self, data_dir: str, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.data_dir = data_dir
|
||||
|
||||
def setup(self, cfg: dict):
|
||||
"""Initialize splits based on config."""
|
||||
self.split_mode = cfg.get('split_mode', 'ratio')
|
||||
# Load your data here
|
||||
self.items = self._load_items()
|
||||
self._create_splits(cfg)
|
||||
|
||||
def _load_items(self) -> list[DataItem]:
|
||||
"""Load raw data into DataItem objects."""
|
||||
items = []
|
||||
# TODO: Load your data
|
||||
for entry in your_data:
|
||||
items.append(DataItem(
|
||||
id=entry['id'],
|
||||
input=entry['question'],
|
||||
ground_truth=entry['answer'],
|
||||
metadata=entry.get('metadata', {})
|
||||
))
|
||||
return items
|
||||
|
||||
def get_split_items(self, split: str) -> list[DataItem]:
|
||||
"""Return items for a given split (train/valid/test)."""
|
||||
return self.splits[split]
|
||||
```
|
||||
|
||||
## Step 3: Implement the Environment Adapter
|
||||
|
||||
Create `skillopt/envs/my_benchmark/env.py`:
|
||||
|
||||
```python
|
||||
from skillopt.envs.base import EnvAdapter, TaskResult
|
||||
|
||||
class MyBenchmarkEnv(EnvAdapter):
|
||||
"""Execute tasks and evaluate results."""
|
||||
|
||||
def __init__(self, cfg: dict):
|
||||
super().__init__(cfg)
|
||||
|
||||
async def execute(self, item: DataItem, skill: str, model) -> TaskResult:
|
||||
"""
|
||||
Execute a single task.
|
||||
|
||||
Args:
|
||||
item: The data item to process
|
||||
skill: Current skill document content
|
||||
model: The target model instance
|
||||
|
||||
Returns:
|
||||
TaskResult with prediction, score, and trajectory
|
||||
"""
|
||||
# Build prompt with skill document
|
||||
prompt = self.build_prompt(item, skill)
|
||||
|
||||
# Get model response
|
||||
response = await model.generate(prompt)
|
||||
|
||||
# Extract prediction
|
||||
prediction = self.parse_response(response)
|
||||
|
||||
# Score against ground truth
|
||||
score = self.evaluate(prediction, item.ground_truth)
|
||||
|
||||
return TaskResult(
|
||||
item_id=item.id,
|
||||
prediction=prediction,
|
||||
score=score,
|
||||
trajectory=[
|
||||
{"role": "system", "content": skill},
|
||||
{"role": "user", "content": item.input},
|
||||
{"role": "assistant", "content": response}
|
||||
]
|
||||
)
|
||||
|
||||
def evaluate(self, prediction: str, ground_truth: str) -> float:
|
||||
"""
|
||||
Score a prediction against ground truth.
|
||||
|
||||
Returns:
|
||||
Float between 0.0 and 1.0
|
||||
"""
|
||||
# TODO: Implement your scoring logic
|
||||
# Examples: exact match, F1, ANLS, etc.
|
||||
return float(prediction.strip() == ground_truth.strip())
|
||||
|
||||
def build_prompt(self, item, skill: str) -> str:
|
||||
"""Combine skill document with task input."""
|
||||
return f"{skill}\n\n---\n\nQuestion: {item.input}"
|
||||
|
||||
def parse_response(self, response: str) -> str:
|
||||
"""Extract the answer from model response."""
|
||||
return response.strip()
|
||||
```
|
||||
|
||||
## Step 4: Register the Benchmark
|
||||
|
||||
Add to `skillopt/envs/__init__.py`:
|
||||
|
||||
```python
|
||||
from .my_benchmark.env import MyBenchmarkEnv
|
||||
from .my_benchmark.loader import MyBenchmarkDataLoader
|
||||
|
||||
BENCHMARK_REGISTRY = {
|
||||
# ... existing benchmarks ...
|
||||
'my_benchmark': {
|
||||
'env': MyBenchmarkEnv,
|
||||
'loader': MyBenchmarkDataLoader,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
## Step 5: Create Config
|
||||
|
||||
Create `configs/my_benchmark/default.yaml`:
|
||||
|
||||
```yaml
|
||||
_base_: ['../_base_/default.yaml']
|
||||
|
||||
env:
|
||||
name: my_benchmark
|
||||
data_path: data/my_benchmark
|
||||
split_mode: ratio
|
||||
split_ratio: "2:1:7"
|
||||
|
||||
train:
|
||||
num_epochs: 4
|
||||
batch_size: 40
|
||||
|
||||
optimizer:
|
||||
learning_rate: 4
|
||||
lr_scheduler: cosine
|
||||
use_slow_update: true
|
||||
use_meta_skill: true
|
||||
|
||||
gradient:
|
||||
analyst_workers: 16
|
||||
```
|
||||
|
||||
## Step 6: Run
|
||||
|
||||
```bash
|
||||
python scripts/train.py --config configs/my_benchmark/default.yaml
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
!!! tip
|
||||
- Use a small `batch_size` (10-20) for initial testing
|
||||
- The `evaluate()` method is critical — a noisy metric will confuse the optimizer
|
||||
@@ -1,78 +0,0 @@
|
||||
# Skill Document
|
||||
|
||||
A **skill document** is a Markdown file that serves as the "prompt weights" of your agent. SkillOpt trains this document through iterative optimization.
|
||||
|
||||
## What is a Skill Document?
|
||||
|
||||
A skill document is a structured set of instructions that tells a language model **how** to approach a specific type of task. It's analogous to learned weights in a neural network — encoding task-specific knowledge in natural language rather than floating-point parameters.
|
||||
|
||||
## Structure
|
||||
|
||||
A typical skill document contains:
|
||||
|
||||
```markdown
|
||||
# Task Strategy
|
||||
|
||||
## General Approach
|
||||
- Break complex problems into sub-steps
|
||||
- Always verify intermediate results
|
||||
|
||||
## Common Patterns
|
||||
- When you see X, try approach Y
|
||||
- Avoid Z because it leads to errors
|
||||
|
||||
## Edge Cases
|
||||
- If the input contains A, handle it specially by...
|
||||
- Watch out for B — it requires C
|
||||
|
||||
## Output Format
|
||||
- Always include reasoning before the answer
|
||||
- Format numbers with proper units
|
||||
```
|
||||
|
||||
## How It Evolves
|
||||
|
||||
During training, the skill document is modified by **edit patches**:
|
||||
|
||||
1. **Additions**: New rules or strategies discovered from failed trajectories
|
||||
2. **Modifications**: Refining existing rules that are partially correct
|
||||
3. **Deletions**: Removing rules that consistently lead to errors
|
||||
|
||||
Each edit is validated through the **gate** mechanism before being permanently accepted.
|
||||
|
||||
## Initial Skill
|
||||
|
||||
You can start training with:
|
||||
|
||||
- **Empty skill**: The system learns everything from scratch
|
||||
- **Seed skill**: Provide initial instructions to bootstrap training
|
||||
- **Pre-trained skill**: Transfer a skill from a related benchmark
|
||||
|
||||
Configure the initial skill in your YAML:
|
||||
|
||||
```yaml
|
||||
train:
|
||||
init_skill: "path/to/initial_skill.md" # or omit for empty
|
||||
```
|
||||
|
||||
## Skill Quality Metrics
|
||||
|
||||
Track your skill's evolution through:
|
||||
|
||||
- **Validation score**: Primary metric on the selection split
|
||||
- **Test score**: Final metric on held-out test data
|
||||
- **Skill length**: Total tokens in the document
|
||||
- **Edit acceptance rate**: Fraction of proposed edits that pass gating
|
||||
|
||||
## Best Practices
|
||||
|
||||
!!! tip "Tips for better skills"
|
||||
1. **Start with a seed skill** (`env.skill_init`) if you have domain knowledge — it converges faster
|
||||
2. **Use cosine LR schedule** — aggressive early exploration + careful late refinement
|
||||
3. **Enable slow update** (`use_slow_update: true`) to prevent forgetting across epochs
|
||||
4. **Enable meta skill** (`use_meta_skill: true`) so the optimizer accumulates strategy memory
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Deep Learning Analogy](dl-analogy.md)
|
||||
- [Configuration Reference](../reference/config.md)
|
||||
@@ -1,92 +0,0 @@
|
||||
# The Training Loop
|
||||
|
||||
SkillOpt's core insight: **optimizing natural-language skill documents follows the same structure as training neural networks**.
|
||||
|
||||
## Overview
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ Training Loop │
|
||||
│ │
|
||||
│ for epoch in epochs: │
|
||||
│ for step in steps: │
|
||||
│ 1. Rollout — Target executes tasks │
|
||||
│ 2. Reflect — Optimizer analyzes trajectories │
|
||||
│ 3. Aggregate — Hierarchical merge of patches │
|
||||
│ 4. Select — Rank & clip edits (learning rate) │
|
||||
│ 5. Update — Apply patches to skill doc │
|
||||
│ 6. Gate — Validate & accept/reject │
|
||||
│ │
|
||||
│ Epoch Boundary: │
|
||||
│ • Slow Update (longitudinal comparison & guidance) │
|
||||
│ • Meta Skill (cross-epoch strategy memory) │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Stage Details
|
||||
|
||||
### 1. Rollout (Forward Pass)
|
||||
|
||||
The **target** model executes tasks using the current skill document as its prompt. Each task produces a trajectory and a score.
|
||||
|
||||
```python
|
||||
# Analogy: forward pass through the network
|
||||
predictions = model(input, skill_document)
|
||||
scores = evaluate(predictions, ground_truth)
|
||||
```
|
||||
|
||||
### 2. Reflect (Backward Pass)
|
||||
|
||||
The **optimizer** model analyzes failed trajectories and produces **edit patches** — structured suggestions for improving the skill document.
|
||||
|
||||
Two modes:
|
||||
|
||||
- **Shallow**: Analyze each trajectory independently
|
||||
- **Deep**: Cross-reference multiple failures to find systemic issues
|
||||
|
||||
```python
|
||||
# Analogy: computing gradients
|
||||
gradients = loss.backward() # → edit patches
|
||||
```
|
||||
|
||||
### 3. Aggregate
|
||||
|
||||
Semantically similar edit patches are merged to avoid redundant edits.
|
||||
|
||||
### 4. Select (Gradient Clipping)
|
||||
|
||||
Edits are ranked by relevance score. The `learning_rate` parameter caps how many edits are applied per step — just like gradient clipping prevents overshooting.
|
||||
|
||||
```python
|
||||
# Analogy: gradient clipping + optimizer step size
|
||||
selected = top_k(edits, k=learning_rate)
|
||||
```
|
||||
|
||||
The `lr_scheduler` adjusts this over training:
|
||||
|
||||
- **cosine**: Start aggressive, taper smoothly
|
||||
- **linear**: Linear decay
|
||||
- **constant**: Fixed rate
|
||||
|
||||
### 5. Update (Parameter Update)
|
||||
|
||||
Selected edits are applied to the skill document, producing a new version.
|
||||
|
||||
### 6. Gate (Validation)
|
||||
|
||||
The updated skill is evaluated on a **selection split** (analogous to a validation set). The update is only accepted if performance improves.
|
||||
|
||||
## Epoch Boundary Mechanisms
|
||||
|
||||
### Slow Update
|
||||
|
||||
At the end of each epoch (starting from epoch 2), the system performs a **longitudinal comparison**: it rolls out both the previous epoch's skill and the current skill on the same samples, categorizes items as improved/regressed/persistent_fail/stable_success, then generates high-level **guidance** that is injected into the skill document. This prevents catastrophic forgetting of earlier improvements.
|
||||
|
||||
### Meta Skill
|
||||
|
||||
A **meta-skill memory** accumulates high-level strategy notes across the entire training run. At the end of each epoch, the optimizer reflects on what changed between epochs and produces a compact memory that is provided as additional context during future reflection steps.
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Understand Skill Documents](skill-document.md)
|
||||
- [DL ↔ SkillOpt analogy table](dl-analogy.md)
|
||||
@@ -1,911 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SkillOpt — Documentation & Reproduction Guide</title>
|
||||
<meta name="description" content="Complete documentation and reproduction guide for SkillOpt: installation, data preparation, training, configuration reference, framework internals, and API reference.">
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 23 23'%3E%3Crect width='10' height='10' fill='%23F25022'/%3E%3Crect x='13' width='10' height='10' fill='%237FBA00'/%3E%3Crect y='13' width='10' height='10' fill='%2300A4EF'/%3E%3Crect x='13' y='13' width='10' height='10' fill='%23FFB900'/%3E%3C/svg%3E">
|
||||
<style>
|
||||
:root {
|
||||
--bg: #ffffff;
|
||||
--bg-soft: #f7f8fb;
|
||||
--sidebar-bg: #fbfcfe;
|
||||
--ink: #1f2733;
|
||||
--muted: #5b6675;
|
||||
--quiet: #8a94a3;
|
||||
--line: #e6e9ef;
|
||||
--line-strong: #d3d9e3;
|
||||
--brand: #4f46e5;
|
||||
--brand-soft: #eef0fe;
|
||||
--accent: #0ea5e9;
|
||||
--green: #16a34a;
|
||||
--amber: #d97706;
|
||||
--red: #dc2626;
|
||||
--code-bg: #0f172a;
|
||||
--code-ink: #e2e8f0;
|
||||
--inline-code-bg: #eef1f6;
|
||||
--inline-code-ink: #b3146b;
|
||||
--sidebar-w: 300px;
|
||||
--toc-w: 220px;
|
||||
--mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
|
||||
--sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html { scroll-behavior: smooth; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--sans);
|
||||
color: var(--ink);
|
||||
background: var(--bg);
|
||||
font-size: 15px;
|
||||
line-height: 1.65;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* ── Top bar ─────────────────────────────────────────── */
|
||||
header.topbar {
|
||||
position: sticky; top: 0; z-index: 40;
|
||||
height: 56px;
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
padding: 0 20px;
|
||||
background: rgba(255,255,255,0.92);
|
||||
backdrop-filter: blur(8px);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.topbar .logo { width: 22px; height: 22px; flex: none; }
|
||||
.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
|
||||
.topbar .brand span { color: var(--brand); }
|
||||
.topbar .tag { color: var(--quiet); font-size: 13px; border-left: 1px solid var(--line-strong); padding-left: 14px; }
|
||||
.topbar .spacer { flex: 1; }
|
||||
.topbar a.gh {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-size: 13px; font-weight: 600; color: var(--muted);
|
||||
text-decoration: none; padding: 6px 12px; border: 1px solid var(--line-strong);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.topbar a.gh:hover { color: var(--brand); border-color: var(--brand); }
|
||||
#menuBtn {
|
||||
display: none; background: none; border: 1px solid var(--line-strong);
|
||||
border-radius: 8px; width: 38px; height: 34px; cursor: pointer; font-size: 18px; color: var(--muted);
|
||||
}
|
||||
|
||||
/* ── Layout ──────────────────────────────────────────── */
|
||||
.layout { display: flex; align-items: flex-start; }
|
||||
|
||||
/* ── Sidebar (left nav) ──────────────────────────────── */
|
||||
nav.sidebar {
|
||||
position: sticky; top: 56px;
|
||||
width: var(--sidebar-w); flex: none;
|
||||
height: calc(100vh - 56px);
|
||||
overflow-y: auto;
|
||||
background: var(--sidebar-bg);
|
||||
border-right: 1px solid var(--line);
|
||||
padding: 22px 14px 60px 20px;
|
||||
}
|
||||
nav.sidebar .group { margin-bottom: 22px; }
|
||||
nav.sidebar .group > .glabel {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
font-size: 11.5px; font-weight: 700; text-transform: uppercase;
|
||||
letter-spacing: 0.07em; color: var(--quiet);
|
||||
margin: 0 0 8px 2px;
|
||||
}
|
||||
nav.sidebar .group > .glabel .num {
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
width: 18px; height: 18px; border-radius: 5px;
|
||||
background: var(--brand-soft); color: var(--brand);
|
||||
font-size: 11px; font-weight: 700;
|
||||
}
|
||||
nav.sidebar a {
|
||||
display: block; text-decoration: none;
|
||||
color: var(--muted); font-size: 13.5px;
|
||||
padding: 5px 10px; border-radius: 7px; margin: 1px 0;
|
||||
border-left: 2px solid transparent;
|
||||
}
|
||||
nav.sidebar a:hover { background: #eef1f6; color: var(--ink); }
|
||||
nav.sidebar a.active {
|
||||
color: var(--brand); background: var(--brand-soft);
|
||||
border-left-color: var(--brand); font-weight: 600;
|
||||
}
|
||||
|
||||
/* ── Content ─────────────────────────────────────────── */
|
||||
main.content {
|
||||
flex: 1; min-width: 0;
|
||||
padding: 38px 46px 120px;
|
||||
max-width: 900px;
|
||||
}
|
||||
main.content section { scroll-margin-top: 72px; }
|
||||
main h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 8px; }
|
||||
main h2 {
|
||||
font-size: 23px; letter-spacing: -0.015em; margin: 52px 0 14px;
|
||||
padding-bottom: 10px; border-bottom: 1px solid var(--line);
|
||||
}
|
||||
main section:first-of-type h2 { margin-top: 8px; }
|
||||
main h3 { font-size: 17.5px; margin: 30px 0 10px; letter-spacing: -0.01em; }
|
||||
main h4 { font-size: 15px; margin: 22px 0 8px; color: var(--ink); }
|
||||
main p { margin: 12px 0; color: #2c3645; }
|
||||
main ul, main ol { margin: 12px 0; padding-left: 22px; }
|
||||
main li { margin: 5px 0; }
|
||||
main a { color: var(--brand); text-decoration: none; }
|
||||
main a:hover { text-decoration: underline; }
|
||||
.lead { font-size: 16.5px; color: var(--muted); margin: 6px 0 4px; }
|
||||
.eyebrow { color: var(--brand); font-weight: 700; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; }
|
||||
|
||||
/* code */
|
||||
code {
|
||||
font-family: var(--mono); font-size: 0.86em;
|
||||
background: var(--inline-code-bg); color: var(--inline-code-ink);
|
||||
padding: 2px 6px; border-radius: 5px;
|
||||
}
|
||||
pre {
|
||||
background: var(--code-bg); color: var(--code-ink);
|
||||
border-radius: 12px; padding: 16px 18px; overflow-x: auto;
|
||||
font-family: var(--mono); font-size: 13px; line-height: 1.6;
|
||||
margin: 14px 0; border: 1px solid #1e293b;
|
||||
}
|
||||
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
|
||||
.tok-c { color: #7c8aa5; } /* comment */
|
||||
.tok-k { color: #c4b5fd; } /* keyword */
|
||||
.tok-s { color: #86efac; } /* string */
|
||||
.tok-f { color: #93c5fd; } /* flag/path */
|
||||
.tok-n { color: #fca5a5; } /* number/value */
|
||||
|
||||
/* tables */
|
||||
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; }
|
||||
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
|
||||
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
||||
thead th { background: var(--bg-soft); font-weight: 700; color: var(--ink); white-space: nowrap; }
|
||||
tbody tr:last-child td { border-bottom: none; }
|
||||
td code { white-space: nowrap; }
|
||||
td.def { color: var(--muted); font-family: var(--mono); font-size: 12px; }
|
||||
|
||||
/* callouts */
|
||||
.note { border-radius: 10px; padding: 12px 16px; margin: 16px 0; border: 1px solid; font-size: 14px; }
|
||||
.note p { margin: 4px 0; }
|
||||
.note .nh { font-weight: 700; display: block; margin-bottom: 2px; }
|
||||
.note.info { background: #eff6ff; border-color: #bfdbfe; }
|
||||
.note.info .nh { color: #1d4ed8; }
|
||||
.note.tip { background: #ecfdf5; border-color: #a7f3d0; }
|
||||
.note.tip .nh { color: #047857; }
|
||||
.note.warn { background: #fffbeb; border-color: #fde68a; }
|
||||
.note.warn .nh { color: #b45309; }
|
||||
|
||||
.pill { display:inline-block; font-size: 11px; font-weight:700; padding: 1px 8px; border-radius: 999px; vertical-align: middle; }
|
||||
.pill.def { background:#eef2ff; color:#4338ca; }
|
||||
.pill.opt { background:#f1f5f9; color:#475569; }
|
||||
|
||||
/* card grid */
|
||||
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap: 14px; margin: 18px 0; }
|
||||
.card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--bg-soft); }
|
||||
.card h4 { margin: 0 0 6px; font-size: 14.5px; }
|
||||
.card p { margin: 0; font-size: 13px; color: var(--muted); }
|
||||
|
||||
/* anchor link on hover */
|
||||
.anchor { color: var(--quiet); text-decoration: none; font-weight: 400; opacity: 0; margin-left: 8px; font-size: 0.8em; }
|
||||
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
|
||||
|
||||
/* ── Right TOC ───────────────────────────────────────── */
|
||||
aside.toc {
|
||||
position: sticky; top: 56px;
|
||||
width: var(--toc-w); flex: none;
|
||||
height: calc(100vh - 56px); overflow-y: auto;
|
||||
padding: 38px 18px; border-left: 1px solid var(--line);
|
||||
}
|
||||
aside.toc .tl { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--quiet); margin-bottom: 10px; }
|
||||
aside.toc a { display: block; color: var(--muted); text-decoration: none; font-size: 12.5px; padding: 4px 8px; border-left: 2px solid var(--line); line-height: 1.45; }
|
||||
aside.toc a:hover { color: var(--ink); }
|
||||
aside.toc a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
|
||||
|
||||
.footer-note { margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--quiet); font-size: 13px; }
|
||||
|
||||
/* responsive */
|
||||
@media (max-width: 1180px) { aside.toc { display: none; } }
|
||||
@media (max-width: 860px) {
|
||||
#menuBtn { display: inline-block; }
|
||||
nav.sidebar {
|
||||
position: fixed; left: 0; top: 56px; z-index: 35;
|
||||
transform: translateX(-100%); transition: transform 0.22s ease;
|
||||
box-shadow: 0 16px 40px rgba(15,23,42,0.18);
|
||||
}
|
||||
nav.sidebar.open { transform: translateX(0); }
|
||||
main.content { padding: 28px 20px 100px; }
|
||||
.topbar .tag { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
<button id="menuBtn" aria-label="Toggle navigation">☰</button>
|
||||
<svg class="logo" viewBox="0 0 23 23"><rect width="10" height="10" fill="#F25022"/><rect x="13" width="10" height="10" fill="#7FBA00"/><rect y="13" width="10" height="10" fill="#00A4EF"/><rect x="13" y="13" width="10" height="10" fill="#FFB900"/></svg>
|
||||
<span class="brand">Skill<span>Opt</span></span>
|
||||
<span class="tag">Documentation & Reproduction Guide</span>
|
||||
<span class="spacer"></span>
|
||||
<a class="gh" href="https://github.com/microsoft/SkillOpt" target="_blank" rel="noopener">GitHub ↗</a>
|
||||
<a class="gh" href="https://arxiv.org/abs/2605.23904" target="_blank" rel="noopener">Paper ↗</a>
|
||||
</header>
|
||||
|
||||
<div class="layout">
|
||||
|
||||
<!-- ───────────── LEFT NAV ───────────── -->
|
||||
<nav class="sidebar" id="sidebar">
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">1</span> Overview</div>
|
||||
<a href="#what-is">What is SkillOpt</a>
|
||||
<a href="#analogy">DL ↔ SkillOpt analogy</a>
|
||||
<a href="#features">Key features</a>
|
||||
<a href="#layout">Repository layout</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">2</span> Installation</div>
|
||||
<a href="#requirements">Requirements</a>
|
||||
<a href="#install">Install the package</a>
|
||||
<a href="#credentials">Configure credentials</a>
|
||||
<a href="#verify">Verify installation</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">3</span> Data Preparation</div>
|
||||
<a href="#split-dir">Split directory format</a>
|
||||
<a href="#item-schema">Item JSON schema</a>
|
||||
<a href="#split-modes">Split modes</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">4</span> Quick Start</div>
|
||||
<a href="#train">Train a skill</a>
|
||||
<a href="#eval">Evaluate a skill</a>
|
||||
<a href="#outputs">Output structure</a>
|
||||
<a href="#resume">Auto-resume</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">5</span> How It Works</div>
|
||||
<a href="#loop">The training loop</a>
|
||||
<a href="#stages">The six per-step stages</a>
|
||||
<a href="#gate">Validation gate</a>
|
||||
<a href="#slow-update">Slow update (momentum)</a>
|
||||
<a href="#meta-skill">Meta skill (memory)</a>
|
||||
<a href="#skill-doc">Skill document anatomy</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">6</span> Configuration</div>
|
||||
<a href="#config-system">Config system</a>
|
||||
<a href="#cfg-model">model.*</a>
|
||||
<a href="#cfg-train">train.*</a>
|
||||
<a href="#cfg-gradient">gradient.*</a>
|
||||
<a href="#cfg-optimizer">optimizer.*</a>
|
||||
<a href="#cfg-evaluation">evaluation.*</a>
|
||||
<a href="#cfg-env">env.*</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">7</span> Benchmarks</div>
|
||||
<a href="#bench-list">Supported benchmarks</a>
|
||||
<a href="#bench-new">Add a new benchmark</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div class="glabel"><span class="num">8</span> API Reference</div>
|
||||
<a href="#module-map">Module map</a>
|
||||
<a href="#functions">Core functions</a>
|
||||
<a href="#cli">CLI scripts</a>
|
||||
<a href="#webui">WebUI</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- ───────────── MAIN CONTENT ───────────── -->
|
||||
<main class="content">
|
||||
|
||||
<span class="eyebrow">Microsoft Research</span>
|
||||
<h1>SkillOpt Documentation & Reproduction Guide</h1>
|
||||
<p class="lead">Train agent skills like you train neural networks — with epochs, (mini-)batch size, learning rates, and validation gates — but without touching any model weights.</p>
|
||||
<p>This guide walks you from a clean checkout to a reproduced result and a full reference for every configuration knob and core function. It is generated from, and kept consistent with, the current state of the codebase.</p>
|
||||
|
||||
<!-- ===================== 1. OVERVIEW ===================== -->
|
||||
<section id="what-is">
|
||||
<h2>1.1 What is SkillOpt <a class="anchor" href="#what-is">#</a></h2>
|
||||
<p><strong>SkillOpt</strong> is a text-space optimizer that improves a <em>frozen</em> language agent by iteratively editing a natural-language <strong>skill document</strong> — never the model weights. The skill document is a Markdown file that conditions a target model as it executes tasks. SkillOpt treats this document as the "weights" and runs a training loop that mirrors deep-learning training: rollout (forward pass), reflect (backward pass / gradients), select & apply edits (optimizer step), and a validation gate (accept/reject).</p>
|
||||
<p>Two roles split every model call:</p>
|
||||
<ul>
|
||||
<li><strong>Target</strong> — executes tasks using the current skill document (the agent being improved).</li>
|
||||
<li><strong>Optimizer</strong> — analyzes the target's trajectories and proposes edits to the skill document.</li>
|
||||
</ul>
|
||||
<p>The same loop drives six benchmarks out of the box (QA, document QA, embodied agents, math, spreadsheet code generation, and tool-augmented QA).</p>
|
||||
</section>
|
||||
|
||||
<section id="analogy">
|
||||
<h2>1.2 Deep-Learning ↔ SkillOpt Analogy <a class="anchor" href="#analogy">#</a></h2>
|
||||
<p>Every concept below maps to a concrete code construct, so deep-learning intuitions transfer directly to hyperparameter tuning.</p>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead><tr><th>Deep learning</th><th>SkillOpt</th><th>Where it lives</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>Model weights</td><td>Skill document (Markdown)</td><td><code>skillopt/optimizer/skill.py</code></td></tr>
|
||||
<tr><td>Forward pass</td><td>Rollout — target runs tasks</td><td><code>envs/<bench>/rollout.py</code></td></tr>
|
||||
<tr><td>Loss / score</td><td>Task evaluator</td><td><code>envs/<bench>/evaluator.py</code></td></tr>
|
||||
<tr><td>Backprop / gradients</td><td>Reflect → edit patches</td><td><code>gradient/reflect.py</code></td></tr>
|
||||
<tr><td>Gradient aggregation</td><td>Hierarchical patch merge</td><td><code>gradient/aggregate.py</code></td></tr>
|
||||
<tr><td>Gradient clipping</td><td>Rank & select top-k edits</td><td><code>optimizer/clip.py</code></td></tr>
|
||||
<tr><td>Learning rate</td><td><code>optimizer.learning_rate</code> (edits/step)</td><td><code>optimizer/scheduler.py</code></td></tr>
|
||||
<tr><td>LR scheduler</td><td><code>lr_scheduler</code> (cosine/linear/…)</td><td><code>optimizer/scheduler.py</code></td></tr>
|
||||
<tr><td>Optimizer step</td><td>Apply patches to the document</td><td><code>optimizer/skill.py</code></td></tr>
|
||||
<tr><td>Validation set</td><td>Selection split (<code>valid_seen</code>)</td><td><code>evaluation/gate.py</code></td></tr>
|
||||
<tr><td>Early stopping / accept</td><td>Validation gate</td><td><code>evaluation/gate.py</code></td></tr>
|
||||
<tr><td>Momentum</td><td>Slow update (epoch boundary)</td><td><code>optimizer/slow_update.py</code></td></tr>
|
||||
<tr><td>Meta-learning</td><td>Meta skill (cross-epoch memory)</td><td><code>optimizer/meta_skill.py</code></td></tr>
|
||||
<tr><td>Batch / minibatch</td><td><code>batch_size</code> / <code>minibatch_size</code></td><td><code>engine/trainer.py</code></td></tr>
|
||||
<tr><td>Epoch</td><td>Epoch (+ slow update & meta skill)</td><td><code>engine/trainer.py</code></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="note tip"><span class="nh">What transfers from DL</span>
|
||||
<p>Cosine schedule tends to beat constant; moderate learning rates (≈4–16 edits/step) beat very high/low; slow update curbs cross-epoch forgetting; meta-skill memory improves reflection quality. Conversely, bigger rollout batches and many epochs show diminishing returns — skills converge in ~2–4 epochs.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="features">
|
||||
<h2>1.3 Key Features <a class="anchor" href="#features">#</a></h2>
|
||||
<div class="cards">
|
||||
<div class="card"><h4>Validation gating</h4><p>Every candidate skill is scored on a held-out selection split and only accepted if it beats the current/best skill.</p></div>
|
||||
<div class="card"><h4>Slow update</h4><p>Epoch-boundary longitudinal comparison writes guidance into a protected region — momentum against forgetting. Force-injected or selection-gated.</p></div>
|
||||
<div class="card"><h4>Meta skill</h4><p>Optimizer-side memory that reflects on what worked across epochs and feeds back into reflection.</p></div>
|
||||
<div class="card"><h4>Pluggable backends</h4><p>OpenAI / Azure OpenAI, Anthropic Claude, local Qwen (vLLM), plus Codex/Claude-Code exec backends for the target.</p></div>
|
||||
<div class="card"><h4>Six benchmarks</h4><p>SearchQA, DocVQA, ALFWorld, LiveMathematicianBench, SpreadsheetBench, OfficeQA — each a self-contained env module.</p></div>
|
||||
<div class="card"><h4>Auto-resume</h4><p>Every run is checkpointed step-by-step; re-running the same command continues from the last completed step.</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="layout">
|
||||
<h2>1.4 Repository Layout <a class="anchor" href="#layout">#</a></h2>
|
||||
<pre><code><span class="tok-c"># top level</span>
|
||||
configs/ <span class="tok-c"># YAML configs (_base_ + per-benchmark)</span>
|
||||
scripts/ <span class="tok-c"># train.py, eval_only.py CLIs</span>
|
||||
ckpt/ <span class="tok-c"># packaged reference skills (e.g. gpt5.5_skill.md)</span>
|
||||
docs/ <span class="tok-c"># this guide + mkdocs sources</span>
|
||||
skillopt/ <span class="tok-c"># the package</span>
|
||||
├─ config.py <span class="tok-c"># YAML loading, _base_ inheritance, flatten</span>
|
||||
├─ engine/trainer.py<span class="tok-c"># the training loop (ReflACTTrainer)</span>
|
||||
├─ gradient/ <span class="tok-c"># reflect.py (analyst), aggregate.py (merge)</span>
|
||||
├─ optimizer/ <span class="tok-c"># skill edits, scheduler, clip, slow_update, meta_skill</span>
|
||||
├─ evaluation/ <span class="tok-c"># gate.py (accept/reject logic)</span>
|
||||
├─ model/ <span class="tok-c"># backend clients + routing</span>
|
||||
└─ envs/<benchmark>/ <span class="tok-c"># adapter, dataloader, rollout, evaluator, reflect</span></code></pre>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 2. INSTALLATION ===================== -->
|
||||
<section id="requirements">
|
||||
<h2>2.1 Requirements <a class="anchor" href="#requirements">#</a></h2>
|
||||
<ul>
|
||||
<li>Python ≥ 3.10</li>
|
||||
<li>Credentials for at least one model backend (Azure OpenAI, OpenAI-compatible, Anthropic, or a local Qwen server)</li>
|
||||
<li>Benchmark datasets are <strong>not</strong> bundled — prepare your own splits (see §3)</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="install">
|
||||
<h2>2.2 Install the Package <a class="anchor" href="#install">#</a></h2>
|
||||
<pre><code><span class="tok-k">git</span> clone https://github.com/microsoft/SkillOpt.git
|
||||
<span class="tok-k">cd</span> SkillOpt
|
||||
<span class="tok-k">pip</span> install -e .
|
||||
|
||||
<span class="tok-c"># Optional extras (install only what you need):</span>
|
||||
<span class="tok-k">pip</span> install -e <span class="tok-s">".[alfworld]"</span> <span class="tok-c"># ALFWorld benchmark</span>
|
||||
<span class="tok-k">pip</span> install -e <span class="tok-s">".[claude]"</span> <span class="tok-c"># Anthropic Claude backend</span>
|
||||
<span class="tok-k">pip</span> install -e <span class="tok-s">".[qwen]"</span> <span class="tok-c"># local Qwen backend</span>
|
||||
<span class="tok-k">pip</span> install -e <span class="tok-s">".[webui]"</span> <span class="tok-c"># monitoring dashboard</span>
|
||||
|
||||
<span class="tok-c"># ALFWorld also needs its data assets:</span>
|
||||
<span class="tok-k">alfworld-download</span></code></pre>
|
||||
</section>
|
||||
|
||||
<section id="credentials">
|
||||
<h2>2.3 Configure Credentials <a class="anchor" href="#credentials">#</a></h2>
|
||||
<p>Copy the template and fill in whichever backend you will use:</p>
|
||||
<pre><code><span class="tok-k">cp</span> .env.example .env
|
||||
<span class="tok-c"># edit .env, then:</span>
|
||||
<span class="tok-k">set</span> -a; <span class="tok-k">source</span> .env; <span class="tok-k">set</span> +a</code></pre>
|
||||
<div class="note info"><span class="nh">One env-var family for all OpenAI modes</span>
|
||||
<p>SkillOpt reuses the <code>AZURE_OPENAI_*</code> variable names even for plain OpenAI — there is no separate <code>OPENAI_API_KEY</code> knob. <code>AZURE_OPENAI_ENDPOINT</code> is required for every OpenAI auth mode.</p>
|
||||
</div>
|
||||
<h4>Azure OpenAI (default)</h4>
|
||||
<pre><code><span class="tok-k">export</span> AZURE_OPENAI_ENDPOINT=<span class="tok-s">"https://your-resource.openai.azure.com/"</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_API_VERSION=<span class="tok-s">"2024-12-01-preview"</span>
|
||||
<span class="tok-c"># Auth option 1 — API key:</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_API_KEY=<span class="tok-s">"your-key"</span>
|
||||
<span class="tok-c"># Auth option 2 — Azure CLI (no key; recommended on Azure VMs):</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_AUTH_MODE=azure_cli
|
||||
<span class="tok-c"># Auth option 3 — Managed Identity:</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_AUTH_MODE=managed_identity
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID=<span class="tok-s">"your-client-id"</span></code></pre>
|
||||
<h4>OpenAI-compatible endpoint</h4>
|
||||
<pre><code><span class="tok-k">export</span> AZURE_OPENAI_ENDPOINT=<span class="tok-s">"https://api.openai.com/v1"</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_API_KEY=<span class="tok-s">"sk-..."</span>
|
||||
<span class="tok-k">export</span> AZURE_OPENAI_AUTH_MODE=openai_compatible</code></pre>
|
||||
<h4>Anthropic Claude / local Qwen</h4>
|
||||
<pre><code><span class="tok-k">export</span> ANTHROPIC_API_KEY=<span class="tok-s">"sk-ant-..."</span> <span class="tok-c"># claude_chat backend</span>
|
||||
|
||||
<span class="tok-k">export</span> QWEN_CHAT_BASE_URL=<span class="tok-s">"http://localhost:8000/v1"</span> <span class="tok-c"># local vLLM</span>
|
||||
<span class="tok-k">export</span> QWEN_CHAT_MODEL=<span class="tok-s">"Qwen/Qwen3.5-4B"</span></code></pre>
|
||||
</section>
|
||||
|
||||
<section id="verify">
|
||||
<h2>2.4 Verify Installation <a class="anchor" href="#verify">#</a></h2>
|
||||
<pre><code><span class="tok-k">python</span> -c <span class="tok-s">"import skillopt; print('SkillOpt ready!')"</span></code></pre>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 3. DATA ===================== -->
|
||||
<section id="split-dir">
|
||||
<h2>3.1 Split Directory Format <a class="anchor" href="#split-dir">#</a></h2>
|
||||
<p>With <code>env.split_mode: split_dir</code> (the recommended, deterministic mode), SkillOpt reads a directory containing <code>train/</code>, <code>val/</code>, and <code>test/</code> subfolders, each holding a JSON array of task items:</p>
|
||||
<pre><code>data/my_split/
|
||||
├─ train/items.json <span class="tok-c"># used for rollout (the "train split")</span>
|
||||
├─ val/items.json <span class="tok-c"># selection split → validation gate (valid_seen)</span>
|
||||
└─ test/items.json <span class="tok-c"># held-out final eval (valid_unseen)</span></code></pre>
|
||||
<div class="note info"><span class="nh">Split naming</span>
|
||||
<p>Internally the splits are referred to as <code>train</code>, <code>valid_seen</code> (validation/selection), and <code>valid_unseen</code> (test). The <code>--split</code> flag of <code>eval_only.py</code> uses these names.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="item-schema">
|
||||
<h2>3.2 Item JSON Schema <a class="anchor" href="#item-schema">#</a></h2>
|
||||
<p>Required fields depend on the benchmark; consult <code>skillopt/envs/<benchmark>/dataloader.py</code> for the exact contract. A SearchQA item, for example:</p>
|
||||
<pre><code>[
|
||||
{
|
||||
<span class="tok-f">"id"</span>: <span class="tok-s">"unique_item_id"</span>,
|
||||
<span class="tok-f">"question"</span>: <span class="tok-s">"Who wrote the novel ..."</span>,
|
||||
<span class="tok-f">"context"</span>: <span class="tok-s">"[DOC] relevant passage text ..."</span>,
|
||||
<span class="tok-f">"answers"</span>: [<span class="tok-s">"expected answer"</span>]
|
||||
}
|
||||
]</code></pre>
|
||||
<div class="note warn"><span class="nh">Datasets not included</span>
|
||||
<p>This repository ships no benchmark data. Prepare your own splits in the format above before training.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="split-modes">
|
||||
<h2>3.3 Split Modes <a class="anchor" href="#split-modes">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th><code>env.split_mode</code></th><th>Behavior</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>split_dir</code></td><td>Use a pre-built directory with explicit <code>train/val/test</code> folders (set <code>env.split_dir</code>). Deterministic and reproducible.</td></tr>
|
||||
<tr><td><code>ratio</code></td><td>Build a deterministic split on the fly from a single <code>env.data_path</code>, using <code>split_seed</code> (and a train:val:test ratio). Convenient for quick experiments.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 4. QUICK START ===================== -->
|
||||
<section id="train">
|
||||
<h2>4.1 Train a Skill <a class="anchor" href="#train">#</a></h2>
|
||||
<pre><code><span class="tok-c"># Minimal SearchQA run</span>
|
||||
<span class="tok-k">python</span> scripts/train.py \
|
||||
<span class="tok-f">--config</span> configs/searchqa/default.yaml \
|
||||
<span class="tok-f">--split_dir</span> /path/to/your/searchqa_split \
|
||||
<span class="tok-f">--azure_openai_endpoint</span> https://your-resource.openai.azure.com/ \
|
||||
<span class="tok-f">--optimizer_model</span> gpt-5.5 \
|
||||
<span class="tok-f">--target_model</span> gpt-5.5</code></pre>
|
||||
<p>Swap the config for another benchmark (e.g. <code>configs/livemathematicianbench/default.yaml</code>, <code>configs/alfworld/default.yaml</code>). Common CLI arguments:</p>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Argument</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>--config</code></td><td>Benchmark config YAML (required)</td></tr>
|
||||
<tr><td><code>--split_dir</code></td><td>Path to the data split directory</td></tr>
|
||||
<tr><td><code>--azure_openai_endpoint</code></td><td>Azure OpenAI endpoint URL</td></tr>
|
||||
<tr><td><code>--optimizer_model</code> / <code>--target_model</code></td><td>Deployment names for optimizer / target</td></tr>
|
||||
<tr><td><code>--num_epochs</code> / <code>--batch_size</code></td><td>Epochs and rollout batch size</td></tr>
|
||||
<tr><td><code>--out_root</code></td><td>Output directory</td></tr>
|
||||
<tr><td><code>--cfg-options k=v ...</code></td><td>Override any config key (see §6.1)</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="eval">
|
||||
<h2>4.2 Evaluate a Skill <a class="anchor" href="#eval">#</a></h2>
|
||||
<p>Evaluate any skill document (a packaged reference skill, or a trained run's <code>best_skill.md</code>) without training:</p>
|
||||
<pre><code><span class="tok-c"># Evaluate the packaged GPT-5.5 SearchQA skill on the test split</span>
|
||||
<span class="tok-k">python</span> scripts/eval_only.py \
|
||||
<span class="tok-f">--config</span> configs/searchqa/default.yaml \
|
||||
<span class="tok-f">--skill</span> ckpt/searchqa/gpt5.5_skill.md \
|
||||
<span class="tok-f">--split</span> valid_unseen \
|
||||
<span class="tok-f">--split_dir</span> /path/to/searchqa_split \
|
||||
<span class="tok-f">--azure_openai_endpoint</span> https://your-resource.openai.azure.com/</code></pre>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th><code>--split</code></th><th>Meaning</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>valid_unseen</code></td><td>Test set (held-out)</td></tr>
|
||||
<tr><td><code>valid_seen</code></td><td>Validation / selection set</td></tr>
|
||||
<tr><td><code>train</code></td><td>Training set</td></tr>
|
||||
<tr><td><code>all</code></td><td>All splits combined (default)</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="outputs">
|
||||
<h2>4.3 Output Structure <a class="anchor" href="#outputs">#</a></h2>
|
||||
<pre><code>outputs/<run_name>/
|
||||
├─ config.json <span class="tok-c"># flattened runtime config</span>
|
||||
├─ history.json <span class="tok-c"># per-step training history</span>
|
||||
├─ runtime_state.json <span class="tok-c"># resume checkpoint</span>
|
||||
├─ best_skill.md <span class="tok-c"># best validated skill document</span>
|
||||
├─ skills/skill_vXXXX.md<span class="tok-c"># skill snapshot per step</span>
|
||||
├─ steps/step_XXXX/ <span class="tok-c"># per-step artifacts (patches, evals)</span>
|
||||
├─ slow_update/epoch_XX/<span class="tok-c"># slow-update logs & rollouts</span>
|
||||
└─ meta_skill/epoch_XX/ <span class="tok-c"># meta-skill logs</span></code></pre>
|
||||
</section>
|
||||
|
||||
<section id="resume">
|
||||
<h2>4.4 Auto-Resume <a class="anchor" href="#resume">#</a></h2>
|
||||
<p>Each completed step persists its state to <code>runtime_state.json</code> and a <code>steps/step_XXXX/</code> directory. Re-running the <em>same command</em> against the same <code>out_root</code> detects finished work and continues from the last completed step — including epoch-boundary slow-update and meta-skill stages.</p>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 5. HOW IT WORKS ===================== -->
|
||||
<section id="loop">
|
||||
<h2>5.1 The Training Loop <a class="anchor" href="#loop">#</a></h2>
|
||||
<p>The loop lives in <code>ReflACTTrainer</code> (<code>skillopt/engine/trainer.py</code>). Each epoch runs a series of optimization steps over rollout batches, then performs two epoch-boundary stages.</p>
|
||||
<pre><code><span class="tok-k">for</span> epoch <span class="tok-k">in</span> epochs:
|
||||
<span class="tok-k">for</span> step <span class="tok-k">in</span> steps:
|
||||
1. Rollout <span class="tok-c"># target executes a batch of tasks</span>
|
||||
2. Reflect <span class="tok-c"># optimizer analyzes trajectories → edit patches</span>
|
||||
3. Aggregate <span class="tok-c"># hierarchically merge similar patches</span>
|
||||
4. Select <span class="tok-c"># rank & clip edits to the learning rate</span>
|
||||
5. Update <span class="tok-c"># apply patches → candidate skill</span>
|
||||
6. Gate <span class="tok-c"># score on selection split → accept / reject</span>
|
||||
|
||||
<span class="tok-c"># epoch boundary (from epoch 2 onward)</span>
|
||||
Slow update <span class="tok-c"># longitudinal comparison → protected guidance</span>
|
||||
Meta skill <span class="tok-c"># cross-epoch optimizer memory</span></code></pre>
|
||||
</section>
|
||||
|
||||
<section id="stages">
|
||||
<h2>5.2 The Six Per-Step Stages <a class="anchor" href="#stages">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Stage</th><th>What happens</th><th>Source</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><strong>1. Rollout</strong></td><td>The target model runs each task in the batch with the current skill as context, producing trajectories and scores.</td><td><code>envs/<b>/rollout.py</code></td></tr>
|
||||
<tr><td><strong>2. Reflect</strong></td><td>The optimizer runs an error analyst (and optional success analyst) over minibatches of trajectories, emitting structured edit patches. Runs in parallel across <code>analyst_workers</code>.</td><td><code>gradient/reflect.py</code></td></tr>
|
||||
<tr><td><strong>3. Aggregate</strong></td><td>Semantically similar patches are merged hierarchically to remove redundancy.</td><td><code>gradient/aggregate.py</code> → <code>merge_patches</code></td></tr>
|
||||
<tr><td><strong>4. Select</strong></td><td>Patches are ranked and clipped to the current learning rate (max edits this step), set by the scheduler.</td><td><code>optimizer/clip.py</code> → <code>rank_and_select</code></td></tr>
|
||||
<tr><td><strong>5. Update</strong></td><td>Selected edits are applied to the skill document, producing a candidate skill (patch / rewrite modes).</td><td><code>optimizer/skill.py</code>, <code>update_modes.py</code></td></tr>
|
||||
<tr><td><strong>6. Gate</strong></td><td>The candidate is scored on the selection split and accepted only if it improves (see §5.3).</td><td><code>evaluation/gate.py</code> → <code>evaluate_gate</code></td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="gate">
|
||||
<h2>5.3 Validation Gate <a class="anchor" href="#gate">#</a></h2>
|
||||
<p><code>evaluate_gate</code> is a pure decision function. It compares the candidate's selection-set score against the <em>current</em> and <em>best</em> skills:</p>
|
||||
<ul>
|
||||
<li><strong>accept_new_best</strong> — candidate > current <em>and</em> candidate > best → becomes both current and best.</li>
|
||||
<li><strong>accept</strong> — candidate > current but ≤ best → becomes current only.</li>
|
||||
<li><strong>reject</strong> — candidate ≤ current → discarded; current/best unchanged.</li>
|
||||
</ul>
|
||||
<p>The comparison metric is configurable via <code>evaluation.gate_metric</code>:</p>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Metric</th><th>Score used</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>hard</code> <span class="pill def">default</span></td><td>Exact-match / discrete score</td></tr>
|
||||
<tr><td><code>soft</code></td><td>Partial-credit / continuous score</td></tr>
|
||||
<tr><td><code>mixed</code></td><td>Weighted blend, controlled by <code>gate_mixed_weight</code></td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="note info"><span class="nh">When to use soft/mixed</span>
|
||||
<p>The <code>soft</code>/<code>mixed</code> metrics (contributed config <code>configs/examples/soft_gate.yaml</code>) help when the selection split is small and rewards are continuous, where a discrete hard gate may reject every candidate and stall training. Paper numbers use the default <code>hard</code> gate.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="slow-update">
|
||||
<h2>5.4 Slow Update (Momentum) <a class="anchor" href="#slow-update">#</a></h2>
|
||||
<p>At each epoch boundary (from epoch 2), the slow update rolls out both the <em>previous</em> epoch's skill and the <em>current</em> skill on the same sampled tasks, categorizes items (improved / regressed / persistent-fail / stable-success), and asks the optimizer to write a free-form <strong>guidance</strong> block. This guidance lands in a <strong>protected region</strong> of the skill that step-level edits cannot touch — only the slow update overwrites it. It is SkillOpt's analogue of momentum, countering cross-epoch forgetting.</p>
|
||||
<p>Acceptance has two modes, selected by <code>optimizer.slow_update_gate_with_selection</code>:</p>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Mode</th><th>Behavior</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>false</code> <span class="pill def">default</span> — force-injected</td><td>Guidance is injected into both current and best skills unconditionally. The longitudinal guidance always persists; it is not gated by step-level selection scores.</td></tr>
|
||||
<tr><td><code>true</code> — gated</td><td>The slow-update candidate is scored on the selection split and accepted/rejected through the same validation gate as step-level updates.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="meta-skill">
|
||||
<h2>5.5 Meta Skill (Optimizer Memory) <a class="anchor" href="#meta-skill">#</a></h2>
|
||||
<p>The meta skill is <strong>optimizer-side memory</strong> — it never modifies the target skill document. At the end of each epoch (skipped for epoch 1), the optimizer compares the previous and current epoch's last-step skills on the same sampled tasks and writes a compact, evidence-based reflection on what kind of edits helped or hurt. That memory is then injected as extra context into the next epoch's reflect / merge / learning-rate / ranking stages, so the optimizer accumulates strategy across the run.</p>
|
||||
</section>
|
||||
|
||||
<section id="skill-doc">
|
||||
<h2>5.6 Skill Document Anatomy <a class="anchor" href="#skill-doc">#</a></h2>
|
||||
<p>A skill document is plain Markdown. Initial skills can be empty (learn from scratch) or seeded with domain knowledge via <code>env.skill_init</code>. During training the document accrues rules, patterns, and edge-case handling through accepted edit patches. A dedicated protected region holds the slow-update guidance, delimited by HTML-comment markers:</p>
|
||||
<pre><code><span class="tok-c"># Question Answering Skill</span>
|
||||
|
||||
<span class="tok-c">## Learned rules ...</span>
|
||||
- When the context contains multiple candidates, prefer ...
|
||||
|
||||
<span class="tok-c"><!-- SLOW_UPDATE_START --></span>
|
||||
<span class="tok-c"># (epoch-level longitudinal guidance — only the slow update writes here)</span>
|
||||
<span class="tok-c"><!-- SLOW_UPDATE_END --></span></code></pre>
|
||||
<p>Helpers in <code>optimizer/slow_update.py</code> manage this region: <code>inject_empty_slow_update_field</code> (placeholder at epoch 1), <code>extract_slow_update_field</code> (read), and <code>replace_slow_update_field</code> (overwrite). Step-level edits are blocked from modifying anything inside the markers.</p>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 6. CONFIGURATION ===================== -->
|
||||
<section id="config-system">
|
||||
<h2>6.1 Configuration System <a class="anchor" href="#config-system">#</a></h2>
|
||||
<p>Configs are <strong>structured YAML</strong> with section blocks (<code>model</code>, <code>train</code>, <code>gradient</code>, <code>optimizer</code>, <code>evaluation</code>, <code>env</code>) and <code>_base_</code> inheritance. A benchmark config inherits the shared defaults and overrides only what differs:</p>
|
||||
<pre><code><span class="tok-c"># configs/searchqa/default.yaml</span>
|
||||
<span class="tok-f">_base_</span>: ../_base_/default.yaml
|
||||
<span class="tok-f">train</span>:
|
||||
<span class="tok-f">train_size</span>: <span class="tok-n">400</span>
|
||||
<span class="tok-f">batch_size</span>: <span class="tok-n">40</span>
|
||||
<span class="tok-f">optimizer</span>:
|
||||
<span class="tok-f">learning_rate</span>: <span class="tok-n">4</span>
|
||||
<span class="tok-f">env</span>:
|
||||
<span class="tok-f">name</span>: searchqa
|
||||
<span class="tok-f">split_dir</span>: data/searchqa_split</code></pre>
|
||||
<p>Override any key at the command line without editing files:</p>
|
||||
<pre><code><span class="tok-k">python</span> scripts/train.py --config configs/searchqa/default.yaml \
|
||||
<span class="tok-f">--cfg-options</span> optimizer.learning_rate=<span class="tok-n">16</span> optimizer.lr_scheduler=linear</code></pre>
|
||||
<div class="note info"><span class="nh">Reading the tables below</span>
|
||||
<p>Each section lists the key (relative to its YAML block), type, default (from <code>configs/_base_/default.yaml</code>), allowed values, and meaning. Defaults shown are the shipped base defaults.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-model">
|
||||
<h2>6.2 <code>model.*</code> <a class="anchor" href="#cfg-model">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>Description / options</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>backend</code></td><td>str</td><td class="def">azure_openai</td><td>High-level backend label for the run.</td></tr>
|
||||
<tr><td><code>optimizer</code></td><td>str</td><td class="def">gpt-5.5</td><td>Optimizer model deployment (writes skill edits).</td></tr>
|
||||
<tr><td><code>target</code></td><td>str</td><td class="def">gpt-5.5</td><td>Target model deployment (executes tasks).</td></tr>
|
||||
<tr><td><code>optimizer_backend</code></td><td>str</td><td class="def">openai_chat</td><td>Client path for the optimizer: <code>openai_chat</code> or <code>claude_chat</code>.</td></tr>
|
||||
<tr><td><code>target_backend</code></td><td>str</td><td class="def">openai_chat</td><td>Client path for the target: <code>openai_chat</code> / <code>claude_chat</code> / <code>qwen_chat</code> / <code>codex_exec</code> / <code>claude_code_exec</code>.</td></tr>
|
||||
<tr><td><code>reasoning_effort</code></td><td>str</td><td class="def">medium</td><td><code>low</code> / <code>medium</code> / <code>high</code> / <code>xhigh</code> / <code>max</code> (or empty).</td></tr>
|
||||
<tr><td><code>rewrite_reasoning_effort</code></td><td>str</td><td class="def">""</td><td>Override effort for full-rewrite calls (empty = inherit).</td></tr>
|
||||
<tr><td><code>rewrite_max_completion_tokens</code></td><td>int</td><td class="def">64000</td><td>Token cap for full-rewrite optimizer calls.</td></tr>
|
||||
<tr><td><code>azure_openai_endpoint</code></td><td>str</td><td class="def">""</td><td>Azure resource URL (or via <code>AZURE_OPENAI_ENDPOINT</code>).</td></tr>
|
||||
<tr><td><code>azure_openai_api_version</code></td><td>str</td><td class="def">2024-12-01-preview</td><td>Azure API version header.</td></tr>
|
||||
<tr><td><code>azure_openai_auth_mode</code></td><td>str</td><td class="def">""</td><td><code>api_key</code> / <code>azure_cli</code> / <code>managed_identity</code> / <code>openai_compatible</code> (empty → env default).</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="note info"><span class="nh">Separate optimizer / target endpoints</span>
|
||||
<p>Every <code>azure_openai_*</code> key also has <code>optimizer_azure_openai_*</code> and <code>target_azure_openai_*</code> variants, letting you point the optimizer and target at different Azure resources. Exec backends (<code>codex_exec</code>, <code>claude_code_exec</code>) add their own <code>codex_exec_*</code> / <code>claude_code_exec_*</code> knobs (sandbox, reasoning effort, SDK mode, etc.).</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-train">
|
||||
<h2>6.3 <code>train.*</code> <a class="anchor" href="#cfg-train">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>DL analogy</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>num_epochs</code></td><td>int</td><td class="def">4</td><td>Epochs</td><td>Number of training epochs.</td></tr>
|
||||
<tr><td><code>train_size</code></td><td>int</td><td class="def">0</td><td>Train-set size</td><td>0 = derive from the dataset split. (Fixed by split size when using <code>split_dir</code>.)</td></tr>
|
||||
<tr><td><code>batch_size</code></td><td>int</td><td class="def">40</td><td>Batch size</td><td>Tasks rolled out per optimization step.</td></tr>
|
||||
<tr><td><code>accumulation</code></td><td>int</td><td class="def">1</td><td>Grad accumulation</td><td>Accumulation rounds per step.</td></tr>
|
||||
<tr><td><code>seed</code></td><td>int</td><td class="def">42</td><td>Random seed</td><td>Reproducibility seed.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-gradient">
|
||||
<h2>6.4 <code>gradient.*</code> <a class="anchor" href="#cfg-gradient">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>minibatch_size</code></td><td>int</td><td class="def">8</td><td>Trajectories per reflect minibatch.</td></tr>
|
||||
<tr><td><code>merge_batch_size</code></td><td>int</td><td class="def">8</td><td>Patches per merge batch during aggregation.</td></tr>
|
||||
<tr><td><code>analyst_workers</code></td><td>int</td><td class="def">16</td><td>Parallel reflection workers (data parallelism).</td></tr>
|
||||
<tr><td><code>max_analyst_rounds</code></td><td>int</td><td class="def">3</td><td>Max rounds of analyst reflection per step.</td></tr>
|
||||
<tr><td><code>failure_only</code></td><td>bool</td><td class="def">false</td><td>Reflect only on failed trajectories when true.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-optimizer">
|
||||
<h2>6.5 <code>optimizer.*</code> <a class="anchor" href="#cfg-optimizer">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>DL analogy</th><th>Description / options</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>learning_rate</code></td><td>int</td><td class="def">4</td><td>Learning rate</td><td>Max edit patches applied per step (the "edit budget").</td></tr>
|
||||
<tr><td><code>min_learning_rate</code></td><td>int</td><td class="def">2</td><td>Min LR</td><td>Floor edit budget for decaying schedulers.</td></tr>
|
||||
<tr><td><code>lr_scheduler</code></td><td>str</td><td class="def">cosine</td><td>LR schedule</td><td><code>constant</code> / <code>linear</code> / <code>cosine</code> / <code>autonomous</code>.</td></tr>
|
||||
<tr><td><code>lr_control_mode</code></td><td>str</td><td class="def">fixed</td><td>—</td><td><code>fixed</code> / <code>autonomous</code> / <code>none</code>.</td></tr>
|
||||
<tr><td><code>skill_update_mode</code></td><td>str</td><td class="def">patch</td><td>—</td><td><code>patch</code> / <code>rewrite_from_suggestions</code> / <code>full_rewrite_minibatch</code>.</td></tr>
|
||||
<tr><td><code>use_slow_update</code></td><td>bool</td><td class="def">true</td><td>Momentum</td><td>Enable epoch-boundary slow update.</td></tr>
|
||||
<tr><td><code>slow_update_samples</code></td><td>int</td><td class="def">20</td><td>—</td><td>Tasks sampled for the longitudinal comparison.</td></tr>
|
||||
<tr><td><code>slow_update_gate_with_selection</code></td><td>bool</td><td class="def">false</td><td>—</td><td><code>false</code> = force-inject guidance; <code>true</code> = gate it on the selection split (see §5.4).</td></tr>
|
||||
<tr><td><code>longitudinal_pair_policy</code></td><td>str</td><td class="def">mixed</td><td>—</td><td><code>mixed</code> / <code>changed</code> / <code>unchanged</code> — which comparison pairs to keep.</td></tr>
|
||||
<tr><td><code>use_meta_skill</code></td><td>bool</td><td class="def">true</td><td>Meta-learning</td><td>Enable cross-epoch optimizer memory.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-evaluation">
|
||||
<h2>6.6 <code>evaluation.*</code> <a class="anchor" href="#cfg-evaluation">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>Description / options</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>use_gate</code></td><td>bool</td><td class="def">true</td><td>Validation gating is mandatory in this branch (must remain <code>true</code>).</td></tr>
|
||||
<tr><td><code>gate_metric</code></td><td>str</td><td class="def">hard</td><td><code>hard</code> / <code>soft</code> / <code>mixed</code> — score used by the gate (see §5.3).</td></tr>
|
||||
<tr><td><code>gate_mixed_weight</code></td><td>float</td><td class="def">0.5</td><td>Weight on the soft score when <code>gate_metric = mixed</code>.</td></tr>
|
||||
<tr><td><code>sel_env_num</code></td><td>int</td><td class="def">0</td><td>Selection-split eval size (0 = use full split).</td></tr>
|
||||
<tr><td><code>test_env_num</code></td><td>int</td><td class="def">0</td><td>Test-split eval size (0 = use full split).</td></tr>
|
||||
<tr><td><code>eval_test</code></td><td>bool</td><td class="def">true</td><td>Run a final test evaluation after training.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="note warn"><span class="nh">Gate is required</span>
|
||||
<p>Setting <code>evaluation.use_gate: false</code> raises an error — validation gating cannot be disabled in this branch.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="cfg-env">
|
||||
<h2>6.7 <code>env.*</code> <a class="anchor" href="#cfg-env">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Key</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>name</code></td><td>str</td><td class="def">""</td><td>Benchmark name (<code>searchqa</code>, <code>docvqa</code>, <code>alfworld</code>, …). Selects the env module.</td></tr>
|
||||
<tr><td><code>skill_init</code></td><td>str</td><td class="def">""</td><td>Path to a seed skill (empty = start from scratch).</td></tr>
|
||||
<tr><td><code>split_mode</code></td><td>str</td><td class="def">ratio</td><td><code>ratio</code> or <code>split_dir</code> (see §3.3).</td></tr>
|
||||
<tr><td><code>split_dir</code></td><td>str</td><td class="def">""</td><td>Pre-split directory (when <code>split_mode = split_dir</code>).</td></tr>
|
||||
<tr><td><code>data_path</code></td><td>str</td><td class="def">""</td><td>Single dataset path (when <code>split_mode = ratio</code>).</td></tr>
|
||||
<tr><td><code>split_seed</code></td><td>int</td><td class="def">42</td><td>Seed for deterministic ratio splitting.</td></tr>
|
||||
<tr><td><code>exec_timeout</code></td><td>int</td><td class="def">120</td><td>Per-task target/code-agent timeout (seconds).</td></tr>
|
||||
<tr><td><code>out_root</code></td><td>str</td><td class="def">""</td><td>Output directory for the run.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="note info"><span class="nh">Benchmark-specific env keys</span>
|
||||
<p>Env blocks may carry extra benchmark-specific keys (e.g. <code>max_turns</code>, <code>workers</code>, <code>max_completion_tokens</code>, <code>limit</code>). Unmapped env keys are passed straight through to the benchmark adapter — check the relevant <code>configs/<benchmark>/default.yaml</code>.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 7. BENCHMARKS ===================== -->
|
||||
<section id="bench-list">
|
||||
<h2>7.1 Supported Benchmarks <a class="anchor" href="#bench-list">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Benchmark</th><th>Type</th><th>Config</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>SearchQA</td><td>Question answering</td><td><code>configs/searchqa/default.yaml</code></td></tr>
|
||||
<tr><td>DocVQA</td><td>Document QA</td><td><code>configs/docvqa/default.yaml</code></td></tr>
|
||||
<tr><td>ALFWorld</td><td>Embodied agent</td><td><code>configs/alfworld/default.yaml</code></td></tr>
|
||||
<tr><td>LiveMathematicianBench</td><td>Math reasoning</td><td><code>configs/livemathematicianbench/default.yaml</code></td></tr>
|
||||
<tr><td>SpreadsheetBench</td><td>Spreadsheet code generation</td><td><code>configs/spreadsheetbench/default.yaml</code></td></tr>
|
||||
<tr><td>OfficeQA</td><td>Tool-augmented QA</td><td><code>configs/officeqa/default.yaml</code></td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<p>Each benchmark is a self-contained module under <code>skillopt/envs/<benchmark>/</code> with an <code>adapter.py</code>, <code>dataloader.py</code>, <code>rollout.py</code>, and <code>evaluator.py</code> (some add a custom <code>reflect.py</code>). Packaged reference skills live in <code>ckpt/<benchmark>/</code>.</p>
|
||||
</section>
|
||||
|
||||
<section id="bench-new">
|
||||
<h2>7.2 Add a New Benchmark <a class="anchor" href="#bench-new">#</a></h2>
|
||||
<p>Use <code>skillopt/envs/_template/</code> as a starting point. At minimum, implement:</p>
|
||||
<ol>
|
||||
<li><strong>Dataloader</strong> — read your item JSON into the framework's item dicts (<code>dataloader.py</code>).</li>
|
||||
<li><strong>Rollout</strong> — run the target on one item with the current skill and return a trajectory + score (<code>rollout.py</code>).</li>
|
||||
<li><strong>Evaluator</strong> — score predictions against ground truth (<code>evaluator.py</code>).</li>
|
||||
<li><strong>Adapter</strong> — wire the above into the trainer's expected interface and register the env name (<code>adapter.py</code>).</li>
|
||||
</ol>
|
||||
<p>Then add a <code>configs/<name>/default.yaml</code> inheriting <code>_base_/default.yaml</code> and set <code>env.name</code> to your new benchmark.</p>
|
||||
</section>
|
||||
|
||||
<!-- ===================== 8. API REFERENCE ===================== -->
|
||||
<section id="module-map">
|
||||
<h2>8.1 Module Map <a class="anchor" href="#module-map">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Module</th><th>Responsibility</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>skillopt/config.py</code></td><td>Load structured YAML, resolve <code>_base_</code> inheritance, flatten to the trainer's flat dict, apply CLI overrides.</td></tr>
|
||||
<tr><td><code>skillopt/engine/trainer.py</code></td><td><code>ReflACTTrainer</code> — orchestrates the whole loop, gating, slow update, meta skill, resume, and artifact writing.</td></tr>
|
||||
<tr><td><code>skillopt/gradient/</code></td><td>Reflection ("backward pass"): <code>reflect.py</code> analysts, <code>aggregate.py</code> patch merging.</td></tr>
|
||||
<tr><td><code>skillopt/optimizer/</code></td><td>The "optimizer": edit application, learning-rate scheduling, edit selection, slow update, meta skill, rewrite modes.</td></tr>
|
||||
<tr><td><code>skillopt/evaluation/gate.py</code></td><td>Pure accept/reject decision and metric selection.</td></tr>
|
||||
<tr><td><code>skillopt/model/</code></td><td>Backend clients (OpenAI/Azure, Claude, Qwen, Codex/Claude-Code exec) and routing.</td></tr>
|
||||
<tr><td><code>skillopt/envs/<b>/</code></td><td>Per-benchmark dataloader, rollout, evaluator, adapter.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="functions">
|
||||
<h2>8.2 Core Functions <a class="anchor" href="#functions">#</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Function</th><th>File</th><th>Purpose</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>load_config</code> / <code>flatten_config</code> / <code>apply_overrides</code></td><td><code>config.py</code></td><td>Load YAML with inheritance; flatten sections; apply <code>key=value</code> overrides.</td></tr>
|
||||
<tr><td><code>run_minibatch_reflect</code></td><td><code>gradient/reflect.py</code></td><td>Run error/success analysts over trajectory minibatches → edit patches.</td></tr>
|
||||
<tr><td><code>merge_patches</code></td><td><code>gradient/aggregate.py</code></td><td>Hierarchically merge semantically similar patches.</td></tr>
|
||||
<tr><td><code>rank_and_select</code></td><td><code>optimizer/clip.py</code></td><td>Rank edits and clip to the learning-rate budget.</td></tr>
|
||||
<tr><td><code>build_scheduler</code></td><td><code>optimizer/scheduler.py</code></td><td>Construct the LR (edit-budget) scheduler: constant/linear/cosine/autonomous.</td></tr>
|
||||
<tr><td><code>decide_autonomous_learning_rate</code></td><td><code>optimizer/lr_autonomous.py</code></td><td>Let the optimizer pick the next learning rate (autonomous mode).</td></tr>
|
||||
<tr><td><code>apply_patch</code> / <code>apply_edit</code></td><td><code>optimizer/skill.py</code></td><td>Apply edits to the skill document (respecting the protected region).</td></tr>
|
||||
<tr><td><code>rewrite_skill_from_suggestions</code></td><td><code>optimizer/rewrite.py</code></td><td>Full-rewrite update mode from accumulated suggestions.</td></tr>
|
||||
<tr><td><code>evaluate_gate</code> / <code>select_gate_score</code></td><td><code>evaluation/gate.py</code></td><td>Accept/reject decision; compute hard/soft/mixed score.</td></tr>
|
||||
<tr><td><code>run_slow_update</code></td><td><code>optimizer/slow_update.py</code></td><td>Produce epoch-boundary longitudinal guidance.</td></tr>
|
||||
<tr><td><code>replace_slow_update_field</code> / <code>extract_slow_update_field</code></td><td><code>optimizer/slow_update.py</code></td><td>Read/overwrite the protected guidance region.</td></tr>
|
||||
<tr><td><code>run_meta_skill</code> / <code>format_meta_skill_context</code></td><td><code>optimizer/meta_skill.py</code></td><td>Generate cross-epoch optimizer memory and render it into reflection context.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section id="cli">
|
||||
<h2>8.3 CLI Scripts <a class="anchor" href="#cli">#</a></h2>
|
||||
<h4>scripts/train.py</h4>
|
||||
<p>Runs a full training loop. Required: <code>--config</code>. Override config via <code>--cfg-options section.key=value …</code> or legacy flat flags (<code>--num_epochs</code>, <code>--batch_size</code>, <code>--optimizer_model</code>, <code>--target_model</code>, <code>--lr_scheduler</code>, <code>--edit_budget</code>, <code>--split_dir</code>, …).</p>
|
||||
<h4>scripts/eval_only.py</h4>
|
||||
<p>Evaluates a skill document without training. Required: <code>--config</code> and <code>--skill</code>. Use <code>--split</code> to choose <code>train</code> / <code>valid_seen</code> / <code>valid_unseen</code> / <code>all</code>.</p>
|
||||
<pre><code><span class="tok-k">python</span> scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill outputs/my_run/best_skill.md \
|
||||
--split valid_unseen</code></pre>
|
||||
</section>
|
||||
|
||||
<section id="webui">
|
||||
<h2>8.4 WebUI <a class="anchor" href="#webui">#</a></h2>
|
||||
<p>An optional Gradio dashboard to configure parameters and monitor runs:</p>
|
||||
<pre><code><span class="tok-k">pip</span> install -e <span class="tok-s">".[webui]"</span>
|
||||
<span class="tok-k">python</span> -m skillopt_webui.app <span class="tok-c"># http://localhost:7860</span>
|
||||
<span class="tok-k">python</span> -m skillopt_webui.app --share <span class="tok-c"># public share link</span></code></pre>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Flag</th><th>Default</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>--port</code></td><td class="def">7860</td><td>Server port.</td></tr>
|
||||
<tr><td><code>--host</code></td><td class="def">0.0.0.0</td><td>Bind address.</td></tr>
|
||||
<tr><td><code>--share</code></td><td class="def">off</td><td>Create a public Gradio share link.</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
|
||||
<div class="footer-note">
|
||||
SkillOpt — Executive Strategy for Self-Evolving Agent Skills ·
|
||||
<a href="https://github.com/microsoft/SkillOpt">github.com/microsoft/SkillOpt</a> ·
|
||||
<a href="https://arxiv.org/abs/2605.23904">arXiv:2605.23904</a><br>
|
||||
This guide reflects the current configuration defaults in <code>configs/_base_/default.yaml</code>. When in doubt, the code is the source of truth.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- ───────────── RIGHT TOC ───────────── -->
|
||||
<aside class="toc" id="toc">
|
||||
<div class="tl">On this page</div>
|
||||
<div id="tocLinks"></div>
|
||||
</aside>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
// Build right-hand "On this page" from <h2> elements
|
||||
var sections = Array.prototype.slice.call(document.querySelectorAll('main.content section[id]'));
|
||||
var tocLinks = document.getElementById('tocLinks');
|
||||
var h2s = Array.prototype.slice.call(document.querySelectorAll('main.content h2'));
|
||||
h2s.forEach(function (h) {
|
||||
var sec = h.closest('section');
|
||||
if (!sec || !sec.id) return;
|
||||
var a = document.createElement('a');
|
||||
a.href = '#' + sec.id;
|
||||
a.textContent = h.textContent.replace(/#$/, '').trim();
|
||||
a.dataset.target = sec.id;
|
||||
tocLinks.appendChild(a);
|
||||
});
|
||||
|
||||
var sideLinks = Array.prototype.slice.call(document.querySelectorAll('nav.sidebar a'));
|
||||
var tocAnchors = Array.prototype.slice.call(tocLinks.querySelectorAll('a'));
|
||||
|
||||
function setActive(id) {
|
||||
sideLinks.forEach(function (a) {
|
||||
a.classList.toggle('active', a.getAttribute('href') === '#' + id);
|
||||
});
|
||||
tocAnchors.forEach(function (a) {
|
||||
a.classList.toggle('active', a.dataset.target === id);
|
||||
});
|
||||
}
|
||||
|
||||
// Scroll spy
|
||||
var observer = new IntersectionObserver(function (entries) {
|
||||
entries.forEach(function (e) {
|
||||
if (e.isIntersecting) setActive(e.target.id);
|
||||
});
|
||||
}, { rootMargin: '-64px 0px -75% 0px', threshold: 0 });
|
||||
sections.forEach(function (s) { observer.observe(s); });
|
||||
|
||||
// Mobile sidebar toggle
|
||||
var btn = document.getElementById('menuBtn');
|
||||
var sidebar = document.getElementById('sidebar');
|
||||
btn.addEventListener('click', function () { sidebar.classList.toggle('open'); });
|
||||
sideLinks.forEach(function (a) {
|
||||
a.addEventListener('click', function () { sidebar.classList.remove('open'); });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
---
|
||||
hide:
|
||||
- navigation
|
||||
---
|
||||
|
||||
<div class="hero" markdown>
|
||||
|
||||
# SkillOpt
|
||||
|
||||
### Train Agent Skills Like Neural Networks
|
||||
|
||||
*Optimize natural-language skill documents through iterative rollout, reflection, and gated validation — with epochs, learning rates, and validation gates — without touching model weights.*
|
||||
|
||||
[Get Started :material-rocket-launch:](guide/installation.md){ .md-button .md-button--primary }
|
||||
[View on GitHub :material-github:](https://github.com/microsoft/SkillOpt){ .md-button }
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
<div class="pipeline-container" markdown>
|
||||
<div class="pipeline-wrapper">
|
||||
|
||||
<div class="pipeline-stage" id="stage-rollout">
|
||||
<div class="stage-icon">🎯</div>
|
||||
<div class="stage-label">Rollout</div>
|
||||
<div class="stage-desc">Target executes tasks</div>
|
||||
</div>
|
||||
|
||||
<div class="pipeline-arrow"><div class="flow-line"></div></div>
|
||||
|
||||
<div class="pipeline-stage" id="stage-reflect">
|
||||
<div class="stage-icon">🔍</div>
|
||||
<div class="stage-label">Reflect</div>
|
||||
<div class="stage-desc">Optimizer analyzes trajectories</div>
|
||||
</div>
|
||||
|
||||
<div class="pipeline-arrow"><div class="flow-line"></div></div>
|
||||
|
||||
<div class="pipeline-stage" id="stage-aggregate">
|
||||
<div class="stage-icon">🔗</div>
|
||||
<div class="stage-label">Aggregate</div>
|
||||
<div class="stage-desc">Merge edit patches</div>
|
||||
</div>
|
||||
|
||||
<div class="pipeline-arrow"><div class="flow-line"></div></div>
|
||||
|
||||
<div class="pipeline-stage" id="stage-select">
|
||||
<div class="stage-icon">✂️</div>
|
||||
<div class="stage-label">Select</div>
|
||||
<div class="stage-desc">Rank & clip edits</div>
|
||||
</div>
|
||||
|
||||
<div class="pipeline-arrow"><div class="flow-line"></div></div>
|
||||
|
||||
<div class="pipeline-stage" id="stage-update">
|
||||
<div class="stage-icon">📝</div>
|
||||
<div class="stage-label">Update</div>
|
||||
<div class="stage-desc">Apply to skill doc</div>
|
||||
</div>
|
||||
|
||||
<div class="pipeline-arrow"><div class="flow-line"></div></div>
|
||||
|
||||
<div class="pipeline-stage" id="stage-gate">
|
||||
<div class="stage-icon">🚦</div>
|
||||
<div class="stage-label">Gate</div>
|
||||
<div class="stage-desc">Validate & accept</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="pipeline-epoch-bar">
|
||||
<div class="epoch-mechanism">🔄 Slow Update</div>
|
||||
<div class="epoch-mechanism">🧠 Meta Skill</div>
|
||||
<div class="epoch-label">Epoch Boundary</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Deep Learning Analogy
|
||||
|
||||
SkillOpt brings the familiar deep-learning training paradigm to agentic prompt optimization:
|
||||
|
||||
| Deep Learning | SkillOpt |
|
||||
|---|---|
|
||||
| Model weights | Skill document (Markdown) |
|
||||
| Forward pass | Rollout (target executes tasks) |
|
||||
| Loss / gradient | Reflect (optimizer produces edit patches) |
|
||||
| Gradient clipping | Edit selection (`learning_rate` = max edits) |
|
||||
| SGD step | Patch application to skill |
|
||||
| Validation set | Gated evaluation on selection split |
|
||||
| LR schedule | `lr_scheduler`: cosine, linear, constant |
|
||||
| Epochs | Multi-epoch with slow update & meta skill memory |
|
||||
|
||||
---
|
||||
|
||||
## Supported Benchmarks
|
||||
|
||||
| Benchmark | Type | Config |
|
||||
|---|---|---|
|
||||
| **DocVQA** | Document QA | `configs/docvqa/` |
|
||||
| **ALFWorld** | Embodied AI | `configs/alfworld/` |
|
||||
| **OfficeQA** | Enterprise QA | `configs/officeqa/` |
|
||||
| **SearchQA** | Open-domain QA | `configs/searchqa/` |
|
||||
| **LiveMathBench** | Math reasoning | `configs/livemathematicianbench/` |
|
||||
| **SWEBench** | Software Engineering | `configs/swebench/` |
|
||||
| + 5 more | Various | See [docs](guide/first-experiment.md) |
|
||||
|
||||
---
|
||||
|
||||
## Quick Example
|
||||
|
||||
```bash
|
||||
# Install
|
||||
pip install -e .
|
||||
|
||||
# Configure credentials
|
||||
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
|
||||
export AZURE_OPENAI_API_KEY="your-key"
|
||||
|
||||
# Train on SearchQA
|
||||
python scripts/train.py --config configs/searchqa/default.yaml
|
||||
|
||||
# Evaluate best skill
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill outputs/best_skill.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
<div class="grid cards" markdown>
|
||||
|
||||
- :material-book-open-variant:{ .lg .middle } **Getting Started**
|
||||
|
||||
---
|
||||
|
||||
Install SkillOpt, configure your API keys, and run your first experiment in 5 minutes.
|
||||
|
||||
[:octicons-arrow-right-24: Installation](guide/installation.md)
|
||||
|
||||
- :material-puzzle:{ .lg .middle } **Add a Benchmark**
|
||||
|
||||
---
|
||||
|
||||
Extend SkillOpt with your own benchmark in ~100 lines of code.
|
||||
|
||||
[:octicons-arrow-right-24: Extension Guide](guide/new-benchmark.md)
|
||||
|
||||
- :material-cog:{ .lg .middle } **Configuration**
|
||||
|
||||
---
|
||||
|
||||
Full reference for all hyperparameters with deep learning analogies.
|
||||
|
||||
[:octicons-arrow-right-24: Config Reference](reference/config.md)
|
||||
|
||||
- :material-monitor-dashboard:{ .lg .middle } **WebUI**
|
||||
|
||||
---
|
||||
|
||||
Configure, launch, and monitor training from your browser.
|
||||
|
||||
[:octicons-arrow-right-24: WebUI Guide](guide/first-experiment.md#webui)
|
||||
|
||||
</div>
|
||||
@@ -1,81 +0,0 @@
|
||||
# API Reference
|
||||
|
||||
## Core Classes
|
||||
|
||||
### `EnvAdapter`
|
||||
|
||||
Abstract base class for benchmark environments.
|
||||
|
||||
```python
|
||||
class EnvAdapter(ABC):
|
||||
async def execute(self, item, skill, model) -> TaskResult
|
||||
def evaluate(self, prediction, ground_truth) -> float
|
||||
def build_prompt(self, item, skill) -> str
|
||||
```
|
||||
|
||||
### `DataLoader`
|
||||
|
||||
Abstract base class for data loading and splitting.
|
||||
|
||||
```python
|
||||
class DataLoader(ABC):
|
||||
def setup(self, cfg: dict) -> None
|
||||
def get_split_items(self, split: str) -> list[DataItem]
|
||||
```
|
||||
|
||||
### `ModelBackend`
|
||||
|
||||
Abstract base class for LLM backends.
|
||||
|
||||
```python
|
||||
class ModelBackend(ABC):
|
||||
async def generate(self, messages, **kwargs) -> ModelResponse
|
||||
async def generate_with_tools(self, messages, tools, **kwargs) -> ModelResponse
|
||||
```
|
||||
|
||||
### `Trainer`
|
||||
|
||||
Main training loop orchestrator.
|
||||
|
||||
```python
|
||||
class Trainer:
|
||||
def __init__(self, cfg: dict)
|
||||
async def train(self) -> TrainResult
|
||||
async def evaluate(self, skill: str, split: str) -> EvalResult
|
||||
```
|
||||
|
||||
## Data Classes
|
||||
|
||||
### `DataItem`
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class DataItem:
|
||||
id: str
|
||||
input: str
|
||||
ground_truth: str
|
||||
metadata: dict = field(default_factory=dict)
|
||||
```
|
||||
|
||||
### `TaskResult`
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class TaskResult:
|
||||
item_id: str
|
||||
prediction: str
|
||||
score: float
|
||||
trajectory: list[dict]
|
||||
```
|
||||
|
||||
### `ModelResponse`
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class ModelResponse:
|
||||
content: str
|
||||
usage: dict
|
||||
model: str
|
||||
```
|
||||
|
||||
For detailed source code, see the [`skillopt/`](https://github.com/microsoft/SkillOpt/tree/main/skillopt) directory.
|
||||
@@ -1,71 +0,0 @@
|
||||
# CLI Reference
|
||||
|
||||
## Training
|
||||
|
||||
```bash
|
||||
python scripts/train.py --config <config.yaml> [overrides...]
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
| Argument | Description |
|
||||
|---|---|
|
||||
| `--config` | Path to YAML config file (required) |
|
||||
| `key=value` | Override any config parameter |
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Basic training
|
||||
python scripts/train.py --config configs/searchqa/default.yaml
|
||||
|
||||
# With overrides
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--cfg-options optimizer.learning_rate=16 optimizer.lr_scheduler=linear
|
||||
|
||||
# With custom initial skill
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--cfg-options env.skill_init=skills/my_seed.md
|
||||
```
|
||||
|
||||
## Evaluation
|
||||
|
||||
```bash
|
||||
python scripts/eval_only.py --config <config.yaml> --skill <skill.md>
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
| Argument | Description |
|
||||
|---|---|
|
||||
| `--config` | Path to YAML config file (required) |
|
||||
| `--skill` | Path to skill document to evaluate (required) |
|
||||
| `--split` | Evaluation split: `test` (default), `valid`, `train` |
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Evaluate best skill on test set
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill outputs/searchqa/run_001/skills/best_skill.md
|
||||
|
||||
# Evaluate on validation set
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--skill outputs/searchqa/run_001/skills/best_skill.md \
|
||||
--split valid
|
||||
```
|
||||
|
||||
## WebUI
|
||||
|
||||
```bash
|
||||
python -m skillopt_webui.app [--port PORT] [--share]
|
||||
```
|
||||
|
||||
| Argument | Default | Description |
|
||||
|---|---|---|
|
||||
| `--port` | 7860 | Port number |
|
||||
| `--share` | false | Create public Gradio link |
|
||||
@@ -1,72 +0,0 @@
|
||||
# Configuration Reference
|
||||
|
||||
Complete reference for all SkillOpt configuration parameters.
|
||||
|
||||
## Model
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `model.backend` | str | `azure_openai` | Backend: `azure_openai` / `openai_chat` / `claude_code_exec` / `qwen` |
|
||||
| `model.optimizer` | str | `gpt-5.5` | Optimizer model (for reflection & slow update) |
|
||||
| `model.target` | str | `gpt-5.5` | Target model (for rollout execution) |
|
||||
| `model.reasoning_effort` | str | `medium` | Reasoning effort level |
|
||||
|
||||
## Training (`train`)
|
||||
|
||||
| Parameter | Type | Default | DL Analogy | Description |
|
||||
|---|---|---|---|---|
|
||||
| `train.num_epochs` | int | 4 | Epochs | Number of training epochs |
|
||||
| `train.batch_size` | int | 40 | Batch size | Tasks sampled per step |
|
||||
| `train.accumulation` | int | 1 | Gradient accumulation | Accumulation rounds per step |
|
||||
| `train.seed` | int | 42 | Random seed | Reproducibility seed |
|
||||
|
||||
## Gradient / Reflection (`gradient`)
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `gradient.minibatch_size` | int | 8 | Reflect minibatch size |
|
||||
| `gradient.merge_batch_size` | int | 8 | Patch merge batch size |
|
||||
| `gradient.analyst_workers` | int | 16 | Parallel reflection workers |
|
||||
| `gradient.max_analyst_rounds` | int | 3 | Max rounds of analyst reflection |
|
||||
| `gradient.failure_only` | bool | `false` | Only reflect on failures |
|
||||
|
||||
## Optimizer (`optimizer`)
|
||||
|
||||
| Parameter | Type | Default | DL Analogy | Description |
|
||||
|---|---|---|---|---|
|
||||
| `optimizer.learning_rate` | int | 4 | Learning rate | Max edit patches per step (edit budget) |
|
||||
| `optimizer.min_learning_rate` | int | 2 | Min LR | Min edits for decay schedulers |
|
||||
| `optimizer.lr_scheduler` | str | `cosine` | LR schedule | `constant` / `linear` / `cosine` / `autonomous` |
|
||||
| `optimizer.skill_update_mode` | str | `patch` | — | `patch` / `rewrite_from_suggestions` / `full_rewrite_minibatch` |
|
||||
| `optimizer.use_slow_update` | bool | `true` | Momentum | Epoch-boundary longitudinal comparison & guidance |
|
||||
| `optimizer.slow_update_samples` | int | 20 | — | Samples for slow update evaluation |
|
||||
| `optimizer.use_meta_skill` | bool | `true` | Meta-learning | Cross-epoch optimizer-side strategy memory |
|
||||
| `optimizer.longitudinal_pair_policy` | str | `mixed` | — | `mixed` / `changed` / `unchanged` |
|
||||
|
||||
## Evaluation (`evaluation`)
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `evaluation.use_gate` | bool | `true` | Enable validation gating (accept/reject updates) |
|
||||
| `evaluation.eval_test` | bool | `true` | Run test evaluation after training |
|
||||
|
||||
## Environment (`env`)
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `env.name` | str | — | Benchmark name (e.g., `searchqa`, `docvqa`) |
|
||||
| `env.data_path` | str | — | Path to dataset |
|
||||
| `env.skill_init` | str | — | Path to initial seed skill (optional) |
|
||||
| `env.split_mode` | str | `ratio` | `ratio` or `split_dir` |
|
||||
| `env.split_ratio` | str | `2:1:7` | Train:val:test ratio |
|
||||
| `env.exec_timeout` | int | 120 | Per-task timeout in seconds |
|
||||
| `env.out_root` | str | — | Output directory |
|
||||
|
||||
## Azure OpenAI Credentials
|
||||
|
||||
| Variable | Description |
|
||||
|---|---|
|
||||
| `AZURE_OPENAI_ENDPOINT` / `model.azure_openai_endpoint` | Azure resource endpoint |
|
||||
| `AZURE_OPENAI_API_KEY` / `model.azure_openai_api_key` | Azure API key |
|
||||
| `OPENAI_API_KEY` | OpenAI API key (for `openai_chat` backend) |
|
||||
| `ANTHROPIC_API_KEY` | Anthropic API key (for `claude_code_exec` backend) |
|
||||
-2739
File diff suppressed because it is too large
Load Diff
-78
@@ -1,78 +0,0 @@
|
||||
site_name: SkillOpt Documentation
|
||||
site_url: https://microsoft.github.io/SkillOpt
|
||||
site_description: "SkillOpt: Agentic Skill Optimization via Reflective Training Loops"
|
||||
repo_url: https://github.com/microsoft/SkillOpt
|
||||
repo_name: microsoft/SkillOpt
|
||||
|
||||
theme:
|
||||
name: material
|
||||
palette:
|
||||
- scheme: default
|
||||
primary: indigo
|
||||
accent: deep purple
|
||||
toggle:
|
||||
icon: material/brightness-7
|
||||
name: Switch to dark mode
|
||||
- scheme: slate
|
||||
primary: indigo
|
||||
accent: deep purple
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to light mode
|
||||
features:
|
||||
- navigation.instant
|
||||
- navigation.tracking
|
||||
- navigation.sections
|
||||
- navigation.expand
|
||||
- navigation.top
|
||||
- content.code.copy
|
||||
- content.tabs.link
|
||||
- search.suggest
|
||||
- search.highlight
|
||||
icon:
|
||||
repo: fontawesome/brands/github
|
||||
font:
|
||||
text: Inter
|
||||
code: JetBrains Mono
|
||||
|
||||
|
||||
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Getting Started:
|
||||
- Installation: guide/installation.md
|
||||
- First Experiment: guide/first-experiment.md
|
||||
- Configuration: guide/configuration.md
|
||||
- Core Concepts:
|
||||
- Training Loop: guide/training-loop.md
|
||||
- Skill Document: guide/skill-document.md
|
||||
- Deep Learning Analogy: guide/dl-analogy.md
|
||||
- Extension Guides:
|
||||
- Add a New Benchmark: guide/new-benchmark.md
|
||||
- Local Environment Smoke Tests: guide/local-env-smoke.md
|
||||
- Add a New Model Backend: guide/new-backend.md
|
||||
- Reference:
|
||||
- Configuration Reference: reference/config.md
|
||||
- CLI Reference: reference/cli.md
|
||||
- API Reference: reference/api.md
|
||||
- Contributing: contributing.md
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- pymdownx.details
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- attr_list
|
||||
- md_in_html
|
||||
- toc:
|
||||
permalink: true
|
||||
|
||||
plugins:
|
||||
- search
|
||||
@@ -1,75 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=68.0", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "skillopt"
|
||||
version = "0.1.0"
|
||||
description = "SkillOpt: Agentic Skill Optimization via Reflective Training Loops"
|
||||
readme = "README.md"
|
||||
license = {text = "MIT"}
|
||||
requires-python = ">=3.10"
|
||||
authors = [
|
||||
{name = "SkillOpt Team"},
|
||||
]
|
||||
keywords = ["agent", "prompt-optimization", "skill-learning", "LLM", "agentic"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Science/Research",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
]
|
||||
dependencies = [
|
||||
"openai>=1.30.0",
|
||||
"pyyaml>=6.0",
|
||||
"numpy>=1.24.0",
|
||||
"openpyxl>=3.1.0",
|
||||
"azure-identity>=1.15.0",
|
||||
"azure-core>=1.30.0",
|
||||
"httpx>=0.27.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
# Benchmark-specific dependencies
|
||||
alfworld = ["alfworld>=0.4.0", "gymnasium>=0.29.0"]
|
||||
# Claude model backend
|
||||
claude = ["claude-agent-sdk>=0.1.0"]
|
||||
# Qwen local model backend (via vLLM)
|
||||
qwen = ["vllm>=0.4.0"]
|
||||
# Documentation site
|
||||
docs = ["mkdocs-material>=9.5.0", "mkdocstrings[python]>=0.24.0"]
|
||||
# WebUI dashboard
|
||||
webui = ["gradio>=4.0.0"]
|
||||
# Development tools
|
||||
dev = ["ruff>=0.4.0", "pytest>=8.0.0"]
|
||||
# All optional dependencies (except docs/dev/webui)
|
||||
all = [
|
||||
"alfworld>=0.4.0",
|
||||
"gymnasium>=0.29.0",
|
||||
"claude-agent-sdk>=0.1.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
skillopt-train = "scripts.train:main"
|
||||
skillopt-eval = "scripts.eval_only:main"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/microsoft/SkillOpt"
|
||||
Documentation = "https://microsoft.github.io/SkillOpt"
|
||||
Repository = "https://github.com/microsoft/SkillOpt"
|
||||
Issues = "https://github.com/microsoft/SkillOpt/issues"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["skillopt*", "scripts*"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
target-version = "py310"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I", "W"]
|
||||
ignore = ["E501"]
|
||||
@@ -1,25 +0,0 @@
|
||||
# ── Core ──────────────────────────────────────────
|
||||
openai>=1.30.0
|
||||
pyyaml>=6.0
|
||||
numpy>=1.24.0
|
||||
openpyxl>=3.1.0
|
||||
azure-identity>=1.15.0
|
||||
azure-core>=1.30.0
|
||||
httpx>=0.27.0
|
||||
|
||||
# ── Optional: ALFWorld benchmark ──────────────────
|
||||
# alfworld>=0.4.0
|
||||
# gymnasium>=0.29.0
|
||||
|
||||
# ── Optional: Claude model backend ────────────────
|
||||
# claude-agent-sdk>=0.1.0
|
||||
|
||||
# ── Optional: Qwen local model (via vLLM) ────────
|
||||
# vllm>=0.4.0
|
||||
|
||||
# ── Optional: WebUI dashboard ────────────────────
|
||||
# gradio>=4.0.0
|
||||
|
||||
# ── Optional: Documentation site ─────────────────
|
||||
# mkdocs-material>=9.5.0
|
||||
# mkdocstrings[python]>=0.24.0
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PY="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
REAL_CODEX="/home/azureuser/.nvm/versions/node/v18.20.8/bin/codex"
|
||||
CLIENT_ID="8cafa2b1-a2a7-4ad9-814a-ffe4aed7e800"
|
||||
SCOPE="https://cognitiveservices.azure.com/.default"
|
||||
|
||||
token="$("$PY" - <<PY
|
||||
from azure.identity import ManagedIdentityCredential, get_bearer_token_provider
|
||||
cred = ManagedIdentityCredential(client_id="$CLIENT_ID")
|
||||
print(get_bearer_token_provider(cred, "$SCOPE")())
|
||||
PY
|
||||
)"
|
||||
|
||||
export CODEX_HOME="${CODEX_HOME:-$ROOT/.codex_azure}"
|
||||
export AZURE_OPENAI_AUTH_HEADER="Bearer $token"
|
||||
|
||||
exec "$REAL_CODEX" "$@"
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Download BabyVision from Hugging Face and convert it to local meta_data.jsonl + images/ format."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument("--out_dir", type=str, required=True)
|
||||
p.add_argument("--dataset", type=str, default="UnipatAI/BabyVision")
|
||||
p.add_argument("--split", type=str, default="train")
|
||||
return p.parse_args()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
|
||||
try:
|
||||
from datasets import load_dataset
|
||||
except ImportError as exc: # pragma: no cover
|
||||
raise SystemExit("Please install `datasets` first: pip install datasets pillow") from exc
|
||||
|
||||
out_dir = Path(args.out_dir).resolve()
|
||||
images_dir = out_dir / "images"
|
||||
meta_path = out_dir / "meta_data.jsonl"
|
||||
images_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
dataset = load_dataset(args.dataset, split=args.split)
|
||||
with open(meta_path, "w", encoding="utf-8") as outf:
|
||||
for idx, row in enumerate(dataset):
|
||||
image = row.get("image")
|
||||
if image is None:
|
||||
continue
|
||||
task_id = str(row.get("taskId") or row.get("id") or idx + 1)
|
||||
image_name = f"{task_id}.png"
|
||||
image_path = images_dir / image_name
|
||||
image.save(image_path)
|
||||
|
||||
record = dict(row)
|
||||
record["image"] = image_name
|
||||
outf.write(json.dumps(record, ensure_ascii=False) + "\n")
|
||||
|
||||
print(f"Saved BabyVision to {out_dir}")
|
||||
print(f"Metadata: {meta_path}")
|
||||
print(f"Images: {images_dir}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,333 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Evaluate LiveMathematicianBench under current or official-style prompts."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
|
||||
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
_PROJECT_ROOT = os.path.dirname(_SCRIPT_DIR)
|
||||
if _PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, _PROJECT_ROOT)
|
||||
|
||||
from skillopt.envs.livemathematicianbench.dataloader import load_items
|
||||
from skillopt.envs.livemathematicianbench.evaluator import evaluate as current_evaluate
|
||||
from skillopt.envs.livemathematicianbench.rollout import _build_system, _build_user
|
||||
from skillopt.model import (
|
||||
chat_with_deployment,
|
||||
configure_azure_openai,
|
||||
set_backend,
|
||||
set_reasoning_effort,
|
||||
)
|
||||
|
||||
_LABELS = ["A", "B", "C", "D", "E"]
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument("--data_path", type=str, required=True)
|
||||
p.add_argument("--model", type=str, default="gpt-5.4")
|
||||
p.add_argument("--backend", type=str, choices=["azure_openai", "codex", "claude"], default="azure_openai")
|
||||
p.add_argument("--mode", type=str, choices=["current", "official"], required=True)
|
||||
p.add_argument("--reasoning_effort", type=str, default=None)
|
||||
p.add_argument("--azure_endpoint", type=str, default="")
|
||||
p.add_argument("--azure_api_version", type=str, default="")
|
||||
p.add_argument("--azure_api_key", type=str, default="")
|
||||
p.add_argument("--max_completion_tokens", type=int, default=0)
|
||||
p.add_argument("--workers", type=int, default=8)
|
||||
p.add_argument("--seed", type=int, default=20260227)
|
||||
p.add_argument("--skill_path", type=str, default="skillopt/envs/livemathematicianbench/skills/initial.md")
|
||||
p.add_argument("--limit", type=int, default=0)
|
||||
p.add_argument("--resume", action="store_true")
|
||||
p.add_argument("--output_json", type=str, required=True)
|
||||
return p.parse_args()
|
||||
|
||||
def read_skill(skill_path: str) -> str:
|
||||
with open(skill_path, encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def official_extract_answer(response_text: str) -> str | None:
|
||||
if not response_text:
|
||||
return None
|
||||
boxed_match = re.search(r"\\boxed\{([A-Ea-e])\}", response_text)
|
||||
if boxed_match:
|
||||
return boxed_match.group(1).upper()
|
||||
boxed_match = re.search(r"boxed\{([A-Ea-e])\}", response_text)
|
||||
if boxed_match:
|
||||
return boxed_match.group(1).upper()
|
||||
answer_match = re.search(r"answer is[:\s]*([A-Ea-e])", response_text, re.IGNORECASE)
|
||||
if answer_match:
|
||||
return answer_match.group(1).upper()
|
||||
answer_match = re.search(r"Answer[:\s]*\(?([A-Ea-e])\)?", response_text)
|
||||
if answer_match:
|
||||
return answer_match.group(1).upper()
|
||||
final_match = re.search(r"\b([A-Ea-e])\b\s*[.)]?\s*$", response_text.strip())
|
||||
if final_match:
|
||||
return final_match.group(1).upper()
|
||||
return None
|
||||
|
||||
|
||||
def official_format_mcq_prompt(question: str, choices: list[dict]) -> str:
|
||||
lines = [
|
||||
"Answer the following multiple-choice question.",
|
||||
"Think carefully, then provide your final answer in the format: \\boxed{X} where X is A, B, C, D, or E.",
|
||||
"",
|
||||
"Question:",
|
||||
question,
|
||||
"",
|
||||
"Choices:",
|
||||
]
|
||||
for choice in choices:
|
||||
lines.append(f"{choice['label']}. {choice['text']}")
|
||||
lines.append("")
|
||||
lines.append("Your answer:")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def shuffle_choices(item: dict, seed: int) -> tuple[list[dict], dict]:
|
||||
correct_choice = dict(item["correct_choice"])
|
||||
all_choices = [dict(choice) for choice in item["choices"]]
|
||||
rng = random.Random(f"{seed}:{item['id']}")
|
||||
rng.shuffle(all_choices)
|
||||
|
||||
shuffled: list[dict] = []
|
||||
new_correct = dict(correct_choice)
|
||||
correct_text = correct_choice["text"]
|
||||
|
||||
for idx, choice in enumerate(all_choices[: len(_LABELS)]):
|
||||
relabeled = {"label": _LABELS[idx], "text": choice["text"]}
|
||||
shuffled.append(relabeled)
|
||||
if choice["text"] == correct_text:
|
||||
new_correct = dict(relabeled)
|
||||
|
||||
return shuffled, new_correct
|
||||
|
||||
|
||||
def load_existing(output_path: Path) -> dict[str, dict]:
|
||||
if not output_path.exists():
|
||||
return {}
|
||||
with open(output_path, encoding="utf-8") as f:
|
||||
payload = json.load(f)
|
||||
existing = {}
|
||||
for row in payload.get("results", []):
|
||||
existing[str(row["id"])] = row
|
||||
return existing
|
||||
|
||||
|
||||
def save_results(output_path: Path, meta: dict, results: list[dict]) -> None:
|
||||
correct = sum(1 for row in results if row.get("is_correct"))
|
||||
total = len(results)
|
||||
payload = {
|
||||
**meta,
|
||||
"summary": {
|
||||
"correct": correct,
|
||||
"total": total,
|
||||
"accuracy": (correct / total) if total else 0.0,
|
||||
},
|
||||
"results": sorted(results, key=lambda row: str(row["id"])),
|
||||
}
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
json.dump(payload, f, ensure_ascii=False, indent=2)
|
||||
|
||||
|
||||
def call_model(
|
||||
*,
|
||||
model: str,
|
||||
system: str,
|
||||
user: str,
|
||||
max_completion_tokens: int | None,
|
||||
reasoning_effort: str | None,
|
||||
) -> str:
|
||||
last_error: Exception | None = None
|
||||
for attempt in range(5):
|
||||
try:
|
||||
set_reasoning_effort(reasoning_effort)
|
||||
raw, _ = chat_with_deployment(
|
||||
deployment=model,
|
||||
system=system,
|
||||
user=user,
|
||||
max_completion_tokens=max_completion_tokens if max_completion_tokens and max_completion_tokens > 0 else 4096,
|
||||
retries=1,
|
||||
stage="rollout",
|
||||
)
|
||||
return str(raw or "")
|
||||
except Exception as exc: # noqa: BLE001
|
||||
last_error = exc
|
||||
if attempt == 4:
|
||||
break
|
||||
time.sleep(min(2 ** attempt, 10))
|
||||
raise RuntimeError(f"LLM call failed after retries: {last_error}")
|
||||
|
||||
|
||||
def evaluate_one(
|
||||
item: dict,
|
||||
*,
|
||||
mode: str,
|
||||
model: str,
|
||||
skill_content: str,
|
||||
max_completion_tokens: int,
|
||||
reasoning_effort: str | None,
|
||||
seed: int,
|
||||
) -> dict:
|
||||
shuffled_choices, correct_choice = shuffle_choices(item, seed)
|
||||
|
||||
if mode == "official":
|
||||
system = "You are an expert mathematician. Answer accurately."
|
||||
user = official_format_mcq_prompt(item["question"], shuffled_choices)
|
||||
effective_max_completion_tokens = max_completion_tokens if max_completion_tokens > 0 else None
|
||||
else:
|
||||
materialized = dict(item)
|
||||
materialized["choices"] = shuffled_choices
|
||||
materialized["correct_choice"] = correct_choice
|
||||
system = _build_system(skill_content)
|
||||
user = _build_user(materialized, use_theorem=False, use_sketch=False)
|
||||
effective_max_completion_tokens = max_completion_tokens if max_completion_tokens > 0 else 768
|
||||
|
||||
t0 = time.time()
|
||||
response = call_model(
|
||||
model=model,
|
||||
system=system,
|
||||
user=user,
|
||||
max_completion_tokens=effective_max_completion_tokens,
|
||||
reasoning_effort=reasoning_effort,
|
||||
)
|
||||
elapsed = time.time() - t0
|
||||
|
||||
if mode == "official":
|
||||
predicted = official_extract_answer(response)
|
||||
predicted_text = ""
|
||||
for choice in shuffled_choices:
|
||||
if choice["label"] == predicted:
|
||||
predicted_text = choice["text"]
|
||||
break
|
||||
is_correct = predicted == correct_choice["label"]
|
||||
return {
|
||||
"id": item["id"],
|
||||
"question": item["question"],
|
||||
"correct_label": correct_choice["label"],
|
||||
"correct_text": correct_choice["text"],
|
||||
"predicted_label": predicted,
|
||||
"predicted_text": predicted_text,
|
||||
"is_correct": is_correct,
|
||||
"elapsed_seconds": elapsed,
|
||||
"response": response,
|
||||
}
|
||||
|
||||
eval_result = current_evaluate(response, correct_choice, shuffled_choices)
|
||||
return {
|
||||
"id": item["id"],
|
||||
"question": item["question"],
|
||||
"correct_label": correct_choice["label"],
|
||||
"correct_text": correct_choice["text"],
|
||||
"predicted_label": eval_result["predicted_label"],
|
||||
"predicted_text": eval_result["predicted_text"],
|
||||
"is_correct": bool(eval_result["em"]),
|
||||
"elapsed_seconds": elapsed,
|
||||
"response": response,
|
||||
}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
set_backend(args.backend)
|
||||
configure_azure_openai(
|
||||
endpoint=args.azure_endpoint or None,
|
||||
api_version=args.azure_api_version or None,
|
||||
api_key=args.azure_api_key or None,
|
||||
)
|
||||
set_reasoning_effort(args.reasoning_effort)
|
||||
output_path = Path(args.output_json).resolve()
|
||||
skill_content = read_skill(args.skill_path) if args.mode == "current" else ""
|
||||
|
||||
items = load_items(args.data_path)
|
||||
if args.limit:
|
||||
items = items[:args.limit]
|
||||
|
||||
existing = load_existing(output_path) if args.resume else {}
|
||||
pending = [item for item in items if str(item["id"]) not in existing]
|
||||
results = list(existing.values())
|
||||
|
||||
print("=" * 72, flush=True)
|
||||
print("LiveMathematicianBench baseline eval", flush=True)
|
||||
print("=" * 72, flush=True)
|
||||
print(f"Mode: {args.mode}", flush=True)
|
||||
print(f"Model: {args.model}", flush=True)
|
||||
print(f"Reasoning effort: {args.reasoning_effort}", flush=True)
|
||||
print(f"Items: {len(items)} total, {len(pending)} pending, {len(existing)} resumed", flush=True)
|
||||
print(f"Output: {output_path}", flush=True)
|
||||
print("=" * 72, flush=True)
|
||||
|
||||
meta = {
|
||||
"mode": args.mode,
|
||||
"model": args.model,
|
||||
"reasoning_effort": args.reasoning_effort,
|
||||
"seed": args.seed,
|
||||
"max_completion_tokens": args.max_completion_tokens,
|
||||
}
|
||||
|
||||
if not pending:
|
||||
save_results(output_path, meta, results)
|
||||
summary = json.loads(output_path.read_text(encoding="utf-8"))["summary"]
|
||||
print(f"Accuracy: {summary['correct']}/{summary['total']} = {summary['accuracy']:.4f}", flush=True)
|
||||
return
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futs = {
|
||||
ex.submit(
|
||||
evaluate_one,
|
||||
item,
|
||||
mode=args.mode,
|
||||
model=args.model,
|
||||
skill_content=skill_content,
|
||||
max_completion_tokens=args.max_completion_tokens,
|
||||
reasoning_effort=args.reasoning_effort,
|
||||
seed=args.seed,
|
||||
): item
|
||||
for item in pending
|
||||
}
|
||||
completed = 0
|
||||
for fut in as_completed(futs):
|
||||
item = futs[fut]
|
||||
try:
|
||||
row = fut.result()
|
||||
except Exception as exc: # noqa: BLE001
|
||||
row = {
|
||||
"id": item["id"],
|
||||
"question": item["question"],
|
||||
"correct_label": None,
|
||||
"correct_text": item["correct_choice"]["text"],
|
||||
"predicted_label": None,
|
||||
"predicted_text": "",
|
||||
"is_correct": False,
|
||||
"elapsed_seconds": 0.0,
|
||||
"response": "",
|
||||
"error": str(exc),
|
||||
}
|
||||
results.append(row)
|
||||
completed += 1
|
||||
correct = sum(1 for result in results if result.get("is_correct"))
|
||||
total = len(results)
|
||||
print(
|
||||
f"[{completed}/{len(pending)}] id={row['id']} "
|
||||
f"pred={row['predicted_label']} gold={row['correct_label']} "
|
||||
f"acc={correct}/{total}={correct/total:.4f}",
|
||||
flush=True,
|
||||
)
|
||||
save_results(output_path, meta, results)
|
||||
|
||||
summary = json.loads(output_path.read_text(encoding="utf-8"))["summary"]
|
||||
print("=" * 72, flush=True)
|
||||
print(f"Accuracy: {summary['correct']}/{summary['total']} = {summary['accuracy']:.4f}", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+80
-80
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""SkillOpt eval-only: run a single skill on a dataset without training.
|
||||
"""ReflACT eval-only: run a single skill on a dataset without training.
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -29,10 +29,10 @@ from skillopt.model import (
|
||||
configure_claude_code_exec,
|
||||
configure_codex_exec,
|
||||
set_reasoning_effort,
|
||||
set_target_backend,
|
||||
set_target_deployment,
|
||||
set_optimizer_backend,
|
||||
set_optimizer_deployment,
|
||||
set_student_backend,
|
||||
set_student_deployment,
|
||||
set_teacher_backend,
|
||||
set_teacher_deployment,
|
||||
)
|
||||
from skillopt.model.common import default_model_for_backend, normalize_backend_name
|
||||
|
||||
@@ -126,7 +126,7 @@ _BOOL = lambda x: str(x).lower() in ("true", "1", "yes") # noqa: E731
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
p = argparse.ArgumentParser(description="SkillOpt eval-only")
|
||||
p = argparse.ArgumentParser(description="ReflACT eval-only")
|
||||
p.add_argument("--config", type=str, required=True)
|
||||
p.add_argument("--skill", type=str, required=True,
|
||||
help="Path to skill .md file to evaluate")
|
||||
@@ -138,10 +138,10 @@ def parse_args() -> argparse.Namespace:
|
||||
p.add_argument("--env", type=str)
|
||||
p.add_argument("--backend", type=str,
|
||||
choices=["azure_openai", "codex", "codex_exec", "claude", "claude_chat", "claude_code_exec"])
|
||||
p.add_argument("--optimizer_model", type=str)
|
||||
p.add_argument("--target_model", type=str)
|
||||
p.add_argument("--optimizer_backend", type=str)
|
||||
p.add_argument("--target_backend", type=str)
|
||||
p.add_argument("--teacher_model", type=str)
|
||||
p.add_argument("--student_model", type=str)
|
||||
p.add_argument("--teacher_backend", type=str)
|
||||
p.add_argument("--student_backend", type=str)
|
||||
p.add_argument("--reasoning_effort", type=str,
|
||||
choices=["", "low", "medium", "high", "xhigh", "max"])
|
||||
p.add_argument("--azure_endpoint", type=str)
|
||||
@@ -153,18 +153,18 @@ def parse_args() -> argparse.Namespace:
|
||||
p.add_argument("--azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_api_version", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_api_key", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--target_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--target_azure_openai_api_version", type=str)
|
||||
p.add_argument("--target_azure_openai_api_key", type=str)
|
||||
p.add_argument("--target_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--target_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--target_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--teacher_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--teacher_azure_openai_api_version", type=str)
|
||||
p.add_argument("--teacher_azure_openai_api_key", type=str)
|
||||
p.add_argument("--teacher_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--teacher_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--teacher_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--student_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--student_azure_openai_api_version", type=str)
|
||||
p.add_argument("--student_azure_openai_api_key", type=str)
|
||||
p.add_argument("--student_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--student_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--student_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--codex_exec_path", type=str)
|
||||
p.add_argument("--codex_exec_sandbox", type=str)
|
||||
p.add_argument("--codex_exec_profile", type=str)
|
||||
@@ -214,10 +214,10 @@ def main() -> None:
|
||||
from skillopt.config import apply_overrides
|
||||
_MAP = {
|
||||
"backend": "model.backend",
|
||||
"optimizer_model": "model.optimizer",
|
||||
"target_model": "model.target",
|
||||
"optimizer_backend": "model.optimizer_backend",
|
||||
"target_backend": "model.target_backend",
|
||||
"teacher_model": "model.teacher",
|
||||
"student_model": "model.student",
|
||||
"teacher_backend": "model.teacher_backend",
|
||||
"student_backend": "model.student_backend",
|
||||
"reasoning_effort": "model.reasoning_effort",
|
||||
"azure_endpoint": "model.azure_endpoint",
|
||||
"azure_api_version": "model.azure_api_version",
|
||||
@@ -228,18 +228,18 @@ def main() -> None:
|
||||
"azure_openai_auth_mode": "model.azure_openai_auth_mode",
|
||||
"azure_openai_ad_scope": "model.azure_openai_ad_scope",
|
||||
"azure_openai_managed_identity_client_id": "model.azure_openai_managed_identity_client_id",
|
||||
"optimizer_azure_openai_endpoint": "model.optimizer_azure_openai_endpoint",
|
||||
"optimizer_azure_openai_api_version": "model.optimizer_azure_openai_api_version",
|
||||
"optimizer_azure_openai_api_key": "model.optimizer_azure_openai_api_key",
|
||||
"optimizer_azure_openai_auth_mode": "model.optimizer_azure_openai_auth_mode",
|
||||
"optimizer_azure_openai_ad_scope": "model.optimizer_azure_openai_ad_scope",
|
||||
"optimizer_azure_openai_managed_identity_client_id": "model.optimizer_azure_openai_managed_identity_client_id",
|
||||
"target_azure_openai_endpoint": "model.target_azure_openai_endpoint",
|
||||
"target_azure_openai_api_version": "model.target_azure_openai_api_version",
|
||||
"target_azure_openai_api_key": "model.target_azure_openai_api_key",
|
||||
"target_azure_openai_auth_mode": "model.target_azure_openai_auth_mode",
|
||||
"target_azure_openai_ad_scope": "model.target_azure_openai_ad_scope",
|
||||
"target_azure_openai_managed_identity_client_id": "model.target_azure_openai_managed_identity_client_id",
|
||||
"teacher_azure_openai_endpoint": "model.teacher_azure_openai_endpoint",
|
||||
"teacher_azure_openai_api_version": "model.teacher_azure_openai_api_version",
|
||||
"teacher_azure_openai_api_key": "model.teacher_azure_openai_api_key",
|
||||
"teacher_azure_openai_auth_mode": "model.teacher_azure_openai_auth_mode",
|
||||
"teacher_azure_openai_ad_scope": "model.teacher_azure_openai_ad_scope",
|
||||
"teacher_azure_openai_managed_identity_client_id": "model.teacher_azure_openai_managed_identity_client_id",
|
||||
"student_azure_openai_endpoint": "model.student_azure_openai_endpoint",
|
||||
"student_azure_openai_api_version": "model.student_azure_openai_api_version",
|
||||
"student_azure_openai_api_key": "model.student_azure_openai_api_key",
|
||||
"student_azure_openai_auth_mode": "model.student_azure_openai_auth_mode",
|
||||
"student_azure_openai_ad_scope": "model.student_azure_openai_ad_scope",
|
||||
"student_azure_openai_managed_identity_client_id": "model.student_azure_openai_managed_identity_client_id",
|
||||
"codex_exec_path": "model.codex_exec_path",
|
||||
"codex_exec_sandbox": "model.codex_exec_sandbox",
|
||||
"codex_exec_profile": "model.codex_exec_profile",
|
||||
@@ -288,7 +288,7 @@ def main() -> None:
|
||||
explicit_backend = str(option).split("=", 1)[1].strip()
|
||||
break
|
||||
|
||||
backend = normalize_backend_name(cfg.get("model_backend") or cfg.get("target_backend") or "azure_openai")
|
||||
backend = normalize_backend_name(cfg.get("model_backend") or cfg.get("student_backend") or "azure_openai")
|
||||
|
||||
def _has_model_override(dotted_key: str, legacy_key: str) -> bool:
|
||||
if getattr(args, legacy_key, None) is not None:
|
||||
@@ -303,43 +303,43 @@ def main() -> None:
|
||||
backend = normalize_backend_name(explicit_backend)
|
||||
cfg["model_backend"] = backend
|
||||
if backend in {"claude", "claude_chat"}:
|
||||
cfg.setdefault("optimizer_backend", "claude_chat")
|
||||
cfg.setdefault("target_backend", "claude_chat")
|
||||
cfg.setdefault("teacher_backend", "claude_chat")
|
||||
cfg.setdefault("student_backend", "claude_chat")
|
||||
elif backend in {"codex", "codex_exec"}:
|
||||
cfg.setdefault("optimizer_backend", "openai_chat")
|
||||
cfg.setdefault("target_backend", "codex_exec")
|
||||
cfg.setdefault("teacher_backend", "openai_chat")
|
||||
cfg.setdefault("student_backend", "codex_exec")
|
||||
elif backend == "claude_code_exec":
|
||||
cfg.setdefault("optimizer_backend", "openai_chat")
|
||||
cfg.setdefault("target_backend", "claude_code_exec")
|
||||
cfg.setdefault("teacher_backend", "openai_chat")
|
||||
cfg.setdefault("student_backend", "claude_code_exec")
|
||||
else:
|
||||
cfg.setdefault("optimizer_backend", "openai_chat")
|
||||
cfg.setdefault("target_backend", "openai_chat")
|
||||
cfg.setdefault("teacher_backend", "openai_chat")
|
||||
cfg.setdefault("student_backend", "openai_chat")
|
||||
else:
|
||||
cfg.setdefault("optimizer_backend", "openai_chat")
|
||||
cfg.setdefault("target_backend", "openai_chat")
|
||||
cfg.setdefault("teacher_backend", "openai_chat")
|
||||
cfg.setdefault("student_backend", "openai_chat")
|
||||
|
||||
if cfg.get("optimizer_backend") == "claude_chat":
|
||||
if cfg.get("teacher_backend") == "claude_chat":
|
||||
if (
|
||||
str(cfg.get("optimizer_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.optimizer", "optimizer_model")
|
||||
str(cfg.get("teacher_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.teacher", "teacher_model")
|
||||
):
|
||||
cfg["optimizer_model"] = default_model_for_backend("claude_chat")
|
||||
if cfg.get("target_backend") == "claude_chat":
|
||||
cfg["teacher_model"] = default_model_for_backend("claude_chat")
|
||||
if cfg.get("student_backend") == "claude_chat":
|
||||
if (
|
||||
str(cfg.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.target", "target_model")
|
||||
str(cfg.get("student_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.student", "student_model")
|
||||
):
|
||||
cfg["target_model"] = default_model_for_backend("claude_chat")
|
||||
if cfg.get("target_backend") == "claude_code_exec":
|
||||
cfg["student_model"] = default_model_for_backend("claude_chat")
|
||||
if cfg.get("student_backend") == "claude_code_exec":
|
||||
if (
|
||||
str(cfg.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.target", "target_model")
|
||||
str(cfg.get("student_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.student", "student_model")
|
||||
):
|
||||
cfg["target_model"] = default_model_for_backend("claude_chat")
|
||||
cfg["student_model"] = default_model_for_backend("claude_chat")
|
||||
|
||||
if not cfg.get("out_root"):
|
||||
env = cfg.get("env", "unknown")
|
||||
model = cfg.get("target_model", "unknown").replace("/", "-")
|
||||
model = cfg.get("student_model", "unknown").replace("/", "-")
|
||||
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
cfg["out_root"] = os.path.join("outputs", f"eval_{env}_{model}_{ts}")
|
||||
|
||||
@@ -362,27 +362,27 @@ def main() -> None:
|
||||
auth_mode=cfg.get("azure_openai_auth_mode") or None,
|
||||
ad_scope=cfg.get("azure_openai_ad_scope") or None,
|
||||
managed_identity_client_id=cfg.get("azure_openai_managed_identity_client_id") or None,
|
||||
optimizer_endpoint=cfg.get("optimizer_azure_openai_endpoint") or None,
|
||||
optimizer_api_version=cfg.get("optimizer_azure_openai_api_version") or None,
|
||||
optimizer_api_key=cfg.get("optimizer_azure_openai_api_key") or None,
|
||||
optimizer_auth_mode=cfg.get("optimizer_azure_openai_auth_mode") or None,
|
||||
optimizer_ad_scope=cfg.get("optimizer_azure_openai_ad_scope") or None,
|
||||
optimizer_managed_identity_client_id=(
|
||||
cfg.get("optimizer_azure_openai_managed_identity_client_id") or None
|
||||
teacher_endpoint=cfg.get("teacher_azure_openai_endpoint") or None,
|
||||
teacher_api_version=cfg.get("teacher_azure_openai_api_version") or None,
|
||||
teacher_api_key=cfg.get("teacher_azure_openai_api_key") or None,
|
||||
teacher_auth_mode=cfg.get("teacher_azure_openai_auth_mode") or None,
|
||||
teacher_ad_scope=cfg.get("teacher_azure_openai_ad_scope") or None,
|
||||
teacher_managed_identity_client_id=(
|
||||
cfg.get("teacher_azure_openai_managed_identity_client_id") or None
|
||||
),
|
||||
target_endpoint=cfg.get("target_azure_openai_endpoint") or None,
|
||||
target_api_version=cfg.get("target_azure_openai_api_version") or None,
|
||||
target_api_key=cfg.get("target_azure_openai_api_key") or None,
|
||||
target_auth_mode=cfg.get("target_azure_openai_auth_mode") or None,
|
||||
target_ad_scope=cfg.get("target_azure_openai_ad_scope") or None,
|
||||
target_managed_identity_client_id=(
|
||||
cfg.get("target_azure_openai_managed_identity_client_id") or None
|
||||
student_endpoint=cfg.get("student_azure_openai_endpoint") or None,
|
||||
student_api_version=cfg.get("student_azure_openai_api_version") or None,
|
||||
student_api_key=cfg.get("student_azure_openai_api_key") or None,
|
||||
student_auth_mode=cfg.get("student_azure_openai_auth_mode") or None,
|
||||
student_ad_scope=cfg.get("student_azure_openai_ad_scope") or None,
|
||||
student_managed_identity_client_id=(
|
||||
cfg.get("student_azure_openai_managed_identity_client_id") or None
|
||||
),
|
||||
)
|
||||
set_optimizer_backend(cfg.get("optimizer_backend", "openai_chat"))
|
||||
set_target_backend(cfg.get("target_backend", "openai_chat"))
|
||||
set_optimizer_deployment(cfg.get("optimizer_model", default_model_for_backend(backend)))
|
||||
set_target_deployment(cfg.get("target_model", default_model_for_backend(backend)))
|
||||
set_teacher_backend(cfg.get("teacher_backend", "openai_chat"))
|
||||
set_student_backend(cfg.get("student_backend", "openai_chat"))
|
||||
set_teacher_deployment(cfg.get("teacher_model", default_model_for_backend(backend)))
|
||||
set_student_deployment(cfg.get("student_model", default_model_for_backend(backend)))
|
||||
configure_codex_exec(
|
||||
path=cfg.get("codex_exec_path", "codex"),
|
||||
sandbox=cfg.get("codex_exec_sandbox", "workspace-write"),
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Standalone eval: CUSTOM prompt (with Critical Rules) on verified-400.
|
||||
|
||||
Usage:
|
||||
python scripts/eval_prompt_custom.py --workers 8
|
||||
python scripts/eval_prompt_custom.py --workers 32 --limit 20
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import time
|
||||
import traceback
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed, TimeoutError as FuturesTimeoutError
|
||||
|
||||
import openpyxl
|
||||
|
||||
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
_PROJECT_ROOT = os.path.dirname(_SCRIPT_DIR)
|
||||
if _PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, _PROJECT_ROOT)
|
||||
|
||||
from skillopt.model import (
|
||||
chat_messages_with_deployment,
|
||||
configure_azure_openai,
|
||||
set_backend,
|
||||
set_student_deployment,
|
||||
)
|
||||
from skillopt.envs.spreadsheetbench.evaluator import evaluate
|
||||
|
||||
|
||||
# ── Config ──────────────────────────────────────────────────────────────────
|
||||
|
||||
DATA_ROOT = "/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH = os.path.join(DATA_ROOT, "dataset.json")
|
||||
MODEL = "gpt-5-mini"
|
||||
|
||||
# ── Custom Prompt (with Critical Rules) ─────────────────────────────────────
|
||||
|
||||
_SYSTEM_TEMPLATE = """\
|
||||
You are an expert Python programmer specializing in spreadsheet manipulation.
|
||||
You will be given a user instruction together with a preview of an input .xlsx file.
|
||||
Your job is to write a single self-contained Python script that reads the input file
|
||||
at the path stored in the variable INPUT_PATH, performs the requested manipulation,
|
||||
and saves the result to OUTPUT_PATH.
|
||||
|
||||
## Critical Rules
|
||||
1. NEVER write Excel formulas to cells. openpyxl does NOT compute formulas —
|
||||
the evaluator will see None. Compute results in Python and write literal values.
|
||||
2. Use only: standard library, openpyxl, pandas.
|
||||
3. Do NOT hardcode cell values from the preview — iterate over actual rows.
|
||||
4. The script must define INPUT_PATH and OUTPUT_PATH at the top.
|
||||
|
||||
{skill_section}\
|
||||
Return ONLY the Python code inside a single ```python ... ``` fenced block.
|
||||
"""
|
||||
|
||||
|
||||
def build_system(skill_content: str = "") -> str:
|
||||
if skill_content.strip():
|
||||
skill_section = f"## Skill\n{skill_content.strip()}\n\n"
|
||||
else:
|
||||
skill_section = ""
|
||||
return _SYSTEM_TEMPLATE.format(skill_section=skill_section)
|
||||
|
||||
|
||||
def build_user(instruction, input_xlsx, instruction_type="", answer_position=""):
|
||||
try:
|
||||
preview = _preview_workbook(input_xlsx)
|
||||
except Exception as e:
|
||||
preview = f"(failed to preview: {e})"
|
||||
extra = ""
|
||||
if instruction_type:
|
||||
extra += f"\nInstruction type: {instruction_type}"
|
||||
if answer_position:
|
||||
extra += f"\nExpected answer position: {answer_position}"
|
||||
return (
|
||||
f"# Instruction\n{instruction}\n{extra}\n\n"
|
||||
f"# Input spreadsheet preview\n{preview}\n\n"
|
||||
"# Task\n"
|
||||
"Write a Python script that reads the workbook from the variable `INPUT_PATH`, "
|
||||
"applies the instruction, and writes the modified workbook to `OUTPUT_PATH`. "
|
||||
"Preserve all other cells unchanged. "
|
||||
"The preview may be truncated — do not hardcode row counts; "
|
||||
"iterate over all actual rows in the workbook instead.\n"
|
||||
"Return only a ```python``` code block."
|
||||
)
|
||||
|
||||
|
||||
# ── Shared utilities ────────────────────────────────────────────────────────
|
||||
|
||||
def _preview_workbook(path, max_rows=5, max_cols=20):
|
||||
wb = openpyxl.load_workbook(path, data_only=False)
|
||||
chunks = []
|
||||
for sn in wb.sheetnames:
|
||||
ws = wb[sn]
|
||||
chunks.append(f"## Sheet: {sn} (dim={ws.dimensions}, max_row={ws.max_row}, max_col={ws.max_column})")
|
||||
for row in ws.iter_rows(min_row=1, max_row=min(ws.max_row, max_rows),
|
||||
max_col=min(ws.max_column, max_cols), values_only=False):
|
||||
cells = []
|
||||
for c in row:
|
||||
v = c.value
|
||||
s = "" if v is None else str(v)
|
||||
if len(s) > 40: s = s[:37] + "..."
|
||||
cells.append(f"{c.coordinate}={s}")
|
||||
chunks.append(" | ".join(cells))
|
||||
if ws.max_row > max_rows:
|
||||
chunks.append(f"... ({ws.max_row - max_rows} more rows)")
|
||||
chunks.append("")
|
||||
wb.close()
|
||||
return "\n".join(chunks)
|
||||
|
||||
|
||||
def extract_code(text):
|
||||
if "```" not in text:
|
||||
return text.strip()
|
||||
start = text.find("```")
|
||||
nl = text.find("\n", start)
|
||||
end = text.find("```", nl + 1)
|
||||
if nl == -1 or end == -1:
|
||||
return text.strip()
|
||||
return text[nl + 1:end].strip()
|
||||
|
||||
|
||||
_PATH_RE = re.compile(r'^\s*(INPUT_PATH|OUTPUT_PATH)\s*=\s*.+$', re.MULTILINE)
|
||||
|
||||
def strip_paths(code):
|
||||
return _PATH_RE.sub("", code)
|
||||
|
||||
|
||||
RUNNER_TEMPLATE = textwrap.dedent("""
|
||||
import os, sys, traceback
|
||||
INPUT_PATH = {input_path!r}
|
||||
OUTPUT_PATH = {output_path!r}
|
||||
try:
|
||||
{code_indented}
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
sys.exit(2)
|
||||
""")
|
||||
|
||||
|
||||
def run_code(code, input_path, output_path, timeout=120):
|
||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
||||
cleaned = strip_paths(code)
|
||||
indented = textwrap.indent(cleaned, " ")
|
||||
script = RUNNER_TEMPLATE.format(input_path=input_path, output_path=output_path, code_indented=indented)
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
|
||||
f.write(script)
|
||||
tmp = f.name
|
||||
try:
|
||||
proc = subprocess.run([sys.executable, tmp], capture_output=True, text=True, timeout=timeout)
|
||||
if proc.returncode != 0:
|
||||
return False, (proc.stdout + "\n" + proc.stderr).strip()
|
||||
if not os.path.exists(output_path):
|
||||
return False, "output file was not created"
|
||||
return True, ""
|
||||
except subprocess.TimeoutExpired:
|
||||
return False, f"timeout after {timeout}s"
|
||||
finally:
|
||||
try: os.unlink(tmp)
|
||||
except OSError: pass
|
||||
|
||||
|
||||
def find_test_cases(task_dir):
|
||||
cases = []
|
||||
for ip in sorted(glob.glob(os.path.join(task_dir, "*_input.xlsx"))):
|
||||
no = os.path.basename(ip).split("_", 1)[0]
|
||||
ap = ip.replace("_input.xlsx", "_answer.xlsx")
|
||||
if os.path.exists(ap): cases.append((no, ip, ap))
|
||||
for ip in sorted(glob.glob(os.path.join(task_dir, "*_init.xlsx"))):
|
||||
no = os.path.basename(ip).split("_", 1)[0]
|
||||
ap = ip.replace("_init.xlsx", "_golden.xlsx")
|
||||
if os.path.exists(ap): cases.append((no, ip, ap))
|
||||
if not cases:
|
||||
bare_init = os.path.join(task_dir, "initial.xlsx")
|
||||
bare_gold = os.path.join(task_dir, "golden.xlsx")
|
||||
if os.path.exists(bare_init) and os.path.exists(bare_gold):
|
||||
cases.append(("1", bare_init, bare_gold))
|
||||
return cases
|
||||
|
||||
|
||||
def load_items(path):
|
||||
if path.endswith(".json"):
|
||||
with open(path) as f:
|
||||
data = json.load(f)
|
||||
if isinstance(data, dict):
|
||||
data = data.get("data") or list(data.values())
|
||||
return list(data)
|
||||
items = []
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line: items.append(json.loads(line))
|
||||
return items
|
||||
|
||||
|
||||
# ── LLM call ────────────────────────────────────────────────────────────────
|
||||
|
||||
def llm_call(messages, deployment, max_tokens=16384, retries=5, llm_timeout=120):
|
||||
raw, _ = chat_messages_with_deployment(
|
||||
deployment=deployment,
|
||||
messages=messages,
|
||||
max_completion_tokens=max_tokens,
|
||||
retries=retries,
|
||||
stage="rollout",
|
||||
timeout=llm_timeout,
|
||||
)
|
||||
return str(raw or "")
|
||||
|
||||
|
||||
# ── Process one task ────────────────────────────────────────────────────────
|
||||
|
||||
def process_one(item, data_root, out_root, model):
|
||||
task_id = str(item["id"])
|
||||
instruction = item["instruction"]
|
||||
instruction_type = item.get("instruction_type", "")
|
||||
answer_position = item.get("answer_position", "")
|
||||
answer_sheet = item.get("answer_sheet", "")
|
||||
if answer_position and answer_sheet and "!" not in answer_position:
|
||||
answer_position = f"{answer_sheet}!{answer_position}"
|
||||
|
||||
sp = item.get("spreadsheet_path", f"spreadsheet/{task_id}")
|
||||
task_dir = sp if os.path.isabs(sp) else os.path.join(data_root, sp)
|
||||
|
||||
result = {"id": task_id, "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": "", "error": ""}
|
||||
try:
|
||||
cases = find_test_cases(task_dir)
|
||||
result["n_cases"] = len(cases)
|
||||
if not cases:
|
||||
result["fail_reason"] = "no-test-cases"
|
||||
return result
|
||||
|
||||
task_out = os.path.join(out_root, "predictions", task_id)
|
||||
os.makedirs(task_out, exist_ok=True)
|
||||
|
||||
# LLM call
|
||||
system = build_system("")
|
||||
user = build_user(instruction, cases[0][1], instruction_type, answer_position)
|
||||
messages = [{"role": "system", "content": system}, {"role": "user", "content": user}]
|
||||
|
||||
raw = llm_call(messages, model)
|
||||
time.sleep(3)
|
||||
code = extract_code(raw)
|
||||
|
||||
with open(os.path.join(task_out, "code.py"), "w") as f: f.write(code)
|
||||
with open(os.path.join(task_out, "raw.txt"), "w") as f: f.write(raw)
|
||||
|
||||
if not code.strip():
|
||||
result["fail_reason"] = "empty-code"
|
||||
return result
|
||||
|
||||
# Execute + evaluate each test case
|
||||
for no, ip, ap in cases:
|
||||
pred = os.path.join(task_out, f"{no}_pred.xlsx")
|
||||
ok_exec, err = run_code(code, ip, pred)
|
||||
if not ok_exec:
|
||||
if not result["fail_reason"]:
|
||||
result["fail_reason"] = f"exec: {err[:200]}"
|
||||
continue
|
||||
try:
|
||||
ev = evaluate(pred, ap, instruction_type, answer_position)
|
||||
except Exception as e:
|
||||
ev = {"ok": False, "reason": str(e)}
|
||||
if ev["ok"]:
|
||||
result["n_pass"] += 1
|
||||
|
||||
nc, np = result["n_cases"], result["n_pass"]
|
||||
result["soft"] = np / nc if nc else 0.0
|
||||
result["hard"] = 1 if nc > 0 and np == nc else 0
|
||||
result["ok"] = bool(result["hard"])
|
||||
if result["ok"]: result["fail_reason"] = ""
|
||||
return result
|
||||
except Exception as e:
|
||||
result["fail_reason"] = f"unexpected: {e}"
|
||||
result["error"] = traceback.format_exc()
|
||||
return result
|
||||
|
||||
|
||||
# ── Main ────────────────────────────────────────────────────────────────────
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Eval CUSTOM prompt on verified-400")
|
||||
ap.add_argument("--model", default=MODEL)
|
||||
ap.add_argument("--backend", choices=["azure_openai", "codex", "claude"], default="azure_openai")
|
||||
ap.add_argument("--azure_endpoint", default="")
|
||||
ap.add_argument("--azure_api_version", default="")
|
||||
ap.add_argument("--azure_api_key", default="")
|
||||
ap.add_argument("--workers", type=int, default=8)
|
||||
ap.add_argument("--limit", type=int, default=0)
|
||||
ap.add_argument("--out_root", default="")
|
||||
args = ap.parse_args()
|
||||
|
||||
set_backend(args.backend)
|
||||
configure_azure_openai(
|
||||
endpoint=args.azure_endpoint or None,
|
||||
api_version=args.azure_api_version or None,
|
||||
api_key=args.azure_api_key or None,
|
||||
)
|
||||
set_student_deployment(args.model)
|
||||
ts = time.strftime("%Y%m%d_%H%M%S")
|
||||
out_root = args.out_root or os.path.join(_PROJECT_ROOT, "outputs", f"prompt_custom_{args.model}_{ts}")
|
||||
out_root = os.path.abspath(out_root)
|
||||
os.makedirs(out_root, exist_ok=True)
|
||||
|
||||
items = load_items(JSONL_PATH)
|
||||
if args.limit: items = items[:args.limit]
|
||||
|
||||
print(f"{'='*60}")
|
||||
print(f" Prompt: CUSTOM (Critical Rules)")
|
||||
print(f" Model: {args.model}")
|
||||
print(f" Items: {len(items)}")
|
||||
print(f" Output: {out_root}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
t0 = time.time()
|
||||
results = []
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futs = {ex.submit(process_one, it, DATA_ROOT, out_root, args.model): it for it in items}
|
||||
for i, fut in enumerate(as_completed(futs), 1):
|
||||
item = futs[fut]
|
||||
try:
|
||||
res = fut.result(timeout=300)
|
||||
except FuturesTimeoutError:
|
||||
res = {"id": str(item["id"]), "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": "timeout"}
|
||||
except Exception as e:
|
||||
res = {"id": str(item["id"]), "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": str(e)}
|
||||
results.append(res)
|
||||
status = "PASS" if res.get("hard") else "FAIL"
|
||||
dt = time.time() - t0
|
||||
print(f" {i}/{len(items)} id={res['id']:<10} {status} cases={res.get('n_pass',0)}/{res.get('n_cases',0)} dt={dt:.0f}s")
|
||||
|
||||
# Summary
|
||||
hard_sum = sum(r.get("hard", 0) for r in results)
|
||||
soft_sum = sum(r.get("soft", 0.0) for r in results)
|
||||
n = len(results)
|
||||
print(f"\n{'='*60}")
|
||||
print(f" CUSTOM prompt: hard={hard_sum}/{n}={hard_sum/n:.4f} soft={soft_sum/n:.4f}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
with open(os.path.join(out_root, "results.jsonl"), "w") as f:
|
||||
for r in results:
|
||||
f.write(json.dumps(r, ensure_ascii=False) + "\n")
|
||||
with open(os.path.join(out_root, "summary.json"), "w") as f:
|
||||
json.dump({"prompt": "custom", "model": args.model, "n": n,
|
||||
"hard": hard_sum/n, "soft": soft_sum/n}, f, indent=2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,352 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Standalone eval: OFFICIAL prompt (SpreadsheetBench original) on verified-400.
|
||||
|
||||
Usage:
|
||||
python scripts/eval_prompt_official.py --workers 8
|
||||
python scripts/eval_prompt_official.py --workers 32 --limit 20
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import time
|
||||
import traceback
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed, TimeoutError as FuturesTimeoutError
|
||||
|
||||
import openpyxl
|
||||
|
||||
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
_PROJECT_ROOT = os.path.dirname(_SCRIPT_DIR)
|
||||
if _PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, _PROJECT_ROOT)
|
||||
|
||||
from skillopt.model import (
|
||||
chat_messages_with_deployment,
|
||||
configure_azure_openai,
|
||||
set_backend,
|
||||
set_student_deployment,
|
||||
)
|
||||
from skillopt.envs.spreadsheetbench.evaluator import evaluate
|
||||
|
||||
|
||||
# ── Config ──────────────────────────────────────────────────────────────────
|
||||
|
||||
DATA_ROOT = "/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH = os.path.join(DATA_ROOT, "dataset.json")
|
||||
MODEL = "gpt-5-mini"
|
||||
|
||||
# ── Official Prompt (from SpreadsheetBench src/prompt.py) ───────────────────
|
||||
|
||||
_SYSTEM_PROMPT = (
|
||||
"You are an expert Python programmer specializing in spreadsheet manipulation. "
|
||||
"You will be given a user instruction together with a preview of an input .xlsx file. "
|
||||
"Your job is to write a single self-contained Python script that reads the input file "
|
||||
"at the path stored in the variable INPUT_PATH, performs the requested manipulation, "
|
||||
"and saves the result to OUTPUT_PATH. Use only the standard library, openpyxl, and pandas. "
|
||||
"Do not print anything. Do not use input(). Do not hardcode file paths. "
|
||||
"Return ONLY the Python code inside a single ```python ... ``` fenced block."
|
||||
)
|
||||
|
||||
|
||||
def build_system(skill_content: str = "") -> str:
|
||||
base = _SYSTEM_PROMPT
|
||||
if skill_content.strip():
|
||||
base += f"\n\n## Skill\n{skill_content.strip()}"
|
||||
return base
|
||||
|
||||
|
||||
def build_user(instruction, input_xlsx, instruction_type="", answer_position=""):
|
||||
try:
|
||||
preview = _preview_workbook(input_xlsx)
|
||||
except Exception as e:
|
||||
preview = f"(failed to preview: {e})"
|
||||
extra = ""
|
||||
if instruction_type:
|
||||
extra += f"\nInstruction type: {instruction_type}"
|
||||
if answer_position:
|
||||
extra += f"\nExpected answer position: {answer_position}"
|
||||
return (
|
||||
f"# Instruction\n{instruction}\n{extra}\n\n"
|
||||
f"# Input spreadsheet preview\n{preview}\n\n"
|
||||
"# Task\n"
|
||||
"Write a Python script that reads the workbook from the variable `INPUT_PATH`, "
|
||||
"applies the instruction, and writes the modified workbook to `OUTPUT_PATH`. "
|
||||
"Preserve all other cells unchanged. "
|
||||
"The preview may be truncated — do not hardcode row counts or assume the data ends at the last previewed row; "
|
||||
"iterate over all actual rows in the workbook instead. "
|
||||
"Return only a ```python``` code block."
|
||||
)
|
||||
|
||||
|
||||
# ── Shared utilities (identical to custom version) ──────────────────────────
|
||||
|
||||
def _preview_workbook(path, max_rows=5, max_cols=20):
|
||||
wb = openpyxl.load_workbook(path, data_only=False)
|
||||
chunks = []
|
||||
for sn in wb.sheetnames:
|
||||
ws = wb[sn]
|
||||
chunks.append(f"## Sheet: {sn} (dim={ws.dimensions}, max_row={ws.max_row}, max_col={ws.max_column})")
|
||||
for row in ws.iter_rows(min_row=1, max_row=min(ws.max_row, max_rows),
|
||||
max_col=min(ws.max_column, max_cols), values_only=False):
|
||||
cells = []
|
||||
for c in row:
|
||||
v = c.value
|
||||
s = "" if v is None else str(v)
|
||||
if len(s) > 40: s = s[:37] + "..."
|
||||
cells.append(f"{c.coordinate}={s}")
|
||||
chunks.append(" | ".join(cells))
|
||||
if ws.max_row > max_rows:
|
||||
chunks.append(f"... ({ws.max_row - max_rows} more rows)")
|
||||
chunks.append("")
|
||||
wb.close()
|
||||
return "\n".join(chunks)
|
||||
|
||||
|
||||
def extract_code(text):
|
||||
if "```" not in text:
|
||||
return text.strip()
|
||||
start = text.find("```")
|
||||
nl = text.find("\n", start)
|
||||
end = text.find("```", nl + 1)
|
||||
if nl == -1 or end == -1:
|
||||
return text.strip()
|
||||
return text[nl + 1:end].strip()
|
||||
|
||||
|
||||
_PATH_RE = re.compile(r'^\s*(INPUT_PATH|OUTPUT_PATH)\s*=\s*.+$', re.MULTILINE)
|
||||
|
||||
def strip_paths(code):
|
||||
return _PATH_RE.sub("", code)
|
||||
|
||||
|
||||
RUNNER_TEMPLATE = textwrap.dedent("""
|
||||
import os, sys, traceback
|
||||
INPUT_PATH = {input_path!r}
|
||||
OUTPUT_PATH = {output_path!r}
|
||||
try:
|
||||
{code_indented}
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
sys.exit(2)
|
||||
""")
|
||||
|
||||
|
||||
def run_code(code, input_path, output_path, timeout=120):
|
||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
||||
cleaned = strip_paths(code)
|
||||
indented = textwrap.indent(cleaned, " ")
|
||||
script = RUNNER_TEMPLATE.format(input_path=input_path, output_path=output_path, code_indented=indented)
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
|
||||
f.write(script)
|
||||
tmp = f.name
|
||||
try:
|
||||
proc = subprocess.run([sys.executable, tmp], capture_output=True, text=True, timeout=timeout)
|
||||
if proc.returncode != 0:
|
||||
return False, (proc.stdout + "\n" + proc.stderr).strip()
|
||||
if not os.path.exists(output_path):
|
||||
return False, "output file was not created"
|
||||
return True, ""
|
||||
except subprocess.TimeoutExpired:
|
||||
return False, f"timeout after {timeout}s"
|
||||
finally:
|
||||
try: os.unlink(tmp)
|
||||
except OSError: pass
|
||||
|
||||
|
||||
def find_test_cases(task_dir):
|
||||
cases = []
|
||||
for ip in sorted(glob.glob(os.path.join(task_dir, "*_input.xlsx"))):
|
||||
no = os.path.basename(ip).split("_", 1)[0]
|
||||
ap = ip.replace("_input.xlsx", "_answer.xlsx")
|
||||
if os.path.exists(ap): cases.append((no, ip, ap))
|
||||
for ip in sorted(glob.glob(os.path.join(task_dir, "*_init.xlsx"))):
|
||||
no = os.path.basename(ip).split("_", 1)[0]
|
||||
ap = ip.replace("_init.xlsx", "_golden.xlsx")
|
||||
if os.path.exists(ap): cases.append((no, ip, ap))
|
||||
if not cases:
|
||||
bare_init = os.path.join(task_dir, "initial.xlsx")
|
||||
bare_gold = os.path.join(task_dir, "golden.xlsx")
|
||||
if os.path.exists(bare_init) and os.path.exists(bare_gold):
|
||||
cases.append(("1", bare_init, bare_gold))
|
||||
return cases
|
||||
|
||||
|
||||
def load_items(path):
|
||||
if path.endswith(".json"):
|
||||
with open(path) as f:
|
||||
data = json.load(f)
|
||||
if isinstance(data, dict):
|
||||
data = data.get("data") or list(data.values())
|
||||
return list(data)
|
||||
items = []
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line: items.append(json.loads(line))
|
||||
return items
|
||||
|
||||
|
||||
# ── LLM call ────────────────────────────────────────────────────────────────
|
||||
|
||||
def llm_call(messages, deployment, max_tokens=16384, retries=5, llm_timeout=120):
|
||||
raw, _ = chat_messages_with_deployment(
|
||||
deployment=deployment,
|
||||
messages=messages,
|
||||
max_completion_tokens=max_tokens,
|
||||
retries=retries,
|
||||
stage="rollout",
|
||||
timeout=llm_timeout,
|
||||
)
|
||||
return str(raw or "")
|
||||
|
||||
|
||||
# ── Process one task ────────────────────────────────────────────────────────
|
||||
|
||||
def process_one(item, data_root, out_root, model):
|
||||
task_id = str(item["id"])
|
||||
instruction = item["instruction"]
|
||||
instruction_type = item.get("instruction_type", "")
|
||||
answer_position = item.get("answer_position", "")
|
||||
answer_sheet = item.get("answer_sheet", "")
|
||||
if answer_position and answer_sheet and "!" not in answer_position:
|
||||
answer_position = f"{answer_sheet}!{answer_position}"
|
||||
|
||||
sp = item.get("spreadsheet_path", f"spreadsheet/{task_id}")
|
||||
task_dir = sp if os.path.isabs(sp) else os.path.join(data_root, sp)
|
||||
|
||||
result = {"id": task_id, "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": "", "error": ""}
|
||||
try:
|
||||
cases = find_test_cases(task_dir)
|
||||
result["n_cases"] = len(cases)
|
||||
if not cases:
|
||||
result["fail_reason"] = "no-test-cases"
|
||||
return result
|
||||
|
||||
task_out = os.path.join(out_root, "predictions", task_id)
|
||||
os.makedirs(task_out, exist_ok=True)
|
||||
|
||||
# LLM call
|
||||
system = build_system("")
|
||||
user = build_user(instruction, cases[0][1], instruction_type, answer_position)
|
||||
messages = [{"role": "system", "content": system}, {"role": "user", "content": user}]
|
||||
|
||||
raw = llm_call(messages, model)
|
||||
time.sleep(3)
|
||||
code = extract_code(raw)
|
||||
|
||||
with open(os.path.join(task_out, "code.py"), "w") as f: f.write(code)
|
||||
with open(os.path.join(task_out, "raw.txt"), "w") as f: f.write(raw)
|
||||
|
||||
if not code.strip():
|
||||
result["fail_reason"] = "empty-code"
|
||||
return result
|
||||
|
||||
# Execute + evaluate each test case
|
||||
for no, ip, ap in cases:
|
||||
pred = os.path.join(task_out, f"{no}_pred.xlsx")
|
||||
ok_exec, err = run_code(code, ip, pred)
|
||||
if not ok_exec:
|
||||
if not result["fail_reason"]:
|
||||
result["fail_reason"] = f"exec: {err[:200]}"
|
||||
continue
|
||||
try:
|
||||
ev = evaluate(pred, ap, instruction_type, answer_position)
|
||||
except Exception as e:
|
||||
ev = {"ok": False, "reason": str(e)}
|
||||
if ev["ok"]:
|
||||
result["n_pass"] += 1
|
||||
|
||||
nc, np = result["n_cases"], result["n_pass"]
|
||||
result["soft"] = np / nc if nc else 0.0
|
||||
result["hard"] = 1 if nc > 0 and np == nc else 0
|
||||
result["ok"] = bool(result["hard"])
|
||||
if result["ok"]: result["fail_reason"] = ""
|
||||
return result
|
||||
except Exception as e:
|
||||
result["fail_reason"] = f"unexpected: {e}"
|
||||
result["error"] = traceback.format_exc()
|
||||
return result
|
||||
|
||||
|
||||
# ── Main ────────────────────────────────────────────────────────────────────
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Eval OFFICIAL prompt on verified-400")
|
||||
ap.add_argument("--model", default=MODEL)
|
||||
ap.add_argument("--backend", choices=["azure_openai", "codex", "claude"], default="azure_openai")
|
||||
ap.add_argument("--azure_endpoint", default="")
|
||||
ap.add_argument("--azure_api_version", default="")
|
||||
ap.add_argument("--azure_api_key", default="")
|
||||
ap.add_argument("--workers", type=int, default=8)
|
||||
ap.add_argument("--limit", type=int, default=0)
|
||||
ap.add_argument("--out_root", default="")
|
||||
args = ap.parse_args()
|
||||
|
||||
set_backend(args.backend)
|
||||
configure_azure_openai(
|
||||
endpoint=args.azure_endpoint or None,
|
||||
api_version=args.azure_api_version or None,
|
||||
api_key=args.azure_api_key or None,
|
||||
)
|
||||
set_student_deployment(args.model)
|
||||
ts = time.strftime("%Y%m%d_%H%M%S")
|
||||
out_root = args.out_root or os.path.join(_PROJECT_ROOT, "outputs", f"prompt_official_{args.model}_{ts}")
|
||||
out_root = os.path.abspath(out_root)
|
||||
os.makedirs(out_root, exist_ok=True)
|
||||
|
||||
items = load_items(JSONL_PATH)
|
||||
if args.limit: items = items[:args.limit]
|
||||
|
||||
print(f"{'='*60}")
|
||||
print(f" Prompt: OFFICIAL (SpreadsheetBench original)")
|
||||
print(f" Model: {args.model}")
|
||||
print(f" Items: {len(items)}")
|
||||
print(f" Output: {out_root}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
t0 = time.time()
|
||||
results = []
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futs = {ex.submit(process_one, it, DATA_ROOT, out_root, args.model): it for it in items}
|
||||
for i, fut in enumerate(as_completed(futs), 1):
|
||||
item = futs[fut]
|
||||
try:
|
||||
res = fut.result(timeout=300)
|
||||
except FuturesTimeoutError:
|
||||
res = {"id": str(item["id"]), "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": "timeout"}
|
||||
except Exception as e:
|
||||
res = {"id": str(item["id"]), "ok": False, "hard": 0, "soft": 0.0,
|
||||
"n_cases": 0, "n_pass": 0, "fail_reason": str(e)}
|
||||
results.append(res)
|
||||
status = "PASS" if res.get("hard") else "FAIL"
|
||||
dt = time.time() - t0
|
||||
print(f" {i}/{len(items)} id={res['id']:<10} {status} cases={res.get('n_pass',0)}/{res.get('n_cases',0)} dt={dt:.0f}s")
|
||||
|
||||
# Summary
|
||||
hard_sum = sum(r.get("hard", 0) for r in results)
|
||||
soft_sum = sum(r.get("soft", 0.0) for r in results)
|
||||
n = len(results)
|
||||
print(f"\n{'='*60}")
|
||||
print(f" OFFICIAL prompt: hard={hard_sum}/{n}={hard_sum/n:.4f} soft={soft_sum/n:.4f}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
with open(os.path.join(out_root, "results.jsonl"), "w") as f:
|
||||
for r in results:
|
||||
f.write(json.dumps(r, ensure_ascii=False) + "\n")
|
||||
with open(os.path.join(out_root, "summary.json"), "w") as f:
|
||||
json.dump({"prompt": "official", "model": args.model, "n": n,
|
||||
"hard": hard_sum/n, "soft": soft_sum/n}, f, indent=2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# ReflACT3 — SearchQA Eval-Only (验证集 500)
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/eval_searchqa_val500.sh --skill_path outputs/xxx/best_skill.md
|
||||
# bash scripts/eval_searchqa_val500.sh --skill_path outputs/xxx/best_skill.md --workers 32
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5-mini}"
|
||||
|
||||
VAL_PATH="/home/azureuser/workspace-yqh/refleAct/search-qa/data/searchqa_val_500.json"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/searchqa_eval_val500_${STUDENT_DEPLOYMENT}_${TIMESTAMP}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " ReflACT3 — SearchQA Eval-Only (val-500)"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo " Data: ${VAL_PATH}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/eval_only.py \
|
||||
--config configs/searchqa_default.yaml \
|
||||
--data_path "${VAL_PATH}" \
|
||||
--out_root "${DEFAULT_OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
echo ""
|
||||
echo "Done! Results saved to: ${DEFAULT_OUT_ROOT}"
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Eval skill0 on full SpreadsheetBench verified-400
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/eval_verified400.sh
|
||||
# bash scripts/eval_verified400.sh --workers 64
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
# ── Paths ────────────────────────────────────────────────────────────────────
|
||||
DATA_ROOT="/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH="${DATA_ROOT}/dataset.json"
|
||||
SKILL_PATH="${PROJECT_ROOT}/skillopt/envs/spreadsheetbench/skills/initial.md"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
OUT_ROOT="${PROJECT_ROOT}/outputs/eval_verified400_${TIMESTAMP}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " Eval skill0 on verified-400 (full)"
|
||||
echo "============================================================"
|
||||
echo " data_root: ${DATA_ROOT}"
|
||||
echo " skill: ${SKILL_PATH}"
|
||||
echo " out_root: ${OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/eval_only.py \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--skill "${SKILL_PATH}" \
|
||||
--split all \
|
||||
--data_root "${DATA_ROOT}" \
|
||||
--jsonl_path "${JSONL_PATH}" \
|
||||
--out_root "${OUT_ROOT}" \
|
||||
"$@"
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Eval skill0 on full SpreadsheetBench verified-400 (MULTI-ROUND codegen)
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/eval_verified400_multi.sh
|
||||
# bash scripts/eval_verified400_multi.sh --workers 64 --max_turns 5
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
DATA_ROOT="/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH="${DATA_ROOT}/dataset.json"
|
||||
SKILL_PATH="${PROJECT_ROOT}/skillopt/envs/spreadsheetbench/skills/initial.md"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
OUT_ROOT="${PROJECT_ROOT}/outputs/eval_multi_verified400_${TIMESTAMP}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " Eval skill0 — MULTI-ROUND codegen — verified-400"
|
||||
echo "============================================================"
|
||||
echo " data_root: ${DATA_ROOT}"
|
||||
echo " skill: ${SKILL_PATH}"
|
||||
echo " mode: multi"
|
||||
echo " out_root: ${OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/eval_only.py \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--skill "${SKILL_PATH}" \
|
||||
--split all \
|
||||
--mode multi \
|
||||
--data_root "${DATA_ROOT}" \
|
||||
--jsonl_path "${JSONL_PATH}" \
|
||||
--out_root "${OUT_ROOT}" \
|
||||
"$@"
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# Eval skill0 on full SpreadsheetBench verified-400 (SINGLE-ROUND codegen)
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/eval_verified400_single.sh
|
||||
# bash scripts/eval_verified400_single.sh --workers 64
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
DATA_ROOT="/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH="${DATA_ROOT}/dataset.json"
|
||||
SKILL_PATH="${PROJECT_ROOT}/skillopt/envs/spreadsheetbench/skills/initial.md"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
OUT_ROOT="${PROJECT_ROOT}/outputs/eval_single_verified400_${TIMESTAMP}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " Eval skill0 — SINGLE-ROUND codegen — verified-400"
|
||||
echo "============================================================"
|
||||
echo " data_root: ${DATA_ROOT}"
|
||||
echo " skill: ${SKILL_PATH}"
|
||||
echo " mode: single"
|
||||
echo " out_root: ${OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/eval_only.py \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--skill "${SKILL_PATH}" \
|
||||
--split all \
|
||||
--mode single \
|
||||
--data_root "${DATA_ROOT}" \
|
||||
--jsonl_path "${JSONL_PATH}" \
|
||||
--out_root "${OUT_ROOT}" \
|
||||
"$@"
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PY="${PY:-python}"
|
||||
RUN_ROOT="${RUN_ROOT:-$ROOT/outputs/harness_bestsetting_fromscratch_$(date -u +%Y%m%d_%H%M%S)_run}"
|
||||
MAX_PARALLEL="${MAX_PARALLEL:-2}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs"
|
||||
cd "$ROOT"
|
||||
export PYTHONPATH="$ROOT:${PYTHONPATH:-}"
|
||||
|
||||
COMMON=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint=https://t2vgoaigpt4o3.openai.azure.com/
|
||||
model.teacher_azure_openai_api_version=2024-12-01-preview
|
||||
model.teacher_azure_openai_auth_mode=azure_cli
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
)
|
||||
|
||||
CODEX=(
|
||||
model.student_backend=codex_exec
|
||||
model.student=gpt-5.5
|
||||
model.codex_exec_use_sdk=auto
|
||||
model.codex_exec_sandbox=workspace-write
|
||||
model.codex_exec_approval_policy=never
|
||||
model.codex_trace_to_teacher=true
|
||||
)
|
||||
|
||||
CLAUDE=(
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=auto
|
||||
model.codex_trace_to_teacher=false
|
||||
)
|
||||
|
||||
active=0
|
||||
launch() {
|
||||
local run_id="$1"; shift
|
||||
local config="$1"; shift
|
||||
local out="$RUN_ROOT/$run_id"
|
||||
local log="$RUN_ROOT/logs/$run_id.log"
|
||||
echo "START $run_id"
|
||||
setsid "$PY" -u scripts/train.py \
|
||||
--config "$config" \
|
||||
--cfg-options "${COMMON[@]}" "$@" "env.out_root=$out" \
|
||||
> "$log" 2>&1 < /dev/null &
|
||||
active=$((active + 1))
|
||||
if (( active >= MAX_PARALLEL )); then
|
||||
wait -n
|
||||
active=$((active - 1))
|
||||
fi
|
||||
}
|
||||
|
||||
# SearchQA best openai-chat setting: optimizer.lr_scheduler=constant.
|
||||
launch HARNESS-BESTSETTING-searchqa-codex configs/searchqa/default.yaml \
|
||||
"${CODEX[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/searchqa/splits
|
||||
|
||||
launch HARNESS-BESTSETTING-searchqa-claude configs/searchqa/default.yaml \
|
||||
"${CLAUDE[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/searchqa/splits
|
||||
|
||||
# SpreadsheetBench best openai-chat setting: optimizer.lr_scheduler=constant.
|
||||
# Must stay env.mode=multi; exec-backend multi support is fixed on this branch.
|
||||
launch HARNESS-BESTSETTING-spreadsheetbench-codex configs/spreadsheetbench/default.yaml \
|
||||
"${CODEX[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi env.workers=4
|
||||
|
||||
launch HARNESS-BESTSETTING-spreadsheetbench-claude configs/spreadsheetbench/default.yaml \
|
||||
"${CLAUDE[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi env.workers=4
|
||||
|
||||
# LiveMathBench best openai-chat setting: optimizer.learning_rate=8.
|
||||
launch HARNESS-BESTSETTING-livemathematicianbench-codex configs/livemathematicianbench/default.yaml \
|
||||
"${CODEX[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/livemathbench/splits
|
||||
|
||||
launch HARNESS-BESTSETTING-livemathematicianbench-claude configs/livemathematicianbench/default.yaml \
|
||||
"${CLAUDE[@]}" \
|
||||
train.batch_size=40 optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant \
|
||||
env.split_dir=data/livemathbench/splits
|
||||
|
||||
# DocVQA best openai-chat setting was full batch. On 10% harness split, train=107.
|
||||
launch HARNESS-BESTSETTING-docvqa10pct-codex configs/docvqa/default.yaml \
|
||||
"${CODEX[@]}" \
|
||||
train.batch_size=107 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct
|
||||
|
||||
launch HARNESS-BESTSETTING-docvqa10pct-claude configs/docvqa/default.yaml \
|
||||
"${CLAUDE[@]}" \
|
||||
train.batch_size=107 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct
|
||||
|
||||
wait
|
||||
echo "All launched runs finished or exited. RUN_ROOT=$RUN_ROOT"
|
||||
Executable
+178
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
# Claude Code on this machine must use the local copilot-api proxy.
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/harness_canonical_claude18_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-harness_canon_claude18_${stamp}}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=sdk
|
||||
model.claude_code_exec_effort=medium
|
||||
model.claude_code_exec_max_thinking_tokens=16384
|
||||
model.codex_trace_to_teacher=false
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local config="$2"
|
||||
local skill="$3"
|
||||
shift 3
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.skill_init="$skill"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
SEARCHQA_SKILL="docs/harness_source_skills/searchqa_best_skill.md"
|
||||
LIVEMATH_SKILL="docs/harness_source_skills/livemathematicianbench_best_skill.md"
|
||||
DOCVQA_SKILL="docs/harness_source_skills/docvqa_best_skill.md"
|
||||
SPREADSHEET_SKILL="docs/harness_source_skills/spreadsheetbench_best_skill.md"
|
||||
|
||||
launch_run "HARNESS-Claude-SearchQA-sched-constant" "configs/searchqa/default.yaml" "$SEARCHQA_SKILL" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-SearchQA-sched-linear" "configs/searchqa/default.yaml" "$SEARCHQA_SKILL" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=linear
|
||||
launch_run "HARNESS-Claude-SearchQA-batch-full" "configs/searchqa/default.yaml" "$SEARCHQA_SKILL" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
train.batch_size=400 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
launch_run "HARNESS-Claude-SearchQA-lr8" "configs/searchqa/default.yaml" "$SEARCHQA_SKILL" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-Claude-LiveMath-lr8" "configs/livemathematicianbench/default.yaml" "$LIVEMATH_SKILL" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-LiveMath-lr16" "configs/livemathematicianbench/default.yaml" "$LIVEMATH_SKILL" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=16 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-LiveMath-slow10" "configs/livemathematicianbench/default.yaml" "$LIVEMATH_SKILL" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine optimizer.slow_update_samples=10
|
||||
launch_run "HARNESS-Claude-LiveMath-sched-linear" "configs/livemathematicianbench/default.yaml" "$LIVEMATH_SKILL" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=linear
|
||||
launch_run "HARNESS-Claude-LiveMath-minibatch4" "configs/livemathematicianbench/default.yaml" "$LIVEMATH_SKILL" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
gradient.minibatch_size=4 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
|
||||
launch_run "HARNESS-Claude-DocVQA10-batch-full" "configs/docvqa/default.yaml" "$DOCVQA_SKILL" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
train.batch_size=107 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
launch_run "HARNESS-Claude-DocVQA10-lr16" "configs/docvqa/default.yaml" "$DOCVQA_SKILL" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
optimizer.learning_rate=16 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-DocVQA10-lr8" "configs/docvqa/default.yaml" "$DOCVQA_SKILL" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-DocVQA10-minibatch32" "configs/docvqa/default.yaml" "$DOCVQA_SKILL" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
gradient.minibatch_size=32 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
launch_run "HARNESS-Claude-DocVQA10-batch24" "configs/docvqa/default.yaml" "$DOCVQA_SKILL" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
train.batch_size=24 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
|
||||
launch_run "HARNESS-Claude-Spreadsheet-sched-constant-multi" "configs/spreadsheetbench/default.yaml" "$SPREADSHEET_SKILL" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-Spreadsheet-lr4-multi" "configs/spreadsheetbench/default.yaml" "$SPREADSHEET_SKILL" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-Spreadsheet-lr16-multi" "configs/spreadsheetbench/default.yaml" "$SPREADSHEET_SKILL" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
optimizer.learning_rate=16 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "HARNESS-Claude-Spreadsheet-minibatch16-multi" "configs/spreadsheetbench/default.yaml" "$SPREADSHEET_SKILL" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
gradient.minibatch_size=16 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/harness_canonical_claude4_smoke_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-harness_canon_claude4_${stamp}}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=sdk
|
||||
model.claude_code_exec_effort=medium
|
||||
model.claude_code_exec_max_thinking_tokens=16384
|
||||
model.codex_trace_to_teacher=false
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local config="$2"
|
||||
local skill="$3"
|
||||
shift 3
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.skill_init="$skill"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
launch_run "HARNESS-Claude-SearchQA-sched-constant" "configs/searchqa/default.yaml" "docs/harness_source_skills/searchqa_best_skill.md" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-Claude-LiveMath-lr8" "configs/livemathematicianbench/default.yaml" "docs/harness_source_skills/livemathematicianbench_best_skill.md" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-Claude-DocVQA10-lr8" "configs/docvqa/default.yaml" "docs/harness_source_skills/docvqa_best_skill.md" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-Claude-Spreadsheet-lr4-multi" "configs/spreadsheetbench/default.yaml" "docs/harness_source_skills/spreadsheetbench_best_skill.md" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
CODEX_WRAPPER="$REPO/scripts/codex_azure_mi.sh"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
# Claude Code is routed through the local copilot-api proxy on this machine.
|
||||
# Do not rely on interactive Claude login state inside tmux/train workers.
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/harness_canonical_step12_wave1_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-harness_canon_wave1_${stamp}}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local backend="$2"
|
||||
local config="$3"
|
||||
local skill="$4"
|
||||
local split_dir="$5"
|
||||
shift 5
|
||||
|
||||
local -a backend_cfg=()
|
||||
if [[ "$backend" == "codex" ]]; then
|
||||
backend_cfg=(
|
||||
model.student_backend=codex_exec
|
||||
model.student=gpt-5.5
|
||||
model.codex_exec_path="$CODEX_WRAPPER"
|
||||
model.codex_exec_use_sdk=auto
|
||||
model.codex_exec_sandbox=workspace-write
|
||||
model.codex_exec_approval_policy=never
|
||||
model.codex_exec_reasoning_effort=medium
|
||||
model.codex_trace_to_teacher=true
|
||||
)
|
||||
elif [[ "$backend" == "claude" ]]; then
|
||||
backend_cfg=(
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=sdk
|
||||
model.claude_code_exec_effort=medium
|
||||
model.claude_code_exec_max_thinking_tokens=16384
|
||||
model.codex_trace_to_teacher=false
|
||||
)
|
||||
else
|
||||
echo "unknown backend: $backend" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
"${backend_cfg[@]}"
|
||||
env.split_dir="$split_dir"
|
||||
env.skill_init="$skill"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
SEARCHQA_SKILL="docs/harness_source_skills/searchqa_best_skill.md"
|
||||
LIVEMATH_SKILL="docs/harness_source_skills/livemathematicianbench_best_skill.md"
|
||||
|
||||
SEARCHQA_CFG="configs/searchqa/default.yaml"
|
||||
LIVEMATH_CFG="configs/livemathematicianbench/default.yaml"
|
||||
|
||||
SEARCHQA_SPLIT="data/searchqa/splits"
|
||||
LIVEMATH_SPLIT="data/livemathbench/splits"
|
||||
|
||||
for backend in codex claude; do
|
||||
prefix="HARNESS-Codex"
|
||||
[[ "$backend" == "claude" ]] && prefix="HARNESS-Claude"
|
||||
|
||||
launch_run "${prefix}-SearchQA-sched-constant" "$backend" "$SEARCHQA_CFG" "$SEARCHQA_SKILL" "$SEARCHQA_SPLIT" \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant
|
||||
launch_run "${prefix}-SearchQA-sched-linear" "$backend" "$SEARCHQA_CFG" "$SEARCHQA_SKILL" "$SEARCHQA_SPLIT" \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=linear
|
||||
launch_run "${prefix}-SearchQA-batch-full" "$backend" "$SEARCHQA_CFG" "$SEARCHQA_SKILL" "$SEARCHQA_SPLIT" \
|
||||
train.batch_size=400 optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=cosine
|
||||
launch_run "${prefix}-SearchQA-lr8" "$backend" "$SEARCHQA_CFG" "$SEARCHQA_SKILL" "$SEARCHQA_SPLIT" \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "${prefix}-LiveMath-lr8" "$backend" "$LIVEMATH_CFG" "$LIVEMATH_SKILL" "$LIVEMATH_SPLIT" \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
launch_run "${prefix}-LiveMath-lr16" "$backend" "$LIVEMATH_CFG" "$LIVEMATH_SKILL" "$LIVEMATH_SPLIT" \
|
||||
optimizer.learning_rate=16 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
done
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/harness_initial_claude4_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-harness_initial_claude4_${stamp}}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=sdk
|
||||
model.claude_code_exec_effort=medium
|
||||
model.claude_code_exec_max_thinking_tokens=16384
|
||||
model.codex_trace_to_teacher=false
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local config="$2"
|
||||
shift 2
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
launch_run "HARNESS-ClaudeInit-SearchQA-sched-constant" "configs/searchqa/default.yaml" \
|
||||
env.split_dir=data/searchqa/splits \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=2 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-ClaudeInit-LiveMath-lr8" "configs/livemathematicianbench/default.yaml" \
|
||||
env.split_dir=data/livemathbench/splits \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-ClaudeInit-DocVQA10-lr8" "configs/docvqa/default.yaml" \
|
||||
env.split_dir=data/harness_splits/docvqa_zisu_first10pct \
|
||||
optimizer.learning_rate=8 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
launch_run "HARNESS-ClaudeInit-Spreadsheet-lr4-multi" "configs/spreadsheetbench/default.yaml" \
|
||||
env.split_dir=data/spreadsheetbench env.data_root=data/spreadsheetbench/files env.mode=multi \
|
||||
optimizer.learning_rate=4 optimizer.min_learning_rate=1 optimizer.lr_scheduler=constant
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/harness_initial_spreadsheet_clean_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-harness_initial_spreadsheet_clean_${stamp}}"
|
||||
RUN_ID="HARNESS-ClaudeInit-Spreadsheet-lr4-multi-clean"
|
||||
SPLIT_DIR="${SPREADSHEET_SPLIT_DIR:-data/harness_splits/spreadsheetbench_full}"
|
||||
DATA_ROOT="${SPREADSHEET_DATA_ROOT:-data/spreadsheetbench/files}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
cmd_file="$RUN_ROOT/commands/${RUN_ID}.sh"
|
||||
log_file="$RUN_ROOT/logs/${RUN_ID}.log"
|
||||
out_root="$RUN_ROOT/$RUN_ID"
|
||||
|
||||
cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config configs/spreadsheetbench/default.yaml
|
||||
--cfg-options
|
||||
model.teacher_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.lr_control_mode=fixed
|
||||
optimizer.skill_update_mode=patch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
model.student_backend=claude_code_exec
|
||||
model.student=claude-sonnet-4-6
|
||||
model.claude_code_exec_use_sdk=sdk
|
||||
model.claude_code_exec_effort=medium
|
||||
model.claude_code_exec_max_thinking_tokens=16384
|
||||
model.codex_trace_to_teacher=false
|
||||
env.out_root="$out_root"
|
||||
env.split_dir="$SPLIT_DIR"
|
||||
env.data_root="$DATA_ROOT"
|
||||
env.mode=multi
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=1
|
||||
optimizer.lr_scheduler=constant
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
tmux new-session -d -s "$SESSION" -n "$RUN_ID" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
echo "RUN_ID=$RUN_ID"
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/lrctrl_fullrewrite_neutral3_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-lrctrl_fullrewrite_neutral3_${stamp}}"
|
||||
SEED="${3:-42}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.student_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.student=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.student_azure_openai_endpoint="${STUDENT_AZURE_OPENAI_ENDPOINT:-$TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.student_azure_openai_api_version="${STUDENT_AZURE_OPENAI_API_VERSION:-$TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.student_azure_openai_auth_mode="${STUDENT_AZURE_OPENAI_AUTH_MODE:-$TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.student_azure_openai_managed_identity_client_id="${STUDENT_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID:-$TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.student_azure_openai_ad_scope="${STUDENT_AZURE_OPENAI_AD_SCOPE:-$TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed="${SEED}"
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_scheduler=cosine
|
||||
optimizer.lr_control_mode=none
|
||||
optimizer.skill_update_mode=full_rewrite_minibatch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local config="$2"
|
||||
shift 2
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
launch_run "LRCTRL-searchqa-full-rewrite-neutral3-seed${SEED}" "configs/searchqa/default.yaml" \
|
||||
env.split_dir=data/ablation_splits/searchqa/2-1-7_seed42
|
||||
|
||||
launch_run "LRCTRL-spreadsheetbench-full-rewrite-neutral3-seed${SEED}" "configs/spreadsheetbench/default.yaml" \
|
||||
env.split_dir=data/ablation_splits/spreadsheetbench/2-1-7_seed42 \
|
||||
env.data_root=data/spreadsheetbench_verified_400 \
|
||||
env.mode=multi
|
||||
|
||||
launch_run "LRCTRL-livemathematicianbench-full-rewrite-neutral3-seed${SEED}" "configs/livemathematicianbench/default.yaml" \
|
||||
env.split_dir=data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
echo "SEED=$SEED"
|
||||
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/lrctrl_fullrewrite_neutral3_spreadsheet_promptweak_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-lrctrl_fr_spreadsheet_promptweak_${stamp}}"
|
||||
START_INDEX="${3:-4}"
|
||||
N_REPEATS="${4:-3}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.student_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.student=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.student_azure_openai_endpoint="${STUDENT_AZURE_OPENAI_ENDPOINT:-$TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.student_azure_openai_api_version="${STUDENT_AZURE_OPENAI_API_VERSION:-$TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.student_azure_openai_auth_mode="${STUDENT_AZURE_OPENAI_AUTH_MODE:-$TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.student_azure_openai_managed_identity_client_id="${STUDENT_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID:-$TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.student_azure_openai_ad_scope="${STUDENT_AZURE_OPENAI_AD_SCOPE:-$TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_scheduler=cosine
|
||||
optimizer.lr_control_mode=none
|
||||
optimizer.skill_update_mode=full_rewrite_minibatch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
env.split_dir=data/ablation_splits/spreadsheetbench/2-1-7_seed42
|
||||
env.data_root=data/spreadsheetbench_verified_400
|
||||
env.mode=multi
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config configs/spreadsheetbench/default.yaml
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.out_root="$out_root"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
for ((i=START_INDEX; i<START_INDEX+N_REPEATS; i++)); do
|
||||
launch_run "LRCTRL-spreadsheetbench-full-rewrite-neutral3-promptweak-r${i}"
|
||||
done
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
echo "START_INDEX=$START_INDEX"
|
||||
echo "N_REPEATS=$N_REPEATS"
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/lrctrl_fullrewrite_neutral3_sq_lm_extra_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-lrctrl_fr_sq_lm_extra_${stamp}}"
|
||||
START_INDEX="${3:-4}"
|
||||
N_REPEATS="${4:-3}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
COMMON_CFG=(
|
||||
model.teacher_backend=openai_chat
|
||||
model.student_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.student=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.student_azure_openai_endpoint="${STUDENT_AZURE_OPENAI_ENDPOINT:-$TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.student_azure_openai_api_version="${STUDENT_AZURE_OPENAI_API_VERSION:-$TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.student_azure_openai_auth_mode="${STUDENT_AZURE_OPENAI_AUTH_MODE:-$TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.student_azure_openai_managed_identity_client_id="${STUDENT_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID:-$TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.student_azure_openai_ad_scope="${STUDENT_AZURE_OPENAI_AD_SCOPE:-$TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_scheduler=cosine
|
||||
optimizer.lr_control_mode=none
|
||||
optimizer.skill_update_mode=full_rewrite_minibatch
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_skill=true
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
)
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
local config="$2"
|
||||
shift 2
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
local out_root="$RUN_ROOT/$run_id"
|
||||
|
||||
local -a cmd=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config "$config"
|
||||
--cfg-options
|
||||
"${COMMON_CFG[@]}"
|
||||
env.out_root="$out_root"
|
||||
"$@"
|
||||
)
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf '%q ' "${cmd[@]}"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
for ((i=START_INDEX; i<START_INDEX+N_REPEATS; i++)); do
|
||||
launch_run "LRCTRL-searchqa-full-rewrite-neutral3-extra-r${i}" "configs/searchqa/default.yaml" \
|
||||
env.split_dir=data/ablation_splits/searchqa/2-1-7_seed42
|
||||
|
||||
launch_run "LRCTRL-livemathematicianbench-full-rewrite-neutral3-extra-r${i}" "configs/livemathematicianbench/default.yaml" \
|
||||
env.split_dir=data/ablation_splits/livemathematicianbench/2-1-7_seed42
|
||||
done
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
echo "START_INDEX=$START_INDEX"
|
||||
echo "N_REPEATS=$N_REPEATS"
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO="/home/azureuser/workspace-gzy/SkillReflection"
|
||||
PYTHON="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
|
||||
cd "$REPO"
|
||||
|
||||
export ANTHROPIC_BASE_URL="${ANTHROPIC_BASE_URL:-http://127.0.0.1:4343}"
|
||||
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-dummy}"
|
||||
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-claude-sonnet-4-6}"
|
||||
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-claude-sonnet-4-6}"
|
||||
export DISABLE_NON_ESSENTIAL_MODEL_CALLS="${DISABLE_NON_ESSENTIAL_MODEL_CALLS:-1}"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="${CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
|
||||
|
||||
if [[ -f ".secrets/teacher_oaidr9.env" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source ".secrets/teacher_oaidr9.env"
|
||||
else
|
||||
echo "missing .secrets/teacher_oaidr9.env" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stamp="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${1:-outputs/spreadsheet_full_replacements_workers2_timeout1020_${stamp}_run}"
|
||||
SESSION="${2:-spreadsheet_full_replacements_${stamp}}"
|
||||
|
||||
mkdir -p "$RUN_ROOT/logs" "$RUN_ROOT/commands"
|
||||
|
||||
tmux_started=0
|
||||
|
||||
launch_run() {
|
||||
local run_id="$1"
|
||||
shift
|
||||
|
||||
local cmd_file="$RUN_ROOT/commands/${run_id}.sh"
|
||||
local log_file="$RUN_ROOT/logs/${run_id}.log"
|
||||
|
||||
{
|
||||
echo "#!/usr/bin/env bash"
|
||||
echo "set -euo pipefail"
|
||||
echo "cd '$REPO'"
|
||||
printf 'export ANTHROPIC_BASE_URL=%q\n' "$ANTHROPIC_BASE_URL"
|
||||
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$ANTHROPIC_AUTH_TOKEN"
|
||||
printf 'export ANTHROPIC_MODEL=%q\n' "$ANTHROPIC_MODEL"
|
||||
printf 'export ANTHROPIC_SMALL_FAST_MODEL=%q\n' "$ANTHROPIC_SMALL_FAST_MODEL"
|
||||
printf 'export DISABLE_NON_ESSENTIAL_MODEL_CALLS=%q\n' "$DISABLE_NON_ESSENTIAL_MODEL_CALLS"
|
||||
printf 'export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=%q\n' "$CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"
|
||||
printf '%q ' "$@"
|
||||
printf ' >%q 2>&1 < /dev/null\n' "$log_file"
|
||||
} > "$cmd_file"
|
||||
chmod +x "$cmd_file"
|
||||
|
||||
if [[ "$tmux_started" -eq 0 ]]; then
|
||||
tmux new-session -d -s "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
tmux_started=1
|
||||
else
|
||||
tmux new-window -t "$SESSION" -n "$run_id" "bash '$cmd_file'; code=\$?; echo EXIT:\$code; sleep 3600"
|
||||
fi
|
||||
echo "$run_id"
|
||||
}
|
||||
|
||||
OPENAI_COMMON=(
|
||||
"$PYTHON" -u scripts/train.py
|
||||
--config configs/spreadsheetbench/default.yaml
|
||||
--cfg-options
|
||||
model.teacher_backend=openai_chat
|
||||
model.student_backend=openai_chat
|
||||
model.teacher=gpt-5.5
|
||||
model.student=gpt-5.5
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.student_azure_openai_endpoint="${STUDENT_AZURE_OPENAI_ENDPOINT:-$TEACHER_AZURE_OPENAI_ENDPOINT}"
|
||||
model.student_azure_openai_api_version="${STUDENT_AZURE_OPENAI_API_VERSION:-$TEACHER_AZURE_OPENAI_API_VERSION}"
|
||||
model.student_azure_openai_auth_mode="${STUDENT_AZURE_OPENAI_AUTH_MODE:-$TEACHER_AZURE_OPENAI_AUTH_MODE}"
|
||||
model.student_azure_openai_managed_identity_client_id="${STUDENT_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID:-$TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}"
|
||||
model.student_azure_openai_ad_scope="${STUDENT_AZURE_OPENAI_AD_SCOPE:-$TEACHER_AZURE_OPENAI_AD_SCOPE}"
|
||||
model.reasoning_effort=medium
|
||||
train.num_epochs=4
|
||||
train.train_size=0
|
||||
train.batch_size=40
|
||||
train.accumulation=1
|
||||
train.seed=42
|
||||
gradient.minibatch_size=8
|
||||
gradient.merge_batch_size=8
|
||||
gradient.analyst_workers=16
|
||||
gradient.use_deep_reflect=false
|
||||
optimizer.learning_rate=4
|
||||
optimizer.min_learning_rate=2
|
||||
optimizer.lr_scheduler=cosine
|
||||
optimizer.use_slow_update=true
|
||||
optimizer.slow_update_samples=20
|
||||
optimizer.use_meta_reflect=false
|
||||
evaluation.use_gate=true
|
||||
evaluation.eval_test=true
|
||||
env.split_mode=split_dir
|
||||
env.workers=2
|
||||
env.exec_timeout=1020
|
||||
env.split_dir=data/ablation_splits/spreadsheetbench/2-1-7_seed42
|
||||
env.data_root=data/spreadsheetbench_verified_400
|
||||
env.mode=multi
|
||||
)
|
||||
|
||||
HARNESS_RUN="HARNESS-ClaudeInit-Spreadsheet-lr4-multi-full"
|
||||
launch_run "$HARNESS_RUN" \
|
||||
"$PYTHON" -u scripts/train.py \
|
||||
--config configs/spreadsheetbench/default.yaml \
|
||||
--cfg-options \
|
||||
model.teacher_backend=openai_chat \
|
||||
model.teacher=gpt-5.5 \
|
||||
model.teacher_azure_openai_endpoint="${TEACHER_AZURE_OPENAI_ENDPOINT}" \
|
||||
model.teacher_azure_openai_api_version="${TEACHER_AZURE_OPENAI_API_VERSION}" \
|
||||
model.teacher_azure_openai_auth_mode="${TEACHER_AZURE_OPENAI_AUTH_MODE}" \
|
||||
model.teacher_azure_openai_managed_identity_client_id="${TEACHER_AZURE_OPENAI_MANAGED_IDENTITY_CLIENT_ID}" \
|
||||
model.teacher_azure_openai_ad_scope="${TEACHER_AZURE_OPENAI_AD_SCOPE}" \
|
||||
model.reasoning_effort=medium \
|
||||
train.num_epochs=4 \
|
||||
train.train_size=0 \
|
||||
train.batch_size=40 \
|
||||
train.accumulation=1 \
|
||||
train.seed=42 \
|
||||
gradient.minibatch_size=8 \
|
||||
gradient.merge_batch_size=8 \
|
||||
gradient.analyst_workers=16 \
|
||||
gradient.use_deep_reflect=false \
|
||||
optimizer.lr_control_mode=fixed \
|
||||
optimizer.skill_update_mode=patch \
|
||||
optimizer.use_slow_update=true \
|
||||
optimizer.slow_update_samples=20 \
|
||||
optimizer.use_meta_skill=true \
|
||||
optimizer.use_meta_reflect=false \
|
||||
evaluation.use_gate=true \
|
||||
evaluation.eval_test=true \
|
||||
env.split_mode=split_dir \
|
||||
env.workers=2 \
|
||||
env.exec_timeout=1020 \
|
||||
model.student_backend=claude_code_exec \
|
||||
model.student=claude-sonnet-4-6 \
|
||||
model.claude_code_exec_use_sdk=sdk \
|
||||
model.claude_code_exec_effort=medium \
|
||||
model.claude_code_exec_max_thinking_tokens=16384 \
|
||||
model.codex_trace_to_teacher=false \
|
||||
env.out_root="$RUN_ROOT/$HARNESS_RUN" \
|
||||
env.split_dir=data/spreadsheetbench/splits \
|
||||
env.data_root=data/spreadsheetbench/files \
|
||||
env.mode=multi \
|
||||
optimizer.learning_rate=4 \
|
||||
optimizer.min_learning_rate=1 \
|
||||
optimizer.lr_scheduler=constant
|
||||
|
||||
for repeat in r1 r2 r3; do
|
||||
run_id="LRCTRL-spreadsheetbench-full-rewrite-neutral3-full-${repeat}"
|
||||
launch_run "$run_id" \
|
||||
"${OPENAI_COMMON[@]}" \
|
||||
optimizer.lr_control_mode=none \
|
||||
optimizer.skill_update_mode=full_rewrite_minibatch \
|
||||
optimizer.use_meta_skill=true \
|
||||
env.out_root="$RUN_ROOT/$run_id"
|
||||
done
|
||||
|
||||
for repeat in r1 r2 r3; do
|
||||
run_id="SLOWMETA-spreadsheetbench-true-false-full-${repeat}"
|
||||
launch_run "$run_id" \
|
||||
"${OPENAI_COMMON[@]}" \
|
||||
optimizer.lr_control_mode=fixed \
|
||||
optimizer.skill_update_mode=patch \
|
||||
optimizer.use_meta_skill=false \
|
||||
env.out_root="$RUN_ROOT/$run_id"
|
||||
done
|
||||
|
||||
echo "RUN_ROOT=$RUN_ROOT"
|
||||
echo "SESSION=$SESSION"
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:?usage: monitor_harness_claude18.sh RUN_ROOT}"
|
||||
|
||||
while true; do
|
||||
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "===== $ts CLAUDE18 ====="
|
||||
uptime | sed 's/^/uptime=/'
|
||||
active="$(pgrep -af "scripts/train.py.*${ROOT}" | grep -v pgrep | wc -l || true)"
|
||||
claude_child="$(pgrep -af 'claude.*--output-format stream-json' | grep -v pgrep | wc -l || true)"
|
||||
echo "active_train_total=$active"
|
||||
echo "active_codex_train=0"
|
||||
echo "active_claude_train=$active"
|
||||
echo "claude_child=$claude_child"
|
||||
|
||||
for d in "$ROOT"/HARNESS-Claude-*; do
|
||||
[[ -d "$d" ]] || continue
|
||||
rid="$(basename "$d")"
|
||||
read -r base best < <(python3 - "$d" <<'PY'
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
d = Path(sys.argv[1])
|
||||
s = d / "summary.json"
|
||||
if not s.exists():
|
||||
print("pending pending")
|
||||
raise SystemExit
|
||||
try:
|
||||
obj = json.loads(s.read_text())
|
||||
except Exception:
|
||||
print("pending pending")
|
||||
raise SystemExit
|
||||
base = obj.get("baseline_test_hard", obj.get("base_test", "pending"))
|
||||
best = obj.get("test_hard", obj.get("best_test", "pending"))
|
||||
def fmt(x):
|
||||
if isinstance(x, (int, float)):
|
||||
return f"{x:.4f}"
|
||||
return str(x)
|
||||
print(fmt(base), fmt(best))
|
||||
PY
|
||||
)
|
||||
scan_files="$(mktemp)"
|
||||
find "$d" \
|
||||
\( -path '*/codex_exec' -o -path '*/codex_multi' \) -prune -o \
|
||||
-maxdepth 6 -type f \
|
||||
\( -name 'claude_trace_summary.txt' -o -name 'codex_trace_summary.txt' -o -name '*.log' -o -name 'summary.json' \) \
|
||||
-print > "$scan_files" 2>/dev/null || true
|
||||
auth="$({ xargs -r rg -l 'Not logged in|authentication_failed' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
e429="$({ xargs -r rg -l 'Too Many Requests|RateLimitError|Error code: 429|api_error_status.: 429|rate_limit|too_many_requests' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
e401="$({ xargs -r rg -l '401 Unauthorized|Error code: 401|HTTP 401|AuthenticationTypeDisabled|PermissionDeniedError' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
timeout="$({ xargs -r rg -l 'TimeoutError|Task timed out|timed out after|subprocess.TimeoutExpired|timeout_exceeded' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
teacher="$({ xargs -r rg -l 'APITimeoutError|APIConnectionError|AuthenticationError|Azure OpenAI Responses API is enabled only|teacher.*error' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
results="$(find "$d" -maxdepth 5 -path '*/results.jsonl' -type f -print0 2>/dev/null | xargs -0 -r wc -l | awk 'END{print $1+0}')"
|
||||
empty="$({ xargs -r rg -l 'final response chars: 0|\"final_response\"\\s*:\\s*\"\"|\"result\"\\s*:\\s*\"\"' < "$scan_files" 2>/dev/null || true; } | wc -l | tr -d ' ')"
|
||||
rm -f "$scan_files"
|
||||
errors=$((auth + e429 + e401 + timeout + teacher))
|
||||
echo "$rid Base=$base Best=$best Errors=$errors auth=$auth 429=$e429 401=$e401 timeout=$timeout teacher=$teacher Results=$results Empty=$empty"
|
||||
done | sort
|
||||
echo
|
||||
sleep 60
|
||||
done
|
||||
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prepare fixed data splits for ablation experiments."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import random
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
DATASETS = {
|
||||
"searchqa": {
|
||||
"raw": PROJECT_ROOT / "data/searchqa_train_2000.json",
|
||||
"out": PROJECT_ROOT / "data/ablation_splits/searchqa",
|
||||
"filenames": {"train": "train.json", "val": "selection.json", "test": "test.json"},
|
||||
},
|
||||
"spreadsheetbench": {
|
||||
"raw": PROJECT_ROOT / "data/spreadsheetbench_verified_400/dataset.json",
|
||||
"out": PROJECT_ROOT / "data/ablation_splits/spreadsheetbench",
|
||||
"filenames": {"train": "train.json", "val": "sel.json", "test": "test.json"},
|
||||
},
|
||||
}
|
||||
|
||||
SPLITS = ("1shot", "1:1:8", "2:1:7", "4:1:5")
|
||||
|
||||
|
||||
def load_items(path: Path) -> list[dict]:
|
||||
with path.open(encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
if not isinstance(data, list):
|
||||
raise TypeError(f"Expected JSON array in {path}, got {type(data).__name__}")
|
||||
return data
|
||||
|
||||
|
||||
def split_counts(total: int, split: str) -> tuple[int, int, int]:
|
||||
if split == "1shot":
|
||||
if total < 3:
|
||||
raise ValueError(f"Need at least 3 items for 1shot split, got {total}")
|
||||
return 1, 1, total - 2
|
||||
|
||||
ratio = split
|
||||
weights = [int(part) for part in ratio.split(":")]
|
||||
if len(weights) != 3 or min(weights) <= 0:
|
||||
raise ValueError(f"Invalid ratio: {ratio}")
|
||||
denom = sum(weights)
|
||||
raw = [total * weight / denom for weight in weights]
|
||||
counts = [int(value) for value in raw]
|
||||
remaining = total - sum(counts)
|
||||
order = sorted(
|
||||
range(3),
|
||||
key=lambda idx: (raw[idx] - counts[idx], weights[idx]),
|
||||
reverse=True,
|
||||
)
|
||||
for idx in order[:remaining]:
|
||||
counts[idx] += 1
|
||||
return counts[0], counts[1], counts[2]
|
||||
|
||||
|
||||
def split_tag(split: str) -> str:
|
||||
return "1shot" if split == "1shot" else split.replace(":", "-")
|
||||
|
||||
|
||||
def write_json(path: Path, items: list[dict]) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open("w", encoding="utf-8") as f:
|
||||
json.dump(items, f, ensure_ascii=False, indent=2)
|
||||
|
||||
|
||||
def prepare_dataset(name: str, *, seed: int, force: bool) -> None:
|
||||
spec = DATASETS[name]
|
||||
raw_path = spec["raw"]
|
||||
out_root = spec["out"]
|
||||
filenames = spec["filenames"]
|
||||
|
||||
items = load_items(raw_path)
|
||||
for split in SPLITS:
|
||||
ratio_tag = split_tag(split)
|
||||
split_dir = out_root / f"{ratio_tag}_seed{seed}"
|
||||
manifest_path = split_dir / "split_manifest.json"
|
||||
if manifest_path.exists() and not force:
|
||||
print(f"skip {name} {split}: {split_dir} exists")
|
||||
continue
|
||||
|
||||
shuffled = list(items)
|
||||
random.Random(seed).shuffle(shuffled)
|
||||
train_n, val_n, test_n = split_counts(len(shuffled), split)
|
||||
train_items = shuffled[:train_n]
|
||||
val_items = shuffled[train_n: train_n + val_n]
|
||||
test_items = shuffled[train_n + val_n: train_n + val_n + test_n]
|
||||
|
||||
write_json(split_dir / "train" / filenames["train"], train_items)
|
||||
write_json(split_dir / "val" / filenames["val"], val_items)
|
||||
write_json(split_dir / "test" / filenames["test"], test_items)
|
||||
write_json(
|
||||
manifest_path,
|
||||
{
|
||||
"dataset": name,
|
||||
"source": str(raw_path),
|
||||
"split_mode": "precomputed_ratio",
|
||||
"split_name": split,
|
||||
"split_ratio": split if split != "1shot" else "1 train / 1 val / rest test",
|
||||
"split_seed": seed,
|
||||
"counts": {
|
||||
"train": len(train_items),
|
||||
"val": len(val_items),
|
||||
"test": len(test_items),
|
||||
},
|
||||
},
|
||||
)
|
||||
print(
|
||||
f"wrote {name} {split} -> {split_dir} "
|
||||
f"(train={len(train_items)}, val={len(val_items)}, test={len(test_items)})"
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--seed", type=int, default=42)
|
||||
parser.add_argument("--force", action="store_true")
|
||||
parser.add_argument("--dataset", choices=sorted(DATASETS), action="append")
|
||||
args = parser.parse_args()
|
||||
|
||||
for name in args.dataset or sorted(DATASETS):
|
||||
prepare_dataset(name, seed=args.seed, force=args.force)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+680
@@ -0,0 +1,680 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Launch the SearchQA / SpreadsheetBench ablation matrix.
|
||||
|
||||
By default this script prints commands only. Pass --execute to actually start
|
||||
runs. Every run writes to a unique out_root under the run root and logs stdout
|
||||
/ stderr to logs/<run_id>.log.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
PYTHON_BIN = Path("/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python")
|
||||
|
||||
T2_ENDPOINT = "https://t2vgoaigpt4o3.openai.azure.com/"
|
||||
SEARCHAGENT5_ENDPOINT = "https://searchagent5.cognitiveservices.azure.com/"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Experiment:
|
||||
run_id: str
|
||||
benchmark: str
|
||||
config: str
|
||||
overrides: tuple[str, ...]
|
||||
|
||||
|
||||
BENCH_CONFIG = {
|
||||
"searchqa": "configs/searchqa/default.yaml",
|
||||
"spreadsheetbench": "configs/spreadsheetbench/default.yaml",
|
||||
"livemathematicianbench": "configs/livemathematicianbench/default.yaml",
|
||||
"alfworld": "configs/alfworld/default.yaml",
|
||||
"docvqa": "configs/docvqa/default.yaml",
|
||||
}
|
||||
|
||||
DEFAULT_SPLIT = {
|
||||
"searchqa": "data/ablation_splits/searchqa/2-1-7_seed42",
|
||||
"spreadsheetbench": "data/ablation_splits/spreadsheetbench/2-1-7_seed42",
|
||||
"livemathematicianbench": "data/ablation_splits/livemathematicianbench/2-1-7_seed42",
|
||||
"alfworld": "data/ablation_splits/alfworld/2-1-7_seed42",
|
||||
"docvqa": "/home/azureuser/zisu/SkillReflection/data/docvqa/splits",
|
||||
}
|
||||
|
||||
DEFAULT_TRAIN_SIZE = {
|
||||
"searchqa": 400,
|
||||
"spreadsheetbench": 80,
|
||||
"livemathematicianbench": 35,
|
||||
"alfworld": 39,
|
||||
"docvqa": 1070,
|
||||
}
|
||||
|
||||
BATCH_SIZE_VALUES: tuple[int | str, ...] = (8, 24, 40, 56, "full")
|
||||
|
||||
SPLITS = {
|
||||
"searchqa": {
|
||||
"1shot": ("data/ablation_splits/searchqa/1shot_seed42", ("optimizer.slow_update_samples=1",)),
|
||||
"1-1-8": ("data/ablation_splits/searchqa/1-1-8_seed42", ()),
|
||||
"2-1-7": ("data/ablation_splits/searchqa/2-1-7_seed42", ()),
|
||||
"4-1-5": ("data/ablation_splits/searchqa/4-1-5_seed42", ()),
|
||||
},
|
||||
"spreadsheetbench": {
|
||||
"1shot": ("data/ablation_splits/spreadsheetbench/1shot_seed42", ("optimizer.slow_update_samples=1",)),
|
||||
"1-1-8": ("data/ablation_splits/spreadsheetbench/1-1-8_seed42", ()),
|
||||
"2-1-7": ("data/ablation_splits/spreadsheetbench/2-1-7_seed42", ()),
|
||||
"4-1-5": ("data/ablation_splits/spreadsheetbench/4-1-5_seed42", ()),
|
||||
},
|
||||
"livemathematicianbench": {
|
||||
"1shot": ("data/ablation_splits/livemathematicianbench/1shot_seed42", ("optimizer.slow_update_samples=1",)),
|
||||
"1-1-8": ("data/ablation_splits/livemathematicianbench/1-1-8_seed42", ()),
|
||||
"2-1-7": ("data/ablation_splits/livemathematicianbench/2-1-7_seed42", ()),
|
||||
"4-1-5": ("data/ablation_splits/livemathematicianbench/4-1-5_seed42", ()),
|
||||
},
|
||||
"alfworld": {
|
||||
"1shot": ("data/ablation_splits/alfworld/1shot_seed42", ("optimizer.slow_update_samples=1",)),
|
||||
"1-1-8": ("data/ablation_splits/alfworld/1-1-8_seed42", ()),
|
||||
"2-1-7": ("data/ablation_splits/alfworld/2-1-7_seed42", ()),
|
||||
"4-1-5": ("data/ablation_splits/alfworld/4-1-5_seed42", ()),
|
||||
},
|
||||
"docvqa": {
|
||||
"1shot": ("data/ablation_splits/docvqa/1shot_seed42", ("optimizer.slow_update_samples=1",)),
|
||||
"1-1-8": ("data/ablation_splits/docvqa/1-1-8_seed42", ()),
|
||||
"2-1-7": ("/home/azureuser/zisu/SkillReflection/data/docvqa/splits", ()),
|
||||
"4-1-5": ("data/ablation_splits/docvqa/4-1-5_seed42", ()),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def common_overrides(benchmark: str, out_root: Path) -> list[str]:
|
||||
return [
|
||||
"model.teacher_backend=openai_chat",
|
||||
"model.student_backend=openai_chat",
|
||||
"model.teacher=gpt-5.5",
|
||||
"model.student=gpt-5.5",
|
||||
f"model.teacher_azure_openai_endpoint={T2_ENDPOINT}",
|
||||
"model.teacher_azure_openai_api_version=2024-12-01-preview",
|
||||
"model.teacher_azure_openai_auth_mode=azure_cli",
|
||||
f"model.student_azure_openai_endpoint={T2_ENDPOINT}",
|
||||
"model.student_azure_openai_api_version=2024-12-01-preview",
|
||||
"model.student_azure_openai_auth_mode=azure_cli",
|
||||
"model.reasoning_effort=medium",
|
||||
"train.num_epochs=4",
|
||||
"train.train_size=0",
|
||||
"train.batch_size=40",
|
||||
"train.accumulation=1",
|
||||
"train.seed=42",
|
||||
"gradient.minibatch_size=8",
|
||||
"gradient.merge_batch_size=8",
|
||||
"gradient.analyst_workers=16",
|
||||
"gradient.use_deep_reflect=false",
|
||||
"optimizer.learning_rate=4",
|
||||
"optimizer.min_learning_rate=2",
|
||||
"optimizer.lr_scheduler=cosine",
|
||||
"optimizer.skill_update_mode=patch",
|
||||
"optimizer.use_slow_update=true",
|
||||
"optimizer.slow_update_samples=20",
|
||||
"optimizer.use_meta_skill=true",
|
||||
"optimizer.use_meta_reflect=false",
|
||||
"evaluation.use_gate=true",
|
||||
"evaluation.eval_test=true",
|
||||
"env.split_mode=split_dir",
|
||||
f"env.split_dir={DEFAULT_SPLIT[benchmark]}",
|
||||
f"env.out_root={out_root}",
|
||||
]
|
||||
|
||||
|
||||
def make_experiment(
|
||||
group: str,
|
||||
benchmark: str,
|
||||
suffix: str,
|
||||
run_root: Path,
|
||||
overrides: list[str],
|
||||
) -> Experiment:
|
||||
run_id = f"{group}-{benchmark}-{suffix}"
|
||||
out_root = run_root / run_id
|
||||
all_overrides = common_overrides(benchmark, out_root)
|
||||
all_overrides.extend(overrides)
|
||||
return Experiment(
|
||||
run_id=run_id,
|
||||
benchmark=benchmark,
|
||||
config=BENCH_CONFIG[benchmark],
|
||||
overrides=tuple(all_overrides),
|
||||
)
|
||||
|
||||
|
||||
def build_matrix(
|
||||
groups: set[str],
|
||||
benchmarks: list[str],
|
||||
run_root: Path,
|
||||
*,
|
||||
include_duplicate_defaults: bool = False,
|
||||
) -> list[Experiment]:
|
||||
exps: list[Experiment] = []
|
||||
group_order = [
|
||||
"default",
|
||||
"split",
|
||||
"batch",
|
||||
"mbs",
|
||||
"lr",
|
||||
"sched",
|
||||
"slown",
|
||||
"mod",
|
||||
"smodel",
|
||||
"longpair",
|
||||
"lrctrl",
|
||||
]
|
||||
|
||||
for group in group_order:
|
||||
if group not in groups:
|
||||
continue
|
||||
for benchmark in benchmarks:
|
||||
if group == "default":
|
||||
exps.append(make_experiment("DEFAULT", benchmark, "5.5", run_root, []))
|
||||
continue
|
||||
|
||||
if group == "split":
|
||||
for tag, (split_dir, extra) in SPLITS[benchmark].items():
|
||||
if not include_duplicate_defaults and tag == "2-1-7":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SPLIT",
|
||||
benchmark,
|
||||
tag,
|
||||
run_root,
|
||||
[f"env.split_dir={split_dir}", *extra],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "mbs":
|
||||
for value in (1, 2, 4, 8, 16, 32):
|
||||
if not include_duplicate_defaults and value == 8:
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"MBS",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[f"gradient.minibatch_size={value}"],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "batch":
|
||||
for value in BATCH_SIZE_VALUES:
|
||||
if not include_duplicate_defaults and value == 40:
|
||||
continue
|
||||
batch_size = DEFAULT_TRAIN_SIZE[benchmark] if value == "full" else int(value)
|
||||
exps.append(make_experiment(
|
||||
"BATCH",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[
|
||||
f"train.batch_size={batch_size}",
|
||||
"gradient.minibatch_size=8",
|
||||
],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "lr":
|
||||
for value in (1, 2, 4, 8, 16):
|
||||
exps.append(make_experiment(
|
||||
"LR",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[
|
||||
"optimizer.lr_scheduler=constant",
|
||||
"optimizer.min_learning_rate=1",
|
||||
f"optimizer.learning_rate={value}",
|
||||
],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "sched":
|
||||
for value in ("constant", "cosine", "linear"):
|
||||
if not include_duplicate_defaults and value == "cosine":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SCHED",
|
||||
benchmark,
|
||||
value,
|
||||
run_root,
|
||||
[f"optimizer.lr_scheduler={value}"],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "slown":
|
||||
for value in (5, 10, 20, 40):
|
||||
if not include_duplicate_defaults and value == 20:
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SLOWN",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[f"optimizer.slow_update_samples={value}"],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "mod":
|
||||
settings = {
|
||||
"slow-meta": ("true", "true"),
|
||||
"slow-only": ("true", "false"),
|
||||
"meta-only": ("false", "true"),
|
||||
"none": ("false", "false"),
|
||||
}
|
||||
for tag, (slow, meta) in settings.items():
|
||||
if not include_duplicate_defaults and tag == "slow-meta":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"MOD",
|
||||
benchmark,
|
||||
tag,
|
||||
run_root,
|
||||
[
|
||||
f"optimizer.use_slow_update={slow}",
|
||||
f"optimizer.use_meta_skill={meta}",
|
||||
],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "smodel":
|
||||
student_settings = {
|
||||
"5.4": [
|
||||
"model.student=gpt-5.4-pro",
|
||||
f"model.student_azure_openai_endpoint={T2_ENDPOINT}",
|
||||
"model.student_azure_openai_api_version=2025-03-01-preview",
|
||||
"model.student_azure_openai_auth_mode=azure_cli",
|
||||
],
|
||||
"5.4-mini": [
|
||||
"model.student=gpt-5.4-mini",
|
||||
f"model.student_azure_openai_endpoint={SEARCHAGENT5_ENDPOINT}",
|
||||
"model.student_azure_openai_api_version=2024-12-01-preview",
|
||||
"model.student_azure_openai_auth_mode=azure_cli",
|
||||
],
|
||||
"5.5": [],
|
||||
}
|
||||
for tag, overrides in student_settings.items():
|
||||
if not include_duplicate_defaults and tag == "5.5":
|
||||
continue
|
||||
exps.append(make_experiment("SMODEL", benchmark, tag, run_root, overrides))
|
||||
continue
|
||||
|
||||
if group == "longpair":
|
||||
for value in ("changed", "unchanged"):
|
||||
exps.append(make_experiment(
|
||||
"LONGPAIR",
|
||||
benchmark,
|
||||
value,
|
||||
run_root,
|
||||
[f"optimizer.longitudinal_pair_policy={value}"],
|
||||
))
|
||||
continue
|
||||
|
||||
if group == "lrctrl":
|
||||
settings = {
|
||||
"autonomous": ["optimizer.lr_control_mode=autonomous"],
|
||||
"full-rewrite": [
|
||||
"optimizer.lr_control_mode=none",
|
||||
"optimizer.skill_update_mode=full_rewrite_minibatch",
|
||||
],
|
||||
}
|
||||
for tag, overrides in settings.items():
|
||||
exps.append(make_experiment("LRCTRL", benchmark, tag, run_root, overrides))
|
||||
continue
|
||||
|
||||
return exps
|
||||
|
||||
|
||||
def _build_matrix_legacy(
|
||||
groups: set[str],
|
||||
benchmarks: list[str],
|
||||
run_root: Path,
|
||||
*,
|
||||
include_duplicate_defaults: bool = False,
|
||||
) -> list[Experiment]:
|
||||
exps: list[Experiment] = []
|
||||
for benchmark in benchmarks:
|
||||
if "default" in groups:
|
||||
exps.append(make_experiment("DEFAULT", benchmark, "5.5", run_root, []))
|
||||
|
||||
if "split" in groups:
|
||||
for tag, (split_dir, extra) in SPLITS[benchmark].items():
|
||||
if not include_duplicate_defaults and tag == "2-1-7":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SPLIT",
|
||||
benchmark,
|
||||
tag,
|
||||
run_root,
|
||||
[f"env.split_dir={split_dir}", *extra],
|
||||
))
|
||||
|
||||
if "mbs" in groups:
|
||||
for value in (1, 2, 4, 8, 16, 32):
|
||||
if not include_duplicate_defaults and value == 8:
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"MBS",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[f"gradient.minibatch_size={value}"],
|
||||
))
|
||||
|
||||
if "batch" in groups:
|
||||
for value in BATCH_SIZE_VALUES:
|
||||
if not include_duplicate_defaults and value == 40:
|
||||
continue
|
||||
batch_size = DEFAULT_TRAIN_SIZE[benchmark] if value == "full" else int(value)
|
||||
exps.append(make_experiment(
|
||||
"BATCH",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[
|
||||
f"train.batch_size={batch_size}",
|
||||
"gradient.minibatch_size=8",
|
||||
],
|
||||
))
|
||||
|
||||
if "lr" in groups:
|
||||
for value in (1, 2, 4, 8, 16):
|
||||
exps.append(make_experiment(
|
||||
"LR",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[
|
||||
"optimizer.lr_scheduler=constant",
|
||||
"optimizer.min_learning_rate=1",
|
||||
f"optimizer.learning_rate={value}",
|
||||
],
|
||||
))
|
||||
|
||||
if "sched" in groups:
|
||||
for value in ("constant", "cosine", "linear"):
|
||||
if not include_duplicate_defaults and value == "cosine":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SCHED",
|
||||
benchmark,
|
||||
value,
|
||||
run_root,
|
||||
[f"optimizer.lr_scheduler={value}"],
|
||||
))
|
||||
|
||||
if "slown" in groups:
|
||||
for value in (5, 10, 20, 40):
|
||||
if not include_duplicate_defaults and value == 20:
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"SLOWN",
|
||||
benchmark,
|
||||
str(value),
|
||||
run_root,
|
||||
[f"optimizer.slow_update_samples={value}"],
|
||||
))
|
||||
|
||||
if "mod" in groups:
|
||||
settings = {
|
||||
"slow-meta": ("true", "true"),
|
||||
"slow-only": ("true", "false"),
|
||||
"meta-only": ("false", "true"),
|
||||
"none": ("false", "false"),
|
||||
}
|
||||
for tag, (slow, meta) in settings.items():
|
||||
if not include_duplicate_defaults and tag == "slow-meta":
|
||||
continue
|
||||
exps.append(make_experiment(
|
||||
"MOD",
|
||||
benchmark,
|
||||
tag,
|
||||
run_root,
|
||||
[
|
||||
f"optimizer.use_slow_update={slow}",
|
||||
f"optimizer.use_meta_skill={meta}",
|
||||
],
|
||||
))
|
||||
|
||||
if "smodel" in groups:
|
||||
student_settings = {
|
||||
"5.4": [
|
||||
"model.student=gpt-5.4-pro",
|
||||
f"model.student_azure_openai_endpoint={T2_ENDPOINT}",
|
||||
"model.student_azure_openai_api_version=2025-03-01-preview",
|
||||
"model.student_azure_openai_auth_mode=azure_cli",
|
||||
],
|
||||
"5.4-mini": [
|
||||
"model.student=gpt-5.4-mini",
|
||||
f"model.student_azure_openai_endpoint={SEARCHAGENT5_ENDPOINT}",
|
||||
"model.student_azure_openai_api_version=2024-12-01-preview",
|
||||
"model.student_azure_openai_auth_mode=azure_cli",
|
||||
],
|
||||
"5.5": [],
|
||||
}
|
||||
for tag, overrides in student_settings.items():
|
||||
if not include_duplicate_defaults and tag == "5.5":
|
||||
continue
|
||||
exps.append(make_experiment("SMODEL", benchmark, tag, run_root, overrides))
|
||||
|
||||
if "longpair" in groups:
|
||||
for value in ("changed", "unchanged"):
|
||||
exps.append(make_experiment(
|
||||
"LONGPAIR",
|
||||
benchmark,
|
||||
value,
|
||||
run_root,
|
||||
[f"optimizer.longitudinal_pair_policy={value}"],
|
||||
))
|
||||
|
||||
if "lrctrl" in groups:
|
||||
settings = {
|
||||
"autonomous": ["optimizer.lr_control_mode=autonomous"],
|
||||
"full-rewrite": [
|
||||
"optimizer.lr_control_mode=none",
|
||||
"optimizer.skill_update_mode=full_rewrite_minibatch",
|
||||
],
|
||||
}
|
||||
for tag, overrides in settings.items():
|
||||
exps.append(make_experiment("LRCTRL", benchmark, tag, run_root, overrides))
|
||||
|
||||
return exps
|
||||
|
||||
|
||||
def command_for(exp: Experiment) -> list[str]:
|
||||
return [
|
||||
str(PYTHON_BIN),
|
||||
"scripts/train.py",
|
||||
"--config",
|
||||
exp.config,
|
||||
"--cfg-options",
|
||||
*exp.overrides,
|
||||
]
|
||||
|
||||
|
||||
def active_run_ids(run_root: Path, valid_run_ids: set[str] | None = None) -> set[str]:
|
||||
try:
|
||||
raw = subprocess.check_output(["pgrep", "-af", "scripts/train.py"], text=True)
|
||||
except subprocess.CalledProcessError:
|
||||
return set()
|
||||
pattern = re.compile(re.escape(str(run_root)) + r"/([^\s]+)")
|
||||
active: set[str] = set()
|
||||
for line in raw.splitlines():
|
||||
for match in pattern.finditer(line):
|
||||
run_id = match.group(1).strip("'\"")
|
||||
if run_id.endswith(".log") or "/" in run_id:
|
||||
continue
|
||||
if valid_run_ids is not None and run_id not in valid_run_ids:
|
||||
continue
|
||||
active.add(run_id)
|
||||
return active
|
||||
|
||||
|
||||
def completed_run_ids(run_root: Path) -> set[str]:
|
||||
return {
|
||||
path.parent.name
|
||||
for path in run_root.glob("*/summary.json")
|
||||
if path.is_file()
|
||||
}
|
||||
|
||||
|
||||
def print_commands(exps: list[Experiment]) -> None:
|
||||
for exp in exps:
|
||||
cmd = command_for(exp)
|
||||
print(f"\n# {exp.run_id}")
|
||||
print(" ".join(subprocess.list2cmdline([part]) for part in cmd))
|
||||
|
||||
|
||||
def run_commands(
|
||||
exps: list[Experiment],
|
||||
run_root: Path,
|
||||
max_parallel: int,
|
||||
run_retries: int,
|
||||
) -> int:
|
||||
logs_dir = run_root / "logs"
|
||||
logs_dir.mkdir(parents=True, exist_ok=True)
|
||||
active: list[tuple[Experiment, subprocess.Popen, object]] = []
|
||||
valid_run_ids = {exp.run_id for exp in exps}
|
||||
skipped_completed = completed_run_ids(run_root)
|
||||
skipped_active = active_run_ids(run_root, valid_run_ids)
|
||||
pending: list[tuple[Experiment, int]] = [
|
||||
(exp, 0)
|
||||
for exp in exps
|
||||
if exp.run_id not in skipped_completed and exp.run_id not in skipped_active
|
||||
]
|
||||
for run_id in sorted(skipped_completed):
|
||||
print(f"[SKIP_COMPLETED] {run_id}", flush=True)
|
||||
for run_id in sorted(skipped_active):
|
||||
print(f"[SKIP_ACTIVE] {run_id}", flush=True)
|
||||
failures = 0
|
||||
|
||||
while pending or active:
|
||||
external_active = active_run_ids(run_root, valid_run_ids) - {exp.run_id for exp, _, _ in active}
|
||||
while pending and len(active) + len(external_active) < max_parallel:
|
||||
exp, attempt = pending.pop(0)
|
||||
log_path = logs_dir / f"{exp.run_id}.log"
|
||||
if attempt:
|
||||
log_path = logs_dir / f"{exp.run_id}.retry{attempt}.log"
|
||||
log_f = open(log_path, "w", encoding="utf-8")
|
||||
print(f"[START] {exp.run_id} attempt={attempt + 1} log={log_path}", flush=True)
|
||||
proc = subprocess.Popen(
|
||||
command_for(exp),
|
||||
cwd=PROJECT_ROOT,
|
||||
stdout=log_f,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
)
|
||||
setattr(proc, "_attempt", attempt)
|
||||
active.append((exp, proc, log_f))
|
||||
|
||||
time.sleep(5)
|
||||
still_active: list[tuple[Experiment, subprocess.Popen, object]] = []
|
||||
for exp, proc, log_f in active:
|
||||
rc = proc.poll()
|
||||
if rc is None:
|
||||
still_active.append((exp, proc, log_f))
|
||||
continue
|
||||
log_f.close()
|
||||
if rc == 0:
|
||||
print(f"[DONE] {exp.run_id}", flush=True)
|
||||
else:
|
||||
if getattr(proc, "_attempt", 0) < run_retries:
|
||||
next_attempt = getattr(proc, "_attempt", 0) + 1
|
||||
pending.append((exp, next_attempt))
|
||||
print(f"[RETRY] {exp.run_id} rc={rc} next_attempt={next_attempt + 1}", flush=True)
|
||||
else:
|
||||
failures += 1
|
||||
print(f"[FAIL] {exp.run_id} rc={rc}", flush=True)
|
||||
active = still_active
|
||||
|
||||
return failures
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
"--groups",
|
||||
nargs="+",
|
||||
default=["default"],
|
||||
choices=[
|
||||
"default",
|
||||
"split",
|
||||
"batch",
|
||||
"mbs",
|
||||
"lr",
|
||||
"sched",
|
||||
"slown",
|
||||
"mod",
|
||||
"smodel",
|
||||
"longpair",
|
||||
"lrctrl",
|
||||
"all",
|
||||
],
|
||||
help="Experiment groups to include. Default: default.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bench",
|
||||
nargs="+",
|
||||
default=["searchqa", "spreadsheetbench"],
|
||||
choices=["searchqa", "spreadsheetbench", "livemathematicianbench", "alfworld", "docvqa"],
|
||||
)
|
||||
parser.add_argument("--run-root", default="", help="Output root. Default: outputs/ablation_<UTC timestamp>.")
|
||||
parser.add_argument("--max-parallel", type=int, default=1)
|
||||
parser.add_argument("--run-retries", type=int, default=1, help="Retry failed runs this many times. Default: 1.")
|
||||
parser.add_argument(
|
||||
"--include-duplicate-defaults",
|
||||
action="store_true",
|
||||
help="Also run ablation points that are exactly the default setting.",
|
||||
)
|
||||
parser.add_argument("--execute", action="store_true", help="Actually start runs. Without this, print commands only.")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
groups = set(args.groups)
|
||||
if "all" in groups:
|
||||
groups = {"default", "split", "batch", "mbs", "lr", "sched", "slown", "mod", "smodel"}
|
||||
|
||||
ts = time.strftime("%Y%m%d_%H%M%S", time.gmtime())
|
||||
run_root = Path(args.run_root) if args.run_root else PROJECT_ROOT / "outputs" / f"ablation_{ts}"
|
||||
if not run_root.is_absolute():
|
||||
run_root = PROJECT_ROOT / run_root
|
||||
run_root.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
exps = build_matrix(
|
||||
groups,
|
||||
args.bench,
|
||||
run_root,
|
||||
include_duplicate_defaults=args.include_duplicate_defaults,
|
||||
)
|
||||
print(f"run_root={run_root}")
|
||||
print(f"num_experiments={len(exps)}")
|
||||
print(f"groups={','.join(sorted(groups))}")
|
||||
print(f"bench={','.join(args.bench)}")
|
||||
|
||||
if not args.execute:
|
||||
print_commands(exps)
|
||||
return
|
||||
|
||||
max_parallel = max(1, int(args.max_parallel))
|
||||
failures = run_commands(
|
||||
exps,
|
||||
run_root,
|
||||
max_parallel=max_parallel,
|
||||
run_retries=max(0, int(args.run_retries)),
|
||||
)
|
||||
if failures:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+25
-17
@@ -1,26 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# SkillOpt — ALFWorld training launch script
|
||||
#
|
||||
# Prerequisites:
|
||||
# pip install -e ".[alfworld]"
|
||||
# pip install alfworld[full] && alfworld-download
|
||||
# ReflACT — ALFWorld training launch script
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/run_alfworld.sh
|
||||
# bash scripts/run_alfworld.sh --num_epochs 2 --edit_budget 6
|
||||
# bash scripts/run_alfworld.sh --split_dir /path/to/alfworld_split
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
# ── Paths ────────────────────────────────────────────────────────────────────
|
||||
WORKSPACE="/home/azureuser/workspace-gzy"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
# Activate conda environment
|
||||
export PATH="${WORKSPACE}/miniconda3/envs/skillopt/bin:${WORKSPACE}/miniconda3/bin:${PATH}"
|
||||
|
||||
# ALFWorld data — uses ~/.cache/alfworld by default
|
||||
# ALFWorld data — uses ~/.cache/alfworld by default (standard alfworld location)
|
||||
export ALFWORLD_DATA="${ALFWORLD_DATA:-${HOME}/.cache/alfworld}"
|
||||
|
||||
# Ensure ReflACT is importable
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
# ── Verify ALFWorld data exists ──────────────────────────────────────────────
|
||||
if [ ! -d "${ALFWORLD_DATA}/json_2.1.1" ]; then
|
||||
echo "ERROR: ALFWorld data not found at ${ALFWORLD_DATA}/json_2.1.1"
|
||||
echo ""
|
||||
@@ -32,17 +34,25 @@ if [ ! -d "${ALFWORLD_DATA}/json_2.1.1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OPTIMIZER_MODEL="${OPTIMIZER_MODEL:-gpt-5.5}"
|
||||
TARGET_MODEL="${TARGET_MODEL:-gpt-5.5}"
|
||||
# ── Azure OpenAI credentials ────────────────────────────────────────────────
|
||||
export AZURE_OPENAI_ENDPOINT="${AZURE_OPENAI_ENDPOINT:-https://agl-dev.cognitiveservices.azure.com/}"
|
||||
export AZURE_OPENAI_API_KEY="${AZURE_OPENAI_API_KEY:-<your-azure-openai-api-key>}"
|
||||
export AZURE_OPENAI_API_VERSION="${AZURE_OPENAI_API_VERSION:-2025-04-01-preview}"
|
||||
|
||||
# ── Model configuration ─────────────────────────────────────────────────────
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
# ── Output directory ─────────────────────────────────────────────────────────
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_alfworld_${TARGET_MODEL}_${TIMESTAMP}"
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_alfworld_${STUDENT_DEPLOYMENT}_${TIMESTAMP}"
|
||||
|
||||
# ── Run ──────────────────────────────────────────────────────────────────────
|
||||
echo "============================================================"
|
||||
echo " SkillOpt — ALFWorld Training"
|
||||
echo " ReflACT — Reflective Agent Tuning (ALFWorld)"
|
||||
echo "============================================================"
|
||||
echo " Optimizer: ${OPTIMIZER_MODEL}"
|
||||
echo " Target: ${TARGET_MODEL}"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo " ALFWORLD_DATA: ${ALFWORLD_DATA}"
|
||||
echo " Output: ${DEFAULT_OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
@@ -50,9 +60,7 @@ echo "============================================================"
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/alfworld/default.yaml \
|
||||
--optimizer_model "${OPTIMIZER_MODEL}" \
|
||||
--target_model "${TARGET_MODEL}" \
|
||||
--config configs/alfworld_default.yaml \
|
||||
--out_root "${DEFAULT_OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
|
||||
Executable
+94
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_ROOT="/home/azureuser/workspace-gzy/SkillReflection_dev"
|
||||
PYTHON_BIN="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
TS="$(date -u +%Y%m%d_%H%M%S)"
|
||||
RUN_ROOT="${PROJECT_ROOT}/outputs/meta_skill_ablation_${TS}"
|
||||
|
||||
mkdir -p "${RUN_ROOT}"
|
||||
|
||||
run_train() {
|
||||
local benchmark="$1"
|
||||
local reasoning="$2"
|
||||
local condition="$3"
|
||||
local config_path=""
|
||||
local reasoning_override=""
|
||||
local meta_skill_flag=""
|
||||
|
||||
case "${benchmark}" in
|
||||
searchqa)
|
||||
config_path="configs/searchqa/default.yaml"
|
||||
;;
|
||||
spreadsheetbench)
|
||||
config_path="configs/spreadsheetbench/default.yaml"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown benchmark: ${benchmark}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${reasoning}" in
|
||||
medium)
|
||||
reasoning_override="model.reasoning_effort=medium"
|
||||
;;
|
||||
none)
|
||||
reasoning_override="model.reasoning_effort="
|
||||
;;
|
||||
*)
|
||||
echo "Unknown reasoning setting: ${reasoning}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${condition}" in
|
||||
slow)
|
||||
meta_skill_flag="optimizer.use_meta_skill=false"
|
||||
;;
|
||||
slow_meta)
|
||||
meta_skill_flag="optimizer.use_meta_skill=true"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown condition: ${condition}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
local out_root="${RUN_ROOT}/${benchmark}_${reasoning}_${condition}"
|
||||
|
||||
echo
|
||||
echo "============================================================"
|
||||
echo "START ${benchmark} ${reasoning} ${condition}"
|
||||
echo "out_root=${out_root}"
|
||||
echo "============================================================"
|
||||
|
||||
(
|
||||
cd "${PROJECT_ROOT}"
|
||||
"${PYTHON_BIN}" scripts/train.py \
|
||||
--config "${config_path}" \
|
||||
--cfg-options \
|
||||
"${reasoning_override}" \
|
||||
"optimizer.use_slow_update=true" \
|
||||
"${meta_skill_flag}" \
|
||||
"optimizer.use_meta_reflect=false" \
|
||||
"gradient.use_deep_reflect=false" \
|
||||
"env.out_root=${out_root}"
|
||||
)
|
||||
|
||||
echo
|
||||
echo "============================================================"
|
||||
echo "DONE ${benchmark} ${reasoning} ${condition}"
|
||||
echo "============================================================"
|
||||
}
|
||||
|
||||
for benchmark in searchqa spreadsheetbench; do
|
||||
for reasoning in medium none; do
|
||||
run_train "${benchmark}" "${reasoning}" "slow"
|
||||
run_train "${benchmark}" "${reasoning}" "slow_meta"
|
||||
done
|
||||
done
|
||||
|
||||
echo
|
||||
echo "All runs completed."
|
||||
echo "Run root: ${RUN_ROOT}"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_ROOT="/home/azureuser/workspace-gzy/SkillReflection_dev"
|
||||
PYTHON_BIN="/home/azureuser/workspace-gzy/miniconda3/envs/skillopt/bin/python"
|
||||
RUN_ROOT="${PROJECT_ROOT}/outputs/meta_skill_parallel_20260430_072356"
|
||||
LOG_DIR="${PROJECT_ROOT}/logs/meta_skill_parallel_20260430_072356"
|
||||
|
||||
mkdir -p "${RUN_ROOT}" "${LOG_DIR}"
|
||||
|
||||
start_run() {
|
||||
local name="$1"
|
||||
local config_path="$2"
|
||||
local meta_skill="$3"
|
||||
local out_root="${RUN_ROOT}/${name}"
|
||||
local log_path="${LOG_DIR}/${name}.log"
|
||||
|
||||
echo "[START] ${name}"
|
||||
echo " out_root=${out_root}"
|
||||
echo " log=${log_path}"
|
||||
|
||||
(
|
||||
cd "${PROJECT_ROOT}"
|
||||
PYTHONUNBUFFERED=1 "${PYTHON_BIN}" scripts/train.py \
|
||||
--config "${config_path}" \
|
||||
--cfg-options \
|
||||
"model.reasoning_effort=medium" \
|
||||
"optimizer.use_slow_update=true" \
|
||||
"optimizer.use_meta_skill=${meta_skill}" \
|
||||
"optimizer.use_meta_reflect=false" \
|
||||
"gradient.use_deep_reflect=false" \
|
||||
"env.out_root=${out_root}"
|
||||
) > "${log_path}" 2>&1 &
|
||||
|
||||
echo "$!" > "${LOG_DIR}/${name}.pid"
|
||||
}
|
||||
|
||||
start_run "searchqa_medium_slow_meta" "configs/searchqa/default.yaml" "true"
|
||||
start_run "spreadsheetbench_medium_slow" "configs/spreadsheetbench/default.yaml" "false"
|
||||
start_run "spreadsheetbench_medium_slow_meta" "configs/spreadsheetbench/default.yaml" "true"
|
||||
|
||||
echo "[WAIT] missing comparison runs are active"
|
||||
wait
|
||||
+14
-11
@@ -1,38 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# SkillOpt — SearchQA training launch script
|
||||
# ReflACT — SearchQA training launch script
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/run_searchqa.sh
|
||||
# bash scripts/run_searchqa.sh --data_path data/searchqa_train_2000.json
|
||||
# bash scripts/run_searchqa.sh --num_epochs 2 --edit_budget 6
|
||||
# bash scripts/run_searchqa.sh --split_dir /path/to/searchqa_split
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
# ── Paths ────────────────────────────────────────────────────────────────────
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
# Ensure ReflACT is importable
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
OPTIMIZER_MODEL="${OPTIMIZER_MODEL:-gpt-5.5}"
|
||||
TARGET_MODEL="${TARGET_MODEL:-gpt-5.5}"
|
||||
# ── Model configuration ─────────────────────────────────────────────────────
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
# ── Output directory ─────────────────────────────────────────────────────────
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_searchqa_${TARGET_MODEL}_${TIMESTAMP}"
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_searchqa_${STUDENT_DEPLOYMENT}_${TIMESTAMP}"
|
||||
|
||||
# ── Run ──────────────────────────────────────────────────────────────────────
|
||||
echo "============================================================"
|
||||
echo " SkillOpt — SearchQA Training"
|
||||
echo " ReflACT — Reflective Agent Tuning (SearchQA)"
|
||||
echo "============================================================"
|
||||
echo " Optimizer: ${OPTIMIZER_MODEL}"
|
||||
echo " Target: ${TARGET_MODEL}"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa/default.yaml \
|
||||
--optimizer_model "${OPTIMIZER_MODEL}" \
|
||||
--target_model "${TARGET_MODEL}" \
|
||||
--config configs/searchqa_default.yaml \
|
||||
--out_root "${DEFAULT_OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
|
||||
@@ -1,37 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# SkillOpt — SpreadsheetBench training launch script
|
||||
# ReflACT — SpreadsheetBench training launch script
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/run_spreadsheetbench.sh --split_dir /path/to/split --data_root /path/to/data
|
||||
# bash scripts/run_spreadsheetbench.sh --num_epochs 2 --edit_budget 6
|
||||
# bash scripts/run_spreadsheetbench.sh \
|
||||
# --data_root /path/to/data \
|
||||
# --jsonl_path /path/to/benchmark.jsonl
|
||||
#
|
||||
# bash scripts/run_spreadsheetbench.sh \
|
||||
# --data_root /path/to/data \
|
||||
# --jsonl_path /path/to/benchmark.jsonl \
|
||||
# --num_epochs 2 --edit_budget 6
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
# ── Paths ────────────────────────────────────────────────────────────────────
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
# Ensure ReflACT is importable
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
OPTIMIZER_MODEL="${OPTIMIZER_MODEL:-gpt-5.5}"
|
||||
TARGET_MODEL="${TARGET_MODEL:-gpt-5.5}"
|
||||
# ── Model configuration ─────────────────────────────────────────────────────
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
# ── Output directory ─────────────────────────────────────────────────────────
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_spreadsheetbench_${TARGET_MODEL}_${TIMESTAMP}"
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/skillopt_spreadsheetbench_${STUDENT_DEPLOYMENT}_${TIMESTAMP}"
|
||||
|
||||
# ── Run ──────────────────────────────────────────────────────────────────────
|
||||
echo "============================================================"
|
||||
echo " SkillOpt — SpreadsheetBench Training"
|
||||
echo " ReflACT — Reflective Agent Tuning (SpreadsheetBench)"
|
||||
echo "============================================================"
|
||||
echo " Optimizer: ${OPTIMIZER_MODEL}"
|
||||
echo " Target: ${TARGET_MODEL}"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/spreadsheetbench/default.yaml \
|
||||
--optimizer_model "${OPTIMIZER_MODEL}" \
|
||||
--target_model "${TARGET_MODEL}" \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--out_root "${DEFAULT_OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
|
||||
+77
-88
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""SkillOpt unified training entry point.
|
||||
"""ReflACT unified training entry point.
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -125,7 +125,7 @@ _BOOL = lambda x: x.lower() in ("true", "1", "yes") # noqa: E731
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
p = argparse.ArgumentParser(
|
||||
description="SkillOpt: Executive Strategy for Self-Evolving Agent Skills",
|
||||
description="ReflACT: Reflective Agent Tuning",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog=__doc__,
|
||||
)
|
||||
@@ -137,11 +137,11 @@ def parse_args() -> argparse.Namespace:
|
||||
# Legacy flat CLI overrides (still work, prefer --cfg-options for new usage)
|
||||
p.add_argument("--env", type=str)
|
||||
p.add_argument("--backend", type=str,
|
||||
choices=["azure_openai", "codex", "codex_exec", "claude", "claude_chat", "claude_code_exec", "qwen", "qwen_chat"])
|
||||
p.add_argument("--optimizer_model", type=str)
|
||||
p.add_argument("--target_model", type=str)
|
||||
p.add_argument("--optimizer_backend", type=str)
|
||||
p.add_argument("--target_backend", type=str)
|
||||
choices=["azure_openai", "codex", "codex_exec", "claude", "claude_chat", "claude_code_exec"])
|
||||
p.add_argument("--teacher_model", type=str)
|
||||
p.add_argument("--student_model", type=str)
|
||||
p.add_argument("--teacher_backend", type=str)
|
||||
p.add_argument("--student_backend", type=str)
|
||||
p.add_argument("--reasoning_effort", type=str,
|
||||
choices=["", "low", "medium", "high", "xhigh", "max"])
|
||||
p.add_argument("--rewrite_reasoning_effort", type=str)
|
||||
@@ -155,24 +155,18 @@ def parse_args() -> argparse.Namespace:
|
||||
p.add_argument("--azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_api_version", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_api_key", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--optimizer_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--target_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--target_azure_openai_api_version", type=str)
|
||||
p.add_argument("--target_azure_openai_api_key", type=str)
|
||||
p.add_argument("--target_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--target_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--target_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--qwen_chat_base_url", type=str)
|
||||
p.add_argument("--qwen_chat_api_key", type=str)
|
||||
p.add_argument("--qwen_chat_temperature", type=float)
|
||||
p.add_argument("--qwen_chat_timeout_seconds", type=float)
|
||||
p.add_argument("--qwen_chat_max_tokens", type=int)
|
||||
p.add_argument("--qwen_chat_enable_thinking", type=_BOOL)
|
||||
p.add_argument("--teacher_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--teacher_azure_openai_api_version", type=str)
|
||||
p.add_argument("--teacher_azure_openai_api_key", type=str)
|
||||
p.add_argument("--teacher_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--teacher_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--teacher_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--student_azure_openai_endpoint", type=str)
|
||||
p.add_argument("--student_azure_openai_api_version", type=str)
|
||||
p.add_argument("--student_azure_openai_api_key", type=str)
|
||||
p.add_argument("--student_azure_openai_auth_mode", type=str)
|
||||
p.add_argument("--student_azure_openai_ad_scope", type=str)
|
||||
p.add_argument("--student_azure_openai_managed_identity_client_id", type=str)
|
||||
p.add_argument("--codex_exec_path", type=str)
|
||||
p.add_argument("--codex_exec_sandbox", type=str)
|
||||
p.add_argument("--codex_exec_profile", type=str)
|
||||
@@ -187,7 +181,7 @@ def parse_args() -> argparse.Namespace:
|
||||
p.add_argument("--claude_code_exec_use_sdk", type=str)
|
||||
p.add_argument("--claude_code_exec_effort", type=str)
|
||||
p.add_argument("--claude_code_exec_max_thinking_tokens", type=int)
|
||||
p.add_argument("--codex_trace_to_optimizer", type=_BOOL)
|
||||
p.add_argument("--codex_trace_to_teacher", type=_BOOL)
|
||||
p.add_argument("--skill_init", type=str)
|
||||
p.add_argument("--num_epochs", type=int)
|
||||
p.add_argument("--train_size", type=int)
|
||||
@@ -212,6 +206,8 @@ def parse_args() -> argparse.Namespace:
|
||||
p.add_argument("--analyst_workers", type=int)
|
||||
p.add_argument("--failure_only", type=_BOOL)
|
||||
p.add_argument("--minibatch_size", type=int)
|
||||
p.add_argument("--use_meta_reflect", type=_BOOL)
|
||||
p.add_argument("--meta_edit_budget", type=int)
|
||||
p.add_argument("--skill_update_mode", type=str,
|
||||
choices=[
|
||||
"patch",
|
||||
@@ -222,6 +218,9 @@ def parse_args() -> argparse.Namespace:
|
||||
"full_rewrite_minibatch",
|
||||
"minibatch_full_rewrite",
|
||||
])
|
||||
p.add_argument("--use_deep_reflect", type=_BOOL)
|
||||
p.add_argument("--deep_reflect_failures", type=int)
|
||||
p.add_argument("--deep_reflect_successes", type=int)
|
||||
p.add_argument("--use_slow_update", type=_BOOL)
|
||||
p.add_argument("--slow_update_samples", type=int)
|
||||
p.add_argument("--longitudinal_pair_policy", type=str,
|
||||
@@ -255,10 +254,10 @@ def parse_args() -> argparse.Namespace:
|
||||
|
||||
_LEGACY_TO_STRUCTURED: dict[str, str] = {
|
||||
"backend": "model.backend",
|
||||
"optimizer_model": "model.optimizer",
|
||||
"target_model": "model.target",
|
||||
"optimizer_backend": "model.optimizer_backend",
|
||||
"target_backend": "model.target_backend",
|
||||
"teacher_model": "model.teacher",
|
||||
"student_model": "model.student",
|
||||
"teacher_backend": "model.teacher_backend",
|
||||
"student_backend": "model.student_backend",
|
||||
"reasoning_effort": "model.reasoning_effort",
|
||||
"rewrite_reasoning_effort": "model.rewrite_reasoning_effort",
|
||||
"rewrite_max_completion_tokens": "model.rewrite_max_completion_tokens",
|
||||
@@ -271,24 +270,18 @@ _LEGACY_TO_STRUCTURED: dict[str, str] = {
|
||||
"azure_openai_auth_mode": "model.azure_openai_auth_mode",
|
||||
"azure_openai_ad_scope": "model.azure_openai_ad_scope",
|
||||
"azure_openai_managed_identity_client_id": "model.azure_openai_managed_identity_client_id",
|
||||
"optimizer_azure_openai_endpoint": "model.optimizer_azure_openai_endpoint",
|
||||
"optimizer_azure_openai_api_version": "model.optimizer_azure_openai_api_version",
|
||||
"optimizer_azure_openai_api_key": "model.optimizer_azure_openai_api_key",
|
||||
"optimizer_azure_openai_auth_mode": "model.optimizer_azure_openai_auth_mode",
|
||||
"optimizer_azure_openai_ad_scope": "model.optimizer_azure_openai_ad_scope",
|
||||
"optimizer_azure_openai_managed_identity_client_id": "model.optimizer_azure_openai_managed_identity_client_id",
|
||||
"target_azure_openai_endpoint": "model.target_azure_openai_endpoint",
|
||||
"target_azure_openai_api_version": "model.target_azure_openai_api_version",
|
||||
"target_azure_openai_api_key": "model.target_azure_openai_api_key",
|
||||
"target_azure_openai_auth_mode": "model.target_azure_openai_auth_mode",
|
||||
"target_azure_openai_ad_scope": "model.target_azure_openai_ad_scope",
|
||||
"target_azure_openai_managed_identity_client_id": "model.target_azure_openai_managed_identity_client_id",
|
||||
"qwen_chat_base_url": "model.qwen_chat_base_url",
|
||||
"qwen_chat_api_key": "model.qwen_chat_api_key",
|
||||
"qwen_chat_temperature": "model.qwen_chat_temperature",
|
||||
"qwen_chat_timeout_seconds": "model.qwen_chat_timeout_seconds",
|
||||
"qwen_chat_max_tokens": "model.qwen_chat_max_tokens",
|
||||
"qwen_chat_enable_thinking": "model.qwen_chat_enable_thinking",
|
||||
"teacher_azure_openai_endpoint": "model.teacher_azure_openai_endpoint",
|
||||
"teacher_azure_openai_api_version": "model.teacher_azure_openai_api_version",
|
||||
"teacher_azure_openai_api_key": "model.teacher_azure_openai_api_key",
|
||||
"teacher_azure_openai_auth_mode": "model.teacher_azure_openai_auth_mode",
|
||||
"teacher_azure_openai_ad_scope": "model.teacher_azure_openai_ad_scope",
|
||||
"teacher_azure_openai_managed_identity_client_id": "model.teacher_azure_openai_managed_identity_client_id",
|
||||
"student_azure_openai_endpoint": "model.student_azure_openai_endpoint",
|
||||
"student_azure_openai_api_version": "model.student_azure_openai_api_version",
|
||||
"student_azure_openai_api_key": "model.student_azure_openai_api_key",
|
||||
"student_azure_openai_auth_mode": "model.student_azure_openai_auth_mode",
|
||||
"student_azure_openai_ad_scope": "model.student_azure_openai_ad_scope",
|
||||
"student_azure_openai_managed_identity_client_id": "model.student_azure_openai_managed_identity_client_id",
|
||||
"codex_exec_path": "model.codex_exec_path",
|
||||
"codex_exec_sandbox": "model.codex_exec_sandbox",
|
||||
"codex_exec_profile": "model.codex_exec_profile",
|
||||
@@ -303,7 +296,7 @@ _LEGACY_TO_STRUCTURED: dict[str, str] = {
|
||||
"claude_code_exec_use_sdk": "model.claude_code_exec_use_sdk",
|
||||
"claude_code_exec_effort": "model.claude_code_exec_effort",
|
||||
"claude_code_exec_max_thinking_tokens": "model.claude_code_exec_max_thinking_tokens",
|
||||
"codex_trace_to_optimizer": "model.codex_trace_to_optimizer",
|
||||
"codex_trace_to_teacher": "model.codex_trace_to_teacher",
|
||||
"num_epochs": "train.num_epochs",
|
||||
"train_size": "train.train_size",
|
||||
"steps_per_epoch": "train.steps_per_epoch",
|
||||
@@ -315,11 +308,16 @@ _LEGACY_TO_STRUCTURED: dict[str, str] = {
|
||||
"analyst_workers": "gradient.analyst_workers",
|
||||
"max_analyst_rounds": "gradient.max_analyst_rounds",
|
||||
"failure_only": "gradient.failure_only",
|
||||
"use_deep_reflect": "gradient.use_deep_reflect",
|
||||
"deep_reflect_failures": "gradient.deep_reflect_failures",
|
||||
"deep_reflect_successes": "gradient.deep_reflect_successes",
|
||||
"edit_budget": "optimizer.learning_rate",
|
||||
"min_edit_budget": "optimizer.min_learning_rate",
|
||||
"lr_scheduler": "optimizer.lr_scheduler",
|
||||
"lr_control_mode": "optimizer.lr_control_mode",
|
||||
"skill_update_mode": "optimizer.skill_update_mode",
|
||||
"use_meta_reflect": "optimizer.use_meta_reflect",
|
||||
"meta_edit_budget": "optimizer.meta_learning_rate",
|
||||
"use_slow_update": "optimizer.use_slow_update",
|
||||
"slow_update_samples": "optimizer.slow_update_samples",
|
||||
"longitudinal_pair_policy": "optimizer.longitudinal_pair_policy",
|
||||
@@ -377,7 +375,7 @@ def load_config(args: argparse.Namespace) -> dict:
|
||||
explicit_backend = str(option).split("=", 1)[1].strip()
|
||||
break
|
||||
|
||||
backend = normalize_backend_name(flat.get("model_backend") or flat.get("target_backend") or "azure_openai")
|
||||
backend = normalize_backend_name(flat.get("model_backend") or flat.get("student_backend") or "azure_openai")
|
||||
|
||||
def _has_model_override(dotted_key: str, legacy_key: str) -> bool:
|
||||
if getattr(args, legacy_key, None) is not None:
|
||||
@@ -392,53 +390,44 @@ def load_config(args: argparse.Namespace) -> dict:
|
||||
backend = normalize_backend_name(explicit_backend)
|
||||
flat["model_backend"] = backend
|
||||
if backend in {"claude", "claude_chat"}:
|
||||
flat.setdefault("optimizer_backend", "claude_chat")
|
||||
flat.setdefault("target_backend", "claude_chat")
|
||||
flat.setdefault("teacher_backend", "claude_chat")
|
||||
flat.setdefault("student_backend", "claude_chat")
|
||||
elif backend in {"codex", "codex_exec"}:
|
||||
flat.setdefault("optimizer_backend", "openai_chat")
|
||||
flat.setdefault("target_backend", "codex_exec")
|
||||
flat.setdefault("teacher_backend", "openai_chat")
|
||||
flat.setdefault("student_backend", "codex_exec")
|
||||
elif backend == "claude_code_exec":
|
||||
flat.setdefault("optimizer_backend", "openai_chat")
|
||||
flat.setdefault("target_backend", "claude_code_exec")
|
||||
elif backend in {"qwen", "qwen_chat"}:
|
||||
flat.setdefault("optimizer_backend", "openai_chat")
|
||||
flat.setdefault("target_backend", "qwen_chat")
|
||||
flat.setdefault("teacher_backend", "openai_chat")
|
||||
flat.setdefault("student_backend", "claude_code_exec")
|
||||
else:
|
||||
flat.setdefault("optimizer_backend", "openai_chat")
|
||||
flat.setdefault("target_backend", "openai_chat")
|
||||
flat.setdefault("teacher_backend", "openai_chat")
|
||||
flat.setdefault("student_backend", "openai_chat")
|
||||
else:
|
||||
flat.setdefault("optimizer_backend", "openai_chat")
|
||||
flat.setdefault("target_backend", "openai_chat")
|
||||
flat.setdefault("teacher_backend", "openai_chat")
|
||||
flat.setdefault("student_backend", "openai_chat")
|
||||
|
||||
if flat.get("optimizer_backend") == "claude_chat":
|
||||
if flat.get("teacher_backend") == "claude_chat":
|
||||
if (
|
||||
str(flat.get("optimizer_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.optimizer", "optimizer_model")
|
||||
str(flat.get("teacher_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.teacher", "teacher_model")
|
||||
):
|
||||
flat["optimizer_model"] = default_model_for_backend("claude_chat")
|
||||
if flat.get("target_backend") == "claude_chat":
|
||||
flat["teacher_model"] = default_model_for_backend("claude_chat")
|
||||
if flat.get("student_backend") == "claude_chat":
|
||||
if (
|
||||
str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.target", "target_model")
|
||||
str(flat.get("student_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.student", "student_model")
|
||||
):
|
||||
flat["target_model"] = default_model_for_backend("claude_chat")
|
||||
if flat.get("target_backend") == "claude_code_exec":
|
||||
flat["student_model"] = default_model_for_backend("claude_chat")
|
||||
if flat.get("student_backend") == "claude_code_exec":
|
||||
if (
|
||||
str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.target", "target_model")
|
||||
str(flat.get("student_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.student", "student_model")
|
||||
):
|
||||
flat["target_model"] = default_model_for_backend("claude_chat")
|
||||
if flat.get("target_backend") == "qwen_chat":
|
||||
if (
|
||||
str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
|
||||
and not _has_model_override("model.target", "target_model")
|
||||
):
|
||||
flat["target_model"] = default_model_for_backend("qwen_chat")
|
||||
flat["student_model"] = default_model_for_backend("claude_chat")
|
||||
|
||||
# Auto-generate output root
|
||||
if not flat.get("out_root"):
|
||||
env = flat.get("env", "unknown")
|
||||
model = flat.get("optimizer_model", "unknown").replace("/", "-")
|
||||
model = flat.get("teacher_model", "unknown").replace("/", "-")
|
||||
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
flat["out_root"] = os.path.join("outputs", f"skillopt_{env}_{model}_{ts}")
|
||||
|
||||
@@ -453,13 +442,13 @@ def main() -> None:
|
||||
cfg = load_config(args)
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f" SkillOpt — Executive Strategy for Self-Evolving Agent Skills")
|
||||
print(f" ReflACT — Reflective Agent Tuning")
|
||||
print(f"{'='*60}")
|
||||
print(f" env: {cfg.get('env')}")
|
||||
print(f" optimizer_model: {cfg.get('optimizer_model')}")
|
||||
print(f" target_model: {cfg.get('target_model')}")
|
||||
print(f" optimizer_backend:{cfg.get('optimizer_backend', 'openai_chat')}")
|
||||
print(f" target_backend:{cfg.get('target_backend', 'openai_chat')}")
|
||||
print(f" teacher_model: {cfg.get('teacher_model')}")
|
||||
print(f" student_model: {cfg.get('student_model')}")
|
||||
print(f" teacher_backend:{cfg.get('teacher_backend', 'openai_chat')}")
|
||||
print(f" student_backend:{cfg.get('student_backend', 'openai_chat')}")
|
||||
print(f" reasoning: {cfg.get('reasoning_effort') or 'off'}")
|
||||
print(f" rewrite_effort: {cfg.get('rewrite_reasoning_effort') or 'off'}")
|
||||
print(f" epochs: {cfg.get('num_epochs')}")
|
||||
@@ -472,8 +461,8 @@ def main() -> None:
|
||||
print(f" min_edit_budget:{cfg.get('min_edit_budget', 2)}")
|
||||
print(f" minibatch_size: {cfg.get('minibatch_size')}")
|
||||
print(f" seed: {cfg.get('seed')}")
|
||||
print(f" meta_reflect: {cfg.get('use_meta_reflect', False)}")
|
||||
print(f" meta_skill: {cfg.get('use_meta_skill', False)}")
|
||||
print(f" slow_update: {cfg.get('use_slow_update', False)}")
|
||||
print(f" out_root: {cfg.get('out_root')}")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# ReflACT3 — SearchQA Training
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/train_searchqa.sh
|
||||
# bash scripts/train_searchqa.sh --limit 50
|
||||
# bash scripts/train_searchqa.sh --num_epochs 2 --workers 32
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
|
||||
# ── Models ───────────────────────────────────────────────────────────────────
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
# ── Data ─────────────────────────────────────────────────────────────────────
|
||||
DATA_PATH="/home/azureuser/workspace-yqh/refleAct/search-qa/data/searchqa_train_2000.json"
|
||||
|
||||
# ── Output ───────────────────────────────────────────────────────────────────
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEFAULT_OUT_ROOT="${PROJECT_ROOT}/outputs/searchqa-metaskill/searchqa_${STUDENT_DEPLOYMENT}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " ReflACT3 — SearchQA Training"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo " Data: ${DATA_PATH}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/searchqa_default.yaml \
|
||||
--data_path "${DATA_PATH}" \
|
||||
--out_root "${DEFAULT_OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
echo ""
|
||||
echo "Done! Results saved to: ${DEFAULT_OUT_ROOT}"
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# ReflACT — SpreadsheetBench training (MULTI-ROUND codegen, no tool-call)
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/train_spreadsheet_multi.sh
|
||||
# bash scripts/train_spreadsheet_multi.sh --num_epochs 2 --max_turns 5
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
DATA_ROOT="/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH="${DATA_ROOT}/dataset.json"
|
||||
SPLIT_DIR="/home/azureuser/workspace-yqh/refleACT3/data/spreadsheetbench_split_2_1_7"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
OUT_ROOT="${PROJECT_ROOT}/outputs/spreadsheet-metaskill-new/train_multi_${STUDENT_DEPLOYMENT}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " ReflACT — SpreadsheetBench Training (MULTI-ROUND)"
|
||||
echo "============================================================"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo " Mode: multi"
|
||||
echo " Data: ${DATA_ROOT}"
|
||||
echo " Split: ${SPLIT_DIR}"
|
||||
echo " Output: ${OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--mode multi \
|
||||
--data_root "${DATA_ROOT}" \
|
||||
--jsonl_path "${JSONL_PATH}" \
|
||||
--split_dir "${SPLIT_DIR}" \
|
||||
--out_root "${OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
echo ""
|
||||
echo "Done! Results saved to: ${OUT_ROOT}"
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# ReflACT — SpreadsheetBench training (SINGLE-ROUND codegen, no tool-call)
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/train_spreadsheet_single.sh
|
||||
# bash scripts/train_spreadsheet_single.sh --num_epochs 2 --edit_budget 6
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")"
|
||||
|
||||
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH:-}"
|
||||
export TEACHER_DEPLOYMENT="${TEACHER_DEPLOYMENT:-gpt-5.5}"
|
||||
export STUDENT_DEPLOYMENT="${STUDENT_DEPLOYMENT:-gpt-5.5}"
|
||||
|
||||
DATA_ROOT="/home/azureuser/workspace-yqh/sr/spreadsheetbench/data/spreadsheetbench_verified_400"
|
||||
JSONL_PATH="${DATA_ROOT}/dataset.json"
|
||||
SPLIT_DIR="/home/azureuser/workspace-yqh/refleACT3/data/spreadsheetbench_split_2_1_7"
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
OUT_ROOT="${PROJECT_ROOT}/outputs/spreadsheet-metaskill-new/train_single_${STUDENT_DEPLOYMENT}"
|
||||
|
||||
echo "============================================================"
|
||||
echo " ReflACT — SpreadsheetBench Training (SINGLE-ROUND)"
|
||||
echo "============================================================"
|
||||
echo " Teacher: ${TEACHER_DEPLOYMENT}"
|
||||
echo " Student: ${STUDENT_DEPLOYMENT}"
|
||||
echo " Mode: single"
|
||||
echo " Data: ${DATA_ROOT}"
|
||||
echo " Split: ${SPLIT_DIR}"
|
||||
echo " Output: ${OUT_ROOT}"
|
||||
echo "============================================================"
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
|
||||
python scripts/train.py \
|
||||
--config configs/spreadsheetbench_default.yaml \
|
||||
--mode single \
|
||||
--data_root "${DATA_ROOT}" \
|
||||
--jsonl_path "${JSONL_PATH}" \
|
||||
--split_dir "${SPLIT_DIR}" \
|
||||
--out_root "${OUT_ROOT}" \
|
||||
"$@"
|
||||
|
||||
echo ""
|
||||
echo "Done! Results saved to: ${OUT_ROOT}"
|
||||
@@ -0,0 +1,218 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Watch an ablation run root and rerun final failures.
|
||||
|
||||
This watcher is intended to run in tmux next to scripts/run_ablation_matrix.py.
|
||||
It writes STATUS.md on every poll and starts a direct rerun for any run that
|
||||
the launcher marks as final [FAIL].
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from run_ablation_matrix import PROJECT_ROOT, build_matrix, command_for
|
||||
|
||||
|
||||
RUN_RE = re.compile(r"\[(START|DONE|FAIL|RETRY)\]\s+([^\s]+)")
|
||||
ERROR_RE = re.compile(
|
||||
r"Traceback|RuntimeError|AuthenticationError|PermissionDenied|"
|
||||
r"DeploymentNotFound|LLM call failed|LLM message call failed|"
|
||||
r"BadRequestError|RateLimitError",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def read_text(path: Path) -> str:
|
||||
try:
|
||||
return path.read_text(encoding="utf-8", errors="replace")
|
||||
except FileNotFoundError:
|
||||
return ""
|
||||
|
||||
|
||||
def parse_launcher(path: Path) -> dict[str, list[str]]:
|
||||
events = {"START": [], "DONE": [], "FAIL": [], "RETRY": []}
|
||||
for line in read_text(path).splitlines():
|
||||
match = RUN_RE.search(line)
|
||||
if match:
|
||||
events[match.group(1)].append(match.group(2))
|
||||
return events
|
||||
|
||||
|
||||
def active_run_ids(run_root: Path) -> list[str]:
|
||||
try:
|
||||
raw = subprocess.check_output(["pgrep", "-af", "scripts/train.py"], text=True)
|
||||
except subprocess.CalledProcessError:
|
||||
return []
|
||||
active: list[str] = []
|
||||
pattern = re.compile(re.escape(str(run_root)) + r"/([^\s]+)")
|
||||
for line in raw.splitlines():
|
||||
for match in pattern.finditer(line):
|
||||
active.append(match.group(1))
|
||||
return sorted(set(active))
|
||||
|
||||
|
||||
def scan_errors(logs_dir: Path) -> dict[str, str]:
|
||||
errors: dict[str, str] = {}
|
||||
for log_path in sorted(logs_dir.glob("*.log")):
|
||||
text = read_text(log_path)
|
||||
match = ERROR_RE.search(text)
|
||||
if match:
|
||||
run_id = log_path.name.split(".watchrerun", 1)[0].removesuffix(".log")
|
||||
errors[run_id] = match.group(0)
|
||||
return errors
|
||||
|
||||
|
||||
def load_state(path: Path) -> dict:
|
||||
try:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
return {"reruns": {}}
|
||||
|
||||
|
||||
def save_state(path: Path, state: dict) -> None:
|
||||
tmp = path.with_suffix(".tmp")
|
||||
tmp.write_text(json.dumps(state, indent=2, ensure_ascii=False), encoding="utf-8")
|
||||
tmp.replace(path)
|
||||
|
||||
|
||||
def write_status(
|
||||
run_root: Path,
|
||||
total: int,
|
||||
events: dict[str, list[str]],
|
||||
active: list[str],
|
||||
completed: list[str],
|
||||
pending: list[str],
|
||||
errors: dict[str, str],
|
||||
reruns: dict[str, int],
|
||||
) -> None:
|
||||
now = time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime())
|
||||
failed = sorted(set(events["FAIL"]))
|
||||
retrying = sorted(set(events["RETRY"]))
|
||||
lines = [
|
||||
"# Ablation Status",
|
||||
"",
|
||||
f"Updated: {now}",
|
||||
f"Run root: `{run_root}`",
|
||||
"",
|
||||
"| Metric | Count |",
|
||||
"| --- | ---: |",
|
||||
f"| Total planned | {total} |",
|
||||
f"| Completed summaries | {len(completed)} |",
|
||||
f"| Active train processes | {len(active)} |",
|
||||
f"| Pending/not summarized | {len(pending)} |",
|
||||
f"| Launcher final fails | {len(failed)} |",
|
||||
f"| Launcher retries | {len(retrying)} |",
|
||||
f"| Logs with error patterns | {len(errors)} |",
|
||||
"",
|
||||
"## Active",
|
||||
"",
|
||||
*(f"- `{run_id}`" for run_id in active),
|
||||
"",
|
||||
"## Final Fails",
|
||||
"",
|
||||
*(f"- `{run_id}` watcher_reruns={reruns.get(run_id, 0)}" for run_id in failed),
|
||||
"",
|
||||
"## Error Patterns",
|
||||
"",
|
||||
*(f"- `{run_id}`: `{err}`" for run_id, err in sorted(errors.items())),
|
||||
"",
|
||||
"## Recent Launcher",
|
||||
"",
|
||||
"```text",
|
||||
"\n".join(read_text(run_root / "launcher.log").splitlines()[-30:]),
|
||||
"```",
|
||||
]
|
||||
(run_root / "STATUS.md").write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--run-root", required=True)
|
||||
parser.add_argument("--interval", type=int, default=60)
|
||||
parser.add_argument("--watcher-retries", type=int, default=1)
|
||||
parser.add_argument("--groups", nargs="+", default=["all"])
|
||||
parser.add_argument("--bench", nargs="+", default=["searchqa", "spreadsheetbench"])
|
||||
args = parser.parse_args()
|
||||
|
||||
run_root = Path(args.run_root).resolve()
|
||||
logs_dir = run_root / "logs"
|
||||
logs_dir.mkdir(parents=True, exist_ok=True)
|
||||
state_path = run_root / "watcher_state.json"
|
||||
|
||||
groups = set(args.groups)
|
||||
if "all" in groups:
|
||||
groups = {"default", "split", "mbs", "lr", "sched", "slown", "mod", "smodel"}
|
||||
experiments = {
|
||||
exp.run_id: exp
|
||||
for exp in build_matrix(groups, args.bench, run_root, include_duplicate_defaults=False)
|
||||
}
|
||||
|
||||
active_reruns: dict[str, subprocess.Popen] = {}
|
||||
while True:
|
||||
state = load_state(state_path)
|
||||
reruns = state.setdefault("reruns", {})
|
||||
events = parse_launcher(run_root / "launcher.log")
|
||||
active = active_run_ids(run_root)
|
||||
completed = sorted(
|
||||
run_id for run_id in experiments
|
||||
if (run_root / run_id / "summary.json").exists()
|
||||
)
|
||||
pending = sorted(set(experiments) - set(completed))
|
||||
errors = scan_errors(logs_dir)
|
||||
|
||||
# Reap watcher-started reruns.
|
||||
for run_id, proc in list(active_reruns.items()):
|
||||
rc = proc.poll()
|
||||
if rc is None:
|
||||
continue
|
||||
active_reruns.pop(run_id, None)
|
||||
with open(logs_dir / f"{run_id}.watcher.log", "a", encoding="utf-8") as f:
|
||||
f.write(f"\n[WATCHER_DONE] rc={rc} time={time.time()}\n")
|
||||
|
||||
for run_id in sorted(set(events["FAIL"])):
|
||||
if run_id not in experiments:
|
||||
continue
|
||||
if (run_root / run_id / "summary.json").exists():
|
||||
continue
|
||||
if run_id in active or run_id in active_reruns:
|
||||
continue
|
||||
count = int(reruns.get(run_id, 0))
|
||||
if count >= args.watcher_retries:
|
||||
continue
|
||||
reruns[run_id] = count + 1
|
||||
save_state(state_path, state)
|
||||
log_path = logs_dir / f"{run_id}.watchrerun{count + 1}.log"
|
||||
with open(log_path, "w", encoding="utf-8") as log_f:
|
||||
log_f.write(f"[WATCHER_START] run_id={run_id} attempt={count + 1}\n")
|
||||
log_f.flush()
|
||||
proc = subprocess.Popen(
|
||||
command_for(experiments[run_id]),
|
||||
cwd=PROJECT_ROOT,
|
||||
stdout=log_f,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
close_fds=True,
|
||||
)
|
||||
active_reruns[run_id] = proc
|
||||
|
||||
save_state(state_path, state)
|
||||
write_status(
|
||||
run_root=run_root,
|
||||
total=len(experiments),
|
||||
events=events,
|
||||
active=active,
|
||||
completed=completed,
|
||||
pending=pending,
|
||||
errors=errors,
|
||||
reruns={k: int(v) for k, v in reruns.items()},
|
||||
)
|
||||
time.sleep(max(5, int(args.interval)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1 +0,0 @@
|
||||
<svg id="logomark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 74.492 100.25"><g id="tiny_-_black" data-name="tiny - black"><path d="M586.72,255.616a3.377,3.377,0,0,1,.448.031,5.917,5.917,0,0,1,3.581,2.79c.454,1.116.314,2.023-1.315,4.141L563.168,293.6l-8.558-10.047,29.348-26.616a4.406,4.406,0,0,1,2.762-1.321m0-1.5a5.766,5.766,0,0,0-3.69,1.643l-.041.032-.038.035L553.6,282.442l-1.077.977.943,1.107,8.558,10.047,1.145,1.344,1.141-1.348,26.267-31.022.022-.027.022-.028c1.574-2.046,2.327-3.622,1.516-5.619a7.309,7.309,0,0,0-4.779-3.714,5.083,5.083,0,0,0-.64-.043Z" transform="translate(-526.086 -245.559)"/><path d="M553.423,284.593l8.977,10.558L597.911,337.9c.873,1.093,1.419,2.186,1.047,3.418a4.092,4.092,0,0,1-2.721,2.837,3.557,3.557,0,0,1-1.045.159,4,4,0,0,1-2.687-1.124L548.01,300.808c-3.5-3.5-2.971-8.151.436-11.558l4.977-4.657m.124-2.17L552.4,283.5l-4.976,4.656c-4.192,4.191-4.372,9.816-.473,13.714l44.521,42.4a5.485,5.485,0,0,0,3.722,1.538,5.1,5.1,0,0,0,1.483-.224,5.59,5.59,0,0,0,3.719-3.838,5.176,5.176,0,0,0-1.31-4.788l-35.53-42.767-8.988-10.571-1.019-1.2Z" transform="translate(-526.086 -245.559)"/><path d="M562.4,295.151l9.556,11.5,5.761-5.356a7.926,7.926,0,0,0,.041-11.743l-43.7-41.923s-1.671-2.029-3.437-2.071a4.49,4.49,0,0,0-4.23,2.718c-.688,1.651-.194,2.809,1.315,4.97l29.306,35.565Z" transform="translate(-526.086 -245.559)"/><path d="M553.7,306.223l-17.116,21.024c-1.255,1.337-2.032,3.683-1.331,5.367a4.587,4.587,0,0,0,4.287,2.841,4.087,4.087,0,0,0,3.082-1.523l20.328-18.9Z" transform="translate(-526.086 -245.559)"/><path d="M592.074,250.547" transform="translate(-526.086 -245.559)" fill="#fff" stroke="#000" stroke-miterlimit="10" stroke-width="0.25"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 390 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 407 KiB |
-2739
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,7 @@ from skillopt.types import ( # noqa: F401
|
||||
FailureSummaryEntry,
|
||||
GateAction,
|
||||
GateResult,
|
||||
MetaReflectResult,
|
||||
Patch,
|
||||
RawPatch,
|
||||
RolloutResult,
|
||||
|
||||
+21
-26
@@ -30,10 +30,10 @@ _STRUCTURED_SECTIONS = frozenset({
|
||||
|
||||
_FLATTEN_MAP: dict[str, str] = {
|
||||
"model.backend": "model_backend",
|
||||
"model.optimizer": "optimizer_model",
|
||||
"model.target": "target_model",
|
||||
"model.optimizer_backend": "optimizer_backend",
|
||||
"model.target_backend": "target_backend",
|
||||
"model.teacher": "teacher_model",
|
||||
"model.student": "student_model",
|
||||
"model.teacher_backend": "teacher_backend",
|
||||
"model.student_backend": "student_backend",
|
||||
"model.reasoning_effort": "reasoning_effort",
|
||||
"model.rewrite_reasoning_effort": "rewrite_reasoning_effort",
|
||||
"model.rewrite_max_completion_tokens": "rewrite_max_completion_tokens",
|
||||
@@ -51,7 +51,7 @@ _FLATTEN_MAP: dict[str, str] = {
|
||||
"model.claude_code_exec_use_sdk": "claude_code_exec_use_sdk",
|
||||
"model.claude_code_exec_effort": "claude_code_exec_effort",
|
||||
"model.claude_code_exec_max_thinking_tokens": "claude_code_exec_max_thinking_tokens",
|
||||
"model.codex_trace_to_optimizer": "codex_trace_to_optimizer",
|
||||
"model.codex_trace_to_teacher": "codex_trace_to_teacher",
|
||||
"model.azure_endpoint": "azure_endpoint",
|
||||
"model.azure_api_version": "azure_api_version",
|
||||
"model.azure_api_key": "azure_api_key",
|
||||
@@ -61,24 +61,18 @@ _FLATTEN_MAP: dict[str, str] = {
|
||||
"model.azure_openai_auth_mode": "azure_openai_auth_mode",
|
||||
"model.azure_openai_ad_scope": "azure_openai_ad_scope",
|
||||
"model.azure_openai_managed_identity_client_id": "azure_openai_managed_identity_client_id",
|
||||
"model.optimizer_azure_openai_endpoint": "optimizer_azure_openai_endpoint",
|
||||
"model.optimizer_azure_openai_api_version": "optimizer_azure_openai_api_version",
|
||||
"model.optimizer_azure_openai_api_key": "optimizer_azure_openai_api_key",
|
||||
"model.optimizer_azure_openai_auth_mode": "optimizer_azure_openai_auth_mode",
|
||||
"model.optimizer_azure_openai_ad_scope": "optimizer_azure_openai_ad_scope",
|
||||
"model.optimizer_azure_openai_managed_identity_client_id": "optimizer_azure_openai_managed_identity_client_id",
|
||||
"model.target_azure_openai_endpoint": "target_azure_openai_endpoint",
|
||||
"model.target_azure_openai_api_version": "target_azure_openai_api_version",
|
||||
"model.target_azure_openai_api_key": "target_azure_openai_api_key",
|
||||
"model.target_azure_openai_auth_mode": "target_azure_openai_auth_mode",
|
||||
"model.target_azure_openai_ad_scope": "target_azure_openai_ad_scope",
|
||||
"model.target_azure_openai_managed_identity_client_id": "target_azure_openai_managed_identity_client_id",
|
||||
"model.qwen_chat_base_url": "qwen_chat_base_url",
|
||||
"model.qwen_chat_api_key": "qwen_chat_api_key",
|
||||
"model.qwen_chat_temperature": "qwen_chat_temperature",
|
||||
"model.qwen_chat_timeout_seconds": "qwen_chat_timeout_seconds",
|
||||
"model.qwen_chat_max_tokens": "qwen_chat_max_tokens",
|
||||
"model.qwen_chat_enable_thinking": "qwen_chat_enable_thinking",
|
||||
"model.teacher_azure_openai_endpoint": "teacher_azure_openai_endpoint",
|
||||
"model.teacher_azure_openai_api_version": "teacher_azure_openai_api_version",
|
||||
"model.teacher_azure_openai_api_key": "teacher_azure_openai_api_key",
|
||||
"model.teacher_azure_openai_auth_mode": "teacher_azure_openai_auth_mode",
|
||||
"model.teacher_azure_openai_ad_scope": "teacher_azure_openai_ad_scope",
|
||||
"model.teacher_azure_openai_managed_identity_client_id": "teacher_azure_openai_managed_identity_client_id",
|
||||
"model.student_azure_openai_endpoint": "student_azure_openai_endpoint",
|
||||
"model.student_azure_openai_api_version": "student_azure_openai_api_version",
|
||||
"model.student_azure_openai_api_key": "student_azure_openai_api_key",
|
||||
"model.student_azure_openai_auth_mode": "student_azure_openai_auth_mode",
|
||||
"model.student_azure_openai_ad_scope": "student_azure_openai_ad_scope",
|
||||
"model.student_azure_openai_managed_identity_client_id": "student_azure_openai_managed_identity_client_id",
|
||||
"train.num_epochs": "num_epochs",
|
||||
"train.train_size": "train_size",
|
||||
"train.steps_per_epoch": "steps_per_epoch",
|
||||
@@ -89,21 +83,22 @@ _FLATTEN_MAP: dict[str, str] = {
|
||||
"gradient.merge_batch_size": "merge_batch_size",
|
||||
"gradient.analyst_workers": "analyst_workers",
|
||||
"gradient.failure_only": "failure_only",
|
||||
"gradient.use_deep_reflect": "use_deep_reflect",
|
||||
"gradient.deep_reflect_failures": "deep_reflect_failures",
|
||||
"gradient.deep_reflect_successes": "deep_reflect_successes",
|
||||
"gradient.max_analyst_rounds": "max_analyst_rounds",
|
||||
"optimizer.learning_rate": "edit_budget",
|
||||
"optimizer.min_learning_rate": "min_edit_budget",
|
||||
"optimizer.lr_scheduler": "lr_scheduler",
|
||||
"optimizer.lr_control_mode": "lr_control_mode",
|
||||
"optimizer.skill_update_mode": "skill_update_mode",
|
||||
"optimizer.use_meta_reflect": "use_meta_reflect",
|
||||
"optimizer.meta_learning_rate": "meta_edit_budget",
|
||||
"optimizer.use_slow_update": "use_slow_update",
|
||||
"optimizer.slow_update_samples": "slow_update_samples",
|
||||
"optimizer.slow_update_gate_with_selection": "slow_update_gate_with_selection",
|
||||
"optimizer.longitudinal_pair_policy": "longitudinal_pair_policy",
|
||||
"optimizer.use_meta_skill": "use_meta_skill",
|
||||
"evaluation.use_gate": "use_gate",
|
||||
"evaluation.gate_metric": "gate_metric",
|
||||
"evaluation.gate_mixed_weight": "gate_mixed_weight",
|
||||
"evaluation.sel_env_num": "sel_env_num",
|
||||
"evaluation.test_env_num": "test_env_num",
|
||||
"evaluation.eval_test": "eval_test",
|
||||
|
||||
+2195
-2060
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
# Benchmark Template
|
||||
|
||||
This directory provides scaffold files for adding a new benchmark to SkillOpt.
|
||||
|
||||
## Files
|
||||
|
||||
- `env_template.py` — Environment adapter template
|
||||
- `loader_template.py` — Data loader template
|
||||
- `config_template.yaml` — Config file template
|
||||
|
||||
## Usage
|
||||
|
||||
1. Copy this directory: `cp -r skillopt/envs/_template skillopt/envs/your_benchmark`
|
||||
2. Rename files: remove `_template` suffix
|
||||
3. Implement the `TODO` sections
|
||||
4. Register in `skillopt/envs/__init__.py`
|
||||
5. Create config at `configs/your_benchmark/default.yaml`
|
||||
|
||||
See the [documentation](../../docs/guide/new-benchmark.md) for the full guide.
|
||||
@@ -1,45 +0,0 @@
|
||||
# ──────────────────────────────────────────────────
|
||||
# SkillOpt Config Template — <Your Benchmark Name>
|
||||
# ──────────────────────────────────────────────────
|
||||
# Copy this file to configs/<your_benchmark>/default.yaml
|
||||
# and customize the values below.
|
||||
|
||||
# Inherit global defaults
|
||||
_base_: ['../_base_/default.yaml']
|
||||
|
||||
# ── Environment ──────────────────────────────────
|
||||
env:
|
||||
name: your_benchmark # Must match registry key
|
||||
data_path: data/your_benchmark # Path to your data
|
||||
split_mode: ratio # "ratio" or "split_dir"
|
||||
split_ratio: "2:1:7" # train:val:test
|
||||
exec_timeout: 120 # Per-task timeout (seconds)
|
||||
|
||||
# ── Training ─────────────────────────────────────
|
||||
train:
|
||||
num_epochs: 4 # Number of epochs
|
||||
batch_size: 40 # Tasks per step (batch size)
|
||||
seed: 42
|
||||
|
||||
# ── Gradient (Reflection) ───────────────────────
|
||||
gradient:
|
||||
analyst_workers: 16 # Parallel reflection workers
|
||||
minibatch_size: 8
|
||||
|
||||
# ── Optimizer ────────────────────────────────────
|
||||
optimizer:
|
||||
learning_rate: 4 # Max edits per step (edit budget)
|
||||
lr_scheduler: cosine # cosine | linear | constant | autonomous
|
||||
use_slow_update: true # Epoch-boundary momentum
|
||||
use_meta_skill: true # Cross-epoch optimizer memory
|
||||
|
||||
# ── Evaluation ───────────────────────────────────
|
||||
evaluation:
|
||||
use_gate: true # Validation gating
|
||||
eval_test: true # Run test eval after training
|
||||
|
||||
# ── Model ────────────────────────────────────────
|
||||
model:
|
||||
backend: azure_openai # azure_openai | openai_chat | claude_code_exec | qwen
|
||||
optimizer: gpt-4o
|
||||
target: gpt-4o
|
||||
@@ -1,92 +0,0 @@
|
||||
"""
|
||||
Benchmark Environment Template
|
||||
===============================
|
||||
Copy this file and implement the TODO sections to add a new benchmark.
|
||||
|
||||
The EnvAdapter is responsible for:
|
||||
1. Executing tasks using the target model + current skill document
|
||||
2. Evaluating predictions against ground truth
|
||||
3. Returning structured results for the training loop
|
||||
"""
|
||||
from skillopt.envs.base import EnvAdapter
|
||||
|
||||
|
||||
class TemplateBenchmarkEnv(EnvAdapter):
|
||||
"""
|
||||
Environment adapter for <Your Benchmark Name>.
|
||||
|
||||
Rename this class and implement the abstract methods below.
|
||||
"""
|
||||
|
||||
def __init__(self, cfg: dict):
|
||||
super().__init__(cfg)
|
||||
# TODO: Initialize benchmark-specific state
|
||||
# Example: self.tools = load_tools(cfg)
|
||||
|
||||
async def execute(self, item, skill: str, model):
|
||||
"""
|
||||
Execute a single task with the target model.
|
||||
|
||||
Args:
|
||||
item: DataItem with .id, .input, .ground_truth, .metadata
|
||||
skill: Current skill document content (Markdown string)
|
||||
model: Target model backend instance
|
||||
|
||||
Returns:
|
||||
TaskResult with prediction, score, and trajectory
|
||||
"""
|
||||
# Step 1: Build the prompt combining skill + task input
|
||||
prompt = self.build_prompt(item, skill)
|
||||
|
||||
# Step 2: Call the target model
|
||||
# TODO: Customize the message format for your benchmark
|
||||
messages = [
|
||||
{"role": "system", "content": skill},
|
||||
{"role": "user", "content": item.input},
|
||||
]
|
||||
response = await model.generate(messages)
|
||||
|
||||
# Step 3: Parse the model response into a prediction
|
||||
prediction = self.parse_response(response.content)
|
||||
|
||||
# Step 4: Score the prediction
|
||||
score = self.evaluate(prediction, item.ground_truth)
|
||||
|
||||
# Step 5: Return structured result
|
||||
return {
|
||||
"item_id": item.id,
|
||||
"prediction": prediction,
|
||||
"score": score,
|
||||
"trajectory": messages + [{"role": "assistant", "content": response.content}],
|
||||
}
|
||||
|
||||
def evaluate(self, prediction: str, ground_truth: str) -> float:
|
||||
"""
|
||||
Score a prediction against the ground truth.
|
||||
|
||||
Returns:
|
||||
Float between 0.0 (wrong) and 1.0 (correct)
|
||||
|
||||
TODO: Implement your scoring metric. Common options:
|
||||
- Exact match: float(pred.strip().lower() == gt.strip().lower())
|
||||
- F1 score: compute token overlap
|
||||
- ANLS: for document QA tasks
|
||||
- Custom: any float in [0, 1]
|
||||
"""
|
||||
# Placeholder — exact match
|
||||
return float(prediction.strip().lower() == ground_truth.strip().lower())
|
||||
|
||||
def build_prompt(self, item, skill: str) -> str:
|
||||
"""Combine skill document with task input."""
|
||||
return f"{skill}\n\n---\n\nQuestion: {item.input}"
|
||||
|
||||
def parse_response(self, response: str) -> str:
|
||||
"""
|
||||
Extract the answer from the model's raw response.
|
||||
|
||||
TODO: Implement extraction logic. For example:
|
||||
- Extract text after "Answer:"
|
||||
- Parse JSON output
|
||||
- Extract from code blocks
|
||||
"""
|
||||
return response.strip()
|
||||
@@ -1,103 +0,0 @@
|
||||
"""
|
||||
Benchmark Data Loader Template
|
||||
================================
|
||||
Copy this file and implement the TODO sections to load your benchmark data.
|
||||
|
||||
The DataLoader is responsible for:
|
||||
1. Loading raw data from disk
|
||||
2. Splitting into train / validation / test sets
|
||||
3. Providing DataItem objects to the training loop
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class TemplateBenchmarkLoader:
|
||||
"""
|
||||
Data loader for <Your Benchmark Name>.
|
||||
|
||||
Rename this class and implement the methods below.
|
||||
"""
|
||||
|
||||
def __init__(self, data_dir: str = "data/your_benchmark", **kwargs):
|
||||
self.data_dir = Path(data_dir)
|
||||
self.items = []
|
||||
self.splits = {}
|
||||
|
||||
def setup(self, cfg: dict):
|
||||
"""
|
||||
Initialize the loader with config.
|
||||
|
||||
Called once before training starts.
|
||||
|
||||
Args:
|
||||
cfg: Dict with keys like 'split_mode', 'train_ratio', 'val_ratio', etc.
|
||||
"""
|
||||
# Step 1: Load raw data
|
||||
self.items = self._load_items()
|
||||
|
||||
# Step 2: Create splits
|
||||
split_mode = cfg.get("split_mode", "ratio")
|
||||
if split_mode == "ratio":
|
||||
self._split_by_ratio(
|
||||
train_ratio=cfg.get("train_ratio", 0.7),
|
||||
val_ratio=cfg.get("val_ratio", 0.15),
|
||||
)
|
||||
elif split_mode == "split_dir":
|
||||
self._load_predefined_splits(cfg.get("split_dir", self.data_dir))
|
||||
|
||||
def _load_items(self) -> list:
|
||||
"""
|
||||
Load raw data into structured items.
|
||||
|
||||
TODO: Implement data loading. Each item should have at minimum:
|
||||
- id: unique identifier
|
||||
- input: the task input (question, instruction, etc.)
|
||||
- ground_truth: the expected answer
|
||||
- metadata: optional dict with extra info
|
||||
|
||||
Example:
|
||||
items = []
|
||||
for path in self.data_dir.glob("*.json"):
|
||||
data = json.loads(path.read_text())
|
||||
for entry in data:
|
||||
items.append({
|
||||
"id": entry["id"],
|
||||
"input": entry["question"],
|
||||
"ground_truth": entry["answer"],
|
||||
"metadata": {"source": path.name},
|
||||
})
|
||||
return items
|
||||
"""
|
||||
raise NotImplementedError("Implement _load_items() for your benchmark")
|
||||
|
||||
def _split_by_ratio(self, train_ratio: float, val_ratio: float):
|
||||
"""Split items by ratio."""
|
||||
import random
|
||||
random.shuffle(self.items)
|
||||
n = len(self.items)
|
||||
n_train = int(n * train_ratio)
|
||||
n_val = int(n * val_ratio)
|
||||
self.splits = {
|
||||
"train": self.items[:n_train],
|
||||
"valid": self.items[n_train:n_train + n_val],
|
||||
"test": self.items[n_train + n_val:],
|
||||
}
|
||||
|
||||
def _load_predefined_splits(self, split_dir):
|
||||
"""Load from pre-split directories."""
|
||||
# TODO: Implement if your benchmark has pre-defined splits
|
||||
raise NotImplementedError
|
||||
|
||||
def get_split_items(self, split: str) -> list:
|
||||
"""
|
||||
Return items for a given split.
|
||||
|
||||
Args:
|
||||
split: One of "train", "valid", "test"
|
||||
|
||||
Returns:
|
||||
List of data items for the requested split
|
||||
"""
|
||||
if split not in self.splits:
|
||||
raise ValueError(f"Unknown split '{split}'. Available: {list(self.splits.keys())}")
|
||||
return self.splits[split]
|
||||
@@ -9,6 +9,7 @@ from dataclasses import dataclass
|
||||
import json
|
||||
import os
|
||||
|
||||
from skillopt.gradient.deep_probe import generate_deep_probe_instruction
|
||||
from skillopt.datasets.base import BatchSpec
|
||||
from skillopt.envs.base import EnvAdapter
|
||||
from skillopt.envs.alfworld.dataloader import ALFWorldDataLoader
|
||||
@@ -82,16 +83,20 @@ class ALFWorldAdapter(EnvAdapter):
|
||||
failure_only: bool = False,
|
||||
minibatch_size: int = 8,
|
||||
edit_budget: int = 4,
|
||||
max_completion_tokens: int = 16384,
|
||||
use_deep_reflect: bool = False,
|
||||
deep_reflect_failures: int = 4,
|
||||
deep_reflect_successes: int = 2,
|
||||
) -> None:
|
||||
self.max_steps = max_steps
|
||||
self.workers = max(int(workers or 1), 1)
|
||||
self.max_api_workers = max_api_workers
|
||||
self.max_completion_tokens = int(max_completion_tokens)
|
||||
self.analyst_workers = analyst_workers
|
||||
self.failure_only = failure_only
|
||||
self.minibatch_size = minibatch_size
|
||||
self.edit_budget = edit_budget
|
||||
self.use_deep_reflect = use_deep_reflect
|
||||
self.deep_reflect_failures = deep_reflect_failures
|
||||
self.deep_reflect_successes = deep_reflect_successes
|
||||
self.dataloader = ALFWorldDataLoader(
|
||||
split_dir=split_dir,
|
||||
data_path=data_path,
|
||||
@@ -352,7 +357,6 @@ class ALFWorldAdapter(EnvAdapter):
|
||||
max_steps=self.max_steps,
|
||||
out_root=out_dir,
|
||||
max_api_workers=self.max_api_workers,
|
||||
max_completion_tokens=self.max_completion_tokens,
|
||||
result_ids=getattr(env_manager, "_skillopt_result_ids", None),
|
||||
)
|
||||
|
||||
@@ -415,7 +419,6 @@ class ALFWorldAdapter(EnvAdapter):
|
||||
max_steps=self.max_steps,
|
||||
out_root=out_dir,
|
||||
max_api_workers=min(self.max_api_workers, chunk_size),
|
||||
max_completion_tokens=self.max_completion_tokens,
|
||||
diagnostic_mode=diagnostic_mode,
|
||||
diagnostic_instruction=diagnostic_instruction,
|
||||
result_ids=chunk_ids,
|
||||
@@ -454,6 +457,129 @@ class ALFWorldAdapter(EnvAdapter):
|
||||
meta_skill_context=meta_skill_context,
|
||||
)
|
||||
|
||||
def deep_reflect(
|
||||
self,
|
||||
results: list[dict],
|
||||
skill_content: str,
|
||||
out_dir: str,
|
||||
**kwargs,
|
||||
) -> list[dict | None]:
|
||||
if not self.use_deep_reflect:
|
||||
return []
|
||||
|
||||
prediction_dir = kwargs.get("prediction_dir", os.path.join(out_dir, "predictions"))
|
||||
random_seed = kwargs.get("random_seed")
|
||||
step_buffer_context = kwargs.get("step_buffer_context", "")
|
||||
meta_skill_context = kwargs.get("meta_skill_context", "")
|
||||
selected_items = self.select_representative_items(
|
||||
results,
|
||||
results,
|
||||
n_failures=self.deep_reflect_failures,
|
||||
n_successes=self.deep_reflect_successes,
|
||||
seed=random_seed,
|
||||
)
|
||||
if not selected_items:
|
||||
return []
|
||||
|
||||
selected_ids = {str(item["id"]) for item in selected_items}
|
||||
selected_results = [row for row in results if str(row.get("id")) in selected_ids]
|
||||
selected_examples = self.attach_reference_context(selected_results, selected_items)
|
||||
|
||||
field_counts: dict[str, int] = {}
|
||||
selected_metadata: list[dict] = []
|
||||
for item in selected_items:
|
||||
meta = self.get_reference_metadata(item)
|
||||
for field in meta["fields"]:
|
||||
field_counts[field] = field_counts.get(field, 0) + 1
|
||||
selected_metadata.append({
|
||||
"id": str(item["id"]),
|
||||
"task_type": str(item.get("task_type") or "alfworld"),
|
||||
"gamefile": str(item.get("gamefile") or ""),
|
||||
"reference_fields": meta["fields"],
|
||||
"reference_preview": meta["preview"],
|
||||
})
|
||||
|
||||
deep_dir = os.path.join(out_dir, "deep_reflect")
|
||||
rollout_dir = os.path.join(deep_dir, "rollout")
|
||||
patches_dir = os.path.join(deep_dir, "patches")
|
||||
os.makedirs(deep_dir, exist_ok=True)
|
||||
field_summary = ", ".join(
|
||||
f"{field}({count}/{len(selected_items)})"
|
||||
for field, count in sorted(field_counts.items())
|
||||
) or "none"
|
||||
print(
|
||||
f" [2b/6 DEEP REFLECT setup] selected={len(selected_items)} "
|
||||
f"reference_fields={field_summary}"
|
||||
)
|
||||
probe = generate_deep_probe_instruction(
|
||||
skill_content=skill_content,
|
||||
items=selected_examples,
|
||||
prediction_dir=prediction_dir,
|
||||
system_prompt=self.get_deep_probe_prompt(),
|
||||
step_buffer_context=step_buffer_context,
|
||||
meta_skill_context=meta_skill_context,
|
||||
output_requirements=[
|
||||
"- Some trajectories may include a hidden Reference block. Use it to target the student's latent subgoal, missing precondition, or next-step intent, but do not reveal or paraphrase that reference to the student.",
|
||||
"- The instruction must request a brief diagnostic readout inside the existing <think>...</think> block.",
|
||||
"- The student must still output exactly one admissible action inside <action>...</action>.",
|
||||
"- Do not ask for exhaustive inventories, full plans, or long chain-of-thought.",
|
||||
"- The instruction text should be ready to append directly to the student's prompt.",
|
||||
],
|
||||
)
|
||||
if not probe:
|
||||
return []
|
||||
|
||||
with open(os.path.join(deep_dir, "probe.json"), "w", encoding="utf-8") as f:
|
||||
json.dump(
|
||||
{
|
||||
**probe,
|
||||
"reference_summary": {
|
||||
"selected_count": len(selected_items),
|
||||
"field_counts": field_counts,
|
||||
},
|
||||
"selected_examples": selected_metadata,
|
||||
},
|
||||
f,
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
)
|
||||
|
||||
gamefiles = [str(item.get("gamefile") or "") for item in selected_items]
|
||||
if any(not gamefile for gamefile in gamefiles):
|
||||
return []
|
||||
eval_dataset, is_train = self._infer_dataset_from_gamefile(gamefiles[0])
|
||||
deep_env = ALFWorldBatchRun(
|
||||
env_num=len(selected_items),
|
||||
eval_dataset=eval_dataset,
|
||||
seed=random_seed or 42,
|
||||
is_train=is_train,
|
||||
specific_gamefiles=gamefiles,
|
||||
workers=min(self.workers, max(len(selected_items), 1)),
|
||||
result_ids=[str(item["id"]) for item in selected_items],
|
||||
)
|
||||
deep_results = self._run_batch(
|
||||
deep_env,
|
||||
skill_content=skill_content,
|
||||
out_dir=rollout_dir,
|
||||
diagnostic_mode=True,
|
||||
diagnostic_instruction=probe["probe_instruction"],
|
||||
)
|
||||
deep_results = self.attach_reference_context(deep_results, selected_items)
|
||||
return run_minibatch_reflect(
|
||||
results=deep_results,
|
||||
skill_content=skill_content,
|
||||
prediction_dir=os.path.join(rollout_dir, "predictions"),
|
||||
patches_dir=patches_dir,
|
||||
workers=self.analyst_workers,
|
||||
failure_only=self.failure_only,
|
||||
minibatch_size=self.minibatch_size,
|
||||
edit_budget=self.edit_budget,
|
||||
random_seed=random_seed,
|
||||
error_system=self.get_error_minibatch_prompt(),
|
||||
success_system=self.get_success_minibatch_prompt(),
|
||||
step_buffer_context=step_buffer_context,
|
||||
meta_skill_context=meta_skill_context,
|
||||
)
|
||||
|
||||
def get_task_types(self) -> list[str]:
|
||||
return list(TASKS)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user