Skip to main content

MultiClassifierInstruction

MultiClassifierInstruction defines the multi-state instruction used when each input produces one state for each independent output key. It is the MTP representation used by multi-output CSV conversion.

Key characteristics:

  • Each output key has its own list of allowed states
  • Every sample produces one state per output key
  • Output samples are encoded as a JSON object
  • Final token is always <NON>

MultiClassifierInstruction Parameters

class MultiClassifierInstruction:
def __init__(self, input: StateMachineInput, state_map: dict[str, list[str]]):
  • input: A StateMachineInput instance defining the input TokenSets
  • state_map: A dictionary mapping each output key to its allowed state values

Creating a MultiClassifierInstruction

state_machine_input = mtp.StateMachineInput(
tokensets=[question_tokenset]
)

state_map = {
"Intent": ["greeting", "advice", "farewell"],
"Sentiment": ["positive", "neutral"],
}

multi_classifier_instruction = mtp.MultiClassifierInstruction(
input=state_machine_input,
state_map=state_map,
)

multi_classifier_instruction.add_sample(
input_snippets=["Hello"],
output_snippet='{"Intent":"greeting","Sentiment":"positive"}',
)

Each sample must provide exactly one value for every declared output key. In a multi-output CSV, the output columns become the keys in state_map, and later blank cells inherit the previous value for that same output column.

Guardrails are not supported in multi-classifier CSV conversion. A GUARDRAIL value in a multi-output CSV is treated as a regular classifier state.

For the single-state form, see StateMachineInstruction. For the shared input structure, see StateMachineInput.