Skip to main content
Classes and functions that implement input and output string processing for the Granite 3.3 family of models.

Classes

CLASS Granite33InputProcessor

Input processor for version 3.3 of the main Granite models, all sizes. This input processor is based on the Jinja template from tokenizer_config.json.
Methods:

FUNC sanitize

Sanitize the chat completion by removing Granite 3.3 special tokens. Args:
  • chat_completion: The chat completion request to sanitize.
  • parts: Which parts of the chat completion to sanitize; defaults to "all".
Returns:
  • The sanitized chat completion with all Granite 3.3 special tokens
  • removed from the specified parts.

FUNC transform

Transform the chat completion request into a Granite 3.3 prompt string. Args:
  • chat_completion: The structured chat completion request to convert into a tokenizer-ready prompt string.
  • add_generation_prompt: When True, appends the assistant role header to the end of the prompt to trigger generation. Defaults to True.
Returns:
  • The prompt string formatted for the Granite 3.3 model tokenizer.
Raises:
  • ValueError: If conflicting options are specified, such as enabling thinking mode together with documents, tools, or a custom system message; or enabling citations or hallucinations with a custom system message.