> This page is for NeMo-RL, version último (default).
> For other versions, use one of these documentation indexes:
> - último (default): https://es.nvidia-localization.ferndocs.com/es/nemo/rl/latest/llms.txt
> - 0.3.0: https://es.nvidia-localization.ferndocs.com/es/nemo/rl/0-3-0/llms.txt
> - 0.2.1: https://es.nvidia-localization.ferndocs.com/es/nemo/rl/0-2-1/llms.txt

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

# nemo_rl.models.policy.lm_policy

## Contenido del Módulo

### Clases

| Nombre                                        | Descripción                                                       |
| --------------------------------------------- | ----------------------------------------------------------------- |
| [`Policy`](#nemorlmodelspolicylmpolicypolicy) | Clase base abstracta que define la interfaz para políticas de RL. |

### Datos

`PathLike`

### API

```python
nemo_rl.models.policy.lm_policy.PathLike
```

**Valor**: `None`

```python
class nemo_rl.models.policy.lm_policy.Policy(cluster: nemo_rl.distributed.virtual_cluster.RayVirtualCluster, config: nemo_rl.models.policy.PolicyConfig, tokenizer: transformers.PreTrainedTokenizerBase, name_prefix: str = 'lm_policy', workers_per_node: typing.Optional[typing.Union[int, list[int]]] = None, init_optimizer: bool = True, weights_path: typing.Optional[nemo_rl.models.policy.lm_policy.PathLike] = None, optimizer_path: typing.Optional[nemo_rl.models.policy.lm_policy.PathLike] = None, init_reference_model: bool = True, processor: typing.Optional[transformers.AutoProcessor] = None)
```

**Bases**: `nemo_rl.models.policy.interfaces.ColocatablePolicyInterface`, `nemo_rl.models.generation.interfaces.GenerationInterface`

```python
init_collective(
    ip: str,
    port: int,
    world_size: int
) -> list[ray.ObjectRef]
```

Inicializar la comunicación colectiva.

```python
get_logprobs(data: nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.generation.interfaces.GenerationDatumSpec]) -> nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.policy.interfaces.LogprobOutputSpec]
```

Obtener los logprobs del modelo para un diccionario de datos.

Devuelve:
Un BatchedDataDict con la clave "logprobs" y forma \[batch_size, sequence_length].
Usamos la convención de que el logprob del primer token es 0 para mantener la longitud de secuencia.
El logprob del token de entrada i se especifica en la posición i del tensor de logprobs de salida.

```python
get_reference_policy_logprobs(
    data: nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.generation.interfaces.GenerationDatumSpec],
    micro_batch_size: typing.Optional[int] = None
) -> nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.policy.interfaces.ReferenceLogprobOutputSpec]
```

Obtener los logprobs de la política de referencia para un diccionario de datos.

Devuelve: Idéntico a get_logprobs.

\[The rest of the document remains translated in the same manner, maintaining the same structure and translating only user-visible text.]