> 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.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/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.

# nemo_automodel.components.models.gs1.reader

GS1 decision reads: the checkpoint's own compiler, one question per read, the native decision head.

## Module Contents

### Classes

| Name                                                                                    | Description                                                                                       |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`GS1Branch`](#nemo_automodel-components-models-gs1-reader-GS1Branch)                   | Compiler metadata consumed by `GS1Model.forward` and its readout.                                 |
| [`GS1CompiledRequest`](#nemo_automodel-components-models-gs1-reader-GS1CompiledRequest) | Compiled shared state and native decision branches.                                               |
| [`GS1Compiler`](#nemo_automodel-components-models-gs1-reader-GS1Compiler)               | Public compiler interface exposed by GS1 checkpoints.                                             |
| [`GS1DecisionModel`](#nemo_automodel-components-models-gs1-reader-GS1DecisionModel)     | Native checkpoint methods needed to build the reader.                                             |
| [`GS1DecisionReader`](#nemo_automodel-components-models-gs1-reader-GS1DecisionReader)   | Reads questions through a GS1 checkpoint's own request schema, compiler and decision head.        |
| [`GS1Read`](#nemo_automodel-components-models-gs1-reader-GS1Read)                       | One compiled question: the shared state followed by the question's branch, unpadded.              |
| [`GS1ReaderConfig`](#nemo_automodel-components-models-gs1-reader-GS1ReaderConfig)       | Read GS1 checkpoints (`reader: &#123;_target_: ...GS1ReaderConfig&#125;`); full fine-tuning only. |

### Data

[`STAGE_FORMAT`](#nemo_automodel-components-models-gs1-reader-STAGE_FORMAT)

### API

```python
class nemo_automodel.components.models.gs1.reader.GS1Branch()
```

Protocol

Compiler metadata consumed by `GS1Model.forward` and its readout.

**`candidates`** `tuple[str, ...]`

---

**`decision_position`** `int`

---

**`option_spans`** `tuple[tuple[int, int], ...]`

---

**`option_starts`** `tuple[int, ...]`

---

**`question_end_position`** `int`

---

**`question_span`** `tuple[int, int]`

---

**`question_start_position`** `int`

---

**`state_evidence_start`** `int`

---

**`suffix`** `tuple[int, ...]`

---

**`token_roles`** `tuple[str, ...]`

---

**`visual_inputs`** `dict[str, Any] | None`

---

```python
class nemo_automodel.components.models.gs1.reader.GS1CompiledRequest()
```

Protocol

Compiled shared state and native decision branches.

**`branches`** `tuple[GS1Branch, ...]`

---

**`state`** `tuple[int, ...]`

---

```python
class nemo_automodel.components.models.gs1.reader.GS1Compiler()
```

Protocol

Public compiler interface exposed by GS1 checkpoints.

```python
nemo_automodel.components.models.gs1.reader.GS1Compiler.compile(
    request: pydantic.BaseModel
) -> nemo_automodel.components.models.gs1.reader.GS1CompiledRequest
```

```python
class nemo_automodel.components.models.gs1.reader.GS1DecisionModel()
```

Protocol

Native checkpoint methods needed to build the reader.

```python
nemo_automodel.components.models.gs1.reader.GS1DecisionModel.decision_compiler(
    tokenizer: transformers.PreTrainedTokenizerBase,
    max_context: int
) -> nemo_automodel.components.models.gs1.reader.GS1Compiler
```

```python
class nemo_automodel.components.models.gs1.reader.GS1DecisionReader(
    model: torch.nn.Module,
    compiler: nemo_automodel.components.models.gs1.reader.GS1Compiler,
    request_type: type[pydantic.BaseModel],
    model_id: str,
    max_input_tokens: int,
    device: torch.device
)
```

**Bases:** [DecisionReader\[GS1Read\]](/nemo/automodel/nightly/nemo-automodel/nemo_automodel/components/models/common/decision_reader#nemo_automodel-components-models-common-decision_reader-DecisionReader)

Reads questions through a GS1 checkpoint's own request schema, compiler and decision head.

```python
nemo_automodel.components.models.gs1.reader.GS1DecisionReader.encode(
    record: dict[str, typing.Any],
    question_id: str,
    shuffle_seed: int | None = None
) -> nemo_automodel.components.models.gs1.reader.GS1Read | None
```

Compile one question with the record's state (see `DecisionReader.encode`).

Returns `None` for requests the checkpoint's schema or compiler rejects (including reads longer than
`data.max_tokens`; the compiler never truncates), for branches that need visual inputs (this reader passes
token IDs only) and for questions with fewer than two candidates.

**Raises:**

* `ValueError`: If `shuffle_seed` is set: the compiler fixes the candidate order.

```python
nemo_automodel.components.models.gs1.reader.GS1DecisionReader.identity() -> dict[str, typing.Any]
```

Stage fields of a GS1 stage.

```python
nemo_automodel.components.models.gs1.reader.GS1DecisionReader.logits(
    read: nemo_automodel.components.models.gs1.reader.GS1Read
) -> torch.Tensor
```

Candidate logits of one unpadded single-branch forward, fp32 tensor of shape `[candidates]`.

```python
class nemo_automodel.components.models.gs1.reader.GS1Read(
    question_id: str,
    labels: tuple[str, ...],
    input_ids: tuple[int, ...],
    branch: nemo_automodel.components.models.gs1.reader.GS1Branch,
    state_length: int
)
```

Dataclass

**Bases:** [DecisionRead](/nemo/automodel/nightly/nemo-automodel/nemo_automodel/components/models/common/decision_reader#nemo_automodel-components-models-common-decision_reader-DecisionRead)

One compiled question: the shared state followed by the question's branch, unpadded.

**`branch`** `GS1Branch`

The compiler's branch of the question; `labels` is its `candidates`.

---

**`input_ids`** `tuple[int, ...]`

State tokens followed by the branch suffix.

---

**`state_length`** `int`

Number of state tokens at the start of `input_ids`.

---

```python
class nemo_automodel.components.models.gs1.reader.GS1ReaderConfig()
```

Dataclass

**Bases:** [DecisionReaderConfig\[GS1Read\]](/nemo/automodel/nightly/nemo-automodel/nemo_automodel/components/models/common/decision_reader#nemo_automodel-components-models-common-decision_reader-DecisionReaderConfig)

Read GS1 checkpoints (`reader: &#123;_target_: ...GS1ReaderConfig&#125;`); full fine-tuning only.

```python
nemo_automodel.components.models.gs1.reader.GS1ReaderConfig._build(
    model: torch.nn.Module,
    tokenizer: transformers.PreTrainedTokenizerBase,
    model_path: str,
    revision: str | None,
    max_tokens: int,
    peft: bool,
    device: torch.device
) -> nemo_automodel.components.models.gs1.reader.GS1DecisionReader
```

Build the checkpoint's compiler and load its request schema from the same code revision.

```python
nemo_automodel.components.models.gs1.reader.GS1ReaderConfig.prepare(
    model_path: str,
    revision: str | None
) -> None
```

Check the checkpoint code's dependency and patch Transformers before the checkpoint code loads.

```python
nemo_automodel.components.models.gs1.reader.STAGE_FORMAT = 'gs1-decision-stage-v1'
```