# Sort (`sort-1`): Zero-shot classification

Classify text into your own labels. No training.

Sort puts text into categories you name in the request: `["billing", "bug report", "feature request"]` works on the first call, no examples or training needed.

Set `multi_label: true` when a text can belong to several labels at once (a ticket that's both a bug and a billing problem). Descriptive labels beat terse ones: "asks for a refund" scores better than "refund".

- **Price:** $0.01 per 1,000 label checks. One unit per label per text: classifying one text into 5 labels is 5 units ($0.00005).
- **Languages:** 100+ languages for the text; labels work best in English
- **Input:** A string, or an array of up to 32 strings. Only the first 2,000 characters are read.
- **Batch:** yes, up to 32 inputs per call
- **Status:** live
- **Built on:** [Horizon-Labs/multilingual-zeroshot-small](https://huggingface.co/Horizon-Labs/multilingual-zeroshot-small), Apache-2.0, 141M (mmBERT-small encoder)

## Request

```bash
curl https://labs.greatwork.company/v1/run \
  -H "Authorization: Bearer $GWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"sort-1","input":"I was charged twice for my subscription this month, please fix it.","labels":["billing","bug report","feature request","account access"]}'
```

## Options

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `input` | string or string[] | yes | | A string, or an array of up to 32 strings. Only the first 2,000 characters are read. |
| `labels` | string[] | yes |  | 2 to 20 candidate labels, in plain words. |
| `multi_label` | boolean | no | `false` | Score each label on its own (several can be true) instead of picking one. |
| `template` | string | no | `"This example is {label}."` | Sentence the model checks for each label. `{label}` is replaced. Try "The user wants to {label}." for intents. |

## Output

| Field | Type | Description |
|---|---|---|
| `label` | string | Best label. |
| `score` | number | Its score, 0 to 1. |
| `labels` | object[] | Every label with its score, best first. |

The response envelope is always `{"id", "object": "run", "model", "created", "output", "usage": {"units", "unit", "cost_usd", "cost_micros"}, "latency_ms"}`. With an array input, `output` is an array in the same order.

## Examples (real outputs from our servers)

### Support ticket

```json
{
  "model": "sort-1",
  "input": "I was charged twice for my subscription this month, please fix it.",
  "labels": [
    "billing",
    "bug report",
    "feature request",
    "account access"
  ]
}
```

```json
{
  "label": "billing",
  "score": 0.9881,
  "labels": [
    {
      "label": "billing",
      "score": 0.9881
    },
    {
      "label": "bug report",
      "score": 0.0071
    },
    {
      "label": "feature request",
      "score": 0.0028
    },
    {
      "label": "account access",
      "score": 0.0019
    }
  ]
}
```

216 ms, $0.00004.

### Intent

```json
{
  "model": "sort-1",
  "input": "can you move my 3pm with Dana to tomorrow morning",
  "labels": [
    "schedule a meeting",
    "reschedule a meeting",
    "cancel a meeting",
    "ask a question"
  ],
  "template": "The user wants to {label}."
}
```

```json
{
  "label": "reschedule a meeting",
  "score": 0.5831,
  "labels": [
    {
      "label": "reschedule a meeting",
      "score": 0.5831
    },
    {
      "label": "schedule a meeting",
      "score": 0.2028
    },
    {
      "label": "cancel a meeting",
      "score": 0.1224
    },
    {
      "label": "ask a question",
      "score": 0.0917
    }
  ]
}
```

123 ms, $0.00004.

### Multi-label

```json
{
  "model": "sort-1",
  "input": "The app crashes every time I try to update my credit card.",
  "labels": [
    "billing",
    "bug report",
    "mobile app"
  ],
  "multi_label": true
}
```

```json
{
  "label": "mobile app",
  "score": 0.9947,
  "labels": [
    {
      "label": "mobile app",
      "score": 0.9947
    },
    {
      "label": "bug report",
      "score": 0.9869
    },
    {
      "label": "billing",
      "score": 0.0733
    }
  ],
  "multi_label": true
}
```

98 ms, $0.00003.

## Good for

- Route tickets without training a classifier
- Tag articles with your own taxonomy
- Detect intents in chat messages
- Prototype a classifier before you have data

## Limits and caveats

- Results depend on label wording: try a few phrasings.
- With many similar labels (40+ intents) accuracy drops; split them into groups.
- Swahili is weak.
