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.Choosing the shape
| You need | Schema |
|---|---|
| Exactly one label | Literal[...] |
| Any subset of labels | List[Literal[...]] |
| A taxonomy path | A model with parent / child |
| Marked substrings | A model with text + label, offsets in Python |
Other modalities
Image, audio, video, and document classification follow the same schema pattern with a different input argument. See Multimodal inputs.| Modality | Cookbook |
|---|---|
| Image | image_classification |
| Audio | audio_classification |
| Video | video_classification |
| Document | document_classification |
Next steps
| Task | Guide |
|---|---|
| Extract fields instead of labels | Structured extraction |
| Score outputs against a rubric | LLM as judge |
| Add reviewer agreement | Quality pipeline |