# tinker_cookbook.rl.RLDataset

## _class_ [**tinker_cookbook.rl.RLDataset**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/types.py#L445)( _ABC_)

A dataset that produces batches of [`EnvGroupBuilder`](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/envgroupbuilder/) instances.

This is the primary dataset interface consumed by RL training loops. Implementations must define `get_batch` and `__len__`.

```
class MyDataset(RLDataset):
    def __init__(self, builders: list[EnvGroupBuilder], batch_size: int):
        self.builders = builders
        self.batch_size = batch_size
    def get_batch(self, index: int) -> Sequence[EnvGroupBuilder]:
        start = index * self.batch_size
        return self.builders[start : start + self.batch_size]
    def __len__(self) -> int:
        return len(self.builders) // self.batch_size
```

### [**get_batch**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/types.py#L467)( _index_)

Return a batch of EnvGroupBuilder instances at the given index.

**Parameters:**

- [**index**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/types.py#L467) ( _int_) – The batch index (`0 <= index < len(self)`).

**Returns:** _Sequence[ [EnvGroupBuilder](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/rl/envgroupbuilder/) ]_ – The environment group builders for this batch.

_Abstract method._

## Referenced by

- [tinker_cookbook.distillation.PromptOnlyDataset](https://tinker-docs.thinking-machines-ai/cookbook/api-reference/distillation/promptonlydataset/)
- [tinker_cookbook.rl.RLDatasetBuilder.__call__](https://tinker-docs.thinking-machines-ai/cookbook/api-reference/rl/rldatasetbuilder/#rldatasetbuilder-call)
