Skip to main content
Input and output processing for the Granite 3.2 family of models.

Classes

CLASS Granite32InputProcessor

Input processor for version 3.2 of the main Granite models, all sizes. This input processor is based on the Jinja template that was used during supervised fine tuning of these models. This template is as follows:
Methods:

FUNC sanitize

Sanitize the chat completion by removing Granite 3.2 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.2 special tokens
  • removed from the specified parts.

FUNC transform

Transform the chat completion request into a Granite 3.2 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.2 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.