You need to enable JavaScript to run this app.
DataAgent (OnPremise)

DataAgent (OnPremise)

Copy page
Download PDF
Best Practices
Logical Explanation of the Intelligent Analytics Data Query Chain
Copy page
Download PDF
Logical Explanation of the Intelligent Analytics Data Query Chain

This article provides an overview of the main steps involved when the intelligent analytics Agent performs data queries, along with key points for each corresponding step.

General data query chain

When using the intelligent analytics Agent for data queries, the agent generates data queries based on your questions and returns the final query results. The general process of the underlying data query chain in the agent is as follows.
Image

  1. The agent generates an SQL query based on your questions using NL2SQL.
  2. The agent performs knowledge retrieval based on the knowledge, datasets, and prompts (including system prompts) you have configured, then selects the tables required for data queries, and invokes large model tools to rewrite and execute the SQL query.
  3. The final data query results are returned.

In the general data query chain:

  • The data query chain relies heavily on the invocation of the ANSI_SQL tool.
  • In most scenarios, only one invocation of the ANSI_SQL tool is required. In the React paradigm, the model may decide whether to continue invoking the SQL tool.
  • In a complete React process, if the result of the first SQL invocation is not sufficiently accurate, the overall quality of the chain process is usually low.

Multi-path parallel chain

Reasons for introducing multi-path parallelism

Hallucinations are an inherent problem that objectively exists during the interaction between requests and responses in large models, which can affect the accuracy of data query output.
By adopting a multi-path parallel generation strategy, multiple model inference processes can be triggered simultaneously for the same user request, resulting in several independent candidate outputs. The agent then votes among the candidate results to select the optimal one and returns it, thereby improving the accuracy of data query results.

Multi-path parallel data query chain process

When the parallel mode switch is enabled, each time a data query is performed, the original single general query pipeline is automatically changed to simultaneously trigger three query pipelines. The overall process is illustrated in the following diagram.
Image

  1. The agent initiates data query tasks across all three pipelines and conducts a vote on the results of the first SQL execution, selecting the optimal result based on the multi-path selection logic.
  2. If the data query task involves multiple SQL executions, then in the results of the first SQL execution:
    • The optimal pipeline continues with subsequent SQL task executions.
    • The other pipelines cease execution.
  3. The final output is the optimal data query result among all pipelines.

In parallel pipelines:

  • By default, three data query pipelines are enabled.
  • The voting and selection occur during the first SQL execution:
    • If the result of the first SQL execution is not sufficiently accurate, the overall quality of the pipeline is usually low. Therefore, it is essential to prioritize the result of the first SQL execution.
    • During the first SQL execution, there is limited context and low concurrency, making voting and selection highly cost-effective.
    • Typically, most queries only execute SQL once.
  • The multi-path selection logic is based on a compatibility matrix, as detailed below.

Multi-path selection logic

Based on the compatibility matrix, the decision is made in two steps, ultimately outputting VotingResult.

(1) Full connectivity (is_all_equals) ➡️ First determine "who can represent whom"

  • Objective: Determine whether all results are "mutually compatible" (strong connectivity);
  • Implementation: Use the Floyd-Warshall algorithm to calculate bidirectional reachability between nodes
  • Conclusion: If all nodes are mutually reachable, it is determined as "full connectivity" and the default mainstream index (0) is returned directly.

(2) Mainstream mining (find_major_index) ➡️ Record in a table

  • Core logic: "The node that is connected to the most other nodes is the mainstream";
  • Implementation: Count the number of 1s in each column of the matrix. The column with the highest count corresponds to the major_index (mainstream result index).
Last updated: 2026.06.02 14:59:26