Skip to main content
Back to Library
Prompt Engineering Guide

Mastering Analyze sentiment
on GPT-4o

Stop guessing. See how professional prompt engineering transforms GPT-4o's output for specific technical tasks.

The "Vibe" Prompt

"Analyze the sentiment of the following text: "
Low specificity, inconsistent output

Optimized Version

STABLE
You are an expert sentiment analysis AI. Your task is to provide a detailed sentiment analysis of the given text, following these steps: 1. **Identify Key Entities/Topics:** List the main subjects or entities mentioned in the text. 2. **Extract Sentiment Indicators:** Pinpoint words, phrases, or contextual cues that convey positive, negative, or neutral sentiment regarding each identified entity. 3. **Determine Overall Sentiment per Entity:** Based on the indicators, assign a sentiment label (Positive, Negative, Neutral, Mixed) to each key entity. If mixed, briefly explain why. 4. **Determine Overall Document Sentiment:** Synthesize the sentiment of all entities to determine the overarching sentiment of the entire document. Assign a label (Positive, Negative, Neutral, Mixed). 5. **Provide Justification:** Briefly explain the reasoning behind the overall document sentiment, referencing the entity-specific sentiments and key indicators. Text to analyze: "
Structured, task-focused, reduced hallucinations

Engineering Rationale

The optimized prompt leverages chain-of-thought prompting by breaking down the complex task of sentiment analysis into smaller, manageable steps. This guides the model through a logical reasoning process, ensuring it considers entities, specific indicators, and then synthesizes information for both entity-level and overall document sentiment. This structured approach reduces ambiguity, improves accuracy, and makes the model's 'thinking process' transparent, which can be useful for debugging or understanding its output. It also explicitly sets the persona as an 'expert sentiment analysis AI', which can encourage a more detailed and analytical response.

0%
Token Efficiency Gain
The optimized prompt output will consistently identify multiple entities if present, unlike the naive version which might just give a generalized sentiment.
The optimized prompt output will provide justifications for its sentiment labels, which the naive version will not.
The optimized prompt will be able to distinguish between mixed sentiments more effectively at an entity level, then synthesize for the document.

Ready to stop burning tokens?

Join 5,000+ developers using Prompt Optimizer to slash costs and boost LLM reliability.

Optimize My Prompts