knoten / builtin / ai / localai
Analyze Text
On-device sentiment, toxicity and moderation of text
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Score text for sentiment, toxicity or other moderation labels with a model that runs in your browser, so the text never leaves your device.
What it does
Section titled “What it does”Analyze Text runs the Text through the text-moderation model you pick and returns every label the model knows, with a confidence score from 0 to 1. The labels come from the model: DistilBERT SST-2 (sentiment) gives positive and negative, while toxic-bert and the TensorFlow.js Toxicity model give toxicity categories.
Labels scoring below Confidence threshold are dropped, the rest are sorted best first and cut to Top-K labels. There is no cost per run and no API key.
When to use it
Section titled “When to use it”- Flag toxic comments or messages before you post or forward them.
- Gauge the tone of customer feedback and route negative replies to a person.
- Gate a branch on a score, for example only continue when the text is not toxic.
To sort text into labels you choose yourself (billing, bug report, other), use Classify Text instead.
Inputs and settings
Section titled “Inputs and settings”| Einstellung | Typ | Was es bewirkt |
|---|---|---|
| Model | Model picker | Any installed text-moderation model, across engines. |
| Text | Text | The text to analyze. |
| Confidence threshold | Number | Standard: 0 |
| Top-K labels | Number | Standard: 5 |
- Model: pick DistilBERT SST-2 (sentiment) for positive/negative, or toxic-bert or Toxicity for moderation. The picker also lists the DeBERTa zero-shot model, which needs your own labels: use it with Classify Text, not here.
- Confidence threshold: the default 0 keeps every label. Set it to 0.5 to keep only labels the model is fairly sure about.
- Text: usually an expression, such as
{{ $input.selectionText }}.
Outputs
Section titled “Outputs”-
Output
Each output item has these fields:
| Field | Typ | What it holds |
|---|---|---|
| predictions | List of entries | Labels above the threshold, best first |
| top | Text | The best label, or null when none passed |
| score | Number |
{ "predictions": [], "top": "…", "score": 0}Each entry in predictions is { label, score }. score is the score of top. Branch on {{ $input.top }} for a simple yes/no, or on {{ $input.score }} when you want your own cut-off.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
The node needs a local model instead. The Model picker lists your installed models first, then models that download on first use. To download ahead of time, or to free space later, use the Local AI page.
Example workflow
Section titled “Example workflow”Check the tone of text you select on a page:
- Context Menu with Menu Contexts set to Selection.
- Analyze Text with Model DistilBERT SST-2 (sentiment) and Text
{{ $input.selectionText }}. - Show Notification with Title
Toneand Message{{ $input.top }} ({{ $input.score }}).
Common issues
Section titled “Common issues”- “Choose a model to analyze with.” Model is empty. Pick one; models under Available download on first use.
- “Provide some text to analyze.” Text is empty after expressions run. Check that the field you point to exists in the incoming data.
- “Zero-shot classification needs at least one candidate label.” You picked DeBERTa zero-shot. Use a sentiment or toxicity model here, or switch to Classify Text.
topis null. No label reached Confidence threshold. Lower it.- The first run is slow. The model downloads and loads on first use, then later runs are fast.
Related nodes
Section titled “Related nodes”- Classify Text: sort text into your own labels.
- Sentiment Analysis: sentiment with a chat model.
- Switch: route items by the
toplabel. - Run Local Model: run any installed model for any task.