Skip to content

vllm.renderers.inkling

Native Inkling chat renderer for the Python frontend.

Mirrors the Rust frontend's native Inkling renderer (rust/src/chat/src/renderer/inkling/mod.rs): chat messages are rendered directly to token ids — Inkling has no Jinja chat template and no faithful text form.

The encoding logic lives in inkling_encoding.py behind a narrow "OpenAI messages + tools -> token ids" call; see the swap-point comment in InklingRenderer._render for adopting a standalone Inkling input-processing library (mistral-common style) later.

_HfBackedTmlTokenizer

Adapts an HF tokenizer to the encoding core's tokenizer protocol.

Special-token ids are resolved from the tokenizer vocab at construction (never hardcoded), trying each known spelling — the Inkling HF vocab exposes some semantic slots as <|unused_NNNNNN|> tokens.

Source code in vllm/renderers/inkling.py
class _HfBackedTmlTokenizer:
    """Adapts an HF tokenizer to the encoding core's tokenizer protocol.

    Special-token ids are resolved from the tokenizer vocab at
    construction (never hardcoded), trying each known spelling — the Inkling
    HF vocab exposes some semantic slots as `<|unused_NNNNNN|>` tokens.
    """

    def __init__(
        self, tokenizer: HfTokenizer, split_special_tokens: bool = False
    ) -> None:
        self._tokenizer = tokenizer
        self._encode_kwargs = (
            {"split_special_tokens": True} if split_special_tokens else {}
        )

        vocab = tokenizer.get_vocab()
        special_ids: dict[str, int] = {}
        missing: list[str] = []
        for token, spellings in SPECIAL_TOKEN_SPELLINGS.items():
            for spelling in spellings:
                token_id = vocab.get(spelling)
                if token_id is not None:
                    special_ids[token] = token_id
                    break
            else:
                if token not in OPTIONAL_SPECIAL_TOKENS:
                    missing.append(token)
        if missing:
            raise ValueError(f"Inkling tokenizer is missing special tokens: {missing}")
        self._special_ids = special_ids

    def encode_text(self, text: str) -> list[int]:
        return self._tokenizer.encode(
            text, add_special_tokens=False, **self._encode_kwargs
        )

    def encode_special(self, token: str) -> int:
        try:
            return self._special_ids[token]
        except KeyError:
            raise ValueError(f"Inkling tokenizer does not define {token}") from None

_resolve_inkling2_reasoning_effort(value)

Like the reference, also accept numeric strings and reject the rest.

Source code in vllm/renderers/inkling.py
def _resolve_inkling2_reasoning_effort(value: object) -> float:
    """Like the reference, also accept numeric strings and reject the rest."""
    if isinstance(value, str) and value not in _NAMED_REASONING_EFFORT:
        with contextlib.suppress(ValueError):
            value = float(value)
    effort = _resolve_reasoning_effort(value)
    if effort is None:
        raise ValueError(f"invalid Inkling reasoning_effort: {value!r}")
    return float(effort)