IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Python class

LabelScoringTokenizer

LabelScoringTokenizer​

class max.pipelines.modeling.types.LabelScoringTokenizer(*args, **kwargs)

source

Bases: Protocol

Tokenizer capabilities that label scoring (/v1/decisions) needs.

Declared as a protocol, checked once when a scoring request is admitted, so a tokenizer that lacks a member is refused instead of having its context-length check skipped.

apply_chat_template()​

apply_chat_template(messages, tools, **chat_template_options)

source

Renders messages with the model’s chat template.

Parameters:

Return type:

str

encode()​

async encode(prompt, add_special_tokens=True)

source

Encodes text to token ids.

Parameters:

  • prompt (str)
  • add_special_tokens (bool)

Return type:

ndarray[tuple[Any, …], dtype[integer[Any]]]

max_length​

property max_length: int | None

source

The context length, in tokens; None when unbounded.