> This page is for version v1.4.0.
> For other versions, use one of these documentation indexes:
> - Latest (v1.5.1) (default): https://docs.nvidia.com/dynamo/latest/llms.txt
> - dev: https://docs.nvidia.com/dynamo/dev/llms.txt
> - v1.5.1: https://docs.nvidia.com/dynamo/v1.5.1/llms.txt
> - v1.5.0: https://docs.nvidia.com/dynamo/v1.5.0/llms.txt
> - v1.4.2: https://docs.nvidia.com/dynamo/v1.4.2/llms.txt
> - v1.4.1: https://docs.nvidia.com/dynamo/v1.4.1/llms.txt
> - v1.4.0: https://docs.nvidia.com/dynamo/v1.4.0/llms.txt
> - v1.3.0: https://docs.nvidia.com/dynamo/v1.3.0/llms.txt
> - v1.2.1: https://docs.nvidia.com/dynamo/v1.2.1/llms.txt
> - v1.2.0: https://docs.nvidia.com/dynamo/v1.2.0/llms.txt
> - v1.1.1: https://docs.nvidia.com/dynamo/v1.1.1/llms.txt
> - v1.1.0: https://docs.nvidia.com/dynamo/v1.1.0/llms.txt
> - v1.0.2: https://docs.nvidia.com/dynamo/v1.0.2/llms.txt
> - v1.0.1: https://docs.nvidia.com/dynamo/v1.0.1/llms.txt
> - v1.0.0: https://docs.nvidia.com/dynamo/v1.0.0/llms.txt
> - v0.9.1: https://docs.nvidia.com/dynamo/v-0-9-1/llms.txt
> - v0.9.0: https://docs.nvidia.com/dynamo/v-0-9-0/llms.txt
> - v0.8.1: https://docs.nvidia.com/dynamo/v-0-8-1/llms.txt
> - v0.8.0: https://docs.nvidia.com/dynamo/v-0-8-0/llms.txt
> - v0.7.1: https://docs.nvidia.com/dynamo/v-0-7-1/llms.txt
> - v0.7.0: https://docs.nvidia.com/dynamo/v-0-7-0/llms.txt

> 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/v1.4.0/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/v1.4.0/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/v1.4.0/lib/bindings/python/src/dynamo/logits_processing/examples/forced_sequence.py#L19)

**Public methods**

#### **init**

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

No summary available.

[source](https://github.com/ai-dynamo/dynamo/blob/v1.4.0/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/v1.4.0/lib/bindings/python/src/dynamo/logits_processing/examples/hello_world.py#L11)

**Public methods**

#### **init**

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

No summary available.

[source](https://github.com/ai-dynamo/dynamo/blob/v1.4.0/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/v1.4.0/lib/bindings/python/src/dynamo/logits_processing/examples/temperature.py#L11)

**Public methods**

#### **init**

```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/v1.4.0/lib/bindings/python/src/dynamo/logits_processing/examples/temperature.py#L19)