Transformers
Classification
Text classification for sentiment analysis, topic detection, and more.
Classify text into predefined categories using fine-tuned transformer models. Useful for sentiment analysis, content moderation, and topic detection.
For full API reference (classify(), classifyMany(), options, result types, and custom providers), see the Core Classification guide.
See it in action
Try Sentiment Analyzer and Email Classifier for working demos.
Recommended Models
| Model | Size | Labels | Use Case |
|---|---|---|---|
Xenova/distilbert-base-uncased-finetuned-sst-2-english | ~67MB | POSITIVE/NEGATIVE | Sentiment analysis |
Xenova/twitter-roberta-base-sentiment-latest | ~125MB | Positive/Neutral/Negative | Social media sentiment |
Xenova/toxic-bert | ~110MB | Toxic/Non-toxic | Content moderation |
Best Practices
Classification Tips
- Choose task-specific models — Sentiment models work best for sentiment, not topic detection
- Check allScores — Low confidence scores may indicate ambiguous input
- Batch when possible —
classifyMany()is more efficient than multipleclassify()calls - Cache the model — Create the model instance once and reuse it
Showcase Apps
| App | Description | Links |
|---|---|---|
| Sentiment Analyzer | Sentiment analysis with transformer classification models | Demo · Source |
| Email Classifier | Zero-shot email categorization | Demo · Source |