Exploring Query Generation

  • Release version: Yokohama
  • Updated July 21, 2025
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Exploring Query Generation

    Query Generation is an AI-powered ServiceNow feature that transforms user questions into executable queries, delivering relevant data results. These queries specify the data source, filters, aggregations, and visualization instructions designed to best answer the user's question. The output includes a textual summary, data visualization, and follow-up suggestions, enhancing data exploration efficiency.

    Show full answer Show less

    This feature relies on a semantic data layer, which provides a streamlined, flat representation of tables (Entity records) and columns (Dimension records). This layer helps the system quickly identify relevant facts tables and columns related to the user query while avoiding system overload by limiting included tables. Administrators can view and manage which tables are enabled for semantic generation but should consider performance impacts before adding tables.

    How Query Generation Works

    Before interacting with the large language model (LLM), Query Generation filters the instance schema to focus only on the most relevant entities (facts tables) and dimensions (columns). This targeted filtration:

    • Ensures accurate grounding of available data structures and prevents LLM hallucination of nonexistent tables or columns.
    • Maintains a focused context window to improve the LLM's performance and accuracy.

    The system narrows entities to the two closest matches related to the user's question and selects the 30 most relevant dimensions. The LLM then generates a semantic query based on this filtered data, which is translated into an executable query by a constitutor.

    Users and Roles

    • ServiceNow AI Platform Administrators: Manage Now Assist in Platform Analytics, configure Query Generation, and add or remove tables from the semantic data layer. Only users with the admin role can modify Query Generation records.
    • Now Assist in Platform Analytics Users: Indirectly use Query Generation through their applications. They must have the appropriate roles assigned to access these features but do not interact with Query Generation directly.

    Next Steps

    ServiceNow customers seeking to implement or optimize Query Generation should explore configuration options and detailed references to understand how to tailor the semantic data layer and maximize the accuracy and relevance of generated queries.

    Query Generation is an AI-powered service that translates user questions into an executable query and returns the results. An executable query contains the data source, filter, aggregation, and visualization instructions that best answer the user's question. The results include a textual summary, a data visualization, and suggestions for follow-up.

    Query Generation overview

    Query Generation relies on a semantic data layer to generate queries. The semantic data layer is a flat representation of tables and table columns that the Query Generator uses to find the actual facts tables and columns related to a user utterance. Specifically, facts tables are represented by Entity records and their columns by Dimension records.

    Not all facts tables are included in Query Generation, as this would overload an instance. To see which facts tables are included, open the Semantic Tables Configurations list [sn_query_gen_table_config_list], and note which tables are present and have Enable Semantic Generation = true. You can add more tables to the list, but be careful of possible performance impacts. For more information, see Add a table to the semantic data layer.

    How Query Generation works

    The Query Generation process for producing an executable query.

    Before Query Generation can call the LLM, it has to filter the instance schema down to only the relevant entities and dimensions needed to answer the user's question. This filtration serves two critical purposes:
    • It provides the LLM with precise grounds for truth about available tables and columns, preventing hallucination of non-existent data structures.
    • It maintains a focused context window, which improves LLM performance and accuracy compared to processing the entire schema.

    Query Generation uses a semantic filter to narrow the entities (facts tables) to the 2 closest matches to the user's question. Then from those entities, it narrows the dimensions (columns) to the 30 most similar to the user's question. Query Generation passes these results to the LLM, which generates a semantic query. A constitutor takes this semantic query and translates it into an executable query.

    Query Generation users

    Table 1. Users
    User Description
    ServiceNow AI Platform administrators responsible for Now Assist in Platform Analytics [admin] Administrators can add or remove tables from the semantic data layer. Only users with the admin role can read or change Query Generation records.
    Users of Now Assist in Platform Analytics applications Users of the Now Assist in Platform Analytics applications call Query Generation through those applications, although Query Generation is not visible to them. They should have the required Query Generation user roles through the roles granted to them to use the intermediary application.