Skip to main content

Examples

This page provides a complete, runnable example protocol for each model type. Each file builds a protocol, adds samples, and saves both the model and template files.

Every example is set in "Alice's Adventures in Wonderland", with the model taking the perspective of the Cheshire Cat.

Running an Example

pip install model-train-protocol
python generative_model_example.py

Running an example writes <name>_model.json and <name>_template.json to the current directory. Upload the model file to Databiomes to train it. See Creating a Model for the full workflow.

Generative

A Cheshire Cat NPC that responds to Alice with free-form dialogue. It contains multiple instructions covering conversation, appearing and vanishing, answering questions, and leaving, and demonstrates multiple final tokens, numeric output with NumToken and FinalNumToken, and a guardrail.

Download Generative Example

State Machine

A Cheshire Cat question router that maps each line Alice speaks to one of five states: DIRECTION, IDENTITY, MADNESS, LOCATION, or FAREWELL. It demonstrates StateMachineInstruction, StateMachineInput, and a guardrail.

tip

For most state machines, the CSV interface is faster and requires no code. Use this Python example only when you need custom Tokens, Token descriptions, or multiple input lines.

Download State Machine Example

Multi-Classification

A Cheshire Cat line classifier that labels each line Alice speaks by both emotion and intent, returning a single JSON object. It demonstrates MultiClassifierInstruction and the state_map.

Download Multi-Classification Example

Next Steps