About OpenAI and GPT
OpenAI developed GPT, a type of artificial intelligence model that is capable of generating human-like text. It uses a machine learning technique called pre-training to learn the statistical patterns of a large dataset and then fine-tunes its knowledge on a smaller dataset to perform a specific task. It is trained on a dataset with billions of elements, including a significant part of the internet webpages, books and more.
GPT can be used for a variety of language-based tasks, such as language translation, summarization, question answering, and text generation. It can generate coherent and coherently structured paragraphs, articles, and even entire books, given a prompt or topic. GPT has the ability to learn and adapt to new tasks quickly, making it a powerful tool for natural language processing.
NOTE: There are known limitations to these models and the output is not guaranteed to be factually accurate.
How to use OpenAI in Rows
OpenAI template
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:
1=ASK_OPENAI("Generate 100-word paragraph about the latest iPhone release")
Tips for creating Prompts
The Open AI integration uses its Completions capability, which means that the artificial intelligence model will predict the next word(s) that follow the prompt. With that in mind, here are a few tips on how to construct the right prompt for your task:
- Be specific: The more specific the prompt, the most likely it is to get the intended result. If you're looking for the Population of the country in millions, "The Population of France, in millions is: " is a better prompt than simply "The Population of France".
- Give examples: You can train the model on the type of answer you're looking for. If you are using Open AI for text classification, use the prompt to give a couple of examples of inputs and expected outputs. For example: "Categorize job title by function name. Head of Marketing:Marketing, COO:C-Level, CMO: "
- Phrase the end of the prompt as the start of the answer: The model will answer with a direct continuation to the prompt. Use that insight to end the prompt with the structure you expect from the answer. If you want to use the OpenAI integration to summarize text, be clear on how to start. Example: "What are 2 main takeaways from this review: ",A2(cell reference with the product review)," ? Summarize it into 2 bullet points. Main takeaways: ")
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 English
- 1 token ~= 3/4 words
- 100 tokens ~= 75 words
- 1-2 sentences ~= 30 tokens
- 1 paragraph ~= 100 tokens
- 1,500 words ~= 2048 tokens
You 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:
LATEST MODEL | DESCRIPTION | MAX TOKENS | TRAINING DATA |
---|---|---|---|
gpt-3.5-turbo | Most capable GPT-3.5 model and optimized for chat at 1/10th the cost of text-davinci-003. Will be updated with our latest model iteration. | 4,096 tokens | Up to Sep 2021 |
gpt-3.5-turbo-0301 | Snapshot of gpt-3.5-turbo from March 1st 2023. Unlike gpt-3.5-turbo, this model will not receive updates, and will only be supported for a three month period ending on June 1st 2023. | 4,096 tokens | Up to Sep 2021 |
text-davinci-003 | Can do any language task with better quality, longer output, and consistent instruction-following than the curie, babbage, or ada models. Also supports inserting completions within text. | 4,097 tokens | Up to Jun 2021 |
text-davinci-002 | Similar capabilities to text-davinci-003 but trained with supervised fine-tuning instead of reinforcement learning | 4,097 tokens | Up to Jun 2021 |
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.
1=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:
1=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:
1=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.
For example, if you need to capitalize a string of text, use the function as follows:
1=APPLY_TASK_OPENAI("Capitalize all letters", "i HavE a doG")
Examples of OPENAI in action
There's many things you can do with OpenAI in Rows:
- Clean Up Data: Capitalize text, remove unnecessary text, parse email domains, and more.
- Text Classification: Tag emails, classify emails or classify roles from LinkedIn profiles.
- Sentiment Analysis: This is a subset of Text Classification to identify and extract subjective information from text. It can be used to determine the overall sentiment of a piece of text, as well as to identify specific opinions and emotions within the text.
- Translation: Translation into other languages.
- Summarization: Condense news articles, messages, legal documents, research papers, and more.
- Create Tables with data: Create tables with dummy or public data.
- Find and Enrich data: Generate dummy data or public data points for things you already have on your spreadsheet, like countries and companies.
Let's go through each of them.
Clean up Company names
Goal:
Clean up a list of company names and remove legal abbreviations and filler text.
Example:
1=APPLY_TASK_OPENAI("Remove legal entity abbreviations like GmbH, LLC, Inc., emojis, special characters and unnecessary text",A2)
Details:
Assumes that A2 contains the company name.
Clean up Addresses
Goal
Extract Zip Code, State, and Country Code from an address.
Examples
1=ASK_OPENAI(CONCATENATE("The Zip code of ",A2," is: "))
2=ASK_OPENAI(CONCATENATE("The State of ",A2," is: "))
3=ASK_OPENAI(CONCATENATE("The Country Code of ",A2," is: "))
Details
All examples assume that A2 contains the company name.
Classify functions from a job title
Goal:
Classify a Job Title according to its Function - e.g. C-Level, Marketing, Sales, etc.
Example:
1=CLASSIFY_OPENAI(A2, "Marketing, C-Level, Sales, Engineering, Finance",false)
Details:
- Add the job title to classify as a first argument (here, cell A2)
- Add all the categories you want to classify your titles into as a second argument
- Set
multi-tag
as false to get a strict single-tag categorization - Leave the temperature blank (default 0) to have well-defined answers
Classify sentiment in social media comments
Goal
Analyze comments from social media accounts and extract the sentiment from the text. While this can be performed through a specific-enough and complete prompt with the ASK_OPENAI() function, we introduced he CLASSIFY_OPENAI to make the task easier to solve.
Example:
1=CLASSIFY_OPENAI(A2,"Positive, Neutral or Negative", false)
Details:
- Add the comment to classify as a first argument (here, cell A2)
- Add all the categories you want to classify your comments into as a second argument
- Set
multi-tag
as false to get a strict single-tag categorization - Leave the temperature blank (default 0) to have well-defined answers
Translate product reviews from customers
Goal
Translate product reviews done by customers in third-party platforms - e.g. App Store, Trustpilot - to English.
Example
1=TRANSLATE_OPENAI(A2,"english",1,300)
Details:
- The function assumes that A2 contains the product review text
- Sets a temperature of 1, to help the engine recognize nuances and idiomatic expressions
- Defines a value for the
max_token
parameter - in this case, 300 - to allow enough tokens for the complete translation of the text.
Summarize product reviews from customers
Goal:
Summarize Product review comments into 2 bullet points with the key takeaways.
Example:
1=APPLY_TASK_OPENAI("Summarize into 2 bullet points",A2,,300)
Details:
- The function assumes that A2 contains the product review text
- Defines a value for the
max_token
parameter - in this case, 300 - to allow enough tokens for the complete summarization of the text.
Create a table with dummy names and email addresses
Goal:
Create a table with 5 dummy names and email addresses to test a feature in QA. While this can be performed through a specific-enough prompt within the ASK_OPENAI() function, we introduced he CREATE_LIST_OPENAI to make the task easier to solve.
Example:
1=CREATE_LIST_OPENAI("Full names and email address",5,,500)
Use our Actions wizard to simply the table creation. Look for 'Create list' in our Actions menu, and fill all parameters as follows:
Once clicked on 'Next Step', the table will show up below:
Details:
- 💡 Define a value for the
max_token
parameter - in this case, 500 - to allow enough tokens for the complete translation of the text.
Enrich a country with its emoji flag and population
Goal:
Get the emoji of the flag and the number of inhabitants of a list of countries.
Examples:
1=FIND_FACT_OPENAI("The emoji flag of ",A2)
2=FIND_FACT_OPENAI("The population of ",A2,"number")
Details:
Assumes that A2 contains the country name.
Find the location of a company's HQ
Goal:
Get the address of the headquarter of a list of companies.
Example:
1=FIND_FACT_OPENAI("The HQ address",A2,"number")
Details:
Assumes that A2 contains the name of the company.
Other OpenAI guides
Read our deep dives on how to use OpenAI to automate a lot more tasks: