dynamo.logits_processing

Custom logits processors for LLM token generation.
以 Markdown 格式查看

dynamo.logits_processing publishes 4 classes and 0 functions. Source: lib/bindings/python/src/dynamo/logits_processing/__init__.py

Protocol for logits processors in Dynamo.

1from 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

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

1from dynamo.logits_processing.examples import ForcedSequenceLogitsProcessor
1ForcedSequenceLogitsProcessor(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

Public methods

init

1__init__(token_ids: Sequence[int], eos_token_id: int)

No summary available.

source

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

1from dynamo.logits_processing.examples import HelloWorldLogitsProcessor
1HelloWorldLogitsProcessor(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

Public methods

init

1__init__(tokenizer: PreTrainedTokenizerBase)

No summary available.

source

Example logits processor that applies temperature scaling.

1from dynamo.logits_processing.examples import TemperatureProcessor
1TemperatureProcessor(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

Public methods

init

1__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