LocalMode
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.

ModelSizeLabelsUse Case
Xenova/distilbert-base-uncased-finetuned-sst-2-english~67MBPOSITIVE/NEGATIVESentiment analysis
Xenova/twitter-roberta-base-sentiment-latest~125MBPositive/Neutral/NegativeSocial media sentiment
Xenova/toxic-bert~110MBToxic/Non-toxicContent moderation

Best Practices

Classification Tips

  1. Choose task-specific models — Sentiment models work best for sentiment, not topic detection
  2. Check allScores — Low confidence scores may indicate ambiguous input
  3. Batch when possibleclassifyMany() is more efficient than multiple classify() calls
  4. Cache the model — Create the model instance once and reuse it

Showcase Apps

AppDescriptionLinks
Sentiment AnalyzerSentiment analysis with transformer classification modelsDemo · Source
Email ClassifierZero-shot email categorizationDemo · Source

Next Steps

On this page