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".
Use it
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"
]
}'const res = await fetch("https://labs.greatwork.company/v1/run", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.GWL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "sort-1",
"input": "I was charged twice for my subscription this month, please fix it.",
"labels": [
"billing",
"bug report",
"feature request",
"account access"
]
}),
});
const { output, usage } = await res.json();import os, requests
res = requests.post(
"https://labs.greatwork.company/v1/run",
headers={"Authorization": f"Bearer {os.environ['GWL_API_KEY']}"},
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"
]
},
)
output = res.json()["output"]Set GWL_API_KEY to a key from your dashboard. The bare name sort works too and follows new versions.
Options
input: A string, or an array of up to 32 strings. Only the first 2,000 characters are read.
| Name | Type | Default | What it does |
|---|---|---|---|
labels required | string[] | 2 to 20 candidate labels, in plain words. | |
multi_label | boolean | false | Score each label on its own (several can be true) instead of picking one. |
template | string | "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 | Meaning |
|---|---|---|
label | string | Best label. |
score | number | Its score, 0 to 1. |
labels | object[] | Every label with its score, best first. |
Every response wraps this in {"id", "model", "output", "usage": {"units", "unit", "cost_usd"}, "latency_ms"}. Send an array as input and output is an array in the same order.
Examples
Support ticket
{
"model": "sort-1",
"input": "I was charged twice for my subscription this month, please fix it.",
"labels": [
"billing",
"bug report",
"feature request",
"account access"
]
}{
"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
}
]
}Captured on our production servers: 216 ms, 4 labels, $0.00004.
Intent
{
"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}."
}{
"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
}
]
}Captured on our production servers: 123 ms, 4 labels, $0.00004.
Multi-label
{
"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
}{
"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
}Captured on our production servers: 98 ms, 3 labels, $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.
Pricing
$0.01 per 1,000 label checks. One unit per label per text: classifying one text into 5 labels is 5 units ($0.00005). Failed calls aren't charged, and a call never costs more than its estimate (POST /v1/estimate tells you before you run it).
Built on
Horizon-Labs/multilingual-zeroshot-small, 141M (mmBERT-small encoder) parameters. License: Apache-2.0. We run it on our servers.