choice "billing"confidence 0.81
Request#
{
"route": {
"type": "choice",
"instructions": "Where should this go?",
"criteria": { "billing": "money", "bug": "broken", "account": "login" }
}
}type"choice"required- The question type.
criteriaobjectrequired- Option name to description, 1 to 255 options (two or more make a real choice). A name is any string, the empty string included, and comes back byte for byte. A description is a string, an object (by convention
what,not_forandexamples), an array, ornullwhen the name says enough. instructionsstring | object | array- What to decide. Optional: without it, the choice is answered from its options alone.
Response#
{
"route": {
"type": "choice",
"choice": "billing",
"confidence": 0.81,
"probabilities": { "account": 0.05, "billing": 0.87, "bug": 0.08 }
}
}choicestring- The most likely option, taken from the unrounded probabilities. Always one of the keys you sent.
probabilitiesobject- One entry per option, zeros included, keyed by the option name exactly as sent. Listed alphabetically, but read them by key: the order is not part of the contract. They sum to 1, up to rounding.
confidencenumber- How sure the model is, from 0 to 1. See the formula below.
How confidence is computed#
confidence = (K · p_max − 1) / (K − 1)
- K
- the number of options you sent
- p_max
- the probability of the chosen option
Confidence is 0 when every option is equally likely and 1 when one option has all the probability. For the route above, K is 3 and p_max is 0.87, so confidence is (3 × 0.87 − 1) / 2 = 0.81. It is computed from the unrounded probabilities. Because it rescales by K, a confidence of 0.8 means the same thing on a 3-way and a 10-way choice.
Rounding and ties#
choicecomes from the unrounded probabilities. Two options can both show 0.45 while one was slightly ahead before rounding, and on rare answers the named option is 0.01 below the largest value shown. Trustchoice; do not re-derive it from the rounded list.- A tie goes to the option listed first in your request. Order the options so the one you prefer on a tie comes first.
- The list sums to 1, up to rounding. Each probability is rounded to 2 decimals, then the largest are nudged by 0.01 toward a sum of 1. A nudged value can print as
0.8200000000000001, and a few lists still sum to 0.99 or 1.01. Compare numbers, never strings. confidenceis always a clean two-decimal value. It is computed before rounding, then rounded once.