- Topic Classification: Classifies text into predefined topic categories
- Dual Score Output: Returns both topic label and probability confidence
- Zero-Shot Model: Uses mortizlaurer/roberta-base-zeroshot-v2-0-c for flexible topic classification
- Multi-Score Output: Returns both topic name and probability scores
- top_topic: The predicted topic name from the provided topics list
- top_topic_prob: Probability score (0.0-1.0) for the predicted topic
- Content Categorization: Automatically organizing content by topic
- Document Classification: Sorting documents by subject matter
- News Analysis: Categorizing news articles by topic
- Customer Support: Routing tickets by topic or issue type
- Content Moderation: Identifying content themes for policy enforcement
- top_topic: The predicted topic name from the provided topics list
- Selected from the topics provided during initialization
- Represents the most relevant topic for the input text
- top_topic_prob: Confidence score (0.0-1.0) for the prediction
- 0.0-0.3: Low confidence in topic prediction
- 0.3-0.7: Medium confidence in topic prediction
- 0.7-1.0: High confidence in topic prediction
Parameters
List of topic categories to classify text into.
Returns
A list of Score objects containing:
- top_topic: Score object with predicted topic name
- top_topic_prob: Score object with probability score (0.0-1.0)
Raises
ValueError – If the text is empty or None, or if no scores are returned from the API.Example
This evaluator uses zero-shot classification, meaning it can classify text into
any set of topics provided during initialization without requiring training data
for those specific topics. The mortizlaurer/roberta-base-zeroshot-v2-0-c model
is particularly effective for general-purpose topic classification across
diverse domains. The dual-score output provides both categorical classification
and confidence assessment for robust topic analysis workflows.
name = ‘topic_classification’
Initialize the TopicClassification evaluator.Parameters
List of topic categories to classify text into.
Raises
ValueError – If the topics are empty or None.score()
Score the topic classification of text content.Parameters
The text content to evaluate for topic classification.
Returns
A list of Score objects for topic name and probability.