mlx-optiq
Fine-tuning · Decision models

Fine-tune a decision model

A decision model reads a piece of state and a set of typed questions, and answers all of them in one forward pass with a probability per option. There is no generated text to parse.

That suits routing, triage and classification, where you want a number you can threshold rather than a sentence. Cloudflare's Clef is the open example; OptiQ trains models like it and serves them at POST /v1/systemone.

A state and typed questions go through the backbone with a LoRA and a decision head, which returns a probability per option in one pass.statethe text to judgeurgent? noulteam? choicebackbone+ LoRAheadone passyesyes: 0.990.99billingbilling: 0.620.62technicaltechnical: 0.380.38
The backbone carries a LoRA; the head turns its output into probabilities for every question at once. Numbers are the example request below.

The data

One record per line: the state, the questions, and the answers. A question is noul (yes or no), choice (named options) or score (ordered levels).

train.jsonljson
{"state": "Card declined twice, now locked out.",
 "questions": {"team": {"type": "choice",
                        "criteria": {"billing": "Payments", "technical": "Bugs"}}},
 "answers": {"team": "billing"}}

To train on a distribution instead of one answer, give "gold": {"team": {"probabilities": {"billing": 0.7, "technical": 0.3}}}. A noul answer is true or false; a score answer is the level's index.

Train, export, serve

Start from a model that already has a decision head, such as Clef:

terminalbash
$ optiq lora train mlx-community/clef-flash-OptiQ-4bit --data ./data -o ./adapter
$ optiq lora export mlx-community/clef-flash-OptiQ-4bit --adapter ./adapter -o ./my-decider
$ optiq serve --model ./my-decider

optiq lora train spots the head and trains it in full alongside the LoRA, with cross-entropy against your answers. It holds back about 5% of the records to fit one temperature per question type afterwards, which corrects over- or under-confident probabilities. The export carries the head and the temperatures.

Start from a chat model

Add --decision and a plain model gets a new, untrained head in Clef's design, sized to its backbone:

terminalbash
$ optiq lora train mlx-community/Qwen3.5-2B-OptiQ-4bit --data ./data -o ./adapter \
    --decision --head-warmup-steps 100

A new head needs more data and steps than one that exists. --head-warmup-steps trains the head alone first with the backbone frozen; --head-lr (3e-4 by default) sets its learning rate. Qwen3.5 and Gemma 4 are the tested families. Qwen models get exactly the prompt layout the released heads were trained on; other families wrap the same content in their own chat template.

On the Typed Decisions test split, two models trained this way on the benchmark's 1,080 training records reached 0.802 accuracy (gemma-4-e2b-it-OptiQ-4bit-decision) and 0.772 (Qwen3.5-0.8B-decision). The full table, with KL, Brier and ECE, is in the decision models guide; the training run is written up in decision models on a Mac.

Ask it something

requestbash
$ curl http://127.0.0.1:8080/v1/systemone   -H 'Content-Type: application/json' -d '{
    "state": "Checkout has been failing for every customer for the last hour.",
    "questions": {
      "urgent": {"type": "noul", "instructions": "Is this urgent?"},
      "team": {"type": "choice",
               "criteria": {"billing": "Payments", "technical": "Outages and errors"}}
    }
  }'

Decision models are text-only for now: a request carrying images or video gets a 400 with a message.