In addition to Displayr's Research Agent, Data Preparation Agent, and AI-assisted text categorization, users can access the power of Displayr AI in customizable outputs and variables. This article covers those features found in the menus when inserting variables and outputs.
- Customizing AI features
- Creating custom outputs
- AI-Generated variables
- Save customized AI widgets as templates
Requirements
- A Displayr document with a data set.
- Displayr AI needs to be enabled. See Opting In and Out of Displayr AI.
Customizing AI features
Displayr has built-in features that allow users to create their own AI outputs and variables. For AI-created variables, fields (for data and other items) can be included in the object inspector prompt, which can be further customized via the Customize tab. When using the Custom AI editor, you can reference outputs (tables, visualizations, outputs on a page or in the Report tree) and variables directly in the prompt. See Getting Started with AI Prompting in Displayr for tips on writing prompts.
Creating custom outputs
Users can generate customizable AI outputs that can be placed on pages or be a standalone item in the Report tree. These are accessed via the + > Calculation > Custom AI menu when adding an item in the Report tree:
and via the toolbar when working on a Page:
There are many use cases when it comes to creating Custom AI calculations, including, but not limited to, the following:
Example: Create a custom output
You can pass a specific prompt and relevant variables and outputs from your document to Displayr AI. This feature is customizable and can be as simple or as complex as needed. Use this feature when you have more specific questions about outputs. However, as AI models do not actually execute calculations, results must be carefully scrutinized, and they are not reliable for data calculations that need to be very precise or accurate, or for reporting. If actual calculations are required, it is recommended to perform those using other Displayr features before passing to the AI.
As an example, I added three tables to a page representing brand awareness, consideration, and purchase.
Then...
- From the toolbar, select Calculation
> Custom AI and click on the page.
-
In the Custom AI prompt editor at the top, customize your prompt. Remember, you can reference specific variables, tables, and other outputs on pages or in the Report tree in your prompt. You can reference them by clicking the + next to the variable name in the Data Sources tree, clicking the + next to the output name in the Report tree, or clicking on the reference name of an object on a page that appears just above the object when you hover over it. See How to Use Point and Click Inside R Code to see more details about the ways that you can reference items in the prompt.
- OPTIONAL: In the object inspector, modify the Data > Temperature setting, which ranges from 0 = deterministic to 1 = most creative. Usually, .3 is a good middle ground.
- OPTIONAL: Modify Output type to be plain Text or HTML (which will be exported to PowerPoint as an image).
- Click Calculate to update the output.
- OPTIONAL: Refine your Prompt and recalculate until the AI returns a response that is closer to the format you need.
- OPTIONAL: You can create a combo box filter for viewers to filter the table in the Filters & Weight > Filter(s) area of the object inspector and have the commentary update dynamically. Or create filter variables to apply Page filters to the table in View Mode.
Example: Summarize
You can use Custom AI to summarize various items in your document. You can select Tables, Text, and Calculations, as well as visualizations and advanced analysis outputs.
For example, I'll use Custom AI to help summarize some tables and a correspondence analysis output in a worked example:
- From the toolbar, select Calculation
> Custom AI and click on the page.
-
In the Custom AI prompt editor at the top, customize your prompt. Remember, you can reference specific variables, tables, and other outputs on pages or in the Report tree in your prompt. You can reference them by clicking the + next to the variable name in the Data Sources tree, clicking the + next to the output name in the Report tree, or clicking on the reference name of an object on a page that appears just above the object when you hover over it. See How to Use Point and Click Inside R Code to see more details about the ways that you can reference items in the prompt.
- OPTIONAL: In the object inspector, modify the Data > Temperature setting, which ranges from 0 = deterministic to 1 = most creative. Usually, .3 is a good middle ground.
- OPTIONAL: Modify Output type to be plain Text or HTML (which will be exported to PowerPoint as an image).
- Click Calculate to update the output.
- OPTIONAL: Refine your Prompt and recalculate until the AI returns a response that is closer to the format you need.
AI-Generated variables
Displayr AI can be used to create variables. This causes whatever prompt you provide to be applied to each row of data in a variable. These work by selecting a variable in the Data Sources tree, clicking +, and selecting an option from the menu, including:
When using the AI-generated variable functions, the Data tab of the object inspector has the Prompt field, which is the request being sent to the AI. There will be a default prompt for each feature, but you are able to customize it as you wish. Each feature also has an input Variable field, where you point the AI to a specific variable or set of variables when processing your prompt. For tips on creating custom prompts, see Getting Started with AI Prompting in Displayr.
In addition to these default fields, you can also add your own custom fields and access other settings via the Customize tab in the object inspector. The Temperature field governs how much randomness goes into the result selection, 0-1 (larger values mean it's more "creative"). The Input Options section is how you add more fields to the Data tab if you need to configure other inputs to go along with your Prompt. Here you will select how many additional fields you want to add, give each a name, and specify what type of input it is (i.e., Text, a Control, a Variable, a Table, a Calculation, etc), and set whether multiple items can be selected. The input's name is put inside { } in the Prompt where you want the input to be used.
For example, if I wanted to use AI to generate a custom numeric variable, the Customize > Input Options would look like below:
Then, tick Show Prompt in Data tab, and the Prompt will appear in the Data tab. You can select the specific input to use to run the AI prompt on:
You can also customize any of these AI features and save them as a template to use elsewhere in the same document or other documents.
Poor Text Data
This function allows you to pass text variables to the AI, along with a prompt including details on how to clean the data, including removing profanity and other forms of non-response.
In the example below, a text variable was selected in the Data Sources tree, and then I clicked + > Data Quality > Poor Text Data. Displayr AI created a new variable in the Data Sources tree that coded cases with bad responses as 1s. You can then tick Usable as a filter on this variable in the object inspector, and use it to edit the raw data or remove cases, if necessary.
In some cases, it's the case that the data identified as bad is bad (e.g., "Jajasndnd" as seen below). In other cases, it's not so clear. The prompt can be edited to give better instructions, although sometimes this will be ineffective (due to hallucination or your prompt being insufficiently clear).
Identify Inconsistent Data
Have AI review a variable to make sure it makes sense. In the Data Sources tree, select the variable(s), and click + > Data Quality > Inconsistent. AI will assign a value of 0 if the data is consistent, and a value of 1 if the data is inconsistent. Examples of inconsistent data include a category of "Dog" showing up in an Age variable, an observation where someone under 18 has a living arrangement of "Living alone", or a case where a numeric Age variable doesn't fall within the Age category selected. You can use this AI-created variable to manually review the cases that are flagged. Check Usable as a filter to then use it to filter a Table > Raw Data > Variable(s) output to review the data to determine if it should be excluded from your analysis. For example, the table below looks at inconsistent data between the Preferred Cola and Brand Attitude variable sets:
Custom Code > AI
In the Data Sources tree, the + > Custom Code > AI menu creates different types of variables based on a Prompt and Input Variables. The default behavior will do a complete case analysis of the variables selected and will flag cases with complete data. Flags are coded based on the type of variable you want to create:
- Date: Constructs a Date/Time variable that takes today’s date if the data is complete, and is a missing value if there is incomplete data.
- Numeric: Constructs a Numeric variable which takes the value of 1 if the data is complete and 0 if the data has any missing values. You can tick Usable as filter in the object inspector to be able to filter in complete cases on outputs and analyses.
- Nominal: Constructs a Nominal variable that takes the label 'Complete' if the data is complete and 'Incomplete' if the data has any missing values.
- Ordinal: Same as 'Nominal' but creates an Ordinal variable.
- Text: Same as 'Nominal' but creates a Text variable.
You can also customize the Prompt via the object inspector to have the AI perform different actions, such as converting numbers stored as a Text variable into an actual Numeric variable. Another example would be to have AI identify mentions of proper names (e.g., brands) in text and then create a new text variable that has only that information in it. It can also flag angry comments about a certain brand.
Sentiment
Use + > Numeric Transformations > Sentiment to create a new variable with a sentiment score generated by AI from an input text variable. This is a more robust analysis than our other built-in sentiment analysis tool, which simply counts positive and negative words in a response. You can determine how the sentiment is coded, and AI will be able to evaluate responses in a "smarter" way.
Translate
To translate text variables, click + > Text Manipulation > Translate in the Data Sources tree to create a new version of a selected text variable, translated into a different language. You can use the object inspector to further customize your Prompt and select a Source language (including having the AI auto-detect the language).
Save customized AI widgets as templates
Once you've created a custom AI calculation (widget) to run on outputs in your document, you can save it as a template. This will allow you to apply the same prompt to different outputs in the same document or in other documents since templates are saved to the Displayr Cloud Drive.
To save a customized AI widget:
- Select the output on the page.
- Click the three dots that appear above the output and select Save as Template.
- Give the widget a File name.
- OPTIONAL: Select a folder in the Displayr Cloud Drive to save the template into.
- Click Save.
To insert the saved template into the same document or into a different document:
- Navigate to the page where you want to place the saved prompt.
- From the toolbar, click Template
.
- Select the saved AI widget from the Displayr Cloud Drive list.
- Click Insert.
- Click on the page to place the AI output.
- Select the inputs that you want to run the AI widget on from Tables, Text, Calculations, etc.
- OPTIONAL: Further customize the prompt or items in the Customize tab of the object inspector. Note that if you want to reuse the modified widget, you will need to click Save as Template and give the updated object a new name.
Next
Frequently Asked Questions About Using AI in Displayr