Skip to main content

Adding a Statement to the Semantic Context

The Semantic Context in Waii enhances query generation by providing relevant contextual information. This document explains how to add a statement to the Semantic Context.

Accessing the Semantic Context

  1. Open the SQL Builder.
  2. Find the 'Semantic Context' link in the header, next to the hamburger menu.
  3. Click on it to open a dialog showing all existing semantic context.
  4. At the bottom of the dialog, click the 'Add New' button.

Types of Semantic Statements

Simple Statements

Simple statements are always used when the associated database object is referenced. Examples include:

  • Database Instructions: e.g., "This column is deprecated, don't use."
  • Usage Information: e.g., "Revenue's preferred sort order is descending; typical aggregates are sum."

RAG Statements

RAG (Relevance-Aware Guidance) statements are filtered by relevance to the current questions or instructions. Examples include:

  • Additional Documentation: e.g., Documentation of the ingest process
  • Auxiliary Information: e.g., Annual report

Specifying a Semantic Statement

To add a semantic statement, provide the following information:

  1. Statement

    • Description: The natural language statement giving context.
    • Example: "This column is deprecated, don't use."
  2. Scope

    • Description: The database, schema, or table that this statement refers to.
    • Example: "sales_db.sales_schema.sales_table"
  3. Labels (Optional)

    • Description: Labels to categorize and manage statements.
    • Example: "deprecated, usage"
  4. Always Included

    • Description: Indicates whether it's a Simple (true) or RAG (false) statement.
    • Example: true for Simple, false for RAG.
  5. Lookup Summaries

    • Description: Keys and important information from the document that need to be indexed separately.
    • Example: ID or reference number for documents loaded
  6. Summarization Prompt (Optional)

    • Description: An optional prompt to summarize the statement. Useful for lengthy documents to reduce at runtime.
    • Example: "Summarize the abstract of the document only."

Example

Here is an example of adding a semantic statement:

  • Statement: "This column is deprecated, don't use."
  • Scope: "sales_db.sales_schema.sales_table"
  • Labels: "deprecated, usage"
  • Always Included: true

API/CLI usage

To bulk load or manage semantic context it is recommended to use the CLI or API. Please refer to the respective documentation for details.