Sentiment Analysis
Analyze the overall sentiment of an input text and label it as Positive, Negative, or Neutral.
Introduction
Welcome to the documentation for the Sentiment Analysis Workflow! This Workflow is designed to analyze the sentiment of text and provide valuable insights into the expressed opinions. Whether you’re a marketer, customer service representative, or business owner, this Workflow will assist you in understanding the sentiment behind customer feedback, social media posts, and other textual data. With its advanced algorithms and user-friendly interface, this Workflow is a quick and easy way to leverage sentiment analysis.
Overview
The Sentiment Analysis Workflow leverages state-of-the-art natural language processing to analyze the sentiment of text. It goes beyond simple keyword analysis and provides a nuanced understanding of the expressed sentiment in the text. By analyzing the sentiment, this Workflow enables you to gain valuable insights into customer satisfaction, brand perception, and market trends. With its powerful capabilities and intuitive design, it is the perfect solution for unlocking the sentiment behind textual data.
Note: This Workflow does not break the input text into its composing sentences. The assigned label is the overall sentiment. Therefore, if the input is composed of multiple sentences, some positive (e.g., "She is really excited") and some negative (e.g., "but she was not successful last time"), the overall sentiment is likely to be Neutral.
Key Features
Accurate Sentiment Analysis: Utilizes large language models to accurately analyze the sentiment of text. This feature ensures reliable and accurate sentiment analysis results, allowing you to make informed decisions based on the insights gained.
Fast Analysis: Produces results in a matter of seconds.
How to Use the Workflow
Locate the Workflow in the template page and click on Use template. You can use the Workflow as is or clone it.
Follow these steps to analyze the sentiment of your text:
Input Text: Enter the text you want to analyze into the Workflow. This could be customer feedback, social media posts, product reviews, or any other textual data.
Run the Workflow: Once you have entered the text, click the “Run Workflow” button (on the App page) or use the run options on your data table (bulk/single run) to initiate the analysis process. The Workflow will analyze the text and provide sentiment analysis results.
Workflow Execution
Workflows and templates can be tested on individually provided inputs:
Single run on the App page
Single run on the Build page
Single run on the data table
They can also be set to fetch the data from a dataset and apply the analysis on the whole dataset:
Bulk run on the data table
View Results: The Workflow will display the sentiment analysis results under one of (Positive, Negative, or Neutral) labels.
Deep Dive into the Workflow
Workflow Components
If you clone a template or create a Workflow from scratch, you will have access to the Build tab. Build is where one puts together different components to build a Workflow suitable for their needs.
User Inputs
Long Text Input: An input text component suitable for long text pieces (more than one line), such as answers to a question, reviews, or a text to summarize.
Actions
There is only one LLM component under the Actions in this analysis flow.
Large Language Model (LLM): A large language model component is all set up to provide you access to GPT (and many other LLMs). In the prompt section, you will provide the required information as well as instructions on what is expected to be done.
A Good Prompt
Be short and precise with your instruction/request from the LLM
Explicitly note constraints and goals
Include a few examples when possible
Modify the Workflow: Extracting the Reason Behind the Given Sentiment
The existing Workflow conducts sentiment analysis using large language models. You might want to modify the Workflow to receive other analysis results. This can be easily achieved by cloning the existing workflow and customizing it in your account.
In this tutorial, we’re going to enhance the existing sentiment analyzer by configuring multiple outputs to our Workflow and adding them back to our original spreadsheet as two new columns - we’re extracting the reason behind the given sentiment as well. You’ll learn how you can have a single LLM prompt produce multiple pieces of information.
Copy the Existing Workflow
Cloning the Workflow creates a copy of the Workflow in your account and enables you to modify the components. After cloning the Workflow, select it from the Workflows page and go to the Build tab.
Extracting Sentiment and Reason Simultaneously
We’re going to layer on multiple pieces of functionality within the same Workflow to give us the desired output.
Modify the LLM Prompt
To obtain the explanation for the sentiment score, we could either introduce a separate LLM prompt or simply modify our existing prompt and then transform the output into a JSON. We’ll proceed with the latter.
Adjust the prompt:
Modify the LLM System Prompt
Add this prompt:
Test the Workflow
After adjusting the prompt, try the Workflow on one data sample (i.e., simply copy one of the messages from your dataset and then hit run). This should provide a JSON-like output that includes a reason and the sentiment.
Configure the LLM Output
We aim to add a ‘sentiment’ column and a ‘reason’ column to our original dataset. To do this, we need to adjust our output. We must properly convert our string to JSON. This can be accomplished by adding the ‘Convert string to JSON’ action to our Workflow.
Add a ‘Convert string to JSON’ component to your Workflow. Next, specify the input to this component (i.e., the output of the LLM component). For an LLM component that is called LLM, the output is accessible via
{{llm.answer}}
.
Configure the Workflow Output
Reference the JSON output for ‘sentiment’ and ‘reason’ instead of having the sentiment label as the only output. This can be achieved by clicking on Configure on the output component (i.e., the last component of the page) and adding the output fields.
Save and Run
Save all the changes and you are ready for running your Workflow and exporting the results.
Last updated