7 minutes to read - Aug 29, 2023

How to use OpenAI's ChatGPT for sentiment analysis

VISIT
How to use OpenAI's ChatGPT for sentiment analysis
Learn how to use OpenAI and GPT-3 inside the spreadsheet to classify sentiment in social media comments, summarize customer reviews and more.
Table of Contents
1How to use OpenAI in Rows

How to use OpenAI in Rows


Connecting the OpenAI integration in Rows
You can find the OpenAI integration by browsing the integrations gallery and searching for "OpenAI".

To connect the integration and use the power of AI inside Rows all you need is an API Key. You can get your API key by going to the View API Keys option on your OpenAI account. If you don't have an account yet, sign-up here. All free accounts have API access.


Now simply copy the API key, go to the OpenAI integration page, press Connect, paste it and click Connect. Your Rows workspace is now connected to your OpenAI account and you're ready to go.


Using the OpenAI functions
The OpenAI integration comes with five proprietary functions that automate prompts to address specific types of tasks:
ASK_OPENAI(), which aims at leveraging the power of GPT to solve general tasks.
CREATE_LIST_OPENAI(), which is designed specifically to create tables and list of dummy data, for testing purposes.
CLASSIFY_OPENAI(), which is designed specifically to classify texts into a given set of tags.
TRANSLATE_OPENAI(), which translates texts from/into a wide range of languages.
APPLY_TASK_OPENAI(), which is designed specifically to clean up or apply logic rules to data.
You can use them via the Autocomplete in the editor,or via the Actions wizard:

All OpenAI functions need to be configured through mandatory and optional parameters, depending on their purpose. Let's go through them one by one.
Prompt
The prompt is the instruction to give to the model in our most generic function ASK_OPENAI(). This is where you'll enter the "ask" you want the AI to answer. You can use the prompt to solve a task by explicitly writing it in prose. Example:Temperature (optional)
The temperature is common to all functions and is used to fine tune the sampling temperature, varying between 0 and 1. Use 1 for creative applications, and 0 for well-defined straight answers.
If you're doing tasks that require a factual answer (e.g. country populations, capitalize text), then 0 (the default) is a better fit. If you're using the AI for tasks where there aren't definite answers - such as generating text, summarizing text, or translating - then experiment with a higher temperature, which allows the engine to better capture text nuances and idiomatic expressions.
Max_tokens (optional)
This max_tokens represents the maximum number of tokens to generate in the completion. It's present in all OpenAI functions. You can think of tokens as pieces of words. Here are a few helpful rules of thumb examples from the OpenAI Help center:
1 token ~= 4 chars in English1 token ~= 3/4 words100 tokens ~= 75 words1-2 sentences ~= 30 tokens1 paragraph ~= 100 tokens1,500 words ~= 2048 tokensYou can use any number starting with 0. The default value is 200. Most models have a context length of 2048 tokens, except for the newest models which support a maximum of 4096. For tasks that require more text output - text generation/summarization/translation - pick a higher value (e.g. 250).
Model (optional)
The AI model to use to generate the answer. It can be chosen in both functions, and by default, it uses "gpt-3.5-turbo". Below you find a list of all of the available GPT-3.5 models:
Number of items (optional)
The number of items is available only in the CREATE_LIST_OPENAI() function, and represents the expected number of items in the list.
=CREATE_LIST_OPENAI("Full names and email address",5,,500)
Tags and multi-tag (optional)
The tags and multi-tag properties are available only in the CLASSIFY_OPENAI() function. The first is mandatory and represents the categories you want your text to be classified into.
For example, if you need to classify a list of product reviews in column A, into positive, neutral, negative and very negative, you just need to input those tags separated by a coma, as follows:
=CLASSIFY_OPENAI(A2, "positive, neutral, negative, very negative")
The second is optional and can be "true" (default) or "false". If true, the function can use more than one tag to classify your text. If false, it will only use one tag. Use false when you need a mutually exclusive strict categorization.
Language
The language is available only in the TRANSLATE_OPENAI() function, and indicates the destination language for your translation tasks. Use the function as follows:
=TRANSLATE_OPENAI(B1,"hebrew")
Task and text
The task and text are available only in the APPLY_TASK_OPENAI() function, and are used to specify the logic rule to some text.
Details:
Add the social comment to be analyzed as first argument (here, cell A2).
Add all categories you want to classify your posts into, as second argument
Set multi-tag as false to get a defined categorization
Rate sentiment from customer feedback
Goal: Get a numerical rating of the customer sentiment on product reviews, social media comments of feedback survey responses.
Example:
=CLASSIFY_OPENAI(A2, "1,2,3,4,5. With 1 being very negative and 5 very positive",false,1,200)Details:
Add the product review to be analyzed as first argument (here, cell A2).
Add all categories you want to classify your posts into, as second argument. Here numbers from 1 to 5, being careful to state the meaning of each evaluation.
Set multi-tag as false to get a defined categorization
Tag customer reviews with sentiment
Goal: Automatically tag customer reviews into tags that summarize the reviewers' feedback on the product.
Example:
=CLASSIFY_OPENAI(A2,"anger, frustration, disillusion, enthusiasm, value for money, life changer",true,1,200)
Details:
Add the customer review to be analyzed as first argument (here, cell A2).
Add all categories you want to classify your reviews into, as second argument. Here are "anger, frustration, disillusion, enthusiasm, value for money, life changer".
Set true as multi-tag option, to allow for multiple tag on the same postGenerate emojis from sentiment
Goal: Turn text into emojis that represent the sentiment in a piece of text
Example:
=ASK_OPENAI(CONCATENATE("Return the emoji that represents being ",A2))Details:
Use CONCATENATE() to define the prompt, combining a specific text and the sentiment to be emojized as a first argument (here, cell A2).
=APPLY_TASK_OPENAI("Capitalize all letters", "i HavE a doG")
Examples of CLASSIFY_OPENAI for sentiment analysis
There are several ways to use OpenAI for sentiment analysis:
Classify sentiment in social media comments: Determine the overall sentiment of a piece of text, as well as identify specific opinions and emotions within the text.
Rate sentiment from customer feedback: Get a numerical rating of the customer sentiment on product reviews, social media comments, or feedback survey responses.
Tag customer reviews with sentiment: Automatically tag customer reviews into tags that summarize the reviewer's feedback on the product.
Generate emojis from sentiment: Turn text into emojis that represent the sentiment in a piece of text.
Let's go through each of them.
Classify sentiment in social media comments
Goal
Analyze comments from social media accounts and extract the sentiment from the text.
Article source
Author
loading...