Skip to main content

mellea.formatters.granite.granite3.granite32.output

Parser for Granite 3.2 model output.

Parser which receives Granite 3.2 model output and returns the constituents of the output.

The input to the parser is assumed to be as follows:

response_text

# Citations:
citations_text

# Hallucinations:
hallucinations_text

The output from the lowest level of the parser is a dictionary as follows:

  • "citations": List of citations
  • "docs": List of document references
  • "hallucinations": List of hallucinations
  • "response": Model response text without the above constituents

This dict is further refined into dataclasses before being returned as an extended AssistantMessage.

Classes

CLASS Granite32OutputProcessor

Output processor for version 3.2 of the main Granite models, all sizes.

Methods:

FUNC transform

transform(self, model_output: str, chat_completion: ChatCompletion | None = None) -> AssistantMessage

Parse Granite 3.2 model output into a structured assistant message.

Args:

  • model_output: Raw text output from the Granite 3.2 model.
  • chat_completion: The original chat completion request that produced model_output. Used to determine which output features (thinking, tools, citations, hallucinations) to parse. Defaults to None.

Returns:

  • A :class:Granite3AssistantMessage containing the parsed response text, optional tool calls, chain-of-thought reasoning, citations, documents, and hallucination annotations.

Raises:

  • ValueError: If parsing citations, documents, or hallucinations from the model output fails.