Natural Language Queries

Optimize AI responses for natural language questions

There are three primary methods to more precisely control Natural Language responses in Zing:

  1. Examples: Define specific examples to clarify ambiguous terms and calculations.
    1. Regular
    2. Analysis Question
    3. Run question as custom SQL if exact match
  2. Aliases: Create human-readable labels for databases, fields, and calculations to improve query interpretation.
  3. Exact Responses: Specify exact SQL queries for complex or highly specific questions.

1.1 Example: Regular

Even the best AI needs a little bit of help from time to time to understand your data and questions better. With Zing, you can clarify ambiguous terms and calculations quickly by adding a few training examples to your data source.

Ambiguous terms are words or phrases that have multiple meanings or interpretations, which can lead to confusion or inaccuracies in the AI’s response. For example, the word “bark” can refer to the sound a dog makes or the outer covering of a tree, and without context, an AI might not understand which meaning is intended.

Similarly, ambiguous calculations are those where the operations or variables are not clearly defined or could be interpreted in multiple ways. For example, if someone asks an AI to “calculate the increase,” without specifying what to increase, by how much, or over what time period, the AI would not be able to provide a correct answer.

Example Question and how to fine tune the response
Q:
How many trips are long by plan type?
Task: We want to define “long” as being greater than 10 minutes

Step 1: Go to Zing Console and select a data source

  • Web console: https://console.getzingdata.com/
  • Select your data source you want to train AI on
  • Go to the Examples tab and enter your questions and corresponding SQL.
Zing Data Source

Step 2: Go to Zing App

Ask “How many trips are long by plan type?” and see how AI is now showing a visualization with a filter automatically applied with trips that are longer than 10 minutes!

Zing App AI Response

2. Aliases

Creating human-readable labels ensures your analysis is easily understood by others.
With Zing, you can alias databases, fields, and calculations, enhancing clarity and interpretability across all queries.

To Create a Database Alias:

  • Go to the data source ’edit’ screen in the Zing Data web console.
  • Specify a display name; this will be shown within the Zing app.
  • If left blank, the original database name will be used.

To Create a Field Alias:

  • Go to the data source settings in the Zing web console.
  • Select ‘alias’ and then ‘add/edit.’
  • Choose the fields to alias and save.

These aliases help the AI translate natural language questions into accurate query results.

To Create a Calculation Alias:

  • Go to the data source settings and navigate to the Examples tab.
  • Create a new example by specifying the question text and corresponding SQL.

For example, defining “utilization” as select sum(hours_worked)/sum(hours_available) as utilization from mytable allows you to use “utilization” in natural language queries effectively.

3. Creating Exact Responses

Sometimes a question requires SQL complexity beyond what SwiftQuery can handle. In these cases, you can define an exact response that the AI will use.

How It Works:

  • When a user asks a question that matches an exact response, the AI will run the specified SQL directly.
  • Exact responses can include complex SQL, including CTEs and subqueries.

Please Note:

  • Define a question in the Examples tab with the corresponding SQL.

  • If a user’s query is an exact match, the system executes the SQL; otherwise, it maps to SwiftQuery.

In Addition: Helper Text

You can also create ghost text to guide a user. Ghost text provides a prompt within the input field, offering suggestions on what users might want to ask. This helps users frame their questions more effectively, ensuring they get the most relevant responses.

How It Works

  • Click on ‘Data Sources’
  • Click on ‘Settings’ of your chosen data source
  • Use the Aliases, Examples, or Helper Text functions