Quickstart¶
This walks the full compile → generate → train → eval pipeline on the
travel-booking example. Data generation and evaluation call the Anthropic API;
training and serving need a GPU (use Modal if you don't have one).
Install¶
python -m venv .venv && source .venv/bin/activate
pip install agent2model # core: compile + generate + eval
Optional extras (install only what you need):
| Extra | Adds |
|---|---|
train |
torch, transformers, TRL, DeepSpeed — the fine-tuning stack (GPU) |
serve |
vLLM — the OpenAI-compatible serving endpoint (GPU) |
cloud |
the Modal client for the cloud recipes |
report |
matplotlib — renders the PDF eval report |
openai |
OpenAI-compatible client for the served-model eval condition |
Set your Anthropic key (used by generate and eval):
1. Compile¶
Validate a workflow and emit the canonical IR. Works on a YAML flowchart or a
.py file defining a LangGraph graph.
This writes build/travel/flowchart.json. If the flowchart violates an invariant
(unreachable terminal, dead-end cycle, …) the command prints every problem and
exits non-zero. See the IR spec.
2. Generate¶
Generate synthetic training data by walking the flowchart with Claude. The
command prints the expected cost before starting and the actual cost after,
is resumable (checkpoints to build/travel/generation_state.json), and stops if
the --budget cap is hit.
Output: build/travel/dataset.jsonl (HF chat-template) and
build/travel/cost.json. Useful flags: --seed, --max-concurrent (default 10).
3. Train¶
Full-parameter fine-tune a base model on the dataset. Pick a --size preset
(3b single-GPU, 8b DeepSpeed ZeRO-3); --base and --epochs default to the
preset.
The best checkpoint (by held-out eval loss, default 90/10 split) is saved to
build/travel/model/best. LoRA is not supported — --lora is refused. See
the Training guide.
4. Evaluate or serve¶
Evaluate the compiled model against baselines on the 5-criterion rubric, with bootstrap CIs, significance tests, failure rates, and cost:
Outputs build/travel/eval_report.json and eval_report.pdf. To include the
compiled model as a condition, serve it and pass --served-url. See the
Evaluation guide.
Serve the compiled model behind an OpenAI-compatible endpoint:
No GPU? Reproduce on Modal¶
pip install "agent2model[cloud]"
agent2model cloud setup # one-time, idempotent
modal run -m agent2model.cloud.modal_app::reproduce_travel
This runs generate → train → eval on Modal and produces a compiled 3B model within 5% of the paper's Table 1. The full first-time walkthrough — wizard, doctor checklist, cost-confirmation prompt — lives in the Cloud quickstart; the per-function reference is in Cloud deployment.