NLP Classifier
Classifies text into predefined categories using Natural Language Processing. It can categorize text by sentiment, topic, intent, or any custom classification scheme based on the trained model.
Quick Start
To get started:
- Choose a trained model from the Model to use dropdown
- Set the Threshold value (0-1) to control prediction confidence
- Send text via
msg.payload.text - Receive classification results in
msg.payload
Configuration
Model to use (required)
Select a pre-trained model from the dropdown menu. Models must be trained beforehand using the text classifier trainer block.
Threshold (required)
Confidence threshold (0 to 1) for filtering classification results. Default: 0.5
Note: Lower values return more predictions with potentially lower confidence. Higher values are more selective.
Common Input Format (All Algorithms)
msg.payload.text (string | array)
The input text to classify. Can be a single string or an array of strings.
Example: "This product exceeded my expectations! Highly recommend it to everyone."
Output by Model Type
Low Infra - Good Accuracy - v1 / Low Infra - Good Accuracy - v2 (Transformer-based)
msg.payload contains an output array of predicted class labels.
Example: {"output": ["positive_sentiment"]} or {"output": ["tech", "product_review"]}
Low Infra - Low Accuracy (Deprecate) (FastText-based)
msg.payload is an object with class labels and confidence scores (no output wrapper).
Example: {"predicted_class": ["positive_sentiment"], "confidence": [0.91]}
Example
Input (msg.payload)
{
"text": "This product exceeded my expectations. Highly recommend it."
}Output (msg.payload)
{
"output": ["positive_sentiment"]
}Errors
When the block fails, it raises an error. Use a Catch block in your flow to handle failures and inspect the error payload.
Common mistakes
- Empty text:
msg.payload.textis required and must be a non-empty string. - Threshold out of range: Threshold must be between 0 and 1.
- No predictions above threshold: Lower the threshold if you want more results.
Best Practices
- Use clean, well-formatted text for better classification accuracy
- Start with threshold 0.5 and adjust based on your precision/recall requirements
- Lower threshold (0.3-0.4) for better coverage, higher (0.6-0.8) for more confident predictions
- Ensure training data covers all expected text categories with balanced examples
- Use domain-specific models when working with specialized text (technical, medical, legal, etc.)
- Regularly retrain models as language patterns and classification categories evolve
- Always validate classification results in production applications