OpenAI developed GPT-3, 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 web pages, books, and more.
GPT-3 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 can 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.
The OpenAI integration contains one function - ASK_OPENAI - that you can use to perform hundreds of tasks
You can use the ASK_OPENAI function via the Autocomplete in the editor, or via the Actions wizard.
The function has 4 parameters: 1 mandatory and 3 optional, with the following signature:
ASK_OPENAI(prompt,[temperature], [max_tokens],[model]). Let's go one by one.
prompt is the instruction to give to the model. 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 or you can use spreadsheet functions to concatenate values in different cells to construct the prompt. Examples:
- Use =ASK_OPENAI("Population of France is, in millions, :") if you are not using any cell references inside the prompt.
- Use =ASK_OPENAI(CONCATENATE("The population of ",A2," in millions, is: ")) if you're using A2 as an input (the country name) to the prompt.
temperature is the sampling temperature to use, varying between 0 and 1. Use 1 for creative applications, and 0 for well-defined 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
max_tokens represents the maximum number of tokens to generate in the completion. You can think of tokens as pieces of words. Here are a few helpful rules of thumb examples from the Open AI Help center:
- 1 token ~= 4 chars in English
- 1 token ~= 3/4 words
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 to use to generate the answer. By default, it uses "text-davinci-003". You can see here a list of all of the available GPT-3 models.
Use 'Json table' in the prompt
Include in the
prompt that the goal is to create a "Json table". JSON is the standard file format accepted by Rows to create lists of data.
The prompt will result in a data cell labeled openai. Click on the ▼ icon and select Create Data Table to expand its result in the spreadsheet. Use the wizard on the right side of the spreadsheet to select which columns to add to the table.
Use the max_tokens parameter
Set a large number in the
max_tokens argument to ensure that the OpenAI response is not inadvertently capped to the default max_token value (200).
If that happens, the ASK_OPENAI formula response will be an incomplete JSON file, like the one below. This is an indication that the
max_tokens parameter might be too low.
Be clear on the columns' names
Be specific on which columns you expect to be part of the list. If you want a list of the
names of the last 5 US Presidents, include exactly what you want to see.
1=ASK_OPENAI("Create a json list with the names and birth dates of the last 5 US Presidents",,500)
Be clear on the columns formats
The same applies to the formats of the data. If you want the output to be formatted in a specific way - e.g. dates as YYYY-MM-DD be explicit on the
1=ASK_OPENAI("Create a json list with the names and birth dates (YYYY-MM-DD) of the last 5 US Presidents",,500)
Create a table with 10 names and email addresses to create a dataset to test a feature in QA.
1=ASK_OPENAI("Create a json list with 10 first names, last names and email addressess",,500)
💡 Add variations to the prompt to get different responses of the same structure. If you want to generate a list of email addresses but add diversity to them (e.g mix English with non-English names), be specific on the
1=ASK_OPENAI("Create a JSON list with 10 first names, last names and email addresses. It should contain a mix of nationalities",,500)