StateMachineInstruction
StateMachineInstruction defines the single-state instruction used when each input maps to one output state. It maps one or more input TokenSets to a state string selected from your samples.
Key characteristics:
- Output is created automatically with a single
Statetoken - Final token is always
<NON> - Samples provide a
statestring instead of a response snippet
StateMachineInstruction Parameters
class StateMachineInstruction:
def __init__(self, input: StateMachineInput, states: List[str]):
- input: A
StateMachineInputinstance defining the input TokenSets - states: A list of allowed state names for the instruction output
Creating a StateMachineInstruction
question_tokenset = mtp.TokenSet(tokens=(question, context))
state_machine_input = mtp.StateMachineInput(
tokensets=[question_tokenset]
)
state_machine_instruction = mtp.StateMachineInstruction(
input=state_machine_input,
states=["WHERE"]
)
state_machine_instruction.add_sample(
input_snippets=["Where are you from?"],
state="WHERE"
)
The list of possible states is derived from these samples and stored as the single-state output metadata when state_machine=True. For the multi-state form, see MultiClassifierInstruction. For shared input structure, see StateMachineInput.
Databiomes