Skip to main content
What you learn: the loop, simulate to export, as one program. Needs: nothing. Takes: about twenty seconds on a laptop. whileai is a post-training library for language models: SFT and RL on open models, with the measurement that says whether training helped. It is for AI researchers, ML engineers and applied-AI developers. The loop is simulate, grade, measure with intervals, select, train, prove on a held-out set, serve, and feed the new traces back in. Nothing in that loop needs an account, and every default names the paper it came from. wai is While’s whale and the alias of the whileai SDK: import whileai as wai. The data end of the loop is built for agents that call tools. Give it an agent, or only the agent’s tools and system prompt. It writes the situations the agent might meet, runs the agent through them against a world that fails on purpose, and hands back every conversation as a row you grade with your own judge or a verifier.
The loop, offline, no key, about twenty seconds on a laptop:
Swap the stand-in for your agent and the lambda for your judge and the program is the same. The package then does the bookkeeping that is tempting to skip and expensive to get wrong: pass rates with intervals, difficulty bands for RL, a check that your judge agrees with people, decontamination against your eval set, and a scan for rewards the policy can game. Two domains, kept apart. import whileai as wai is the library: simulate, grade, measure, select, export, on your machine against your models, no account needed. whileai.platform is the While platform: sign in, push datasets, train and serve on hosted GPUs, track versions. Everything that talks to while.ai lives there and nowhere else.

Quickstart

The program above, one step at a time, with what each line prints.

Your model and your key

Name the model as a string, set the provider’s own key, and see exactly what stays on your machine.

Evals

A pass rate with an interval, a table of where the agent fails, and a CI check that goes red when it gets worse.

Train on your own GPU

GRPO or DPO on Modal, a GPU box or a notebook, with the paired delta on a holdout at the end. One A10G, under fifteen minutes.
Never trained a model? Learn is seven lessons from zero, each offline in under a minute, ending at the quickstart above.

The defaults this run used

The program above sets no thresholds, so four defaults produced its numbers. Each one is a named constant in defaults.py, carries its source in a comment beside it, and takes an argument on the call that uses it.

References

  1. Miller, E. Adding Error Bars to Evals: A Statistical Approach to Language Model Evaluations. 2024.
  2. Yu, Q. et al. DAPO: An Open-Source LLM Reinforcement Learning System at Scale. 2025.
  3. Gao, L. et al. Scaling Laws for Reward Model Overoptimization. 2022.

The loop

The loop as seven boxes: Simulate, Grade, Validate the judge, Measure, Select, Guard, Train and export, with a dashed return arrow from Train and export back to Simulate labelled simulate(traces=) The loop as seven boxes: Simulate, Grade, Validate the judge, Measure, Select, Guard, Train and export, with a dashed return arrow from Train and export back to Simulate labelled simulate(traces=) Where each method comes from, with numbered references, is on the engine. The calls in the order a run happens are on the five calls. Every public call, with its signature and docstring, is under API in the sidebar; those pages are generated from the package on each release, so they cannot drift.

Guides

How it works

How the simulator thinks and why.

Character training

A stable way of talking, in the weights.

Harness optimization

A coding agent improves the prompt, tools and loop on your own traffic, gated on days it never saw.

Reward hacking

The gap between the training reward and the eval you care about.

Safety evals

Private data, actions, sends: can they be turned against the owner?

Platform

What the hosted service adds on top of the library, and where the line is.

Recipes

Runnable, one folder each, offline where the method allows.

Replicated papers

One recent post-training paper per recipe, under an hour on one GPU, with the number it moved and the number it did not.

Next

Run uv add whileai, then open the quickstart: it is the program above one line at a time, with what each line prints.
Last modified on September 22, 2026