---
title: Sentiment Analysis
description: Analyze the sentiment of a text using a LLM, or on-device with a Local Classifier
---

Label the tone of a text as positive, negative or neutral (or your own categories), with a chat model or on-device.

## What it does

Sentiment Analysis reads **Text** and returns one label in `sentiment`. What you connect to **Model** decides how; there is no setting to switch:

* **A chat model** (for example [Chat OpenAI](/nodes/builtin/ai/aidependencies/llm/openai/) or [Web LLM](/nodes/builtin/ai/aidependencies/llm/wbellm/)) is told to answer with only one of `positive`, `negative`, `neutral`, or one of your **Custom categories**, without explanation.
* **A [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/)** runs in your browser: free, private and offline. A fixed-label sentiment model uses its own labels, mapped onto `positive`, `negative` and `neutral` (for example `POSITIVE`/`NEGATIVE` or `1 star` to `5 stars`). A zero-shot model scores your **Custom categories** word for word, or `positive, negative, neutral` when none are set. **System message** does not apply.

Older workflows saved with the former **Engine** setting on *On-device* and nothing connected to **Model** keep running their chosen on-device model. To change one, connect a Local Classifier.

## When to use it

* Route negative reviews or support messages to a person, and the rest to an automatic reply.
* Tag feedback by mood (`angry, satisfied, confused`) before saving it.
* Screen customer messages privately, on-device, with a Local Classifier.

To sort text by topic rather than tone, use [Text Classifier](/nodes/builtin/ai/aiagents/textclassifiernode/).

## Inputs and settings

Fill **Text** with an expression such as `{{ $input.text }}`. Write **Custom categories** as a comma-separated list, for example `angry, satisfied, confused`. Keep them short and clearly different from each other.

## Outputs

Each output item has these fields:

```json title="Shape of an output item"
{
  "sentiment": null,
  "score": 0,
  "scores": {},
  "predictions": null
}
```

* With a **chat model**, you get only `sentiment`: the category the model answered.
* With a **Local Classifier**, you also get `score` (the confidence of the top label, 0 to 1) and `scores`, every label with its score.
* Older workflows on the former on-device engine return `sentiment`, `score` and `predictions` (the raw list of labels and scores).

Branch on the label with an [IF](/nodes/builtin/flow/if/) or [Switch](/nodes/builtin/flow/switch/) node, using `{{ $input.sentiment }}`.

## Dependencies and credentials

Connect a chat model, which holds its own API key, or a [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/) to run on-device. The Local Classifier needs an installed model: install one from its picker or the [Local AI](/app/local-models/) page.

## Example workflow

1. [Get Selected Text](/nodes/extension/getselectedtext/) reads a review you highlighted, with **Output field name** `text`.
2. Sentiment Analysis with **Text** `{{ $input.text }}` and a [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/) on **Model**.
3. [IF](/nodes/builtin/flow/if/) checks that `{{ $input.sentiment }}` (**String**) is equal to `negative`.
4. **True** goes to a [Slack](/nodes/builtin/integration/slack/) node that alerts your support channel.

## Common issues

* **"Connect a chat model or a Local Classifier to the Model port."** Nothing is connected to **Model**.
* **"Model not found".** The connected chat model node is not set up: open it and choose a model and its credential.
* **The label has extra words or a different capitalisation.** Some chat models add text. Add a **System message** such as `Answer in lowercase, one word.`, or use a stronger model.
* **"Model "…" isn't available. Install it from Local AI."** An older workflow on the former on-device engine uses a model that is not installed. Install it, or connect a Local Classifier.

## Related nodes

* [Text Classifier](/nodes/builtin/ai/aiagents/textclassifiernode/): sort text into your own categories.
* [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/): the on-device model for this node.
* [Analyze Text](/nodes/builtin/ai/localai/analyze-text/): on-device text classification without a model node.
* [Guardrails](/nodes/builtin/ai/aiagents/guardrails/): pass or fail text against a policy.