Recipes
| Recipe | What it shows | Built on |
|---|---|---|
| Mid-run evaluation | Sanity-check the half-trained model against a fixed prompt at every checkpoint, before the run finishes. | onCheckpoint({ infer }) |
| Early stopping on diverging loss | Abort a run automatically when the loss curve goes the wrong way, and stop the GPU on the backend too. | onLog, AbortSignal, trainer.cancel() |
| Slack / Discord notifications | Post to a webhook on completion or failure, without leaving the trainer file. | onCompleted / onFailed, fetch |
| Programmatic runs (no CLI) | Drive training from a Next.js API route, a cron worker, or CI without going through arkor dev / arkor start. | runTrainer, Trainer.start / wait |
| Customizing the starter templates | Treat the scaffolded templates as starting points. Change the dataset, hyperparameters, callbacks, and base model. | createTrainer, DatasetSource |
A note on callback exceptions before you start
Three of the recipes below put logic inside the lifecycle callbacks. The runtime catches errors thrown out of a callback and routes them through the SSE reconnect loop (SDK § Lifecycle callbacks), andmaxReconnectAttempts defaults to unlimited. In practice that means a throw inside a callback can be silently retried.
The recipes here use a simple convention to stay deterministic:
- State changes go through outer variables. Use an
AbortController, a closure flag, or a returned Promise rather than throwing. - Side effects are guarded with
try / catchinside the callback. If a Slack post fails, log it and continue; do not let it bubble.
Things this section does not cover
- Production deploys. Arkor today only runs on managed GPUs, and
createArkor’sdeployslot is a reserved type field with no implementation. Serving recipes will land when that surface lands. - Multiple trainers per project.
createArkoraccepts a singletrainer; running several together is a programmatic-run pattern (see the recipe), not a manifest pattern. - Custom base models beyond what the backend accepts. The
modelfield is forwarded to the cloud API verbatim; today the curated path is Gemma. Recipes do not pretend other models work end to end.