> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://docs.nvidia.com/dynamo/llms.txt. For full content including API reference and SDK examples, see https://docs.nvidia.com/dynamo/llms-full.txt.

# dynamo.logits_processing

`dynamo.logits_processing` publishes 4 classes and 0 functions. Source: [`lib/bindings/python/src/dynamo/logits_processing/__init__.py`](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/__init__.py)

#### BaseLogitsProcessor (class)

Protocol for logits processors in Dynamo.

```python
from dynamo.logits_processing import BaseLogitsProcessor
```

All logits processors must implement this interface to be compatible
with backend adapters (TRT-LLM, vLLM, SGLang).

[`lib/bindings/python/src/dynamo/logits_processing/base.py#L16`](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/base.py#L16)

#### ForcedSequenceLogitsProcessor (class)

Forces the next `len(token_ids)` outputs, then EOS thereafter.

```python
from dynamo.logits_processing.examples import ForcedSequenceLogitsProcessor
```

```python
ForcedSequenceLogitsProcessor(token_ids: Sequence[int], eos_token_id: int)
```

Stateful: keeps a position counter (`state`) advanced each step.
Must be instantiated per request so concurrent streams don't mix
positions.

[`lib/bindings/python/src/dynamo/logits_processing/examples/forced_sequence.py#L19`](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/forced_sequence.py#L19)

**Public methods**

<h4 id="api-dynamo-logits-processing-examples-forced-sequence-forcedsequencelogitsprocessor-init">
  **init**
</h4>

```python
__init__(token_ids: Sequence[int], eos_token_id: int)
```

No summary available.

[source](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/forced_sequence.py#L27)

#### HelloWorldLogitsProcessor (class)

Sample Logits Processor that always outputs a hardcoded response (`RESPONSE`), no matter the input.

```python
from dynamo.logits_processing.examples import HelloWorldLogitsProcessor
```

```python
HelloWorldLogitsProcessor(tokenizer: PreTrainedTokenizerBase)
```

Thin wrapper over `ForcedSequenceLogitsProcessor`: resolves the
forced token IDs from the tokenizer at construction time, then
reuses the shared forced-sequence masking and per-request state.

[`lib/bindings/python/src/dynamo/logits_processing/examples/hello_world.py#L11`](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/hello_world.py#L11)

**Public methods**

<h4 id="api-dynamo-logits-processing-examples-hello-world-helloworldlogitsprocessor-init">
  **init**
</h4>

```python
__init__(tokenizer: PreTrainedTokenizerBase)
```

No summary available.

[source](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/hello_world.py#L21)

#### TemperatureProcessor (class)

Example logits processor that applies temperature scaling.

```python
from dynamo.logits_processing.examples import TemperatureProcessor
```

```python
TemperatureProcessor(temperature: float = 1.0)
```

This is a simple demonstration of how to implement a logits processor
that can be used with any Dynamo backend.

[`lib/bindings/python/src/dynamo/logits_processing/examples/temperature.py#L11`](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/temperature.py#L11)

**Public methods**

<h4 id="api-dynamo-logits-processing-examples-temperature-temperatureprocessor-init">
  **init**
</h4>

```python
__init__(temperature: float = 1.0)
```

Args: temperature: Scaling factor. Higher values make distribution more uniform, lower values make it more peaked. Must be positive.

[source](https://github.com/ai-dynamo/dynamo/blob/main/lib/bindings/python/src/dynamo/logits_processing/examples/temperature.py#L19)