- Classifier steps
- Classifier steps
Classifier steps
Classifier steps
A classifier step answers fixed questions about a piece of data, with probabilities.
A classifier step asks a decision model one or more questions about some text or JSON. The answer is a label, a probability or a score. There is no agent loop, no tools and no free text, so it is fast and the answer has a fixed shape.
import avalanche as ava
@ava.classifier_step(
questions={
"category": {
"type": "choice",
"instructions": "Which expense category fits this invoice?",
"criteria": {
"software": "Licenses, SaaS and cloud hosting.",
"travel": "Flights, hotels and ground transport.",
"other": "Anything else.",
},
},
"urgent": {
"type": "noul",
"instructions": "Is payment due within 7 days?",
},
}
)
async def categorize(text: str, *, classifier: ava.Classifier) -> str:
result = await classifier(state=text)
return result.choices["category"].choice
Rendering diagram…
The step function
| Name | What it is |
|---|---|
classifier | Supplied by Avalanche. Call it with state=, the data to judge. |
state | Text, or any JSON value: a dict, a list. |
result | One answer per question, read by question name. |
result = await classifier(state=text)
result.choices["category"].choice # "software"
result.choices["category"].probabilities # {"software": 0.91, "travel": 0.03, "other": 0.06}
result.nouls["urgent"].noul # 0.12
Your code decides what to do with the numbers. A label is not an action.
if result.nouls["urgent"].noul >= 0.8:
...
Agent step or classifier step
| Agent step | Classifier step | |
|---|---|---|
| Produces | Anything a signature can describe | A label, a probability or a score |
| Works by | Many turns, tools, code | One call |
| Use for | Reading, research, drafting | Routing, flagging, scoring |
Options
| Option | What it sets |
|---|---|
questions | The default questions. They can also be passed on each call. |
classifier, model | The provider and its model. |
timeout | Seconds allowed per request. Default 10. |
input_model | A model that state is checked against before the request. |
retries, on_uncertain, slug | The same as on a Python step. |
In the UI

Before a run: the provider, the model and the questions of a classifier step.

After a run: each call with its input, and the probability of every answer.
