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

# nemo_gym.prompt

Prompt configuration: YAML-based prompt templates applied at rollout time.

Prompt templates are mutually exclusive with pre-populated
`responses_create_params.input` values. This separation enables prompt
sweeps without re-preparing data.

## Module Contents

### Classes

| Name                                                                    | Description                                                              |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [`MaterializePromptsConfig`](#nemo_gym-prompt-MaterializePromptsConfig) | Apply a prompt template to raw JSONL data, producing materialized JSONL  |
| [`PromptConfig`](#nemo_gym-prompt-PromptConfig)                         | Schema for a prompt YAML file. `user` is required, `system` is optional. |

### Functions

| Name                                                                              | Description                                                                                                 |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| [`_resolve_path`](#nemo_gym-prompt-_resolve_path)                                 | Resolve a path relative to the Gym root (PARENT\_DIR), consistent with config\_paths resolution.            |
| [`apply_prompt_to_row`](#nemo_gym-prompt-apply_prompt_to_row)                     | Apply prompt\_config to a row, building responses\_create\_params.input.                                    |
| [`fill_prompt`](#nemo_gym-prompt-fill_prompt)                                     | Apply a prompt template to a data row, producing message dicts.                                             |
| [`load_prompt_config`](#nemo_gym-prompt-load_prompt_config)                       | Load and validate a YAML prompt config file.                                                                |
| [`materialize_prompts`](#nemo_gym-prompt-materialize_prompts)                     | Apply a prompt template to raw JSONL data, producing materialized JSONL.                                    |
| [`materialize_prompts_cli`](#nemo_gym-prompt-materialize_prompts_cli)             | CLI entry point for ng\_materialize\_prompts.                                                               |
| [`validate_prompt_compatibility`](#nemo_gym-prompt-validate_prompt_compatibility) | Validate that no rows have pre-populated responses\_create\_params.input when a prompt\_config is provided. |

### API

```python
class nemo_gym.prompt.MaterializePromptsConfig()
```

**Bases:** [BaseNeMoGymCLIConfig](/nemo-gym/nemo_gym/config_types#nemo_gym-config_types-BaseNeMoGymCLIConfig)

Apply a prompt template to raw JSONL data, producing materialized JSONL
with populated `responses_create_params.input` for RL training.

Examples:

```python
ng_materialize_prompts \
    +input_jsonl_fpath=data/my_dataset.jsonl \
    +prompt_config=/path/to/my_prompt.yaml \
    +output_jsonl_fpath=my_dataset_materialized.jsonl
```

```python
class nemo_gym.prompt.PromptConfig()
```

**Bases:** `BaseModel`

Schema for a prompt YAML file. `user` is required, `system` is optional.

```python
nemo_gym.prompt._resolve_path(
    path: str
) -> pathlib.Path
```

Resolve a path relative to the Gym root (PARENT\_DIR), consistent with config\_paths resolution.

```python
nemo_gym.prompt.apply_prompt_to_row(
    row: dict,
    prompt_config: nemo_gym.prompt.PromptConfig
) -> dict
```

Apply prompt\_config to a row, building responses\_create\_params.input.

Other fields in responses\_create\_params (tools, metadata, temperature,
max\_output\_tokens) are preserved. Returns a new dict (does not mutate the original).

```python
nemo_gym.prompt.fill_prompt(
    prompt_config: nemo_gym.prompt.PromptConfig,
    row: dict
) -> typing.List[typing.Dict[str, str]]
```

Apply a prompt template to a data row, producing message dicts.

Placeholders (`&#123;field_name&#125;`) are filled from the row's top-level
fields. Literal braces must be doubled (`&#123;&#123;` / `&#125;&#125;`).

```python
nemo_gym.prompt.load_prompt_config(
    path: str
) -> nemo_gym.prompt.PromptConfig
```

Load and validate a YAML prompt config file.

Relative paths are resolved against the Gym root directory (`PARENT_DIR`),
consistent with how `config_paths` and other Gym paths are resolved.

Returns a `PromptConfig` with required `user` and optional `system` fields.
Each value is a string template with `&#123;placeholder&#125;` syntax.
Results are cached so the same file is only parsed once.

```python
nemo_gym.prompt.materialize_prompts(
    input_jsonl: str,
    prompt_config: str,
    output_jsonl: str
) -> None
```

Apply a prompt template to raw JSONL data, producing materialized JSONL.

Reads each row from `input_jsonl`, validates that no row has pre-populated
`responses_create_params.input`, applies the prompt template, and writes
the result to `output_jsonl`.

**Parameters:**

Path to raw JSONL (no responses\_create\_params.input).

Path to prompt YAML file.

Path to write materialized JSONL (with responses\_create\_params.input).

```python
nemo_gym.prompt.materialize_prompts_cli() -> None
```

CLI entry point for ng\_materialize\_prompts.

```python
nemo_gym.prompt.validate_prompt_compatibility(
    rows: typing.List[dict],
    prompt_config: nemo_gym.prompt.PromptConfig
) -> None
```

Validate that no rows have pre-populated responses\_create\_params.input when a prompt\_config is provided.

Collects all violating row indices and reports them in a single error.