Natural language search method, device and electronic equipment
By using a multi-stage pipeline processing approach, the natural language query problem is decomposed into steps such as intent recognition, query rewriting, and process orchestration. This solves the problem of insufficient understanding of complex business scenarios in existing technologies, and enables high-precision data query and visualization result generation, making it suitable for industry scenarios with high data accuracy requirements.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-04-07
AI Technical Summary
Existing natural language lookup systems are unable to handle complex business scenarios, especially in the highly specialized energy and power industry, and suffer from problems such as insufficient understanding of ambiguous and complex intentions, lack of decomposition and planning capabilities, superficial application of domain knowledge, and a disconnect between visualization results and user analysis intentions.
A multi-stage pipeline processing approach is adopted to decompose the natural language query problem into four stages: intent recognition, query rewriting, annotation injection, process orchestration, and intelligent graph generation. Through a progressive approach, the natural language query input by the user is transformed into a clear and accurate set of data results, including intent classification, standardized query generation, structured execution plans for multiple atomic tasks, and final visualization chart generation.
It significantly improves the accuracy of complex queries, ensures a precise understanding of users' true intentions, deeply integrates knowledge from the power industry, and generates data visualization charts that closely match users' analytical intentions, providing valuable business insights.
Smart Images

Figure CN121350071B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a natural language data lookup method, apparatus, and electronic device. Background Technology
[0002] With the development of big data and artificial intelligence technologies, Natural Language Interface to Database (NLIDB) technology, which aims to enable business personnel without professional technical backgrounds to directly query and analyze data through natural language, has become a hot topic in the industry.
[0003] Currently, mainstream natural language query systems typically employ an "end-to-end" processing model. This model receives the user's natural language query and attempts to directly convert it into executable machine instructions, such as Structured Query Language (SQL) queries, through one or two steps. Specifically, these systems usually incorporate the following technologies: 1. Basic Natural Language Processing (NLP): The system first parses the user's input query, using techniques such as intent recognition and entity extraction to understand the user's basic needs. For example, when processing the query "Query the electricity consumption in region A," the system will identify the query intent and key entities such as "region A" and "electricity consumption." 2. Retrieval Augmented Generation (RAG): To improve query accuracy, some more advanced systems have introduced RAG technology. Before generating the final query, this technology retrieves relevant database table structure information (schema) from a knowledge base based on the keywords in the user's original question, and provides this information as context to the Large Language Model (LLM) to help the model generate query statements that are more in line with the actual database situation.
[0004] While existing technologies have made some progress in simplifying data queries, their end-to-end processing model is insufficient for handling real-world, complex business scenarios, especially in the highly specialized energy and power industry, where multi-step reasoning is required for analytical tasks. Therefore, an effective solution is urgently needed to address these technical challenges. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a natural language query method, apparatus, and electronic device. It logically decomposes and plans the fuzzy and complex natural language query problem, systematically transforming it into a clear, accurate, and executable analysis task through a step-by-step approach. This enables the gradual and systematic transformation of user-input natural language statements into a precise data result set, thereby significantly improving the accuracy of complex queries and enabling reliable application in industry scenarios with high data accuracy requirements.
[0006] In a first aspect, the present invention provides a natural language data lookup method, which includes the following steps:
[0007] The system receives a user's natural language query string, performs intent recognition on the natural language query string based on a preset intent system, and outputs the user's intent classification result; the intent classification result is represented by a unique intent code.
[0008] Based on the intent classification results, the natural language query string, and the terminology database, the natural language query string is rewritten to output a standardized query.
[0009] Based on the normalized query and the intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the structured execution plan is executed to obtain a data result set; the orchestration of the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical caliber, professional classification, and data source.
[0010] According to a natural language query method provided by the present invention, the preset intent system includes a pre-defined intent system or a specified intent system; the step of performing intent recognition on the natural language query string based on the preset intent system and outputting the user's intent classification result includes:
[0011] The natural language query string is matched against the preset intent system or the specified intent system to obtain a structured intent object including at least one classification code; wherein the intent recognition supports single intent mode or multi intent mode;
[0012] Based on the structured intent object, prompt words are dynamically generated, and the structured intent object and the corresponding prompt words are determined as the intent classification result.
[0013] According to a natural language query method provided by the present invention, the step of rewriting the natural language query string based on the intent classification result, the natural language query string, and a terminology database, and outputting a standardized query, includes:
[0014] Based on the natural language query string, determine the current time context;
[0015] Based on the current time context and the preset time term library, the relative time expression in the natural language query string is converted into an absolute time range to obtain the normalized time information;
[0016] Based on the terminology database, synonym mapping and concept disambiguation are performed on the proper nouns in the natural language query string to obtain recall terminology information related to the natural language query string; the terminology database contains a set of synonyms for the proper nouns and annotations of thought processes used to explain the differences between the proper nouns and their synonyms;
[0017] The recalled noun information, the normalized time information, and the historical dialogue context are engineered and arranged using a pre-set template to generate the normalized query represented in a structured format.
[0018] According to a natural language data lookup method provided by the present invention, the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules, and labeled samples.
[0019] According to a natural language data lookup method provided by the present invention, the step of orchestrating the natural language data lookup task corresponding to the natural language query string based on the labeled query and the intent classification result to generate the structured execution plan includes:
[0020] Based on the labeled query intent and the relevant business rules, the natural language data lookup task is decomposed into multiple atomic tasks, and a parent atomic task is assigned to each atomic task.
[0021] Based on the dependencies between the atomic tasks, the atomic tasks are organized into a directed acyclic graph (DAG), and the DAG is determined as the structured execution plan; wherein, the nodes of the DAG represent the atomic tasks, and the edges of the DAG represent the dependencies between the atomic tasks.
[0022] According to a natural language lookup method provided by the present invention, the method further includes:
[0023] Based on the data result set, the intent classification results, and the structured execution plan, a visualization chart is generated;
[0024] Based on the visualization charts, text results of natural language analysis are automatically generated; the text results represent natural language summaries corresponding to the key features of the data result set.
[0025] According to a natural language data lookup method provided by the present invention, the step of generating a visualization chart based on the data result set, the intent classification result, and the structured execution plan includes:
[0026] Determine the size of the data result set;
[0027] When the amount of data is less than a preset threshold, the model directly generates the corresponding visualization chart configuration based on the data result set, the intent classification result, and the structured execution plan, using either a free generation or template generation method.
[0028] If the data volume is greater than or equal to the preset threshold, data aggregation is performed to obtain aggregated data; or, code is sampled and the data result set is aggregated based on the code to obtain the aggregated data.
[0029] The visualization chart is generated based on the visualization chart configuration, the aggregated data, the data result set, the intent classification results, and the structured execution plan.
[0030] According to a natural language data lookup method provided by the present invention, the step of generating a visualization chart based on the data result set, the intent classification result, and the structured execution plan includes:
[0031] Based on the intent types identified in the intent classification results and the structured execution plan, assign appropriate chart types to the data result set;
[0032] The visualization chart is generated based on the appropriate chart type, and data anomalies or abnormal ranges are automatically marked in the visualization chart.
[0033] Secondly, the present invention also provides a natural language counting device, which includes the following modules:
[0034] The intent classification module is used to receive the user's natural language query string, perform intent recognition on the natural language query string based on a preset intent system, and output the user's intent classification result; the intent classification result is represented by a unique intent code.
[0035] The query rewriting module is used to rewrite the natural language query string based on the intent classification result, the natural language query string, and the professional terminology database, and output a standardized query.
[0036] The process orchestration and execution module is used to orchestrate the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result, generate a structured execution plan including multiple atomic tasks, and execute the structured execution plan to obtain a data result set. Specifically, the process orchestration and execution module uses the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; it then performs information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; and finally, it orchestrates the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and relevant business rules in the domain context information to generate the structured execution plan. The annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical definitions, professional classifications, and data sources.
[0037] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the natural language lookup methods described above.
[0038] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the natural language lookup method as described above.
[0039] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the natural language lookup methods described above.
[0040] The natural language data lookup method, apparatus, and electronic device provided by this invention first receive a user's natural language query string, perform intent recognition on the query string based on a preset intent system, and output the user's intent classification result, which is represented by a unique intent code; then, based on the intent classification result, the query string, and a terminology database, the query string is rewritten to output a standardized query; furthermore, based on the standardized query and intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the plan is executed to obtain a data result set; based on the standardized query and intent classification result, the natural language query... The natural language data lookup task corresponding to the string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks. These tasks include: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; and orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, intent classification results, and relevant business rules in the domain context information to generate a structured execution plan. The annotated query includes the normalized query and all retrieved business context information related to the normalized query.
[0041] This invention proposes an innovative natural language query method. This method employs a pipelined processing approach, logically decomposing and planning the complex natural language query problem. Through a step-by-step, progressive approach, it systematically transforms the problem into a clear, accurate, and executable analysis task. This method progressively and systematically converts user-input natural language statements into precise data result sets, thereby significantly improving the accuracy of complex queries. It can be reliably applied to industry scenarios with high data accuracy requirements. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 This is one of the flowcharts of the natural language data lookup method provided by the present invention.
[0044] Figure 2 This is the second flowchart of the natural language data lookup method provided by this invention.
[0045] Figure 3This is a schematic diagram of the natural language counting device provided by the present invention.
[0046] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0048] To more clearly understand the various embodiments provided by the present invention, the technical content involved in the present invention will first be described as follows:
[0049] While existing technologies have made some progress in simplifying data queries, their "end-to-end" processing model exposes the following core shortcomings when dealing with real and complex business scenarios, especially in the highly specialized energy and power industry:
[0050] 1. Insufficient ability to understand ambiguous and complex intentions: Natural language itself is full of ambiguity. Existing systems directly process users' raw, colloquial questions. When the question contains ambiguous terms (such as "five standards and seven rates" or "high-loss transformer areas" in the power industry) or complex analytical intentions (such as "comparative analysis of the reasons for the difference in line loss rates between power supply companies A and B last month"), the system is very prone to misunderstanding in the first step. These initial minor errors will be amplified in subsequent processing, ultimately leading to the generation of completely incorrect query results.
[0051] 2. Lack of ability to decompose and plan natural language query tasks: Real-world business analysis is often not a single query action, but a combination of multiple logical steps. For example, to answer "Why did the electricity bill collection rate in a certain region decrease last month?", the system needs to first query the current and past electricity bill collection rates, then query potentially related user payment details, overdue payment records, etc., and finally perform comparative analysis. Existing end-to-end systems lack mechanisms for logically decomposing and planning steps for such complex problems, making it unable to complete analytical tasks requiring multi-step reasoning.
[0052] 3. Superficial application of domain knowledge leads to the "illusion" problem: Standard RAG technology typically only retrieves the physical structure information of the database, ignoring the underlying business logic and industry knowledge. For example, the system may know that "line loss rate" is a field, but it may not know its calculation formula, business definition, or normal fluctuation range. Furthermore, directly using the user's vague original question for retrieval often results in irrelevant or incorrect contextual information being retrieved due to imprecise keywords—a "garbage in, garbage out" scenario. This exacerbates the "illusion" of the large language model, generating logically invalid queries.
[0053] 4. Disconnect between visualization results and user analytical intent: In existing technologies, chart generation is usually a separate step after data querying is completed. Because the user's original analytical intent (e.g., whether they want to "compare trends" or "view distributions") is lost during processing, the system can only "guess" the appropriate chart type based on the structure of the returned data table. This often results in generated charts that fail to effectively answer the user's questions; for example, using a pie chart to display time trends or a scatter plot to compare categorical data, making the visualization results lack insight.
[0054] The purpose of this invention is to overcome the aforementioned deficiencies of existing technologies and provide a novel natural language data lookup method, apparatus, and electronic device. The natural language data lookup method is based on a multi-stage pipelined processing approach. This invention aims to achieve the following objectives by decomposing a complex natural language understanding and analysis task into five stages: intent recognition, query rewriting, annotation injection, process orchestration, and intelligent graph generation:
[0055] 1. Systematically eliminate the ambiguity of natural language to ensure an accurate understanding of the user's true intentions;
[0056] 2. Implement logical decomposition and planning for complex analysis and diagnostic problems;
[0057] 3. Deeply integrate knowledge from the power sector to ensure that the query process conforms to industry business logic and reduces error generation;
[0058] 4. Ensure that the final generated data visualization charts closely match the user's original analytical intent, providing truly valuable business insights.
[0059] The following is combined with Figures 1-4 The present invention describes a natural language lookup method, apparatus, and electronic device.
[0060] Figure 1 This is one of the flowcharts illustrating the natural language data lookup method provided by this invention, such as... Figure 1 As shown, the method includes the following:
[0061] Step 101: Receive the user's natural language query string, perform intent recognition on the query string based on the preset intent system, and output the user's intent classification result; the intent classification result is represented by a unique intent code.
[0062] Specifically, it should be noted that the execution subject of this embodiment is an electronic device, which is used to gradually and systematically transform the natural sentences input by the user into an accurate data result set, thereby significantly improving the accuracy of complex queries and can be reliably applied to industry scenarios with high data accuracy requirements (such as the power industry).
[0063] First, the system receives the user's raw input, performs preliminary analysis on the user's raw input to understand its core analysis objective, and uniquely categorizes the question into a preset classification system, that is, obtains the intent classification result.
[0064] The user's original input is a natural language query string. For example, an electricity marketing person might ask: "Analyze the electricity sales of a power supply unit in a certain area last quarter. Are there any anomalies?"
[0065] The preset intent system can be pre-built based on historical intent classification results, or based on intent classification results specified by the user. Each classification code in the preset intent system represents a different intent category (i.e., intent name), and corresponds to one or more similar questions, which represent historical query strings under that category.
[0066] The system matches the user's natural language query string against a predefined intent system. Once a similar question is found, it retrieves the lowest-level classification code (the finest level of classification code), which outputs the user's intent classification result.
[0067] Step 102: Based on the intent classification results, query string, and professional terminology database, rewrite the query string and output the normalized query.
[0068] After obtaining the intent classification results from intent recognition, the next step is to eliminate linguistic ambiguity and convert the query string into a standardized query that the machine can accurately understand. Standardization steps include: rule-based preprocessing, multi-source retrieval and template enhancement, contextual arrangement, and time and noun disambiguation.
[0069] Specifically, each step is briefly described below:
[0070] Rule-based preprocessing: Perform regular expression-based substitution on questions; preserve technical terms and their relative positions; and concatenate historical dialogues into context.
[0071] Multi-source retrieval and template enhancement: Parallel retrieval of nouns / organizations / dimensions / indicators, unified deduplication and merging according to source quotas; fall back to single-source or rule-based retrieval when multi-source retrieval fails; perform output and intermediate process quality checks on template samples.
[0072] Time and noun disambiguation: Disambiguation is performed using synonyms and explanatory information from a professional terminology database (noun set); complex time windows are derived according to agreed rules (such as year-level inter-period mapping); date granularity is kept consistent.
[0073] Context orchestration: The current time, historical context, nouns and templates are uniformly injected, along with precautions, and the output is in machine-readable format; intermediate inference information can be optionally returned for interpretation.
[0074] For example, based on intent classification results, query strings, and a glossary of technical terms, the query string can be rewritten to output a standardized query.
[0075] Step 103: Based on the normalized query and intent classification results, orchestrate the natural language data lookup task corresponding to the natural language query string to generate a structured execution plan including multiple atomic tasks, and execute the structured execution plan to obtain the data result set; The orchestration of the natural language data lookup task corresponding to the natural language query string based on the normalized query and intent classification results to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, intent classification results, and relevant business rules in the domain context information to generate a structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical caliber, professional classification, and data source.
[0076] Specifically, after obtaining the normalized query and intent classification results, before executing the natural language data lookup task, the complex analysis task (natural language data lookup task) is first decomposed into a series of logically clear and executable atomic steps (that is, generating an execution plan for multiple atomic tasks). This execution plan is a logical blueprint independent of the specific query language; it clearly defines "what to do" and "in what order," transforming complex analysis logic into a sequence of steps that the machine can understand and execute.
[0077] For example, the specific steps of the process arrangement include the following:
[0078] Input: Normalized query.
[0079] Processing: Based on the intent classification results (such as "analyze and diagnose") and the injected business rules, the system decomposes a macro-level analysis task into multiple atomic problems with logical dependencies. The orchestration process supports node-level timeout, retry, and degradation strategies, and supports combinations of preset templates and custom nodes.
[0080] Output: A structured execution plan, typically represented as a Directed Acyclic Graph (DAG).
[0081] For the example above, the generated execution plan might contain the following atomic tasks:
[0082] 1. Atomic Task 1.1: Query the total electricity sales of a local power supply unit in April 2024.
[0083] 2. Atomic Task 1.2: Query the total electricity sales of a local power supply unit in May 2024.
[0084] 3. Atomic Task 1.3: Query the total electricity sales of a local power supply unit in June 2024.
[0085] 4. Atomic Task 2 (Analysis Task 2) (Dependencies 1.1, 1.2, 1.3): Combine the results of the above three atomic tasks, calculate the monthly growth rate, and identify and mark abnormal months according to the injected business rules.
[0086] In this embodiment of the invention, the process orchestration is achieved through the following steps:
[0087] First, by employing Retrieval Augmented Generation (RAG) technology, rich and structured power sector knowledge and labeled assets are injected into the normalized query to obtain a labeled query. For example, this process includes:
[0088] Input: Normalized query;
[0089] Processing: ① Using the normalized query as a keyword, semantic retrieval is performed in a pre-built power domain vector knowledge base to obtain the domain context information corresponding to the normalized query.
[0090] This knowledge base not only contains the table structure information of the database, but also stores:
[0091] Noun set annotation: general knowledge, dimension, organization, and indicator terms and their synonyms / abbreviations mapping.
[0092] Indicator definitions and related business rules: such as statistical scope, professional classification, data sources, etc.
[0093] Corpus template annotation: templates and examples for intent recognition, query rewriting, question decomposition, slot extraction, general application programming interface (API), SQL generation, etc.
[0094] Annotated samples: High-quality samples and versions accumulated by the annotation platform.
[0095] Correspondingly, the domain context information for the retrieved standardized query includes the corresponding database table structure information, noun set annotations, indicator definitions, relevant business rules, and labeled samples.
[0096] ② Enhance the normalized query based on domain context information to generate annotated queries that include domain context information.
[0097] Output: A "Annotated Query" object. This object contains the normalized query and all retrieved, related business context information, providing a complete knowledge base for subsequent complex logic planning.
[0098] Furthermore, based on the labeled query and intent classification results, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate an execution plan. That is, the complex analysis task is decomposed into multiple atomic steps, and there are dependencies between the atomic steps.
[0099] The method provided in this embodiment first receives a user's natural language query string, performs intent recognition on the query string based on a preset intent system, and outputs the user's intent classification result, which is represented by a unique intent code. Then, based on the intent classification result, the query string, and a terminology database, the query string is rewritten to output a standardized query. Next, based on the standardized query and intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated, generating an execution plan including multiple atomic tasks, and the plan is executed to obtain a data result set. The process of orchestrating the natural language data lookup task corresponding to the natural language query string based on the standardized query and intent classification result is described above. The process of generating a structured execution plan comprising multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in a power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; enhancing the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, intent classification results, and relevant business rules in the domain context information to generate a structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, wherein the relevant business rules include statistical definitions, professional classifications, and data sources.
[0100] This invention proposes an innovative natural language query method. This method employs a pipelined processing approach, logically decomposing and planning the complex natural language query problem. Through a step-by-step, progressive approach, it systematically transforms the problem into a clear, accurate, and executable analysis task. This method progressively and systematically converts user-input natural language statements into precise data result sets, thereby significantly improving the accuracy of complex queries. It can be reliably applied to industry scenarios with high data accuracy requirements.
[0101] According to the natural language query method provided by the present invention, the preset intent system includes a pre-defined intent system or a specified intent system; the method performs intent recognition on the natural language query string based on the preset intent system and outputs the user's intent classification result, including:
[0102] The natural language query string is matched against a preset intent system or a specified intent system to obtain a structured intent object that includes at least one classification code; wherein, intent recognition supports single intent mode or multiple intent mode;
[0103] Prompts are dynamically generated based on structured intent objects, and the structured intent objects and their corresponding prompts are identified as intent classification results.
[0104] Specifically, in some embodiments, the intent recognition process in step 101 is implemented through the following steps:
[0105] The pre-defined intent system includes, for example, a historical standard intent tree. Classification is based on this tree, following the rules of prioritizing the last layer and unique numbering. It prioritizes labeled cases in the recall case library to ensure consistency and traceability. The construction process of the pre-defined intent system is as follows:
[0106] 1. Classification and final subdivision: First determine the major categories (number of questions / question and answer / question navigation / ...), and then refine to the final level of coding.
[0107] 2. Similar problem comparison and coding matching: Combine the recalled similar problems with the labeled samples to ensure consistency with the history.
[0108] 3. Output Specifications: Intent recognition supports single intent mode or multiple intent mode. Single intent mode: only the most matching intent number is returned; Multiple intent mode: if the question matches multiple intents, multiple numbers are returned.
[0109] Specify Intent System: Supports loading user-specified intent systems (such as topic / specialized question data) by project or scenario. Within this scope, it takes precedence over the preset system for matching. That is, if there is a user-specified intent, the specified system will be used for matching first. It still needs to meet the requirements of last-layer priority, unique number and machine-readable output, and can be mapped back to global code for statistics and operation and maintenance.
[0110] Matching the query string within a pre-defined or specified intent system yields a structured intent object that includes at least one category code. For example, a structured intent object contains a unique or multiple category codes and an intent name. This structured intent object is used to drive subsequent orchestration, permission verification, and metric statistics.
[0111] After the structured intent object is determined, prompt words are dynamically generated based on the structured intent object. For example, the structure of prompt words is automatically constructed based on the intent list, and single / multi-classification and machine-readable output formats can be switched as needed; whether to send back intermediate inference information is configurable.
[0112] Then, at least one structured intent object with a classification code and its corresponding prompt word are determined as the intent classification result.
[0113] Optionally, the intent recognition process also supports the following mechanisms:
[0114] Template recall and conditional generalization: Select template type according to different modes and filter in combination with context scope; perform conditional generalization when the recall is empty (such as masking partial restrictions or falling back to the previous level intent).
[0115] Output extraction and parsing: Extract intermediate inference and final results according to the preset intention classification system; for multi-class classification, parse by delimiter and retain code value and name; for single-class classification, return a unique result.
[0116] Timeout and fault tolerance: A unified call mechanism with timeout control is adopted to record stage delays; timeouts, connection failures and internal exceptions are classified and handled.
[0117] Pluggable retrieval backend: supports custom sets and range control; performs parallel retrieval, rearrangement, deduplication, and quota-based merging on multi-source results.
[0118] The method provided in this embodiment performs preliminary parsing of the user's original input to understand its core analysis objective and uniquely categorizes the question into a preset intent classification system. This determines the intent classification result, systematically eliminating the ambiguity of natural language and ensuring an accurate understanding of the user's true intent. Subsequently, based on the intent classification result, it performs subsequent query rewriting, process orchestration, and plan execution. This transforms a vague and complex natural language query problem into a clear, accurate, and executable analysis task through a progressive approach. It achieves the gradual and systematic transformation of user-input natural language sentences into a precise data result set, significantly improving the accuracy of complex queries and enabling reliable application in industry scenarios with high data accuracy requirements.
[0119] According to a natural language query method provided by the present invention, based on intent classification results, query strings, and a professional terminology database, the query string is rewritten to output a standardized query, including:
[0120] Determine the current time context based on the query string;
[0121] Based on the current time context and a pre-set time terminology database, the relative time expressions in the query string are converted into absolute time ranges to obtain standardized time information;
[0122] Based on a professional terminology database, synonym mapping and concept disambiguation are performed on proper nouns in the query string to obtain recall terminology information related to the query string; the professional terminology database contains a set of synonyms for proper nouns and annotations of the thought process used to explain the differences between proper nouns and their synonyms;
[0123] The retrieved noun information, normalized time information, and historical dialogue context are engineered and arranged using pre-set templates to generate a normalized query represented in a structured format.
[0124] Specifically, in some embodiments, step 102, query rewriting, is implemented through the following steps:
[0125] Input: The user's original query, that is, the intent classification result of the first stage.
[0126] The process includes sub-steps 1-3:
[0127] 1. Time standardization:
[0128] Based on the query string, the current time context is determined; based on the current time context and the pre-set time terminology library (i.e., the recalled time terminology library), the relative time expressions in the query string are converted into absolute time ranges to obtain the normalized time information.
[0129] Relative time expressions include phrases such as "yesterday / last month / last quarter / last year of the same period last year". Absolute time ranges are, for example, "[January 1, YYYY, December 31, YYYY]". The relative time expressions in the query string are converted into formatted and normalized times. In other words, this invention supports deriving complex time windows according to rules.
[0130] 2. Standardization and disambiguation of proper nouns:
[0131] Based on a professional terminology database, synonym mapping and concept disambiguation are performed on the proper nouns in the query string to obtain recall terminology information related to the query string.
[0132] Professional terms such as organizations, indicators, dimensions, and technical terms are included in the professional terminology database. The database contains a set of synonyms for the proper nouns and annotations of the thought process used to explain the differences between the proper nouns and their synonyms. The differences are clarified by the annotation of "synonym + thought process" in the professional terminology database (noun set) (e.g., "new unit" and "new operating unit" are not the same concept), and the explanation in the annotation shall prevail.
[0133] 3. Semantic Preservation and Completion: No subjective information is added; when key elements are missing, historical dialogue is used as a priority for completion; placeholders are retained but not fabricated when uncertain; when necessary, the "thought process" is provided to the model as a high-weight context to stabilize the rewriting results.
[0134] Furthermore, the recalled noun information, normalized time information, and historical dialogue context are engineered and arranged using pre-set templates to generate normalized queries in structured formats, such as XML.
[0135] Output: A normalized, unambiguous, and directly executable internal query representation (normalized query), which can be processed for format constraints, such as being wrapped in XML tags.
[0136] Optionally, the query rewriting process also includes vector recall and template enhancement steps:
[0137] Noun vector recall: Prioritize vector library retrieval (supports limitation of noun set range and workspace effective interval), and fall back to rule retrieval if it fails;
[0138] Template Recall: Retrieve and rewrite templates by session type / intent and inject them;
[0139] Context engineering orchestration: Template-enhanced information engineering design and optimization and unified injection, producing machine-readable output wrapped in equivalent Extensible Markup Language (XML).
[0140] The method provided in this embodiment first determines the current time context based on the query string; then, based on the current time context and a pre-set time terminology library, the relative time expressions in the query string are converted into absolute time ranges to obtain standardized time information; next, based on a professional terminology library, synonym mapping and concept disambiguation are performed on the proper nouns in the query string to obtain recall terminology information related to the query string. The professional terminology library contains a set of synonyms for the proper nouns and annotations of the thought process used to explain the differences between the proper nouns and their synonyms; finally, the recall terminology information, standardized time information, and historical dialogue context are engineered and arranged using a pre-set template to generate a standardized query represented in a structured format. This embodiment realizes the transformation of colloquial user input into standardized queries that machines can accurately understand, ensuring that the output can be directly used in subsequent stages, significantly improving the accuracy of complex queries, and can be reliably applied to industry scenarios with high data accuracy requirements.
[0141] According to the natural language data lookup method provided by the present invention, the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules and labeled samples.
[0142] The method provided in this embodiment first uses the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; then, it enhances the normalized query based on the domain context information to generate an annotated query that includes the domain context information; furthermore, it orchestrates the natural language data lookup task corresponding to the natural language query string based on the annotated query and intent classification results to generate an execution plan, thereby decomposing the complex analysis task into a series of logically clear and executable atomic steps, and gradually and systematically transforming the natural language question input by the user into accurate data analysis results.
[0143] According to a natural language data lookup method provided by the present invention, the natural language data lookup task corresponding to the natural language query string is arranged in stages based on the labeled query and intent classification results to generate an execution plan, including:
[0144] Based on the labeled query intent and related business rules, the natural language data lookup task is decomposed into multiple atomic tasks, and each atomic task is assigned a parent atomic task to depend on.
[0145] Based on the dependencies between atomic tasks, the atomic tasks are organized into a directed acyclic graph (DAG), and the DAG is determined as the execution plan; where the nodes of the DAG represent atomic tasks, and the edges of the DAG represent the dependencies between atomic tasks.
[0146] Specifically, in some embodiments, the specific implementation process of orchestrating the natural language data lookup task corresponding to the natural language query string based on the labeled query and intent classification results to generate an execution plan includes the following steps:
[0147] First, based on the labeled query intent and relevant business rules, the natural language data lookup task is decomposed into multiple atomic tasks, and each atomic task is assigned a parent atomic task it depends on.
[0148] The intent of the queried object can be determined based on the intent classification results, such as analysis and diagnosis. The relevant business rules are pre-injected domain business rules that represent the specific meaning of each atomic task and the dependencies between each atomic task.
[0149] Based on the query intent (such as "analyze and diagnose") and the injected business rules, a macro-level analysis task (i.e., a natural language data lookup task) can be decomposed into multiple atomic problems with logical dependencies. The orchestration process supports node-level timeout, retry, and degradation strategies, and supports combinations of pre-built templates and custom nodes.
[0150] Furthermore, based on the dependencies between the atomic tasks, the atomic tasks are organized into a directed acyclic graph (DAG), and the DAG is used as the execution plan. The dependencies between the atomic tasks can be determined according to relevant business rules. For example, analyzing the quarter-on-quarter growth rate of electricity sales in a certain quarter requires querying the electricity sales data for each month of that quarter.
[0151] In this DAG, nodes represent atomic tasks, and edges represent the dependencies between these atomic tasks. The DAG also represents a structured execution plan.
[0152] The method provided in this embodiment first decomposes a natural language data query task into multiple atomic tasks based on the labeled query intent and relevant business rules, and assigns a dependent parent atomic task to each atomic task. Then, according to the dependencies between the atomic tasks, the atomic tasks are organized into a directed acyclic graph (DAG), and the DAG is determined as the execution plan. The invention uses a stage orchestration module as its core to perform end-to-end pluggable orchestration for complex analysis and diagnostic scenarios. Problem decomposition, as a sub-stage, breaks down macro-level business problems into atomic tasks with dependencies, and combines these with other stages (rewriting, annotation injection, data retrieval, aggregation, graph generation, etc.) to form an executable flow. This invention systematically transforms a fuzzy and complex natural language query problem into a clear, accurate, and executable analysis task through a progressively layered approach.
[0153] According to the natural language counting method provided by the present invention, the method further includes:
[0154] Based on the data result set, intent classification results, and execution plan, generate visualization charts;
[0155] Based on visual charts, textual results of natural language analysis are automatically generated; the textual results represent natural language summaries corresponding to the key features of the data result set.
[0156] Specifically, in some embodiments, the method further includes presenting the data query results (data result set) to the user in the most efficient and insightful way, encompassing two paths: "adaptive generation with limited data volume" and "code generation aggregation with large data volume." This process is achieved through the following steps:
[0157] Based on the data result set, intent classification results, and execution plan, a visualization chart is generated; based on the visualization chart, text results of natural language analysis are automatically generated; the text results represent natural language summaries corresponding to the key features of the data result set.
[0158] For example, the inputs might be: 1. The data result set returned after the execution phase orchestration plan. 2. The original user intent objects identified in the first phase. 3. The execution plan (DAG).
[0159] Processing strategy: The system makes intelligent decisions by comprehensively utilizing the intent classification results and DAG context, and adopts different strategies according to the amount of data.
[0160] Output: A comprehensive results interface including visual charts, data facts, insightful analytics, and personalized responses, as shown in the attached image. For example, the system will output a line graph showing the change in electricity sales, with the following text description: "Data shows that the electricity sales of a certain power supply unit in May were XXX million kWh, a month-on-month increase of 25%, showing a significant increase. Preliminary analysis suggests this may be related to the commissioning of a large industrial user that month."
[0161] The method provided in this embodiment, when generating visualizations, not only relies on the final data results, but more importantly, it traces back and utilizes the user's original analytical intent and execution plan captured in the first step of the pipeline. This mechanism ensures that the final chart type and presentation format accurately serve the user's analytical purpose, thereby providing more insightful visualization results.
[0162] According to the natural language data lookup method provided by the present invention, based on a data result set, intent classification results, and execution plan, a visualization chart is generated, including:
[0163] Determine the size of the data result set;
[0164] When the amount of data is less than the preset threshold, the model directly generates the corresponding visualization chart configuration based on the data result set, intent classification results and execution plan, using either free generation or template generation methods.
[0165] If the data volume is greater than or equal to a preset threshold, perform data aggregation to obtain aggregated data; or, sample the code and perform aggregation processing on the data result set based on the code to obtain aggregated data.
[0166] Visual charts are generated based on the configuration of the visualization chart, the aggregated data, the data result set, the intent classification results, and the execution plan.
[0167] Specifically, in some embodiments, generating a visualization chart based on the data result set, intent classification results, and execution plan can be achieved through the following steps:
[0168] Generate visualizations according to Strategy 1, which is based on the size of the data set.
[0169] Step 1: Determine the size of the data result set;
[0170] Step 2: Compare the size of the data result set with a preset threshold to determine whether the data result set is small, medium, or large.
[0171] When the data volume is less than the preset threshold: the model directly generates the corresponding visualization chart configuration based on the data result set, intent classification results and execution plan, using either free generation or template generation methods.
[0172] The two chart generation methods for small to medium datasets are: 1. Free generation: Allow the model to freely select a suitable chart based on the data, output a general chart configuration, and perform self-validation; if it fails, return an error to the model for correction until it passes. 2. Template generation: Select the most suitable template from a set of preset templates, generate a general chart configuration, and perform self-validation; if it fails, return an error and iteratively correct until it passes.
[0173] When the data volume is greater than or equal to a preset threshold, a code generation path is adopted. Specifically, data aggregation or sampling code is generated and the data result set is aggregated based on the code to obtain aggregated data; based on the visualization chart configuration or aggregated data, data result set, intent classification results and execution plan, a visualization chart is generated.
[0174] For example: 1. Generate code for data aggregation / sampling / binning to obtain analytical information, rather than directly outputting details. 2. Include background information such as table headers, sample size, and time span in prompts to guide the model in forming reasonable summaries and more coarse-grained visualizations.
[0175] The method provided in this embodiment makes intelligent decisions by comprehensively utilizing the intent classification results and DAG context, and adopts different strategies according to the amount of data. This mechanism ensures that the final chart type and display format can accurately serve the user's analysis purpose, thereby providing more insightful visualization results.
[0176] According to the natural language data lookup method provided by the present invention, based on a data result set, intent classification results, and execution plan, a visualization chart is generated, including:
[0177] Assign appropriate chart types to the data result set based on the intent types and execution plans identified in the intent classification results;
[0178] Generate visualization charts based on appropriate chart types, and automatically mark data outliers or outlier ranges in the visualization charts.
[0179] Specifically, in some embodiments, the process of generating visualization charts based on data result sets, intent classification results, and execution plans includes the following steps:
[0180] First, based on the intent type identified in the intent classification results, an appropriate chart type is assigned to the data result set. That is, the chart type selection is aligned with the intent. If the intent classification results corresponding to the user's input natural language query string identify an intent type, then the appropriate chart type is determined based on that intent type. For example, if the intent type is trend analysis, a line chart is preferred; if the intent type is percentage analysis, a pie chart is preferred.
[0181] Furthermore, visualization charts are generated based on appropriate chart types, and outliers or abnormal intervals are automatically marked on the visualization charts. Simultaneously, standardized natural language summaries are provided.
[0182] The method provided in this embodiment determines the appropriate chart type based on the intent type, and then generates a visualization chart based on the appropriate chart type. This mechanism ensures that the final chart type and display format can accurately serve the user's analysis purpose, thereby providing more insightful visualization results.
[0183] Figure 2 This is the second flowchart of the natural language data lookup method provided by this invention, as shown below. Figure 2 As shown, the method includes:
[0184] Step 201: Receive the user's natural language query string, perform intent recognition on the query string based on the preset intent system, and output the user's intent classification result; the intent classification result is represented by a unique intent code;
[0185] Step 202: Determine the current time context based on the query string;
[0186] Step 203: Based on the current time context and the preset time terminology database, convert the relative time expressions in the query string into absolute time ranges to obtain the normalized time information;
[0187] Step 204: Based on the professional terminology database, perform synonym mapping and concept disambiguation on the proper nouns in the query string to obtain recall terminology information related to the query string; the professional terminology database contains a set of synonyms for proper nouns and annotations of thought processes used to explain the differences;
[0188] Step 205: The recalled noun information, normalized time information, and historical dialogue context are engineered and arranged using a pre-set template to generate a normalized query represented in a structured format.
[0189] Step 206: Use the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules and labeled samples;
[0190] Step 207: Enhance the normalized query based on domain context information to generate an annotated query that includes domain context information;
[0191] Step 208: Based on the labeled query and intent classification results, orchestrate the steps of the natural language data lookup task, generate an execution plan, and execute the plan to obtain the data result set;
[0192] Step 209: Based on the data result set, intent classification results, and execution plan, generate a visualization chart;
[0193] Step 210: Based on the visualization charts, automatically generate the text results of natural language analysis; the text results represent the natural language summaries corresponding to the key features of the data result set.
[0194] The natural language counting device provided by the present invention is described below. The natural language counting device described below can be referred to in correspondence with the natural language counting method described above.
[0195] Compared with existing technologies, the method proposed in this invention has achieved the following significant beneficial effects in applications such as energy and power:
[0196] 1. Significantly improved query accuracy: Through decoupling of phased corpus injection and pluggable orchestration, the system understands user intent more accurately and applies domain knowledge more deeply, thereby significantly improving the accuracy of complex queries and enabling reliable application in industry scenarios with high data accuracy requirements.
[0197] 2. Breakthrough in complex analysis capabilities: The system's stage orchestration capabilities enable it to move beyond simple "question and answer" responses. Instead, it can function like a business analyst, organizing and logically decomposing complex diagnostic and attribution issues into stages. Through multi-stage collaboration, it can complete multi-step investigations, providing in-depth data support for business decisions.
[0198] 3. Significantly enhanced user experience and trust: The system can understand conversational and ambiguous natural language and ultimately respond in a rich media format of "data facts + visual charts + insightful analysis + human-like responses". The results are not only intuitive and easy to understand, but also "the process is explainable and fine-tunable". Users can see how the system arrives at its conclusion step by step, which greatly enhances users' trust in the results.
[0199] 4. Strong domain adaptability and maintainability: The architecture of the present invention is closely integrated with back-end data annotation and knowledge management platforms such as the annotation platform. Business experts can continuously inject new terms, business rules, and annotation samples into the system through this platform, enabling the system to continuously learn and evolve, quickly adapt to new business changes and query requirements, and having good scalability and maintainability.
[0200] 5. Quantitative metrics (internal enterprise evaluation baseline): Intent recognition accuracy rate ≥ XX%, query rewriting disambiguation success rate ≥ XX%, link choreography DAG execution success rate ≥ XX%, mapping and intent Figure 1 consistency ≥ XX%, end-to-end P95 response time < XX milliseconds (ms); unauthorized query interception rate ≥ 99%.
[0201] Figure 3 is a schematic structural diagram of the natural language number query device provided by the present invention. As Figure 3 shown, the natural language number query device 300 includes the following modules:
[0202] An intent classification module 310, configured to receive a natural language query string of a user, perform intent recognition on the natural language query string based on a preset intent system, and output an intent classification result of the user; the intent classification result is represented by a unique intent code;
[0203] A query rewriting module 320, configured to perform query rewriting on the natural language query string based on the intent classification result, the natural language query string, and a professional term library, and output a normalized query;
[0204] The process orchestration and execution module 330 is used to orchestrate the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result, generate a structured execution plan including multiple atomic tasks, and execute the structured execution plan to obtain a data result set. The process of orchestrating the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in a power domain vector knowledge base to obtain domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; and orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and relevant business rules in the domain context information to generate the structured execution plan. The annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical definitions, professional classifications, and data sources.
[0205] The apparatus provided in this embodiment includes an intent classification module 310, which receives a user's natural language query string, performs intent recognition on the query string based on a preset intent system, and outputs the user's intent classification result, represented by a unique intent code; a query rewriting module 320, which rewrites the query string based on the intent classification result, the query string, and a terminology database, and outputs a standardized query; furthermore, a process orchestration and execution module 330, which orchestrates the natural language data lookup task corresponding to the natural language query string based on the standardized query and intent classification result, generates an execution plan including multiple atomic tasks, and executes the plan to obtain a data result set; based on the standardized query and intent classification result... This invention proposes an innovative pipelined processing method that logically decomposes and plans the complex natural language query problem, systematically transforming it into a clear, accurate, and executable analysis task through a step-by-step approach. This method transforms user-input natural language statements into precise data result sets, significantly improving the accuracy of complex queries and enabling reliable application in industry scenarios with high data precision requirements. The method includes: using the normalized query as a keyword to perform semantic retrieval in a power domain vector knowledge base to obtain the corresponding domain context information; enhancing the normalized query based on the domain context information to generate an labeled query that includes the domain context information; and orchestrating the natural language query task based on the labeled query, intent classification results, and relevant business rules in the domain context information to generate a structured execution plan. The labeled query includes the normalized query and all retrieved business context information related to the normalized query.
[0206] According to the natural language counting device 300 provided by the present invention, the intent classification module 310 is specifically used for:
[0207] The natural language query string is matched against the preset intent system or the specified intent system to obtain a structured intent object including at least one classification code; wherein the intent recognition supports single intent mode or multi intent mode;
[0208] Based on the structured intent object, prompt words are dynamically generated, and the structured intent object and the corresponding prompt words are determined as the intent classification result.
[0209] According to the natural language lookup device 300 provided by the present invention, the query rewriting module 320 is specifically used for:
[0210] Based on the natural language query string, determine the current time context;
[0211] Based on the current time context and the preset time term library, the relative time expression in the natural language query string is converted into an absolute time range to obtain the normalized time information;
[0212] Based on the terminology database, synonym mapping and concept disambiguation are performed on the proper nouns in the natural language query string to obtain recall terminology information related to the natural language query string; the terminology database contains a set of synonyms for the proper nouns and annotations of thought processes used to explain the differences between the proper nouns and their synonyms;
[0213] The recalled noun information, the normalized time information, and the historical dialogue context are engineered and arranged using a pre-set template to generate the normalized query represented in a structured format.
[0214] According to the natural language data lookup device 300 provided by the present invention, the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules and annotated samples.
[0215] According to the natural language counting device 300 provided by the present invention, the link arrangement and execution module 330 is further used for:
[0216] Based on the labeled query intent and the relevant business rules, the natural language data lookup task is decomposed into multiple atomic tasks, and a parent atomic task is assigned to each atomic task.
[0217] Based on the dependencies between the atomic tasks, the atomic tasks are organized into a directed acyclic graph (DAG), and the DAG is determined as the structured execution plan; wherein, the nodes of the DAG represent the atomic tasks, and the edges of the DAG represent the dependencies between the atomic tasks.
[0218] According to the natural language counting device 300 provided by the present invention, the device further includes: a chart generation and analysis module;
[0219] The chart generation and analysis module is used for:
[0220] Based on the data result set, the intent classification results, and the structured execution plan, a visualization chart is generated;
[0221] Based on the visualization charts, text results of natural language analysis are automatically generated; the text results represent natural language summaries corresponding to the key features of the data result set.
[0222] According to the natural language data lookup device 300 provided by the present invention, the chart generation and analysis module is specifically used for:
[0223] Determine the size of the data result set;
[0224] When the amount of data is less than a preset threshold, the model directly generates the corresponding visualization chart configuration based on the data result set, the intent classification result, and the structured execution plan, using either a free generation or template generation method.
[0225] If the data volume is greater than or equal to the preset threshold, data aggregation is performed to obtain aggregated data; or, code is sampled and the data result set is aggregated based on the code to obtain the aggregated data.
[0226] The visualization chart is generated based on the configuration of the visualization chart or the aggregated data, the data result set, the intent classification results, and the structured execution plan.
[0227] According to the natural language data lookup device 300 provided by the present invention, the chart generation and analysis module is further used for:
[0228] Based on the intent types identified in the intent classification results and the structured execution plan, assign appropriate chart types to the data result set;
[0229] The visualization chart is generated based on the appropriate chart type, and data anomalies or abnormal ranges are automatically marked in the visualization chart.
[0230] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a natural language lookup method, which includes:
[0231] The system receives a user's natural language query string, performs intent recognition on the natural language query string based on a preset intent system, and outputs the user's intent classification result; the intent classification result is represented by a unique intent code.
[0232] Based on the intent classification results, the natural language query string, and the terminology database, the natural language query string is rewritten to output a standardized query.
[0233] Based on the normalized query and the intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the structured execution plan is executed to obtain a data result set; the orchestration of the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical caliber, professional classification, and data source.
[0234] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0235] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the natural language data lookup method provided by the above methods, the method comprising:
[0236] The system receives a user's natural language query string, performs intent recognition on the natural language query string based on a preset intent system, and outputs the user's intent classification result; the intent classification result is represented by a unique intent code.
[0237] Based on the intent classification results, the natural language query string, and the terminology database, the natural language query string is rewritten to output a standardized query.
[0238] Based on the normalized query and the intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the structured execution plan is executed to obtain a data result set; the orchestration of the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical caliber, professional classification, and data source.
[0239] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the natural language lookup method provided by the methods described above, the method comprising:
[0240] The system receives a user's natural language query string, performs intent recognition on the natural language query string based on a preset intent system, and outputs the user's intent classification result; the intent classification result is represented by a unique intent code.
[0241] Based on the intent classification results, the natural language query string, and the terminology database, the natural language query string is rewritten to output a standardized query.
[0242] Based on the normalized query and the intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the structured execution plan is executed to obtain a data result set; the orchestration of the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; performing information enhancement on the normalized query based on the domain context information to generate an annotated query including the domain context information; orchestrating the natural language data lookup task corresponding to the natural language query string based on the annotated query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan; the annotated query includes the normalized query and all retrieved business context information related to the normalized query, and the relevant business rules include statistical caliber, professional classification, and data source.
[0243] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0244] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0245] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A natural language data lookup method, characterized in that, include: Receive the user's natural language query string, perform intent recognition on the natural language query string based on a preset intent system, and output the user's intent classification result; The intent classification result is represented by a unique intent code; Based on the intent classification results, the natural language query string, and the terminology database, the natural language query string is rewritten to output a standardized query. Based on the normalized query and the intent classification result, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate a structured execution plan including multiple atomic tasks, and the structured execution plan is executed to obtain a data result set; the orchestration of stages for the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result to generate a structured execution plan including multiple atomic tasks includes: using the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules and labeled samples; information enhancement of the normalized query based on the domain context information to generate an annotated query including the domain context information; and the natural language query string is processed based on the annotated query, the intent classification result and the relevant business rules in the domain context information. The corresponding natural language data lookup task is orchestrated in stages to generate the structured execution plan. The labeled query includes the normalized query and all retrieved business context information related to the normalized query. The relevant business rules include statistical caliber, professional classification, and data source. The process of orchestrating the natural language data lookup task corresponding to the natural language query string based on the labeled query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan includes: decomposing the natural language data lookup task into multiple atomic tasks based on the intent of the labeled query and the relevant business rules, and specifying the dependent parent atomic task for each atomic task; organizing the atomic tasks into a directed acyclic graph (DAG) according to the dependencies between the atomic tasks, and determining the DAG as the structured execution plan; wherein, the nodes of the DAG represent the atomic tasks, and the edges of the DAG represent the dependencies between the atomic tasks.
2. The natural language data lookup method according to claim 1, characterized in that, The preset intent system includes a pre-defined intent system or a specified intent system; The process of identifying the intent of the natural language query string based on a preset intent system and outputting the user's intent classification result includes: The natural language query string is matched against the preset intent system or the specified intent system to obtain a structured intent object including at least one classification code; wherein the intent recognition supports single intent mode or multi intent mode; Based on the structured intent object, prompt words are dynamically generated, and the structured intent object and the corresponding prompt words are determined as the intent classification result.
3. The natural language data lookup method according to claim 1, characterized in that, The process of rewriting the natural language query string based on the intent classification result, the natural language query string, and the terminology database, and outputting a standardized query, includes: Based on the natural language query string, determine the current time context; Based on the current time context and the preset time term library, the relative time expression in the natural language query string is converted into an absolute time range to obtain the normalized time information; Based on the terminology database, synonym mapping and concept disambiguation are performed on the proper nouns in the natural language query string to obtain recall terminology information related to the natural language query string; the terminology database contains a set of synonyms for the proper nouns and annotations of thought processes used to explain the differences between the proper nouns and their synonyms; The recalled noun information, the normalized time information, and the historical dialogue context are engineered and arranged using a pre-set template to generate the normalized query represented in a structured format.
4. The natural language lookup method according to claim 1, characterized in that, The method further includes: Based on the data result set, the intent classification results, and the structured execution plan, a visualization chart is generated; Based on the visualization charts, text results of natural language analysis are automatically generated; the text results represent natural language summaries corresponding to the key features of the data result set.
5. The natural language lookup method according to claim 4, characterized in that, The step of generating a visualization chart based on the data result set, the intent classification results, and the structured execution plan includes: Determine the size of the data result set; When the amount of data is less than a preset threshold, the model directly generates the corresponding visualization chart configuration based on the data result set, the intent classification result, and the structured execution plan, using either a free generation or template generation method. If the data volume is greater than or equal to the preset threshold, data aggregation is performed to obtain aggregated data; or, code is sampled and the data result set is aggregated based on the code to obtain the aggregated data. The visualization chart is generated based on the visualization chart configuration, the aggregated data, the data result set, the intent classification results, and the structured execution plan.
6. The natural language data lookup method according to claim 4, characterized in that, The step of generating a visualization chart based on the data result set, the intent classification results, and the structured execution plan includes: Based on the intent types identified in the intent classification results and the structured execution plan, assign appropriate chart types to the data result set; The visualization chart is generated based on the appropriate chart type, and data anomalies or abnormal ranges are automatically marked in the visualization chart.
7. A natural language counting device, characterized in that, include: The intent classification module is used to receive the user's natural language query string, perform intent recognition on the natural language query string based on a preset intent system, and output the user's intent classification result. The intent classification result is represented by a unique intent code; The query rewriting module is used to rewrite the natural language query string based on the intent classification result, the natural language query string, and the professional terminology database, and output a standardized query. The process orchestration and execution module is used to orchestrate the natural language data lookup task corresponding to the natural language query string based on the normalized query and the intent classification result, generate a structured execution plan including multiple atomic tasks, and execute the structured execution plan to obtain a data result set; specifically, the process orchestration and execution module is used to use the normalized query as a keyword to perform semantic retrieval in the power domain vector knowledge base to obtain the domain context information corresponding to the normalized query; the domain context information includes database table structure information, noun set annotation, indicator definition, relevant business rules, and labeled samples; The normalized query is augmented based on the domain context information to generate an annotated query that includes the domain context information; Based on the labeled query, the intent classification result, and the relevant business rules in the domain context information, the natural language data lookup task corresponding to the natural language query string is orchestrated in stages to generate the structured execution plan. The labeled query includes the normalized query and all retrieved business context information related to the normalized query. The relevant business rules include statistical caliber, professional classification, and data source. The orchestration of the natural language data lookup task corresponding to the natural language query string based on the labeled query, the intent classification result, and the relevant business rules in the domain context information to generate the structured execution plan includes: decomposing the natural language data lookup task into multiple atomic tasks based on the intent of the labeled query and the relevant business rules, and specifying a dependent parent atomic task for each atomic task; organizing the atomic tasks into a directed acyclic graph (DAG) according to the dependencies between the atomic tasks, and determining the DAG as the structured execution plan; wherein, the nodes of the DAG represent the atomic tasks, and the edges of the DAG represent the dependencies between the atomic tasks.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the natural language lookup method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Query processing method and device, electronic equipment and storage medium
CN120632209A
User intent and context based search results
US20170242886A1