Expand description
Chat template support for tokenizers using Jinja2 templates
This module provides functionality to apply chat templates to messages, similar to HuggingFace transformers’ apply_chat_template method.
Structs§
- Chat
Template Params - Parameters for chat template application
- Chat
Template Processor - Chat template processor using Jinja2 - simple wrapper like HuggingFace
- Chat
Template State - Chat template state that can be embedded in any tokenizer struct. Eliminates duplicated apply/set/format methods across tokenizer backends.
Enums§
- Chat
Template Content Format - Chat template content format
- Thinking
KeyName - Result of detecting the thinking/reasoning toggle in a chat template. The variable name the template uses for the thinking toggle.
- Thinking
Toggle
Functions§
- detect_
chat_ template_ content_ format - Detect the content format expected by a Jinja2 chat template
- detect_
thinking_ toggle - Detect whether the chat template supports a thinking/reasoning toggle and what its default value is.
- load_
chat_ template_ from_ config - Load chat template from tokenizer config JSON
- load_
chat_ template_ from_ file - Load chat template from a file (.jinja or .json containing Jinja). Shared between all tokenizer backends.