> This page is for version Nightly (default).
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# nemo_automodel.recipes.llm.train_seq_cls

## Module Contents

### Classes

| Name                                                                                                                                     | Description                                                 |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [`TrainFinetuneRecipeForSequenceClassification`](#nemo_automodel-recipes-llm-train_seq_cls-TrainFinetuneRecipeForSequenceClassification) | Recipe for fine-tuning a model for sequence classification. |

### Functions

| Name                                                     | Description                                         |
| -------------------------------------------------------- | --------------------------------------------------- |
| [`main`](#nemo_automodel-recipes-llm-train_seq_cls-main) | Run the sequence-classification fine-tuning recipe. |

### Data

[`logger`](#nemo_automodel-recipes-llm-train_seq_cls-logger)

### API

```python
class nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification(
    cfg
)
```

**Bases:** [BaseRecipe](/nemo-automodel/nemo_automodel/recipes/base_recipe#nemo_automodel-recipes-base_recipe-BaseRecipe)

Recipe for fine-tuning a model for sequence classification.

**`cfg`**

---

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification._run_train_optim_step(
    batches
)
```

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification._validate_one_epoch(
    dataloader
)
```

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification.log_train_metrics(
    log_data
)
```

Log metrics to wandb and other loggers.

**Parameters:**

**`log_data`**

MetricsSample object, containing:
step: int, the current step.
epoch: int, the current epoch.
metrics: Dict\[str, float], containing:
"loss": Training loss.
"accuracy": Training accuracy.
"grad\_norm": Gradient norm from the training step.
"lr": Learning rate.
"mem": Memory allocated.
"tps": Tokens per second (throughput).
"tps\_per\_gpu": Tokens per second per GPU.

---

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification.log_val_metrics(
    log_data
)
```

Log metrics to wandb and other loggers
Args:
log\_data: MetricsSample object, containing:
step: int, the current step.
epoch: int, the current epoch.
metrics: Dict\[str, float], containing:
"val\_loss": Validation loss.
"lr": Learning rate.
"num\_label\_tokens": Number of label tokens.
"mem": Memory allocated.

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification.run_train_validation_loop()
```

```python
nemo_automodel.recipes.llm.train_seq_cls.TrainFinetuneRecipeForSequenceClassification.setup()
```

```python
nemo_automodel.recipes.llm.train_seq_cls.main(
    config_path: str | None = None
)
```

Run the sequence-classification fine-tuning recipe.

```python
nemo_automodel.recipes.llm.train_seq_cls.logger = logging.getLogger(__name__)
```