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

# TRAINING RECIPE

> Request schema for training recipes

A training recipe stores a complete training configuration as a reusable template. The configuration names the base model, the datasets, the training method, the hyperparameters, and the parameter-efficient fine-tuning (PEFT) settings. To save and run recipes in the app, see [Recipes](https://docs.oumi.ai/guides/intro/recipes.md).

| Method | Route | Description |
| - | - | - |
| `POST` | `/v1/projects/{project_id}/recipes` | Create a recipe |
| `POST` | `/v1/projects/{project_id}/recipes/{recipe_id}/versions` | Add a version to a recipe. The body has the same shape as the create request |
| `POST` | `/v1/projects/{project_id}/models:train` | Start training. Pass a saved recipe as `{"recipeId": ..., "recipeVersion": ...}` or pass `{"recipeConfig": {...}}` in `params.recipe` |

Request and response fields use camelCase. The API rejects unknown fields.

***

## REQUEST

```json theme={null}
{
  "displayName": "",
  "description": "",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {},
      "data": {},
      "training": {},
      "peft": {}
    }
  }
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| displayName | string | ✓ | Display name of the recipe. 1 to 128 characters. The characters `<`, `>`, and `&` are not allowed |
| description | string | | Description of the initial recipe version. 1 to 10,000 characters |
| recipeConfig | object | ✓ | The recipe configuration. See [Recipe config](#recipe-config) |

***

## RECIPE CONFIG

`recipeConfig` selects the recipe type and holds the training configuration.

| Field | Type | Required | Description |
| - | - | - | - |
| type | string | ✓ | Must be `train` |
| trainingConfig | object | ✓ | The training configuration. See [Training config](#training-config) |

***

## TRAINING CONFIG

`trainingConfig` contains four sections. Only `model` is required. Oumi fills the omitted settings from the preset recipe for the selected model and training method.

| Field | Type | Required | Description |
| - | - | - | - |
| model | object | ✓ | Base model and tokenizer settings. See [Model](#model) |
| data | object | | Training, validation, and test datasets. See [Data](#data) |
| training | object | | Training method and hyperparameters. See [Training](#training) |
| peft | object | | Parameter-efficient fine-tuning settings. Omit `peft` for full fine-tuning. See [PEFT](#peft) |

***

## MODEL

`model` defines the base model and the tokenizer.

| Field | Type | Required | Description |
| - | - | - | - |
| modelName | string | ✓ | Hugging Face name of a model from [Supported models](https://docs.oumi.ai/reference/supported-models.md). When you set `initModel`, this value must match the base model of that model version |
| initModel | object | | Project model version that supplies the initial weights. See [Init model](#init-model) |
| tokenizerName | string | | Tokenizer name. The model's tokenizer is used when you omit it |
| tokenizerPadToken | string | | Padding token for the tokenizer |
| modelMaxLength | integer | | Maximum sequence length |
| torchDtype | string | | Data type for model parameters, such as `bfloat16` |
| trustRemoteCode | boolean | | Allows code from the model repository to run |
| attnImplementation | string | | Attention implementation, such as `flash_attention_2` |
| chatTemplate | string | | Chat template that formats the inputs |
| freezeLayers | string\[] | | Names of layers to freeze during training. An empty list freezes no layers. Each name is 1 to 128 characters from letters, digits, `_`, `-`, spaces, `/`, `.`, and `@` |
| enableLigerKernel | boolean | | Enables Liger kernel optimizations |

### INIT MODEL

`model.initModel` starts training from the weights of an existing model version in your project instead of the base model weights.

| Field | Type | Required | Description |
| - | - | - | - |
| modelId | integer | ✓ | ID of the project model. Must be greater than `0` |
| modelVersionId | integer | ✓ | Version of that model whose weights are loaded. Must be greater than `0` |

***

## DATA

`data` lists the datasets for each split. Each split is an object with a `datasets` array. A split that you omit has no datasets.

| Field | Type | Required | Description |
| - | - | - | - |
| train | object | | Training datasets |
| validation | object | | Validation datasets |
| test | object | | Test datasets |

Each split contains one field.

| Field | Type | Required | Description |
| - | - | - | - |
| datasets | object\[] | | Dataset references for the split. A split can list more than one dataset. Defaults to an empty list |

### DATASET REFERENCE

| Field | Type | Required | Description |
| - | - | - | - |
| datasetId | integer | ✓ | ID of the dataset. A response shows `-1` when the referenced dataset was deleted |
| datasetVersion | integer | | Version of the dataset. The latest version is used when you omit it |

DPO training requires preference datasets. The other training methods reject preference datasets.

***

## TRAINING

`training` selects the training method and sets the hyperparameters. Omitted fields take the preset value for the model and method.

| Field | Type | Required | Description |
| - | - | - | - |
| trainerType | string | | Training method. See [Trainer type](#trainer-type) |
| onPolicyDistillation | object | | On-policy distillation settings. Use only with `trainerType` `opd`. See [On-policy distillation](#on-policy-distillation) |
| grpo | object | | GRPO settings. Use only with `trainerType` `grpo`. See [GRPO](#grpo) |
| preferenceOptimization | object | | DPO settings. Use only with `trainerType` `dpo`. See [Preference optimization](#preference-optimization) |
| maxSteps | integer | | Maximum number of training steps. A value greater than `0` overrides `numTrainEpochs` |
| numTrainEpochs | integer | | Number of full passes over the training data. From `1` to `30` |
| gradientAccumulationSteps | integer | | Gradient accumulation steps for the reference hardware. At least `1`. Oumi scales the value for the selected training hardware to keep the same effective batch size |
| learningRate | number | | Initial learning rate |
| lrSchedulerType | string | | Learning rate scheduler. See [Enumerated values](#enumerated-values) |
| warmupRatio | number | | Fraction of total steps used for warmup |
| warmupSteps | integer | | Number of warmup steps. Overrides `warmupRatio` |
| optimizer | string | | Optimizer name, such as `adamw_torch`. 1 to 128 characters from letters, digits, `_`, `-`, spaces, `/`, `.`, and `@` |
| weightDecay | number | | Weight decay (L2 penalty) |
| adamBeta1 | number | | Beta1 parameter for Adam optimizers |
| adamBeta2 | number | | Beta2 parameter for Adam optimizers |
| maxGradNorm | number | | Maximum gradient norm for clipping |
| mixedPrecisionDtype | string | | Mixed precision data type. See [Enumerated values](#enumerated-values) |
| enableGradientCheckpointing | boolean | | Enables gradient checkpointing, which reduces memory use |
| evalStrategy | string | | When validation runs. See [Enumerated values](#enumerated-values) |
| evalSteps | number | | Validation interval. An integer sets an exact number of steps. A number greater than `0` and less than `1` sets a fraction of the total training steps. GRPO training does not accept a fraction |
| seed | integer | | Random seed for reproducible runs |

### TRAINER TYPE

| Value | Training method |
| - | - |
| `sft` | Supervised fine-tuning |
| `opd` | On-policy distillation from a teacher model |
| `grpo` | Group relative policy optimization, a reinforcement learning method that scores completions with an evaluator |
| `dpo` | Direct preference optimization on preference datasets |

The API also accepts the legacy values `trl_sft`, `trl_gold`, and `verl_grpo`, and stores them as `sft`, `opd`, and `grpo`.

When you omit `trainerType`, Oumi infers it from the method settings. `onPolicyDistillation` selects `opd`, `grpo` selects `grpo`, and `preferenceOptimization` selects `dpo`. Without any of these settings, the preset trainer for the model applies.

GRPO and DPO are behind feature flags. The API rejects `grpo` and `dpo` in environments where these flags are off.

### ENUMERATED VALUES

| Field | Allowed values |
| - | - |
| lrSchedulerType | `linear`, `cosine`, `cosine_with_restarts`, `cosine_with_min_lr`, `constant` |
| mixedPrecisionDtype | `none`, `fp16`, `bf16` |
| evalStrategy | `no`, `steps`, `epoch` |

***

## ON-POLICY DISTILLATION

`training.onPolicyDistillation` configures on-policy distillation. Use it with `trainerType` `opd`.

| Field | Type | Required | Description |
| - | - | - | - |
| teacherModelName | string | ✓ | Teacher model name. Must be a teacher model listed for the student model |
| temperature | number | | Sampling temperature during generation. From `0` to `1` |
| lmbda | number | | Fraction of on-policy student data. From `0` to `1`. A value of `0.5` means 50% on-policy and 50% off-policy data |
| beta | number | | Jensen-Shannon divergence interpolation coefficient. From `0` to `1`. A value of `0` is KL divergence, `0.5` is symmetric JSD, and `1` is reverse KL |
| maxCompletionLength | integer | | Maximum tokens per completion. At least `1` |

***

## GRPO

`training.grpo` configures GRPO training. Use it with `trainerType` `grpo`.

| Field | Type | Required | Description |
| - | - | - | - |
| evaluatorId | integer | | ID of the evaluator that scores model completions. GRPO training fails validation without it |
| evaluatorVersion | integer | | Version of the evaluator. The latest version is used when you omit it. Requires `evaluatorId` |
| numGenerations | integer | | Completions sampled per prompt to form each group. At least `1`. Larger groups give lower-variance advantage estimates and cost more generation compute |
| maxPromptLength | integer | | Maximum tokens per prompt. At least `1`. Longer prompts are filtered out |
| maxCompletionLength | integer | | Maximum tokens per completion. At least `1` |
| temperature | number | | Sampling temperature for completions during rollouts. From `0` to `2` |
| klCoef | number | | KL penalty coefficient that keeps the policy close to the base model. At least `0`. A value of `0` disables the penalty |

***

## PREFERENCE OPTIMIZATION

`training.preferenceOptimization` configures DPO training. Use it with `trainerType` `dpo`. Omitted fields take the preset value.

| Field | Type | Required | Description |
| - | - | - | - |
| beta | number | | DPO regularization strength. Must be greater than `0` |
| lossType | string | | DPO loss function. `sigmoid` or `nca_pair` |

***

## PEFT

`peft` configures parameter-efficient fine-tuning. Omit `peft`, or omit `peftMethod`, for full fine-tuning.

| Field | Type | Required | Description |
| - | - | - | - |
| peftMethod | string | | Set to `lora` for LoRA fine-tuning. The schema also lists `qlora`, which the training backend does not support |
| loraR | integer | | LoRA rank |
| loraAlpha | integer | | LoRA alpha scaling parameter |
| loraDropout | number | | Dropout probability for LoRA layers |
| targetModules | string\[] | | Modules to adapt. Model-specific defaults apply when you omit it. Each name is 1 to 128 characters from letters, digits, `_`, `-`, spaces, `/`, `.`, and `@` |

***

## VALIDATION RULES

* `trainingConfig.model.modelName` is the only required training field.
* A request can set at most one of `onPolicyDistillation`, `grpo`, and `preferenceOptimization`.
* When `trainerType` is set, it must match the method settings. For example, `grpo` settings require `trainerType` `grpo`.
* `numTrainEpochs` must be from `1` to `30`.
* A fractional `evalSteps` must be greater than `0` and less than `1`. GRPO training accepts only an integer.
* GRPO training requires `training.grpo.evaluatorId`.
* `grpo.evaluatorVersion` requires `grpo.evaluatorId`.
* DPO training requires preference datasets. Other trainer types reject preference datasets.
* `onPolicyDistillation.teacherModelName` must be a teacher model listed for the student model.

***

## EXAMPLES

### SUPERVISED FINE-TUNING WITH LORA

LoRA uses less GPU memory and trains faster than full fine-tuning. Use it as the starting point for most fine-tuning tasks.

```json theme={null}
{
  "displayName": "Llama 3.1 8B LoRA",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {
        "modelName": "meta-llama/Llama-3.1-8B-Instruct",
        "torchDtype": "bfloat16",
        "modelMaxLength": 4096
      },
      "data": {
        "train": {
          "datasets": [{ "datasetId": 101 }]
        },
        "validation": {
          "datasets": [{ "datasetId": 102 }]
        }
      },
      "training": {
        "trainerType": "sft",
        "numTrainEpochs": 3,
        "learningRate": 0.0002,
        "lrSchedulerType": "cosine",
        "warmupRatio": 0.05,
        "maxGradNorm": 1.0,
        "mixedPrecisionDtype": "bf16",
        "enableGradientCheckpointing": true
      },
      "peft": {
        "peftMethod": "lora"
      }
    }
  }
}
```

### FULL FINE-TUNING

Full fine-tuning updates all model parameters. Use it when LoRA quality is not sufficient for your task.

```json theme={null}
{
  "displayName": "Qwen3 8B full fine-tuning",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {
        "modelName": "Qwen/Qwen3-8B",
        "torchDtype": "bfloat16",
        "modelMaxLength": 8192,
        "attnImplementation": "flash_attention_2"
      },
      "data": {
        "train": {
          "datasets": [{ "datasetId": 201 }]
        },
        "validation": {
          "datasets": [{ "datasetId": 202 }]
        },
        "test": {
          "datasets": [{ "datasetId": 203 }]
        }
      },
      "training": {
        "trainerType": "sft",
        "numTrainEpochs": 2,
        "learningRate": 0.00005,
        "lrSchedulerType": "linear",
        "warmupSteps": 100,
        "weightDecay": 0.01,
        "mixedPrecisionDtype": "bf16",
        "enableGradientCheckpointing": true
      }
    }
  }
}
```

### ON-POLICY DISTILLATION INTO A SMALLER MODEL

On-policy distillation trains a smaller student model with guidance from a larger teacher model. See [On-policy distillation](https://docs.oumi.ai/guides/training/on-policy-distillation.md).

```json theme={null}
{
  "displayName": "SmolLM2 on-policy distillation",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {
        "modelName": "HuggingFaceTB/SmolLM2-135M-Instruct",
        "torchDtype": "bfloat16",
        "modelMaxLength": 2048
      },
      "data": {
        "train": {
          "datasets": [{ "datasetId": 301 }]
        }
      },
      "training": {
        "trainerType": "opd",
        "onPolicyDistillation": {
          "teacherModelName": "HuggingFaceTB/SmolLM2-1.7B-Instruct"
        },
        "numTrainEpochs": 3,
        "learningRate": 0.0001,
        "lrSchedulerType": "cosine",
        "warmupRatio": 0.1,
        "mixedPrecisionDtype": "bf16"
      },
      "peft": {
        "peftMethod": "lora"
      }
    }
  }
}
```

### DIRECT PREFERENCE OPTIMIZATION

DPO trains a model to prefer the chosen response over the rejected response in each row of a preference dataset. This example uses full fine-tuning. See [Direct preference optimization](https://docs.oumi.ai/guides/training/direct-preference-optimization.md).

```json theme={null}
{
  "displayName": "Qwen3.5 4B DPO",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {
        "modelName": "Qwen/Qwen3.5-4B"
      },
      "data": {
        "train": {
          "datasets": [{ "datasetId": 401 }]
        }
      },
      "training": {
        "trainerType": "dpo",
        "preferenceOptimization": {
          "beta": 0.1,
          "lossType": "sigmoid"
        },
        "numTrainEpochs": 1
      }
    }
  }
}
```

### GRPO WITH AN EVALUATOR REWARD

GRPO samples several completions for each prompt and scores them with an evaluator. Set `evaluatorId` to an evaluator in the same project.

```json theme={null}
{
  "displayName": "Qwen3.5 4B GRPO",
  "recipeConfig": {
    "type": "train",
    "trainingConfig": {
      "model": {
        "modelName": "Qwen/Qwen3.5-4B"
      },
      "data": {
        "train": {
          "datasets": [{ "datasetId": 501 }]
        }
      },
      "training": {
        "trainerType": "grpo",
        "grpo": {
          "evaluatorId": 12,
          "numGenerations": 8,
          "maxCompletionLength": 1024,
          "temperature": 1.0
        }
      },
      "peft": {
        "peftMethod": "lora"
      }
    }
  }
}
```

Set `seed` in `training` for reproducible runs. Set `enableGradientCheckpointing` to `true` when GPU memory is limited.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.