Skip to content
Catalog

cn8/text-few-shot

Send a `text` plus an `examples` map — each key is a class label and each value is a

Learn more about Few-Shot Classification
Text NLPsyncInstant previewtextanalysisnlp

Try it

Text to classify
Categories with examples

Result

Results show up here

The sample input is ready — just hit Run.

Overview

Send a text plus an examples map — each key is a class label and each value is a short list of example texts for that class. The service compares your text against those examples and returns the predicted label, a confidence value, and an all_scores map of every class to its score. Responses are synchronous, and there's no training step — change the classes any time by editing the examples map.

Key capabilities

Learn from a few examples

Give 2–10 example texts per class and the service generalizes from them — no training required.

Predicted label + all scores

Get the predicted label, a confidence value from 0 to 1, and a score for every class.

Change classes anytime

Add or remove classes whenever you like by editing the examples map — nothing is stored between calls.

Multilingual

Examples and input can be in any supported language, and you can mix languages.

When to use it

Custom taxonomy

Classify into domain-specific categories with a few examples each (e.g. ticket intents, product types).

Intent detection

Recognize user intents from a handful of example utterances per intent.

Evolving categories

Adjust your classes on the fly as your needs change.

Input & output

input

text: a string to classify, plus examples: a map of { label: [example1, example2, ...] }.

JSON body

output

The predicted label, a confidence value, and an all_scores map of every class to its score.

JSON

Guides & tips

How it works

  • You provide a text and an examples map: each label points to a short list of example texts.
  • The service compares your text against the examples for each class and picks the closest one.
  • The predicted class is returned at data.label, its score as confidence, and every class's score in all_scores.

Tips

  • Send examples as an object — {label: [text, text, ...]} — not a list of label/text objects.
  • Use at least 2 examples per class, ideally 5–10, with varied phrasing for better accuracy.
  • The top-level score field is confidence — treat low values (for example below 0.5) as "no confident match" in your app.
  • The price is per request no matter how many classes or examples you send.

Specs

Latency
Typically 1–3 seconds
Async
false
Rate Limit
Per API key
Max Input
Roughly a few hundred tokens per text

Schema

Request body

textrequiredstring

The text to classify.

examplesrequiredobject<string,array<string>>

Map of label → list of example strings, e.g. {"food": ["...", "..."]}.

Response

labelstring

Predicted label.

confidencenumber

Confidence of the predicted label, from 0 to 1. (The field is named confidence.)

all_scoresobject<string,number>

Map of every label to its score. Sort by value to rank the classes.

Pricing

Billed per request, regardless of how many classes or examples you send.

ServiceUnitPrice
Few-Shot Classificationitem$0.006/request

FAQ

Related models