> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Post-Train

> Fine-tune a model on your own traces and grade it with an Arize experiment

The `ax post-train` commands turn a project's traces into a fine-tuned model and score it against a holdout set with an evaluator you already use. Training and serving run on a provider (Baseten by default); the dataset, experiment, and grades land in Arize.

## Setup

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
pip install "arize-ax-cli[baseten]"      # Python 3.12+
export BASETEN_API_KEY=...
ax post-train acknowledge-data-rights    # one-time: trace data is sent to the training provider
ax post-train doctor                     # checks Arize auth, the provider key, and the acknowledgment
```

Your Baseten workspace also needs an `hf_access_token` secret so it can load the base model.

## `ax post-train run`

Run the whole chain: export, build, dataset, train, deploy, eval, undeploy.

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
ax post-train run <project> --space <id> --filter <expr> --evaluator <id> --name <name> [--days <n>] [--base-model <model>] [--target <target>] [--dir <path>] [--provider <provider>] [--confirm] [--verbose]
```

| Option | Description |
| - | - |
| `--space`, `-s` | Space ID (required) |
| `--filter` | Span filter selecting the traces to learn from (required) |
| `--evaluator` | Evaluator ID used to grade the fine-tuned model (required) |
| `--name`, `-n` | Name for the dataset and experiment (required) |
| `--days` | How many days of traces to export (default: 30) |
| `--base-model` | Model to fine-tune (default: Qwen3.5-9B) |
| `--target` | What the model learns to produce: `tool-call`, `assistant`, or `any` (default: `tool-call`) |
| `--dir`, `-d` | Working directory for exported data and run state (default: `post-train`) |
| `--provider` | `baseten` or `fireworks` (default: `baseten`) |
| `--confirm` | Required to start; training and serving cost money |
| `--verbose`, `-v` | Enable verbose logs |

**Example:**

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
ax post-train run my-project --space sp_abc123 --days 30 \
  --filter "attributes.metadata.router_type = 'SEARCH'" \
  --base-model Qwen/Qwen3.6-35B-A3B \
  --evaluator ev_abc123 --name search-finetune --confirm
```

The run is resumable: rerun the same command with the same `--dir` and it picks up after the last completed step. The deployment is removed when the run ends, and the experiment appears on the new dataset in Arize with the evaluator's score for each holdout example.

> [!NOTE]
>
> Steps that spend money stop unless you pass `--confirm`. Use `ax post-train plan` first to see rows, tokens, and an estimated cost.

## Running the steps one at a time

Each step reads and writes `post-train.json` in `--dir`, so you can run them separately, inspect the output in between, or mix them with the Arize UI.

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
ax post-train export my-project --space sp_abc123 --filter "name = 'router'"
ax post-train build --target tool-call --holdout 0.15
ax post-train plan
ax post-train dataset --name search-finetune --space sp_abc123
ax post-train train --confirm
ax post-train deploy --confirm
ax post-train eval --name search-finetune --evaluator ev_abc123 --confirm
ax post-train undeploy
```

| Command | What it does |
| - | - |
| `export` | Downloads every span of the traces matching `--filter` |
| `build` | Builds one training example per LLM span and splits off a holdout set |
| `plan` | Previews rows, tokens, and estimated cost. Makes no network calls |
| `dataset` | Creates the holdout dataset in Arize (add `--gold-queue` for a human labeling queue) |
| `train` | Starts a LoRA fine-tune on the provider |
| `deploy` | Brings the fine-tuned model online. It bills until you undeploy |
| `eval` | Runs the model on the holdout, logs an experiment, and grades it with `--evaluator` |
| `undeploy` | Deletes the deployment so it stops billing |

Run any command with `--help` for its full list of options.

## Providers

Baseten is the default and supports the full chain. Fireworks no longer accepts new fine-tuning jobs, so with `--provider fireworks` you can deploy and evaluate an existing model but not train a new one.
