> 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.components.datasets.llm.hellaswag

## Module Contents

### Classes

| Name                                                                       | Description                                                                                           |
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [`HellaSwag`](#nemo_automodel-components-datasets-llm-hellaswag-HellaSwag) | A dataset wrapper for the HellaSwag benchmark, tailored for single-turn supervised fine-tuning (SFT). |

### API

```python
class nemo_automodel.components.datasets.llm.hellaswag.HellaSwag(
    path_or_dataset,
    tokenizer,
    split = 'train',
    num_samples_limit = None,
    pad_to_max_length = True
)
```

A dataset wrapper for the HellaSwag benchmark, tailored for single-turn supervised fine-tuning (SFT).

This class loads and preprocesses the HellaSwag dataset using a tokenizer and a custom preprocessing
pipeline for language model fine-tuning. The dataset consists of context and multiple-choice endings,
where the goal is to choose the most plausible continuation.

```python
nemo_automodel.components.datasets.llm.hellaswag.HellaSwag.__getitem__(
    index
)
```

Get a processed example by index.

**Parameters:**

Index of the example.

**Returns:**

A tokenized and preprocessed example.

```python
nemo_automodel.components.datasets.llm.hellaswag.HellaSwag.__len__()
```

Get the number of examples in the dataset.

**Returns:**

Length of the processed dataset.

```python
nemo_automodel.components.datasets.llm.hellaswag.HellaSwag.get_context(
    examples
)
```

Extracts the context part of each example.

**Parameters:**

A dictionary containing example data with a "ctx" key.

**Returns:**

list\[str]: List of context strings.

```python
nemo_automodel.components.datasets.llm.hellaswag.HellaSwag.get_target(
    examples
)
```

Extracts the correct ending based on the label.

**Parameters:**

A dictionary with "endings" (list of strings) and "label" (index of correct ending).

**Returns:**

list\[str]: The gold target strings based on the label index.