Skip to main content

Overview

The fastest way to create a state machine is the CSV interface. It only requires Input, Output, and Reference columns and does not require writing any Python, so it is the recommended starting point for most state machines. See CSV Overview.

Use the Python protocol described on this page when you need custom tokens or multiple input lines.

What Is a State Machine?

In MTP, a state machine is a simplified protocol that maps inputs to one of several predefined states instead of generating open-ended text. This is useful when your model should select from a fixed set of outcomes (for example, intent labels or routing states).

State machine protocols:

  • Use a single instruction that chooses between predefined states
  • Do not use final tokens (the final is always <NON>)
  • Do not allow numeric outputs

Enabling State Machines

State machines are disabled by default. Enable them when creating your protocol:

protocol = mtp.Protocol(
name="my_state_machine",
inputs=1,
encrypt=True,
state_machine=True
)

All CSV protocols are state machines.

Where States Are Stored

When state_machine=True, the template includes:

  • model_type: set to state_machine
  • states: a list of state strings derived from the StateMachineInstruction samples

See Template for the fields in the template and how they are structured.

Next Steps