HuggingFace — Sentiment Analysis
hf_inference.nlp.sentimentClassify the sentiment of a text using a HuggingFace NLP model via the Inference API. Returns a predicted label (positive, negative, or neutral) with a confidence score, plus scores for all classes. Default model (cardiffnlp/twitter-roberta-base-sentiment-latest) is optimized for social media and short-form text. Supports custom model override. Useful for customer feedback analysis, social media monitoring, and review classification.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Input text to process. Maximum ~10,000 characters depending on model context window. | |
| model | No | HuggingFace model ID to use for sentiment classification. Default: "cardiffnlp/twitter-roberta-base-sentiment-latest" (3-class: positive/neutral/negative). Alternatives: "distilbert-base-uncased-finetuned-sst-2-english" (2-class: POSITIVE/NEGATIVE), "nlptown/bert-base-multilingual-uncased-sentiment" (1-5 star, multilingual). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present only when the call failed. Includes error code, message, request_id, and any provider-specific extras. | |
| result | No | Tool response payload. Shape varies per tool — consult the tool description and inputSchema. May be an object, array, string, or number depending on the upstream provider response. |