Skip to main content
Type definitions that are shared within the Granite 3 family of models.

Classes

CLASS Hallucination

Hallucination data as returned by the model output parser. Attributes:
  • hallucination_id: Unique identifier for the hallucination entry.
  • risk: Risk level of the hallucination, e.g. "low" or "high".
  • reasoning: Optional model-provided reasoning for why this sentence was flagged.
  • response_text: The portion of the response text that is flagged.
  • response_begin: Start character offset of response_text within the full response string.
  • response_end: End character offset (exclusive) of response_text within the full response string.

CLASS Citation

Citation data as returned by the model output parser. Attributes:
  • citation_id: Unique identifier assigned to this citation.
  • doc_id: Identifier of the source document being cited.
  • context_text: Verbatim text from the source document that is cited.
  • context_begin: Start character offset of context_text within the source document.
  • context_end: End character offset (exclusive) of context_text within the source document.
  • response_text: The portion of the response text that makes this citation.
  • response_begin: Start character offset of response_text within the response string.
  • response_end: End character offset (exclusive) of response_text within the response string.

CLASS Granite3Controls

Control flags for Granite 3.x model output behaviour. Specifies which optional output features the model should produce, such as inline citations, hallucination risk annotations, response length constraints, and originality style. Attributes:
  • citations: When True, instructs the model to annotate factual claims with inline citation markers.
  • hallucinations: When True, instructs the model to append a list of sentences that may be hallucinated.
  • length: Requested response length; must be "short", "long", or None for no constraint.
  • originality: Requested response originality style; must be "extractive", "abstractive", or None.

CLASS Granite3Kwargs

Chat template keyword arguments specific to IBM Granite 3.x models. Extends :class:ChatTemplateKwargs with Granite 3-specific options for output control flags and chain-of-thought (thinking) mode. Attributes:
  • controls: Optional output control flags that enable or configure citations, hallucination detection, response length, and originality style.
  • thinking: When True, enables chain-of-thought reasoning mode. Defaults to False.

CLASS Granite3ChatCompletion

Class that represents the inputs common to IBM Granite 3.x models. Class that represents the inputs that are common to models of the IBM Granite 3.x family.
Methods:

FUNC controls

controls(self) -> Granite3Controls
Return the Granite 3 controls record for this chat completion request. Returns:
  • The controls record from the chat template kwargs, or an empty :class:Granite3Controls if none were specified.

FUNC thinking

thinking(self) -> bool
Return whether chain-of-thought thinking mode is enabled. Returns:
  • True if the thinking flag is set in the chat template kwargs; False otherwise.

CLASS Granite3AssistantMessage

An assistant message with Granite 3 specific fields. Attributes:
  • reasoning_content: Optional chain-of-thought reasoning text produced before the final response.
  • citations: Optional list of citations parsed from the model output.
  • documents: Optional list of documents referenced in the model output.
  • hallucinations: Optional list of hallucination annotations parsed from the model output.
  • stop_reason: Optional reason the model stopped generating.