Literal for one label, a List[Literal] for many.
Literal constrains the model to the closed set. There is no invalid label to clean up downstream.
Multi-label
A review can touch several aspects. Return any subset.Hierarchical
For a taxonomy, return the path instead of a flat label.Span labeling
Asking the model to count characters is unreliable. Have it return the exact substring and locate offsets in Python.str.find() returns -1 when the returned text is not a verbatim substring, which is the signal that the model paraphrased despite the instructions. Guard the offset before you use it. find() also returns the first match only. When the same substring appears more than once, track the search offset or match occurrences in order before assigning spans.
The same shape drives PII redaction: detect the spans, then replace each with its tag in post-processing.