How To
Aug 1, 2023

Using Open AI for Sentiment Analysis

In this age of data-driven marketing, it is an invaluable advantage to be able to gauge how customers perceive your brand. That's why sentiment analysis is so important. Using this technique, you can identify the underlying emotion in product reviews and customer feedback.

But deciphering the underlying sentiment from a myriad of words and phrases and nuanced expressions is difficult for even the most seasoned data analysts. Not to mention the need to train language models using Machine Learning and AI. Or you can use a Python NLP (Natural Language Processing) library, for which you must know the ins and outs of programming.

But what if we told you there’s an easier way to get the job done? Here’s your clue – ChatGPT or OpenAI’s GPT language model, to be exact. Using OpenAI’s GPT model to our aid, we no longer need to train a custom language model or use coding to perform sentiment analysis.

Instead, we will use Gigasheet’s newly introduced no-code custom enrichments and OpenAI API to perform sentiment analysis without writing a single line of code. So, let’s dive straight in.

All About Gigasheet’s No-Code Enrichments and Open AI API

Gigasheet is an analytics tool that makes big data analytics more accessible. Designed for beginners and non-tech users, Gigasheet eliminates the need for coding or database to perform data analysis. Instead, you work with a spreadsheet-like UI, which makes data exploration easier.

Recently, Gigasheet introduced no-code custom enrichments that allow users to use APIs to enrich their data from third-party sources. The best part is that you need not be a programming ninja to take advantage of this new feature.

We can simply create a custom enrichment using OpenAI API to add NLP capabilities to our Gigasheet workflow. This API will enable us to use OpenAI’s renowned GPT language model to analyze sentiment from textual data.

How to Perform OpenAI Sentiment Analysis

Follow these steps to perform sentiment analysis using Gigasheet.

1. Get Your OpenAI API Key

Here's how you can get your API key:

1. Create an account on the OpenAI API platform.

2. Sign in to your newly created OpenAI account, click the profile icon, and select View API Keys.

OpenAI API platform homepage

3. Then click Create New Secret Key. Name your API key, and save it. The key will no longer be accessible in the OpenAI platform, so copy-paste it so you can access it later.

Creation of new OpenAI API keys to perform open ai sentiment analysis

2. Upload Your Customer Feedback Dataset to Gigasheet

The next step is to upload your customer feedback dataset to Gigasheet. We are using a CSV dataset that contains reviews collected from Amazon.com. You can also use datasets stored in formats like XLSX, JSON, LOG, or ZIP.

Our dataset contains columns like reviewer name, review text, overall rating, etc. We will perform sentiment analysis on the content of the review text column.

Dataset opened in Gigasheet for open ai sentiment analysis

Do not have a Gigasheet account yet? You can create one here. It's free.

3. Write a Prompt

Now we will head to the OpenAI API platform and go to its Playground section. Here, we can write a prompt to perform sentiment analysis on the customer reviews present in our dataset.

Open AI Playground is also essential because it will help us convert the prompt into a script or cURL, which we can use in our Gigasheet custom enrichment.

So, first, we will write a prompt as shown below:


OpenAI API platform's Playground section

You can see there are also some options given on the right side of your screen. Ensure that the Mode option is set to Complete and the Model option is text-DaVinci-003. Next, click View Code and copy the cURL.


Copying prompt and cURL from OpenAI Playground to use for open ai sentiment analysis

4. Create Custom Enrichment in Gigasheet

We will head back to Gigasheet to create our GPT enrichment. We all know that not all reviews are helpful or genuine. So, for our analysis, we will stick to reviews that other customers have found useful.

We already have a column helpful_yes that contains the number of customers who found some value in a review. So, we will create a filter only to show reviews that have at least five votes for being helpful.

Simply click Filter in the menu bar to create a filter as shown below:

Filter in Gigasheet

Now for the enrichment part, head over to the Functions tab, click it, and select Enrichments. In the pop-up dialog menu, enable the radio button for cURL.

Creating custom enrichment in Gigasheet for open ai sentiment analysis

Then paste the cURL copied from the OpenAI Playground in the textbox under the CURL REQUEST section. Replace $OPENAI_API_KEY with your OpenAI API key. And click Next.

Creating custom enrichment in Gigasheet

Next, in the ADD SHEET VALUES section, we will modify our prompt to instruct ChatGPT to reference the content. Click and highlight the “review text column” portion of the prompt and select the review_text column, and click Insert Column Reference. And click Next.

Now in the SELECT RESPONSE FIELDS section, you will see multiple columns generated by the API. We only have to select the column containing the sentiment labels the GPT model returned. So, we will check the column named choices/0/text and uncheck the rest. And click Apply and then click Run.

Creating custom enrichment in Gigasheet to complete open ai sentiment analysis

Now we have an active connection between the dataset and the GPT language model. The API will instruct the model to analyze the reviews in the selected column and return the sentiment labels as positive, negative, or neutral.

The processing time depends on the size of the dataset and the length of reviews. But you will be notified via email when the API has completed its operation so you can sit back and relax. Once the processing is done, the API will add the GPT responses to a new column in the dataset.

5. Analyze the GPT Responses

Once the processing is done, a new column choices/0/text will be added to the dataset. It contains entries like Positive, Negative, and Neutral for each review. We can see that the GPT model has also added extra context with labels for some reviews, which clarifies the reasoning behind the sentiment label for those reviews. Want to go futher? Try using Gigasheet's built-in AI Spreadsheet Assistant to help you filter, group, and analyze the data.

using open ai sentiment analysis


Make Data-Driven Decisions using Gigasheet

Gigasheet’s no-code approach to big data is already making it easier for small businesses and non-tech marketers to use data analytics to make informed decisions. With the introduction of custom enrichments, you can go one step further and use data enrichment techniques to fill gaps in your data using third-party APIs. So, sign up today and get started with Gigasheet.

If you liked this ChatGPT enrichment, check out more enrichment ideas and useful APIs in our custom enrichment roundup.

The ease of a spreadsheet with the power of a database, at cloud scale.

No Code
No Database
No Training
Sign Up, Free

Similar posts

By using this website, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.