Skip to main content

Image Style Matching Demo

Interactive notebook demonstrating Graph Evolve for Pokemon-style image generation with Gemini.

1) Prepare a GraphEvolveTaskSet

Minimal dataset:
{
  "metadata": { "name": "support-intents" },
  "initial_prompt": "You classify customer requests into intents.",
  "tasks": [
    { "id": "t1", "input": { "query": "Cancel my plan" } },
    { "id": "t2", "input": { "query": "Update my card" } }
  ],
  "gold_outputs": [
    { "task_id": "t1", "output": { "intent": "cancellation" } },
    { "task_id": "t2", "output": { "intent": "billing" } }
  ],
  "verifier_config": { "mode": "rubric" }
}
tasks[].input and gold_outputs[].output can be any JSON shape. If your graph accepts JSON, it fits here.

2) Create a training job

from synth_ai.sdk import GraphOptimizationJob

job = GraphOptimizationJob.from_dataset(
    dataset=taskset,  # Your GraphEvolveTaskSet dict from above
    policy_models="gpt-4o-mini",
    rollout_budget=200,
    proposer_effort="medium",
    initial_graph_id="preset_classifier_v1",  # Required: preset graph to start from
)
job.submit()
print(f"Job ID: {job.job_id}")
Available initial_graph_id presets include preset_classifier_v1, preset_rlm_v1, and others. See the Graph Optimization API for the full list.

3) Monitor training

Poll for status:
status = job.get_status()
print(status["status"], status.get("best_score"))
Or stream events until the job completes:
result = job.stream_until_complete()
print(f"Best score: {result.best_score}")

4) Download the best graph

When status is terminal (succeeded), download:
graph_txt = job.download_graph_txt()
print(graph_txt)
You’ll get the best prompt snapshot plus a ready-to-run Python snippet.

5) Run inference

output = job.run_inference({"query": "Upgrade my plan"})
print(output)
To target a specific snapshot or override the model, pass prompt_snapshot_id or model to run_inference().

Next steps