BI intelligent question-answering system and method based on business rule retrieval and AI workflow
By configuring business rules and scheduling AI workflows, combined with data rule retrieval and large language models, the problem of supervised fine-tuning training in BI intelligent question answering systems has been solved, enabling the construction of a low-cost, highly flexible professional domain question answering system.
Patent Information
- Application Number
- CN202511649841.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2025-12-12
AI Technical Summary
Existing technologies for constructing BI intelligent question answering systems suffer from several drawbacks, including supervised fine-tuning training reducing the native dialogue capabilities of large language models, high manual annotation costs, and poor flexibility. In particular, retraining is required when business data table fields change.
By employing a business rule-based retrieval and AI workflow approach, and configuring business table knowledge and indicator knowledge through the user interaction module, combined with the AI workflow module to schedule data rules, prompt word construction units, and large language models, a professional domain BI question-answering system can be quickly built.
Without supervised fine-tuning of a large language model, a low-cost and highly flexible BI question-answering system was built, reducing the cost of manual annotation and improving the system's adaptability.
Smart Images

Figure CN121117166A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a BI intelligent question and answer system and method based on business rule retrieval and AI workflow, and belongs to the technical field of intelligent data processing system (BI) and artificial intelligence (AI). BACKGROUND
[0002] Intelligent data processing system (BI) is a system that integrates and analyzes internal and external data of an enterprise to assist in decision-making. The core design idea is to form fixed SQL query statements for various levels of indicators in various dimensions of business data within the business database, execute SQL queries according to the established procedures, and display the query results data on the front page through data visualization to realize user perception of business system data and observation of business indicators.
[0003] In recent years, with the breakthrough progress of large language model technology, Text-to-SQL technology based on large language model has been increasingly applied to BI intelligent question and answer systems, realizing the process of quickly converting user natural language questions or commands into SQL statements executable on databases to further output results. Compared with the traditional communication process of "user proposes requirements -> requirement docking -> developer writes SQL", the Text-to-SQL technology based on large language model greatly reduces development costs and improves the efficiency of BI intelligent question and answer systems in statistical analysis and decision support.
[0004] When constructing a BI question and answer system based on a large language model, how to make the large language model understand the special vocabulary in the user's question is a core problem that needs to be solved to realize intelligent question and answer. Most existing technical solutions to this problem are to supervise and fine-tune the large language model through artificial annotation of business-related question-SQL training sets, so as to realize the understanding of special vocabulary by the large language model. This technical solution has been proven to be effective, but it has the following problems: 1. Supervised fine-tuning will reduce the original dialogue ability of the large language model; 2. The training set is difficult to construct, and the cost of artificial annotation is high; 3. Poor flexibility, when the business statistics range expands or the business data table fields are added, deleted or modified, the Text-to-SQL capability based on the old training set fine-tuning will also be outdated, and the training set must be updated and the large language model must be supervised and fine-tuned again. SUMMARY
[0005] In order to solve the above problems, the present application discloses a BI intelligent question and answer system and method based on business rule retrieval and AI workflow, and the specific technical solutions are as follows: The BI intelligent question and answer method based on business rule retrieval and AI workflow includes the following steps: Step 1: Business rule configuration: the user configures business table knowledge and business index knowledge in the user interaction module, and the knowledge base module manages the knowledge; Step 2: Business rule retrieval: the AI workflow module obtains the BI analysis question input by the user interaction module, and schedules the business retrieval unit to process the BI analysis question; Step 3: The AI workflow schedules the data rule retrieval unit, the prompt word construction unit, the large language model scheduling unit, and the database connection unit: Step 3.1: Data rule retrieval unit scheduling: after the BI analysis question is input, sequentially execute the business table information recall node, the date and time period rule matching node, the aggregation type judgment node, the business index matching node, and the Few-shot example recall node; Step 3.2: Prompt word construction unit: respectively in the business table discrimination stage, the Text-to-SQL stage, and the SQL correction stage, schedule the corresponding prompt word template, and fill the known information in each stage into the prompt word template; Step 3.3: Large language model scheduling unit: respectively in the business table discrimination stage, the Text-to-SQL stage, and the SQL correction stage, schedule appropriate large language models to provide model reasoning services, including thinking large language models and programming large language models; Step 3.4: Database connection unit: schedule the database query interface to execute SQL statements and obtain the execution results, the interface is an internal interface or an external interface.
[0006] Further, the step 1 specifically includes: Step 1.1: Configure business data table information in the business knowledge configuration unit of the user interaction module, the table field name, field type, field description, and field corresponding data dictionary value are obtained directly from the relational database after the user configures the table name, and the field name synonym needs to be manually configured by the user; Step 1.2: Configure business index knowledge in the business knowledge configuration unit of the user interaction module; Step 1.3: The knowledge base module obtains the business data table knowledge and business index knowledge configured in step 1.1 and step 1.2 input by the user interaction module, and stores them in the corresponding knowledge base.
[0007] Further, the execution process of the business rule retrieval unit in step 2 is: 2.1: Recall the first three business data table information closest to the BI analysis question text from the business data table knowledge in the knowledge base module; 2.2: Reason the business data table to be queried by the BI analysis question, and output the table name and table information of the business data table; 2.3: Match the date question in the BI analysis problem, unify the various date questions in the problem into the expression of "BETWWEN start date AND end date"; 2.4: Match the aggregation function question in the BI analysis problem, unify the various aggregation questions in the problem into the corresponding function expression; 2.5: Retrieve the field data dictionary and business indicator knowledge associated with the business data table in the knowledge base module, and match the business indicator nouns and their synonyms, field data dictionary with the processed BI analysis problem one by one to obtain the business indicator nouns and data dictionary involved in the problem; 2.6: Recall the top three "BI analysis question->SQL" question and answer records closest to the BI analysis question text from the Few-shot example knowledge of the knowledge base module; 2.7: Combine the identified business table to be queried, date period, aggregation type, business indicator and few-shot example into the associated business knowledge object of the BI analysis problem, and the business rule retrieval process ends.
[0008] Further, the step 3.2: the construction method of the Text-to-SQL thinking chain prompt word of the prompt word construction unit is: Step 3.21: Create a framework, which includes: main target, business data table information, reasoning basis, SQL reasoning thinking chain and output specification, create the current task using the Text-to-SQL thinking chain prompt word template; Step 3.22: Fill in the business data table information, obtain the associated business knowledge object output by the business rule retrieval process described in step S7, extract the business table information to be queried therein, combine it into the DDL of the business table, and fill it into the [business data table information] part of the prompt word framework; Step 3.23: Construct the reasoning basis, extract the date period, aggregation type, business indicator, few-shot example in the associated business knowledge object, judge the existence of each information one by one, and then organize the corresponding prompt text of each information to construct the [reasoning basis] part of the prompt word framework; Step 3.24: Construct the SQL reasoning thinking chain, in the order of: identify the statistical demand of the input question->locate the relevant column->define the SELECT information->determine the filter condition->add the historical dialogue condition, construct the [SQL reasoning thinking chain] prompt word; Step 3.25: Fill in the output specification, the prompt word construction unit has pre-stored output specification templates for the database dialects of various relational databases, according to the database configuration information provided by the database connection unit, select the output specification template corresponding to it, and fill it into the [output specification] part of the prompt word framework; Step 3.26: Publish the current task, fill in the input question to the prompt word [current task] part.
[0009] The BI intelligent question and answer system based on business rule retrieval and AI workflow comprises a user interaction module, an AI workflow module and a knowledge base module, and the user interaction module, the AI workflow module and the knowledge base module have the following connection relationships: Connection relationship 1: the user interaction module is connected with the knowledge base module, and the user interaction module transmits the business data table knowledge and business index knowledge written by the user on the front page to the knowledge base module; Connection relationship 2: the user interaction module is connected with the AI workflow module, and the user interaction module transmits the BI analysis question written by the user on the front page to the AI workflow module; Connection relationship 3: the AI workflow module is connected with the knowledge base module, and the AI workflow module retrieves business knowledge from the knowledge base module based on the BI analysis question; Connection relationship 4: the AI workflow module is connected with the user interaction module, and the AI workflow module transmits the BI analysis result generated based on the BI analysis question to the user interaction module; Connection relationship 5: the user interaction module is connected with the knowledge base module, and when the user makes positive / feedback on the BI analysis result, the user interaction module transmits the question and answer record of this time to the knowledge base module.
[0010] Further, the execution process of the user interaction module, the AI workflow module and the knowledge base module is as follows: User interaction module: the user interaction module is used to provide a button triggering intelligent dialogue and an intelligent dialogue window, transmit the BI analysis question input by the user in the dialogue window to the AI workflow module, generate the BI analysis result by the AI workflow module and display the BI analysis result in the intelligent dialogue window, and provide a business information configuration page to transmit the information configured by the user in the page to the knowledge base; Knowledge base module: the knowledge base module receives the business data table and business index knowledge written by the user in the user interaction module, stores the business data table and business index knowledge in the corresponding knowledge base, and stores the question and answer record confirmed by the user in the user interaction module in the Few-shot example library; AI workflow module: based on the workflow engine, the AI workflow module receives the BI analysis question input by the user in the user interaction module, schedules the business rule retrieval unit and the large language model according to the steps, retrieves the business data table and business index knowledge related to the BI analysis question based on the knowledge base module, gradually constructs the Text-to-SQL thinking chain prompt word, makes the large language model infer the SQL statement corresponding to the BI analysis question, and transmits the BI analysis result obtained by visualizing the execution result of the SQL statement in the database to the user interaction module.
[0011] Further, the knowledge managed by the knowledge base module specifically includes: Business data table knowledge: The information of each business data table used includes: table name, table description, table field name, field type, field description, field name synonym, field corresponding data dictionary value; Business index knowledge: The business index involved in the business scope includes: business index name, business index interpretation, business index synonym, belonging business table, associated table field, index evaluation pseudo-SQL; Few-shot example: Involved in several BI analysis question and answer records in the business scope, the content of each record includes: BI analysis question and the SQL statement corresponding to the question.
[0012] Further, the AI workflow module specifically includes: Business rule retrieval unit: responsible for executing the business rule retrieval process, based on rule matching and text similarity retrieval, according to the BI analysis question, the associated business data table information, the BI business information involved in the BI analysis question and the Few-shot example similar to the BI analysis question are retrieved from the knowledge base module step by step; Prompt word construction unit: responsible for managing large language model multi-level question and answer prompt word templates, including: business table discrimination prompt word template, Text-to-SQL thought chain prompt word template, SQL correction prompt word template and database dialect prompt word template; responsible for executing each level of prompt word construction process, according to the associated business knowledge obtained by business rule retrieval, based on the prompt word template corresponding to the existence or absence of each type of knowledge, assembling each level of prompt word step by step; Large language model scheduling unit: responsible for scheduling text large language model service or programming large language model service in the business table discrimination stage, SQL reasoning stage and SQL correction stage of the business process, thereby providing the intelligent reasoning capability required in each stage, and providing configurable functions of large language model service; Database connection unit: responsible for executing large language model reasoning in the database to generate SQL, and outputting the SQL execution result according to the interface specification, and providing configuration capability of database connection, in addition, also providing the ability to connect external execution interface of the database.
[0013] Further, the BI business information includes business index, aggregation type, date and time, and data dictionary.
[0014] The beneficial effects of the present application are: The present application realizes the construction of a professional field BI question and answer system with low cost and high flexibility under the condition of not fine-tuning the large language model.
[0015] In the application, the AI workflow opens the following configuration items for system secondary development configuration modification: Prompt word template configuration: business table discriminant prompt word template, Text-to-SQL thought chain prompt word template, SQL correction prompt word template, and database dialect prompt word template.
[0016] Database or search engine connection configuration: support for MySQL, Oracle, PostgreSQL, SQLite, Hive, Elasticsearch, and openlookeng connection configuration.
[0017] Database query interface configuration: in addition to supporting direct configuration of a data source in the system for SQL execution, an interface configuration of transmitting SQL to an external database query interface is also supported. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 The figure is a schematic diagram of the framework of the application; Figure 2 The figure is a schematic diagram of the program running flow of the application. DETAILED DESCRIPTION
[0019] The application will be further illustrated below in combination with the drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the application and are not used to limit the scope of the application.
[0020] In combination with the drawings Figure 1 As can be seen, the system of the application includes a user interaction module, an AI workflow module, and a knowledge base module, and the following connection relationships exist between the modules of the system: Connection relationship 1: the user interaction module is connected to the knowledge base module, and the user interaction module transmits business data table knowledge and business index knowledge written by a user on a front page to the knowledge base module; Connection relationship 2: the user interaction module is connected to the AI workflow module, and the user interaction module transmits a BI analysis question written by a user on a front page to the AI workflow module; Connection relationship 3: the AI workflow module is connected to the knowledge base module, and the AI workflow module retrieves business knowledge from the knowledge base module based on the BI analysis question; Connection relationship 4: the AI workflow module is connected to the user interaction module, and the AI workflow module transmits a BI analysis result generated based on the BI analysis question to the user interaction module; Connection relationship 5: the user interaction module is connected to the knowledge base module, and when a user makes positive / feedback on the BI analysis result, the user interaction module transmits this question and answer record to the knowledge base module.
[0021] The application will be further illustrated below in combination with the drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the application and are not used to limit the scope of the application.Figure 2 The system operation flow of the present application is shown, taking the BI analysis of the MRO (industrial equipment maintenance, repair, operation) system equipment history module as an example, the process of the system to quickly realize the MRO equipment history intelligent BI question and answer system is as follows: Step 1: The user configures business knowledge in the business knowledge configuration unit of the user interaction module.
[0022] Step 1.1: The user configures business data table information in the business knowledge configuration unit of the user interaction module, including: table name, table description, table field name, field type, field description, field name synonym, and field corresponding data dictionary value. Among them: table field name, field type, field description, and field corresponding data dictionary value are obtained directly from the relational database by the user after configuring the table name, and the field name synonym needs to be configured manually by the user.
[0023] Further, the business data table described in step 1.1 is added with an explanation: in order to reduce the query complexity, BI analysis usually does not directly query based on the entity table of the business system, but integrates the business fields / indicators concerned by the user into a view table (a virtual business data table constructed by a fixed SQL statement) as much as possible. The configuration of the business view table of the MRO equipment history in the system is as shown in Table 1: Table 1
[0024] Step 1.2: The user configures business indicator knowledge in the business knowledge configuration unit of the user interaction module, including: business indicator name, indicator interpretation, indicator synonym, belonging business table, associated table field, and indicator evaluation pseudo-SQL. The configuration of the business indicators of the MRO equipment history in the system is as shown in Table 2: Table 2
[0025] Step 1.3: The knowledge base module obtains the business data table knowledge and business indicator knowledge configured in steps 1.1 and 1.2 transmitted by the user interaction module, and stores them in the corresponding knowledge base.
[0026] Step 2.1: The user inputs the MRO equipment history related BI analysis question in the question and answer unit of the user interaction module, and the background program transmits the BI analysis question to the AI workflow module.
[0027] Step 2.2: The AI workflow module obtains the BI analysis question output in Step 2.1. Using the BI analysis question as the retrieval basis, it uses the text similarity retrieval method to calculate the similarity between the BI analysis question and the table descriptions and field descriptions of each business table in the business data table knowledge of the knowledge base module, and recalls the information of the top 3 business tables with the highest text similarity to the BI analysis question.
[0028] Step 2.3: The prompt word construction unit constructs a business table to determine prompt words for the BI analysis question. The detailed process for this step is as follows: Step 1: Obtain the business table discrimination prompt template. The template includes the main objective, business table information, and current task. The [main objective] is fixed, that is: determine which business data table the current task should be queried based on the provided 3 business table information. Step 2: Combine the business table information (table name, table description, table field name, field type, field description, field name synonyms, and corresponding data dictionary values) retrieved from the knowledge base into DDL.
[0029] Step 3: Fill the [Business Table Information] section of the prompt with the DDL of the three business tables, and fill the [Current Task] section with the BI analysis question. The final prompt example is as follows:
[0030] Target: Determine which business table the user's question should be queried from, and output the table name without explanation.
[0031] Business table information: [{'EQASSET': "CREATE TABLE EQASSET (ASSETNUM TEXT COMMENT 'Equipment Number',…) COMMENT 'Equipment Ledger';"}, {'OTR_EQPR_FAULT': "CREATE TABLE OTR_EQPR_FAULT (ASSETNUM TEXTCOMMENT 'Faulty Equipment Number',…) COMMENT 'Fault Record Table';"} Current task: The number of units of each model delivered in 2024.
[0032] Step 2.4: The large language model scheduling unit calls the Deepseek large language model. This system uses the open-source large language model Deepseek-R1-32B. The business table judgment prompt words assembled in Step 2.3 are input into the Deepseek large language model to determine the business table that should be queried for the BI analysis question entered by the current user, and the table name is output. For example: EQASSET.
[0033] Step 2.5: The business rule retrieval unit calls the business rule model to make a date time period matching analysis for the BI analysis question, using regular matching to uniformly parse various date questions in the question into the expression of "BETWEEN start date AND end date", and the current business rule model supports the following date questions as shown in Table 3: Table 3
[0034] Step 2.6: The business rule retrieval unit calls the business rule model to make an aggregation type matching analysis for the BI analysis question, using regular matching to uniformly convert various aggregation questions in the question into corresponding function expressions, and the current business rule model supports the following aggregation questions as shown in Table 4: Table 4
[0035] Step 2.7: The business rule retrieval unit calls the business rule model to make a business knowledge matching for the BI analysis question. Based on the table name output in step 2.4, recall the field data dictionary and business metric knowledge belonging to the table from the knowledge base module and business metric knowledge, and the input and output parsing process is as follows: Input: - bi_question: BI analysis question, for example: Statistics of the over-protected days of the aircraft and navigation radar? - table_name: Table name output in step 2.4, for example: EQASSET; Process: First step: bi_question word segmentation processing: word segmentation needs to use common word dictionary and Chinese stop word dictionary, and the word segmentation result is defined as bi_question_words; Second step: Find out the relevant data dictionary: find out the data dictionary belonging to the table_name from the knowledge base, defined as table_data_dict, and the detailed content of table_data_dict is shown in the [field corresponding data dictionary] of step 1.1 table; Third step: Data dictionary matching: compare the words of bi_question_words with the dictionary items of table_data_dict to locate the data dictionary and field corresponding to the overlapping words; Fourth step: Find out the relevant business metrics: find out the business metric knowledge belonging to the table_name from the knowledge base, defined as business_metrics, and the detailed content of business_metrics is shown in the table of step 1.2. Step 5: Business metric retrieval: Compare the vocabulary of bi_question_words with the business metric names and metric synonyms of business_metrics to locate the business metrics corresponding to the overlapping vocabulary. Step 6: Business-related knowledge assembly: Combine the dictionaries and fields, business metrics located in steps 3 and 6 according to the rules and output.
[0036] Output: - Business-related knowledge: defined as business_knowledge, Examples are as follows: Tip1 Metric [Over Warranty Days]: The number of days that the product has exceeded the warranty date, reference SQL: TRUNC(SYSDATE) - TRUNC(WARRANTY).
[0037] Tip2 Dictionary filter condition: ASSETTYPE IN (passenger_plane, navigation_radar).
[0038] Tip3 Dictionary filter condition: ISWARRANTY = 'OUTWARRANTY.
[0039] Step 2.8: The business rule retrieval unit calls the business rule model using the semantic similarity retrieval method to retrieve historical user questions similar in semantics to the BI analysis question from the Few-shot examples in the knowledge base module based on the BI analysis question, and the SQL statement corresponding to the question.
[0040] Step 2.9: Based on all the information retrieved by the business rules in steps 2.4~2.8, the prompt word generation unit begins to combine the Text-to-SQL prompt words, and the detailed process of this step is as follows: First step: Obtain the Text-to-SQL prompt word template, which contains six parts: main task, business data table information, reasoning basis, SQL reasoning thought chain, output specification, and current task. Among them, the main task is fixed, that is, to generate a SQL statement based on known information and not to explain.
[0041] Second step: Obtain the BI analysis question, historical dialogue, and business-related knowledge retrieved by the business rules. Third step: Extract the business table information to be queried in the associated business knowledge and combine it into the DDL of the business table to fill in the [business data table information] part of the prompt word framework.
[0042] Step 4: Extract the date and time period, aggregation type, business indicators, and few-shot examples from the related business knowledge objects, determine the existence of each piece of information one by one, and then organize the prompt text corresponding to each piece of information to construct the [reasoning basis] part of the prompt word framework.
[0043] Step 5: Construct the [SQL Reasoning Thinking Chain] prompts in the following order: Identify the statistical requirements of the input question -> Locate the relevant columns -> Define SELECT information -> Determine the filtering conditions -> Add historical dialogue conditions.
[0044] Step 6: Based on the database configuration information, select the database dialect output specification prompt word corresponding to its database type and fill it into the [Output Specification] section of the prompt word frame.
[0045] Step 7: Fill the prompt word [Current Task] with the input question. The final Text-to-SQL prompt word example is as follows: Main Objectives
[0046] I need you as an SQL generation assistant to generate Oracle SQL queries based on table information, current task instructions, and evidence, without providing explanations.
[0047] [Business Data Table Information] CREATE TABLE EQASSET (ASSETNUM TEXT COMMENT 'Equipment Number',…) COMMENT 'Equipment Ledger'; [Basis for Reasoning] Tip 1: The indicator [Days Beyond Warranty] refers to the number of days that a product's warranty has expired. Refer to SQL: TRUNC(SYSDATE) - TRUNC(WARRANTY). Tip 2: Dictionary filtering criteria: ASSETTYPE IN (passenger_plane, navigation_radar) Tip 3: Dictionary filter criteria: ISWARRANTY = 'OUTWARRANTY' Tip 4 Few-shot example: Question 1: Calculate the number of days past the warranty period for each piece of equipment. SQL1:SELECT …FROM EQASSET WHERE …; (Question2-SQL2 and Question3-SQL3 are omitted here) [SQL Reasoning Thinking Chain] Step 1: Understand the requirements: Based on the input question and hints, determine the core requirements of the query (such as filtering conditions, aggregation, sorting, etc.).
[0048] Step 2: Identify relevant columns: Analyze the input question and [Business Data Table Information] to determine which columns are involved (such as filtering, sorting, grouping, or result set).
[0049] Step 3: Define the SELECT clause: Based on [Input Question] and [Business Data Table Information], decide which columns to include in the SELECT statement. Ensure that the selected columns provide sufficient information.
[0050] Step 4: Determine filtering conditions: Use the values provided in [Reasoning Basis] as filtering conditions. Check if additional conditions are needed and accurately map them to the corresponding fields and values.
[0051] Step 5: If the input question is related to [Historical Conversations], inherit relevant filtering conditions when generating SQL.
[0052] [Output Specification] Please format the generated SQL output as follows, without any additional content: ```sql The SQL you generated ``` PS1: Must avoid using SELECT *.
[0053] PS2: The generated SQL must comply with Oracle SQL standards.
[0054] [Current Task] Historical Conversations: … (omitted).
[0055] Input Question: Count the number of over-protected days for both commercial aircraft and navigation radars.
[0056] Step 2.10: The large language model scheduling unit calls the programming large language model, and the system uses the open-source large language model Qwen2.5-Coder-32B. The industry Text-to-SQL hint words assembled in step 2.9 are input into the programming large language model, and the SQL statement corresponding to the current user's input BI analysis question is inferred.
[0057] Step 2.11: The database connection unit executes the SQL statement output in step 2.10 in the currently specified database. If the execution is successful, output: {"success": <result>If execution fails, output {"failed":}<error_message >} Step 2.12: Based on the output of Step 2.11, there are two possible scenarios: SQL execution is successful: The <result> data is visualized into statistical charts and tables, and the statistical charts are sent to the user interaction module; When SQL execution fails: the prompt word construction unit constructs an SQL correction prompt word based on <error_message>, and the detailed process is as follows: Step 1: Obtain the SQL correction prompt template. The template includes the main target, business table information, exception error, and currently executing SQL. The [main target] is fixed, that is: correct the currently executing SQL statement based on the provided business table information and exception error information.
[0058] Step 2: Obtain the interface execution exception returned by the database execution unit: the currently executing SQL statement and the exception error message.
[0059] Step 3: Combine the currently used business table information (table name, table description, table field name, field type, field description, field name synonyms, and the corresponding data dictionary values of the fields) into DDL.
[0060] Step 4: Fill the [Business Table Information] section of the prompt with the DDL output from the previous step, and fill the [Error Message] and [Currently Executing SQL] sections of the prompt with the exception information and the currently executing SQL statement. The final SQL correction prompt example is as follows:
[0061] Main Objectives You are an SQL syntax expert. The current SQL statement is throwing the following error during database execution. Please correct the SQL based on the database table information and the error message. Output the corrected SQL without explanation, only providing a suggested solution. [Business Table Information] Table structure information CREATE TABLE EQASSET (ASSETNUM TEXT COMMENT 'Equipment Number',…) COMMENT 'Equipment Ledger'; 2. Table field value information {ASSETTYPE: {passenger_plane:passenger aircraft, aew_radar:airborne early warning radar, navigation_radar:navigation radar, aviation_weather_radar:aviation weather radar}}.
[0062] FDJ: engine.
[0063]
Execution exception error
[0064]
Current exception SQL
[0065]
Output specification
[0066] SQL execution is failed: further, the large language model scheduling unit schedules a programming large language model, submits the above SQL correction prompt word to the programming large language model for reasoning correct executable SQL, and after 3 rounds of iteration, if there is still no executable SQL generated, sends the prompt information of "unable to answer" to the user interaction module.
[0067] The user interaction module's question and answer unit in step 3.1 obtains the BI analysis result returned by the AI workflow module and displays it in the foreground page to show the user.
[0068] Step 3.2 of the user interaction module's question and answer page provides a feedback button, and the user makes feedback on the result of this round of question and answer. If the user approves the answer, the BI analysis question and result of this round of question and answer are sent to the Few-shot example in the knowledge base module as an example.
[0069] All the above processes describe the implementation method of the intelligent BI question and answer system based on business rule retrieval and AI workflow by taking the BI question and answer of MRO equipment history as an example. Through actual application verification, the implementation method of the system can be quickly applied to BI question and answer in specific business fields under the condition that the large language model does not perform supervised fine-tuning training. Those skilled in the art can understand that unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art to which the present application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the prior art, and unless defined as such, should not be interpreted in an idealized or overly formal sense.
[0070] Based on the above ideal embodiments according to the present application, through the above description, relevant personnel can make various changes and modifications without deviating from the technical idea of the present application.< / result>
Claims
1. A BI intelligent question-answering method based on business rule retrieval and AI workflow, characterized in that, Includes the following steps: Step 1: Business rule configuration: Users configure business table knowledge and business indicator knowledge in the user interaction module, and the knowledge base module manages the knowledge. Step 2: Business rule retrieval: The AI workflow module obtains the BI analysis questions passed in by the user interaction module and schedules the business retrieval unit to process the BI analysis questions; Step 3: AI workflow scheduling data rule retrieval unit, prompt word construction unit, large language model scheduling unit, and database connection unit: Step 3.1: Data rule retrieval unit scheduling: After the BI analysis question is input, the business table information retrieval node, date and time period rule matching node, aggregation type judgment node, business indicator matching node, and Few-shot example retrieval node are executed sequentially. Step 3.2: Prompt word construction unit: In the business table discrimination stage, the Text-to-SQL stage, and the SQL correction stage, the corresponding prompt word templates are scheduled, and the known information of each stage is filled into the prompt word templates; Step 3.3: Large Language Model Scheduling Unit: Scheduling appropriate large language models to provide model inference services during the business table discrimination stage, the Text-to-SQL stage, and the SQL correction stage, respectively. The large language models include the thinking large language model and the programming large language model. Step 3.4: Database connection unit: Schedules the database query interface to execute SQL statements and obtains the execution results. The interface can be an internal interface or an external interface.
2. The BI intelligent question answering method based on business rule retrieval and AI workflow according to claim 1, characterized in that, Step 1 specifically includes: Step 1.1: Configure business data table information in the business knowledge configuration unit of the user interaction module. The table field name, field type, field description, and corresponding data dictionary value are directly obtained from the relational database after the user configures the table name. The field name synonyms need to be manually configured by the user. Step 1.2: Configure business indicator knowledge in the business knowledge configuration unit of the user interaction module; Step 1.3: The knowledge base module obtains the business data table knowledge and business indicator knowledge configured in steps 1.1 and 1.2 from the user interaction module and stores them in the corresponding knowledge base.
3. The BI intelligent question answering method based on business rule retrieval and AI workflow according to claim 1, characterized in that, The execution process of the business rule retrieval unit in step 2 is as follows: 2.1: Retrieve the top three business data table entries from the business data table knowledge in the knowledge base module that are closest to the BI analysis question text; 2.2: Determine the business data table to query for the BI analysis problem, and output the table name and information of the business data table; 2.3: Match date queries in BI analysis questions and unify the various date queries in the questions into the expression "BETWWEN Start Date AND End Date"; 2.4: Match aggregate function questions in BI analysis questions and convert various aggregate function questions into corresponding function expressions; 2.5: Retrieve field data dictionaries and business indicator knowledge associated with business data tables in the knowledge base module. After word segmentation of the BI analysis question, match it one by one with business indicator nouns and their synonyms and field data dictionaries to obtain the business indicator nouns and data dictionaries involved in the question. 2.6: Retrieve the top three "BI analysis question -> SQL" Q&A records from the Few-shot example knowledge in the knowledge base module that are closest to the BI analysis question text; 2.7: Combine the identified business tables to be queried, date and time periods, aggregation types, business metrics, and few-shot examples into a related business knowledge object for the BI analysis question, and the business rule retrieval process ends.
4. The BI intelligent question answering method based on business rule retrieval and AI workflow according to claim 1, characterized in that, The method for constructing the Text-to-SQL thought chain prompts in step 3.2 is as follows: Step 3.21: Create a framework, which includes: main objectives, business data table information, reasoning basis, SQL reasoning thought chain, and output specifications. Use the Text-to-SQL thought chain prompt template to create the current task. Step 3.22: Fill in the business data table information, obtain the associated business knowledge object output by the business rule retrieval process described in step S7, extract the business table information to be queried from it, combine it into the business table DDL, and fill it into the [business data table information] part of the prompt word frame; Step 3.23: Construct the reasoning basis, extract the date and time period, aggregation type, business indicators, and few-shot examples from the related business knowledge objects, determine the existence of each piece of information one by one, and then organize the prompt text corresponding to each piece of information to construct the [reasoning basis] part of the prompt word framework; Step 3.24: Construct the SQL reasoning thought chain, following the order of: identifying the statistical requirements of the input question -> locating relevant columns -> defining SELECT information -> determining filtering conditions -> adding historical dialogue conditions, to construct the [SQL reasoning thought chain] prompt words; Step 3.25: Fill in the output specification. The prompt word construction unit has preset output specification templates for the database dialects of each relational database. According to the database configuration information provided by the database connection unit, select the corresponding output specification template and fill it into the [output specification] part of the prompt word frame. Step 3.26: Publish the current task and fill in the prompt word [Current Task] with the input question.
5. A system for implementing the BI intelligent question-answering method based on business rule retrieval and AI workflow as described in any one of claims 1-4, characterized in that, include: The system comprises a user interaction module, an AI workflow module, and a knowledge base module, and the following connection relationships exist between these modules: Connection Relationship 1: The user interaction module is connected to the knowledge base module, and the user interaction module transmits the business data table knowledge and business indicator knowledge written by the user on the front-end page to the knowledge base module; Connection Relationship 2: The user interaction module is connected to the AI workflow module, and the user interaction module transmits the BI analysis questions written by the user on the front-end page to the AI workflow module; Connection Relationship 3: The AI workflow module is connected to the knowledge base module, and the AI workflow module retrieves business knowledge from the knowledge base module based on the BI analysis question; Connection Relationship 4: The AI workflow module is connected to the user interaction module, and the AI workflow module transmits the BI analysis results generated based on the BI analysis problem reasoning to the user interaction module; Connection Relationship 5: The user interaction module is connected to the knowledge base module. When the user provides positive feedback on the BI analysis results, the user interaction module transmits the question and answer record to the knowledge base module.
6. The system according to claim 5, characterized in that, The execution process of the user interaction module, AI workflow module, and knowledge base module is as follows: User Interaction Module: The user interaction module provides a button and intelligent dialogue window to trigger intelligent dialogue. The BI analysis questions entered by the user in the dialogue window are transmitted to the AI Workflow Module. The AI Workflow Module generates BI analysis results and displays them in the intelligent dialogue window. It also provides a business information configuration page, which transmits the information configured by the user on the page to the knowledge base. Knowledge Base Module: The knowledge base module receives business data tables and business indicator knowledge written by users in the user interaction module and stores them in the corresponding knowledge base; it also retrieves the question-and-answer records that users have confirmed as correct in the user interaction module and stores them in the Few-shot sample library. AI Workflow Module: Based on the workflow engine, it receives BI analysis questions input by the user in the user interaction module, schedules the business rule retrieval unit and the large language model step by step, retrieves business data tables and business indicator knowledge related to the BI analysis question based on the knowledge base module, and gradually constructs Text-to-SQL thought chain prompts, enabling the large language model to infer the SQL statement corresponding to the BI analysis question; after visualizing the execution result of the SQL statement in the database, it transmits it to the user interaction module as the BI analysis result.
7. The system according to claim 5, characterized in that, The knowledge managed by the knowledge base module specifically includes: Business data table knowledge: Information on each business data table used includes: table name, table description, table field name, field type, field description, field name synonyms, and the corresponding data dictionary value for each field; Business metrics knowledge: Business metrics within the scope of business include: business metric name, business metric definition, business metric synonyms, business table to which it belongs, related table fields, and pseudo-SQL for metric evaluation; Few-shot example: Several BI analysis Q&A records covering the business scope. Each record includes: the BI analysis question and the corresponding SQL statement.
8. The system according to claim 5, characterized in that, The AI workflow module specifically includes: Business Rule Retrieval Unit: Responsible for executing the business rule retrieval process, based on rule matching and text similarity retrieval, and retrieving business data table information, BI business information related to the BI analysis question, and Few-shot examples similar to the BI analysis question from the knowledge base module step by step according to the BI analysis question; The prompt word construction unit is responsible for managing the multi-level question-answering prompt word templates of the large language model, including: business table discrimination prompt word templates, Text-to-SQL thinking chain prompt word templates, SQL correction prompt word templates, and database dialect prompt word templates; it is responsible for executing the prompt word construction process at each level, retrieving related business knowledge according to business rules, and assembling prompt words at each level step by step based on the prompt word templates corresponding to the existence or absence of various types of knowledge. Large Language Model Scheduling Unit: Responsible for scheduling text-based large language model services or programming-based large language model services during the business table discrimination stage, SQL reasoning stage, and SQL correction stage of the business process, thereby providing the intelligent reasoning capabilities required at each stage, and providing configurable functions for the large language model service; Database connection unit: responsible for executing large language model inference to generate SQL in the database, outputting the SQL execution results according to the interface specification, providing database connection configuration capabilities, and also providing the ability to connect to external database execution interfaces.
9. The system according to claim 5, characterized in that, The BI business information includes business metrics, aggregation types, date and time, and a data dictionary.
Citation Information
Patent Citations
Method, system and equipment for generating SQL (Structured Query Language) statement based on large model
CN119127913A
Power field SQL intelligent agent construction method based on KMDI chain
CN119166662A
Data analysis method, device and equipment and computer storage medium
CN120336346A
Method for obtaining visual chart through question and answer mode access based on FineBI and Text2DSL
CN120407669A
Method and system for realizing Text2SQL (Structured Query Language)
CN120470020A
Cited By
Holographic flow monitoring method and system based on AI and BI
CN121441643A
Intelligent number asking method based on adaptive rule constraint and program product
CN122086959A
Method, system, computer device and storage medium for intelligent questioning
CN122432194A