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 the Sentiment Analyzer block — it runs DistilBERT SST-2 sentiment on single inputs and large batches with throughput. Install it with npx shadcn add @localmode/ui/blocks/text-insights/sentiment-analyzer.

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

Composed Block

BlockDescriptionLinks
Sentiment AnalyzerDistilBERT SST-2 sentiment on single inputs and large batches with throughputLive · Install: npx shadcn add @localmode/ui/blocks/text-insights/sentiment-analyzer

Next Steps

On this page