Decision models
Train your own fast decision model and call it directly through the SystemOne / TypeSafe SDK.
A decision model takes a state (text, JSON, or a chat transcript) and answers one or more named questions in a single request, returning choices, probabilities, and scores instead of free-form text.
Use DecisionModelRecipe when you already use gradiated/linden-1 (or Jev) through the TypeSafe SDK and want a faster, more accurate model trained on your own traffic. Today you download the trained model and run it in your own service. With hosted deployments, coming soon on Gradiated Cloud, it drops straight into TypeSafeClient by changing only the model name.
Question types#
Every decision model supports the three SystemOne question types, and can answer multiple questions in a single call:
Choice: pick one category from a fixed list (billing,technical,other). Returns the chosen option, probabilities for every option, and aconfidencescore.Noul: a yes/no probability from0to1("Does this need immediate attention?"). Apply your own threshold in code.Score: an ordered rating across criteria (["Can wait", "Needs attention today", "Needs immediate attention"]), so confusing the two extremes costs more than mixing up neighboring levels.
What data you need#
- Already calling
gradiated/linden-1? Log each request'sstate,questionsand the answer you accepted, and push them as records. Capturing linden-1 traffic from the gateway automatically is coming soon on Gradiated Cloud. - Pushing your own data? Push plain records with
state,questionsand the expected answers inexpected_outputto aDataset.session_idis optional; set it when several records describe the same ticket or conversation so they stay in one split. Plan for ~200 examples per option to start (1,000+ for harder decisions). - Don't have labels yet? Ask
gradiated/linden-1the same questions through the SystemOne SDK, review a sample of its answers, and push them asexpected_output.
from grad import Grad
client = Grad()
questions = {
"category": {
"type": "choice",
"instructions": "Choose the department for this ticket.",
"criteria": {
"billing": "Charges or payments",
"technical": "Something is broken",
"other": "Anything else",
},
},
"urgent": {
"type": "noul",
"instructions": "Does this need immediate attention?",
},
"effort": {
"type": "score",
"instructions": "Rate how urgently this ticket needs attention.",
"criteria": ["Can wait", "Needs attention today", "Needs immediate attention"],
},
}
dataset = client.datasets.push("ticket-triage", [
{
"state": {"ticket": "I was charged twice. Please fix this today."},
"questions": questions,
"expected_output": {"category": "billing", "urgent": 1.0, "effort": 2},
},
{
"state": {"ticket": "How do I export my invoices to CSV?"},
"questions": questions,
"expected_output": {"category": "billing", "urgent": 0.0, "effort": 0},
},
])
Train the decision model#
DecisionModelRecipe picks the right loss for each question type and specializes a backbone on your questions and state format. On your own server, train a Qwen3 backbone (qwen/qwen3-0.6b or qwen/qwen3-1.7b). The default, gradiated/linden-1, trains on Gradiated Cloud only (coming soon), because its weights aren't public:
from grad import Grad
from grad.recipes import DecisionModelRecipe
client = Grad()
dataset = client.datasets.get("ticket-triage")
run = client.runs.create(
dataset=dataset,
name="ticket-triage",
recipe=DecisionModelRecipe(model="qwen/qwen3-0.6b"),
).wait()
print(run.artifact.id)
print(run.eval_report)
When to use a decision model vs. a router vs. SFT#
- Use a decision model (
DecisionModelRecipe) when your app needs structured judgments (picking a category withChoice, returning a yes/no probability withNoul, or rating on a scale withScore) and calling it through the SystemOne SDK. - Use a Model router when the decision is specifically which LLM should answer this prompt to save money within a quality budget.
- Use Supervised fine-tuning (SFT) when the model needs to generate free-form text, JSON, SQL, or code edits.
Parameters you might change#
model:qwen/qwen3-0.6borqwen/qwen3-1.7bon any server. Leaving it out selectsgradiated/linden-1, which needs Gradiated Cloud (coming soon);adapters.FrozenHead(), which trains only the heads, is available on linden-1 only.loss: picked from each question type (cross-entropy forchoice, binary cross-entropy fornoul, ordinal loss forscore). It can't be overridden; passingloss=is an error.
Every other setting, including the eval split (15% of sessions held out), has a default; see the training parameters reference. Add --dry-run to grad train to see them resolved, with a cost estimate.
Read the evaluation report#
Check run.eval_report before shipping. It has one entry per question under heads (for example run.eval_report.heads["category"]):
- Check each option separately, not just overall accuracy: if 95% of your tickets are
"other"and 5% are"billing", a broken model that always picks"other"still scores 95% overall. Look at the per-option precision and recall (per_option) to make sure rare options (like escalations or safety flags) are actually caught rather than missed. - Look at which mistakes happen (
confusion_matrix): for orderedscorequestions (0 / 1 / 2), mixing up neighbors (0vs1) is normal. If the model frequently confuses0with2, add more examples of those edge cases. - Check if confidence scores are honest (
ece): this measures how closely the model's confidence matches reality (when it says 80% confident, it should be right around 80% of the time). Aim for under0.05so confidence checks in your app code behave predictably.
Each head also reports accuracy and its calibration temperature, plus macro_f1 (choice and score), mae (score) and brier (noul).
Use the model#
The artifact is a decision_bundle: the backbone's LoRA adapter, one small head per question (decision_head.safetensors) and decision_config.json with the questions and calibration temperatures. Download it and answer questions in your own service with transformers and peft; the artifact formats spec has the full reference loader:
from grad import Grad
Grad().artifacts.download("ticket-triage@latest", "./ticket-triage", format="files")
Confidence scores are calibrated during training (a temperature per question, fitted on held-out data), so you can fall back in your own code whenever the model isn't sure enough, for example escalating a ticket or calling gradiated/linden-1 when confidence is below 0.75.
Call it from the TypeSafe SDK on Gradiated Cloud#
On Gradiated Cloud, you'll publish it as a model version from the console or the Models API the trained Artifact, then call it through the SystemOne SDK (TypeSafeClient) by passing "your-org/ticket-triage" as the model, and fall back when confidence is low:
import os
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient
with TypeSafeClient(
base_url="https://api.gradiated.com",
api_key=os.environ["GRADIATED_API_KEY"],
model="<org>/ticket-triage",
) as ts_client:
response = ts_client.system_one(
state={"ticket": "I was charged twice. Please fix this today."},
questions={
"category": Choice(
instructions="Choose the department for this ticket.",
criteria={
"billing": "Charges or payments",
"technical": "Something is broken",
"other": "Anything else",
},
),
"urgent": Noul(instructions="Does this need immediate attention?"),
"effort": Score(
instructions="Rate how urgently this ticket needs attention.",
criteria=["Can wait", "Needs attention today", "Needs immediate attention"],
),
},
)
cat = response.choices["category"]
# Fall back in your own code when the model isn't confident enough
department = cat.choice if cat.confidence >= 0.75 else "human_review"
is_urgent = response.nouls["urgent"].noul >= 0.5
urgency = response.scores["effort"].score
When a prediction turns out wrong in production, record the right answer as a correction in your tracing tool. The next source sync adds it to the dataset as expected_output.
Want more control?#
Custom PyTorch decision losses and dynamic per-request token choices are coming soon with Advanced objectives and Custom loops.