Visual explainer
How A Decision Head Works
Follow a pooled representation through class, score and flag heads, then see how training changes probabilities and why typed predictions can still be wrong.
A decision head maps a model representation to a defined output: a class, a numeric score or a flag. For a ticket router, billing, shipping and returns form a fixed vocabulary. The solid branch selects billing; dashed branches are alternatives. Choosing a label avoids generating the label as free text, but the choice can still be wrong.
Pool the Representation
An encoder contextualizes input tokens through multiple layers. A pooling operation then produces the representation used by sequence-level heads. Our synthetic two-token example has rows (0, 2) and (2, 2); their coordinatewise mean is h = (1, 2). These numbers illustrate pooling, not the semantics of a real ticket embedding. Other architectures use a designated classification token or another pooling rule. One forward pass still contains dependent layers and substantial computation.
Share the Encoder
The junction sends the same h to three separately parameterized heads. The class head predicts billing. A regression head with weights (0.2, 0.3) and zero bias produces 0.2 × 1 + 0.3 × 2 = 0.8. A binary head with weights (1, 0) produces logit 1, whose sigmoid is about 0.731; an illustrative threshold of 0.5 makes the flag true. Its meaning must come from the training labels, such as needs-review. It grants no permission to execute an action. Branch positions show data dependencies, not measured simultaneous execution.
Normalize Class Scores
Let the class logits be (2, 0, 0), ordered billing (B), shipping (S), returns (R). Softmax gives exp(2)/(exp(2)+2) ≈ 0.786986 for B and 1/(exp(2)+2) ≈ 0.106507 for each alternative. The bar divides one unit of probability on a common scale. Printed values round separately and therefore sum to 1.001; the underlying values sum to one. Normalization alone does not establish calibration or correctness. See the probability calibration guide.
Avoid the Output Loop
A, B and C are three illustrative generated output tokens: each later token depends on earlier output. The lower lane maps an already-computed h directly to a class. It avoids that output decoding chain. There is no universal token count or speed ratio: a generator has a prompt-processing pass, often reuses cached state, and can use constrained output decoding. Actual latency depends on model size, input length, hardware and runtime. Typed heads remove a text-parsing requirement at their interface; surrounding serialization still needs validation.
Match the Output Contract
Three finite leaves depict a choice vocabulary. The document depicts an open reply. A classification head suits a stable label set with suitable training data; a scalar head suits a defined numeric target. Producing a new summary or explanation requires a component capable of generating or retrieving that text. A language model can also classify, so benchmark alternatives against the actual task rather than treating heads as universally faster or safer.
Abstention Needs a Policy
The legal request fits none of B, S or R, yet argmax still selects B. A standard three-class softmax has no fourth abstain outcome. Add an explicit other class, a validated confidence gate, or another out-of-distribution policy when deferral is required. Even then, test confident errors separately. A head also cannot create a new class or summarize the request merely because the caller asks it to.
Inspect the Linear Map
This zoom explains the billing logit used earlier. In column-vector notation z = Wh + b. Use W rows (2, 0), (0, 0), (0, 0), zero biases, and h = (1, 2). Billing receives contributions 2 × 1 = 2 and 0 × 2 = 0; the zero is a hollow point rather than an artificially visible bar. The other logits are zero. W has shape 3 × 2: one row per class. PyTorch's Linear layer implements the equivalent operation with its documented tensor convention.
Learn from Labelled Examples
For target B, cross entropy is −log p(B), about 0.239545 at the original logits. The illustrative after-distribution (0.85, 0.075, 0.075) lowers this example's loss to about 0.162519. Both bars use the same scale and B/S/R order. This is a hypothetical training outcome, not a guaranteed optimizer step or a held-out result. For softmax cross entropy, the logit gradient is p minus the one-hot target; parameters and possibly the encoder change through backpropagation. Pass logits directly to CrossEntropyLoss. Regression and binary heads need targets and losses suited to their own outputs; BCEWithLogitsLoss combines sigmoid and binary cross entropy.
Where It Breaks
Suppose two different requests produce the same h = (1, 2), while their true classes are B and S. The deterministic head must produce the same distribution for both, so its B prediction is wrong for the second. Bars use the same scale within this frame, with the earlier distribution compressed to fit beside each input. A correct output type and a normalized distribution cannot recover information the representation discarded. Better representations, representative training data, calibration and explicit review policies address different parts of this problem; none makes every prediction infallible.
The Quick Version
- Heads map representations to defined output types.
- Pooling provides a vector for sequence-level decisions.
- Separate heads can share one encoder.
- Softmax normalizes scores; calibration needs empirical checks.
- Classification avoids generating an output token sequence.
- Match the output contract to the actual task.
- Abstention requires an explicit mechanism.
- Linear weights turn representation coordinates into logits.
- Labelled losses train heads and optionally the encoder.
- Lost information can produce identical, confidently wrong decisions.