IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

TokenSampler

TokenSamplerโ€‹

class max.pipelines.sampling.TokenSampler(session, sampling_config, device, return_logits=False)

source

Bases: object

Samples tokens from the logits.

Parameters:

sample_logits()โ€‹

sample_logits(logits, sampler_inputs, penalty_inputs=None)

source

Samples tokens from the logits.

Parameters:

Return type:

Buffer

sample_logits_with_prev()โ€‹

sample_logits_with_prev(logits, prev_tokens, prev_logits, sampler_inputs, penalty_inputs=None)

source

Samples tokens from the logits with previous logits.

Parameters:

Return type:

tuple[Buffer, Buffer, Buffer]