Data analysis method, data analysis system and related equipment
By parsing the mapping relationship between user questions and database fields in conversational data retrieval software and selecting an appropriate model to generate response text, the problem of resource waste caused by the randomness of user questions is solved, and efficient and accurate data analysis is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2026-03-31
AI Technical Summary
Due to the randomness of user questions, conversational data retrieval software may not yield professional analysis results when starting large language model analysis for each question, leading to a waste of resources.
By obtaining the question from the user's request, parsing the mapping relationship between word segmentation and database fields, calculating the information ratio, selecting an appropriate model to generate the response text, reducing the number of times the large language model is started, and supplementing the parsing results with thesaurus and similar case data when necessary.
It reduces system resource consumption, improves the accuracy and efficiency of analysis results, and meets users' professional analysis needs.
Smart Images

Figure CN121765038A_ABST
Abstract
Description
[0001] This application claims priority to Chinese Patent Application No. 202411382186.1, filed on September 29, 2024, entitled "A Data Processing Method", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of artificial intelligence (AI), and more particularly to a data analysis method, a data analysis system, and related equipment. Background Technology
[0003] With the advent of the information age, data across various fields has experienced explosive growth. This explosive growth has provided tremendous opportunities for data analysis, which has become a key technology in various industries, such as healthcare, finance, and social media. However, since data analysis is based on data querying—relevant data must be retrieved before analysis can begin—data analysis software needs to have data retrieval capabilities. This means the ability to extract the data to be analyzed from databases. For example, business intelligence (BI) analysis software needs BI data retrieval capabilities. However, using this data retrieval function requires users to have certain database expertise, such as understanding database query statements, which creates a learning curve in the field of data analysis.
[0004] With the development of AI technology, conversational data retrieval software has emerged. This software can communicate with users in a conversational manner, generating corresponding data query results based on the natural language text input by the user. For example, a user can input the query question into the tool: "Please help me find out the annual income of Project ABC in the China Region." The tool can then return: "The annual income of Project ABC in the China Region is 10 million yuan." This allows users to complete data queries simply by inputting natural language into the system, without needing specialized database knowledge. Especially for scenarios requiring specialized knowledge, such as data analysis, the automatic parsing and analysis of natural language content by conversational data retrieval software can significantly lower the learning curve for data analysis.
[0005] Typically, conversational data retrieval software is based on a large language model (LLM). The LLM analyzes each different question posed by the user and generates corresponding results. However, because user questions are arbitrary, starting the LLM analysis for each question may not yield professional analysis results, resulting in a waste of resources. Summary of the Invention
[0006] This application provides a data analysis method, a data analysis system, and related equipment to address the problem that conversational data retrieval software may fail to obtain professional analysis results and waste resources when large-scale model analysis is initiated for each question due to the arbitrary nature of user questions.
[0007] Firstly, this application provides a data analysis method executed by a data analysis system, comprising the following steps: obtaining a user request sent by a client, the user request including associated data of a question input by the user; determining the type of user intent based on the user request, wherein the type of user intent is obtained based on the parsing result of the question, the parsing result including the mapping relationship between word segments in the question and mapping fields in the form to be queried; when the type is a data query type, calculating the information ratio of the parsing result, wherein the information ratio is used to indicate the number of word segments that have completed mapping in the question; and selecting the corresponding model based on the information ratio to obtain the response text corresponding to the question.
[0008] Implementing the method described in the first aspect allows for the mapping between word segmentation in the question and fields in the database after receiving the user's question, obtaining parsing results. Then, based on the parsing results, the user's intent is categorized. If the user's intent is determined to be a data table query type, the information ratio in the parsing results is further determined. The corresponding model is then selected based on the information ratio to obtain the response text. This method can achieve intent recognition of the question without activating a large language model, avoiding the need to activate a large language model for intent recognition for every question input by the user. This reduces the resource overhead caused by frequently activating a large language model. Furthermore, selecting different models to process questions based on the information ratio ensures the accuracy of the generated response text, resulting in more professional analysis results that meet the user's needs.
[0009] In one possible implementation, selecting the corresponding model based on the information ratio to obtain the response text of the question refers to inputting the parsing result into the first model to obtain the database query statement corresponding to the question when the information ratio is greater than a threshold, and obtaining the response text of the question based on the database query statement. The threshold is determined based on multiple historical data, and each historical data includes the information ratio of the historical parsing results of historical questions, as well as the correctness of the database query statement generated by the first model based on the historical parsing results.
[0010] Optionally, the first model can be a query statement template-based model. The query statement template may include templates of SQL statements, which may include some empty spaces. Filling these empty spaces based on the parsing results yields a complete SQL statement. For example, if a user is querying the maximum value of a certain field, the system can select the template `select max(column)` and then fill in the parameters of that template based on the parsing results. Furthermore, optimization algorithms can be combined to optimize the generated SQL statement, such as avoiding redundant join operations and selecting appropriate indexes for querying. This application does not impose specific limitations on these optimizations.
[0011] Optionally, the first model can also be an AI model other than a large language model, such as a Seq2Seq (Sequence-to-Sequence) model. This model first converts the natural language question into a fixed-length vector representation, and then generates an SQL statement through a decoder. This method learns the mapping from natural language to SQL statements through a large amount of training data. The SQL statement can also be obtained through other AI models; this application does not impose specific limitations on this.
[0012] In the above implementation, when the information ratio of the parsing result is greater than the threshold, it means that most of the word segmentation in the question has completed the mapping between the words and the fields in the database. At this time, the database query statement corresponding to the question can be obtained based on the parsing result, and then the query result can be obtained to generate the corresponding response text. In this way, some simple questions can obtain the corresponding query results and response text without starting the large language model, which can reduce the waste of system resources.
[0013] In one possible implementation, selecting the corresponding model based on the information ratio to generate the response text for the question refers to obtaining similar case data for the question when the information ratio is not greater than a threshold, inputting the parsing results and similar case data into the second model, and obtaining the database query statement corresponding to the question.
[0014] Optionally, the second model can be a large language model, which can be a generative pre-trained transformer (GPT), a bidirectional encoder representations from transformers (BERT), a text-to-text transformer (T5), etc., and this application does not impose specific limitations. It should be understood that a large language model, trained on a large amount of text data, is capable of understanding complex language structures, semantic relationships, and contextual relationships, and utilizes language generation capabilities to convert natural language into database query statements.
[0015] It should be understood that the first model and the second model can be the same model, such as a large language model; or, the first model can be an AI model or a model based on a query statement template, and the second model can be a large language model. In specific implementation, the specific implementation method of the model can be flexibly selected based on actual business needs, and this application does not make specific limitations.
[0016] In the above implementation method, when the information ratio of the parsing result is not greater than the threshold, it means that some of the word segmentation in the question has not yet completed the mapping between the words and the fields in the database, and the parsing of the question is not thorough enough. At this time, similar case data is obtained based on the question, and the parsing result is supplemented based on the similar case data, so that the second model can obtain sufficient information and make the generated SQL statement more accurate.
[0017] In one possible implementation, when determining the type of user intent based on a user request, the parsing result of the question can be determined based on the associated data of the question, and the type of user intent can be determined based on the dimension information of the mapping field in the parsing result. The number of dimensions of the parsing result of the question corresponding to the user intent of the data query type is greater than the dimension threshold.
[0018] Furthermore, the dimension threshold includes a first quantity and a second quantity. The type of user intent can be determined based on the dimension information of the mapped fields in the parsing result. When the mapped fields in the parsing result include both computed and non-computed fields, and the number of dimensions to which the non-computed fields belong is greater than the first quantity, the user intent is determined to be a data query intent. Alternatively, when the mapped fields in the parsing result do not include computed fields, and the total number of dimensions to which the mapped fields belong is greater than the second quantity, the user intent is determined to be a data query intent.
[0019] It should be understood that query-type questions usually require data in the database to be split, grouped, aggregated, or analyzed in multiple dimensions. In order to answer such questions, the form to be queried needs to have a certain number of dimensions and calculated fields. If the parsing results show that the number of dimensions of the mapped table fields is very small, such as no calculated fields and only 1 dimension, or calculated fields but only 1 other dimension, it means that the form cannot support multi-dimensional analysis and query, and cannot answer query-type questions. In this case, the question is very likely a non-data query type question.
[0020] The above implementation determines the user's intent based on the number of dimensions in the parsed result of the question. This eliminates the need for a large language model for intent recognition, thus avoiding the waste of resources caused by frequently launching a large language model for every question.
[0021] In one possible implementation, determining the parsing result of the question based on the associated data of the question can be achieved by matching the word segments in the question with a thesaurus to obtain the first keyword that matches the word segments. The thesaurus includes keywords and their corresponding synonyms. The first keyword includes keywords that match the word segments, or keywords corresponding to the synonyms that match the word segments. The keywords are obtained based on table data in the database, which includes one or more of table names, table fields, and enumeration values. Based on the first keyword, the mapping relationship between the word segments and the mapping fields in the form to be queried is completed to obtain the parsing result of the question.
[0022] In its implementation, the aforementioned thesaurus may include a mapping relationship between keywords and synonyms. Keywords are obtained based on table data in the database, including table names, field names, and corresponding enumeration values. Synonyms refer to near-synonyms, industry terms, colloquialisms, etc., that have the same meaning as the keywords, and this application does not impose specific limitations on them.
[0023] Furthermore, when matching the word segment in the question with a thesaurus, if a keyword matching the word segment exists, that keyword becomes the first keyword corresponding to the word segment in the question; if a synonym matching the word segment exists, the keyword corresponding to that synonym can be used as the first keyword corresponding to the word segment in the question; if no keyword or synonym matching the word segment exists, the keyword or synonym closest to the word segment can be determined based on a semantic similarity algorithm, thus obtaining the first keyword corresponding to the word segment. Semantic similarity algorithms may include, but are not limited to, edit distance algorithms, Jaccard similarity algorithms, cosine similarity algorithms, etc., and this application does not impose specific limitations.
[0024] In specific implementation, the meaning represented by the above word segmentation matching can include being the same as the word segmentation, or it can include having a semantic similarity to the word segmentation that is higher than a threshold. For example, the keyword matching the word segmentation can refer to the keyword that is exactly the same as the word segmentation, or it can refer to the keyword that has a semantic similarity to the word segmentation that is higher than a threshold. This application does not make any specific limitations.
[0025] In practical implementation, the data analysis system can import information such as table names, field names, and corresponding enumeration values from the database into a thesaurus to obtain multiple keywords. Then, it determines the synonyms of these keywords and establishes a mapping relationship between keywords and synonyms. If enumeration values from different fields are duplicated, deduplication can be performed. Specifically, duplicate enumeration values can be retained, and their mapping relationships with tables and fields can be recorded. When determining synonyms based on keywords, this can be achieved through algorithms or user configuration; this application does not impose specific limitations. For example, when determining synonyms based on algorithms, synonyms for each keyword can be determined based on existing thesaurus and thesaurus, or through semantic similarity algorithms (such as similarity calculations based on pre-trained models like Word2Vec, GloVe, and BERT). When implementing based on user configuration, multiple keywords can be displayed to the user, who can then configure corresponding industry terms or colloquialisms. The above examples are for illustrative purposes only and are not subject to specific limitations in this application.
[0026] Optionally, the above-mentioned thesaurus can be implemented using a trie, which is a tree-like data structure that includes multiple nodes, each node representing a character. All characters on the path from the root node to each node can form a keyword. In this way, keywords with the same prefix can share prefix characters in the trie, thereby saving storage space. At the same time, it can also respond quickly when querying data, improving the efficiency of keyword retrieval.
[0027] The above implementation first generates a series of keywords based on table data in the database, then determines the synonyms of the keywords and stores them in a thesaurus. This way, when a user inputs a flexible question, fuzzy matching can be performed using keywords and synonyms from the thesaurus to obtain the mapping relationship between word segments and fields in the question, thus obtaining the question's parsing result. Based on the parsing result, the type of user intent is identified. Thus, when the data analysis system receives a question, it does not immediately launch the large language model for intent recognition; it only launches the large language model after determining it to be a query. This allows for on-demand launching of the large language model, reducing the number of times it is launched and lowering the memory overhead caused by frequent large language model launches.
[0028] In one possible implementation, the mapping relationship between word segmentation and the mapping fields in the query form based on the first keyword can be based on the distinguishing fields in the question, obtaining multiple candidate tables corresponding to the question, matching the first keyword with the candidate fields in the multiple candidate tables, establishing the mapping relationship between word segmentation and the candidate fields in each candidate table based on the matching first keyword and candidate fields, obtaining the parsing result of each candidate table, determining the query form based on the parsing result of each candidate table, and obtaining the mapping relationship based on the parsing result of the query form.
[0029] In this context, a distinguishing field refers to a field that can differentiate between different data records or tables, or a field that can be used to narrow down the query scope. Distinguishing fields are fields that allow for explicit specification of the query scope or conditions during a query. Filtering based on distinguishing fields results in a lower number of candidate tables, reducing the waste of subsequent computational resources. Specifically, distinguishing fields can include dimension fields and calculated indicator fields. Dimension fields describe the dimensions or categories of data and can be used to group, sort, and filter data. Dimension fields can be determined based on the detailed slicing or filtering conditions that data analysis may require. Typically, dimension fields can include time dimensions, geographical dimensions, business dimensions, etc. Calculated indicator fields are fields with numerical attributes, used for mathematical calculations or statistical analysis. Calculated indicator fields can be determined based on the quantitative indicators that data analysis may require. Typically, calculated indicator fields can include numerical fields, metric fields, dynamic fields, etc. In short, dimension fields are used to describe the classification and grouping of data, such as time, location, product category, etc., while calculated indicator fields are used to describe the quantity or measurement of data, such as sales revenue, quantity, cost, etc. Distinguishing fields can also include many other types, which are not specifically limited in this application.
[0030] Optionally, the system can identify distinctive fields in questions based on a preset distinguishable field library. After segmenting the question into words, multiple words are obtained. These words are then matched with the distinguishable field library to determine the distinctive fields within them. This distinguishable field library may include some pre-stored distinguishable fields, including dimension fields and calculated indicator fields. Dimension fields may include indicators such as time, location, and product dimensions. Calculated indicator fields may include some commonly used calculated indicators, such as sales revenue, profit, total amount, and income. Specifically, some commonly used distinguishable fields can be configured and added to the distinguishable field library according to the actual business scenario. The distinguishable fields in the question can be obtained through simple matching. The system can also identify distinguishable fields in questions based on machine learning algorithms. The question is input into a named entity recognition (NER) model. This model can identify named entities in the question and label them as specific categories. In this embodiment, the named entity is the distinguishable field, and the labeled specific category can be the dimension field, calculated indicator field, or other fields mentioned above.
[0031] In practical implementation, the data analysis system can determine the score of each candidate form based on the parsing results of different candidate forms corresponding to the question, and then determine the form to be queried based on the scores. The voting algorithm may include weighted voting, ranking voting, etc., which are not specifically limited in this application. The scoring process of the candidate forms can be achieved by counting the number of fields in each candidate form that match the keyword, and determining the score of each candidate form based on the number of fields. Alternatively, it can be achieved by counting the matching degree between the fields in each candidate form that match the keyword and the keyword, and determining the score of each candidate form based on the matching degree. Alternatively, it can be achieved by combining both the number of fields and the matching degree to determine the score of each candidate form. Of course, more parameters can be combined to determine the score of the candidate forms, which are not specifically limited in this application.
[0032] The above implementation method filters multiple candidate tables from the database through the discriminative fields in the question, and then determines multiple parsing results of the question based on the thesaurus. Each parsing result corresponds to a candidate table. Then, the form to be queried is determined according to the score of the parsing result. This way, the process of user intent recognition and form location does not require starting a large language model, avoiding the need to start a large language model to process all user question inputs, thereby saving system resources.
[0033] In one possible implementation, obtaining similar case data for a question can be achieved by using mask labels to mark the word segments in the question, obtaining mask results. The mask labels are used to indicate the table data type corresponding to the word segments. The mask labels include multiple levels of mask labels, and the level of detail of the table data type information indicated by the mask labels at different levels is different. The mask labels include one or more of the following: table, dimension, metric, value, and synonym. The mask results are vectorized to obtain the hierarchical mask vector corresponding to the question. The hierarchical mask vector is then matched with a historical vector library to obtain similar case data for the question. The historical vector library includes historical hierarchical mask vectors corresponding to historical questions in the similar case data.
[0034] It should be understood that the masked result obtained after labeling the question can be a question composed of multiple masked labels, so that the masked result can contain information about the sentence structure backbone. Using the sentence backbone for similar case retrieval can retrieve more historical cases. Vectorizing the masked result can not only preserve the information about the sentence structure backbone, but also improve retrieval efficiency, because the vectorized data is easier to calculate. For example, similarity matching can be performed quickly by calculating cosine similarity, Euclidean distance, etc., which can reduce text complexity and make retrieval more efficient.
[0035] In practice, the level of detail in the table data type information indicated by different levels of mask labels varies. In other words, different levels of mask labels reflect their importance and priority in database queries. For example, the mask label indicating the "table name" has a higher level than the mask label indicating the "dimension," because the target table can be directly retrieved based on the table name, while multiple tables meeting the conditions may be filtered based on the dimension, and the target table still needs to be determined from among them. Therefore, the table name has a higher importance and priority than the dimension, and the corresponding mask label level is also higher. Similarly, multiple mask labels and their corresponding levels can be determined based on historical issues and the business requirements of actual application scenarios.
[0036] The above implementation method, by setting different levels of mask labels according to the importance and priority of data queries, can help the model better understand the structure of questions when faced with different types of queries, thereby obtaining more accurate and high-quality similar case data. For example, <metric>Tag segmentation helps the system locate the calculation metrics for queries, while <dimension>Tag-based word segmentation helps the system locate the dimensional information of the query. By identifying word segments with different levels of mask tags, the system can better understand the structure of the question. Simultaneously, word segments with different semantics but belonging to the same level can also be recognized by the system. This allows for the retrieval of cases with different content but similar structure, improving the model's generalization ability. For example, "sales revenue" and "price" are different indicators, but grammatically belong to the same level and can both be classified as such. <metric>The structured tags help improve the model's generalization ability in different scenarios, making the final similar case data more accurate and richer. The SQL statements generated using such similar case data and parsing results are more accurate, and the final response text is also more accurate.
[0037] In one possible implementation, obtaining similar case data for a question can be done by rewriting the question based on a thesaurus to obtain a rewritten question, in which at least one word in the rewritten question is replaced with at least one second keyword that matches the word, and similar case data for the question is obtained based on the rewritten question.
[0038] As mentioned above, the thesaurus stores the mapping relationship between keywords and synonyms. Keywords are determined based on the table data in the database, including information such as table names, field names, and enumeration values. Therefore, rewriting questions based on the thesaurus and replacing some insufficiently informative word segments with keywords can not only increase the amount of information expressed in the questions, but also make the questions more compatible with the field names in the database, reducing the understanding difficulty of large language models.
[0039] In practice, similar case data may include historical questions and corresponding database query statements, as well as intermediate results of the large language model based on historical questions and corresponding database query statements. The specific content included in the similar case data can be determined based on the actual business scenario, and will not be listed here.
[0040] In the specific implementation, the vector library includes historical hierarchical mask vectors corresponding to each similar case data. In the specific implementation, after obtaining the hierarchical mask vector corresponding to the parsing result of the question, the hierarchical mask vector can be matched with multiple historical hierarchical mask vectors in the vector library to obtain historical hierarchical mask vectors that match the hierarchical mask vector. Then, the similar case data corresponding to the historical hierarchical mask vector is obtained, and thus the similar case data corresponding to the question is obtained.
[0041] Optionally, if the hierarchical mask vector corresponding to the parsed result is matched with the historical vector database, and the number of successfully matched case data is multiple, each case data can be scored based on the degree of matching of the hierarchical mask vector in each case data, as well as the quality of the case data (such as the accuracy of the query results, the precision of the model, the recall rate, etc.). The best case data is then selected as the similar case data based on the scoring results. This application does not limit the TOPK recall method used for scoring or selecting the best case.
[0042] The above implementation method rewrites the question based on a thesaurus, replacing some words in the question with fields from the database to retrieve similar cases. This allows for more accurate similar case data to be obtained, thereby generating more accurate SQL statements. As a result, the response text of the conversational data retrieval software can better meet user needs and improve the user experience.
[0043] Secondly, a data analysis system is provided, comprising: a question acquisition unit for acquiring user requests sent by a client, the user request including associated data of a question input by the user; a classification unit for determining the type of user intent based on the user request, wherein the type of user intent is obtained based on the parsing result of the question, the parsing result including the mapping relationship between word segments in the question and mapping fields in the form to be queried; an information ratio judgment unit for calculating the information ratio of the parsing result when the type is a data query type, wherein the information ratio is used to indicate the number of word segments that have completed mapping in the question; and a first response unit for selecting the corresponding model based on the information ratio to obtain the response text corresponding to the question.
[0044] The system described in the second aspect, upon receiving a user's question, first maps the segmented words in the question to fields in the database to obtain a parsing result. Then, based on the parsing result, it classifies the user's intent. If the user's intent is a data table query, it further determines the information ratio in the parsing result and selects the corresponding model to obtain the response text. This method can achieve intent recognition of the question without activating a large language model, avoiding the need to activate a large language model for intent recognition for every question input by the user. This reduces the resource overhead caused by frequently activating a large language model. Furthermore, selecting different models to process questions based on the information ratio ensures the accuracy of the generated response text and meets the user's needs.
[0045] One possible implementation includes various modules for performing the data analysis system in the first aspect or any possible implementation of the first aspect.
[0046] Thirdly, this application provides a computing device including a processor, a memory, a communication interface, and a bus. The processor, memory, and communication interface are connected via the bus and communicate with each other. The memory stores computer execution instructions. When the processor is running, the processor executes the computer execution instructions in the memory to perform the operation steps of the method described in the first aspect or any possible implementation of the first aspect using the hardware resources in the processor.
[0047] Fourthly, this application provides a chip system including a processing chip and a power supply circuit, wherein the power supply circuit is used to supply power to the processing chip, and the processing chip is used to perform the operation steps of the method described in the first aspect or any possible implementation of the first aspect.
[0048] Fifthly, this application provides a computing device cluster, which includes multiple computing devices. Each computing device includes a processor, a memory, a communication interface, and a bus. The processor, memory, and communication interface are connected via the bus and communicate with each other. The memory stores computer execution instructions. When the processor is running, the processor executes the computer execution instructions in the memory to perform the operation steps of the method described in the first aspect or any possible implementation of the first aspect using the hardware resources in the processor.
[0049] Sixthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the methods described in the above aspects.
[0050] In a seventh aspect, this application provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the methods described in the above aspects.
[0051] Based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods. Attached Figure Description
[0052] Figure 1 This is an architecture diagram of a data analysis system provided in this application;
[0053] Figure 2 This is an example diagram of a data analysis system deployed on a cloud platform according to this application;
[0054] Figure 3 This is a flowchart illustrating the steps of a data analysis method provided in this application;
[0055] Figure 4 This is a sample dictionary diagram of a thesaurus provided in this application;
[0056] Figure 5 This is a flowchart illustrating the steps involved in determining the form to be queried in an application scenario using a data analysis method provided in this application.
[0057] Figure 6 This is an example diagram of a query rule provided in this application;
[0058] Figure 7 This is an example diagram of a mask label provided in this application;
[0059] Figure 8 This is a schematic diagram of the software structure of a data analysis system provided in this application;
[0060] Figure 9 This is a schematic diagram of the structure of a computing device provided in this application;
[0061] Figure 10 This is a schematic diagram of the structure of a computing device cluster provided in this application;
[0062] Figure 11 This is a schematic diagram of another computing device cluster provided in this application. Detailed Implementation
[0063] Typically, conversational data extraction software, including BI data extraction and analysis software in the BI field, such as tools, software, or cloud services that convert natural language to structured query language (NL2SQL), first inputs the user's question into an LLM (Local Language Management) system for intent recognition. This determines whether the user's intent (or user intent) is a query form. If the intent is not a query form, such as a question like "How are you?", the LLM's conversational functionality generates a corresponding answer. If the intent is a query form, such as a question like "What was the revenue of Project A this year?", the LLM parses the relevant fields in the question, generates a corresponding SQL statement, uses the SQL statement to query the database to obtain the query results, and then uses the query results to generate the corresponding answer.
[0064] Therefore, every time a user enters a question, a large language model needs to be started for intent recognition. The LLM is very large, containing hundreds of millions of parameters. Each time the large language model is loaded and started, it requires a lot of memory. Conversational data retrieval software will frequently receive user questions, and each question will trigger the LLM, resulting in significant memory overhead and a decrease in the performance of the data retrieval software.
[0065] Meanwhile, some simple query questions may not require starting the LLM. For example, if the user clearly asks which fields they want to query, such as "What is today's sales volume?", these questions can be solved by generating a simple SQL statement. However, some questions may not be query-type questions, such as "How are you?". In these cases, the LLM needs to be started to identify intent, parse fields, and generate SQL statements. This will result in significant memory overhead for the system, leading to a decrease in the performance of conversational data retrieval software.
[0066] Furthermore, since each question triggers an LLM (Local Language Model), and user questions can be diverse—some are for querying data, some for analyzing data, and some may be unrelated to data querying, such as chat-style questions—training a large language model requires using various types of or general data to meet the needs of most users. This can lead to problems such as generalization, inaccuracy, or inefficiency in the large language model's answers. For some specialized fields with high requirements for data retrieval accuracy, such as the BI (Business Intelligence) field, such a large language model cannot meet the user's needs.
[0067] In summary, conversational data retrieval software is based on Large Language Model (LLM). Each time a user inputs a question into the LLM, the LLM needs to be activated to generate the corresponding results. However, due to the randomness of user questions, some questions may not require the activation of the LLM. Activating the LLM for each question may not yield professional analysis results, resulting in a waste of resources.
[0068] To address the issue that data retrieval software requires launching a large model for each different question submitted by a user, which may result in unsatisfactory analysis and wasted resources, this application provides a data analysis method. After receiving a user's question, this method first obtains multiple candidate tables through simple initial screening. Then, based on a thesaurus, it determines the parsing results of each candidate table, completing the mapping between word segmentation in the question and fields in the candidate tables. Based on the parsing results, it locates the corresponding query form for the question. Finally, it categorizes the user's intent based on whether the query form meets the query rules, determining whether the user's intent is a data table query type or a non-data query type. This method can achieve intent recognition of questions without launching a large language model, avoiding the need to launch a large language model for intent recognition for each user's input, thereby reducing the resource overhead caused by frequently launching a large language model.
[0069] Meanwhile, after determining that the question is a data query question, the information ratio in the parsing results can be determined. If the information ratio is greater than the threshold, it means that the question has been parsed sufficiently, and SQL can be directly generated based on the parsing results to complete the data query and generate the corresponding response text. If the information ratio is not greater than the threshold, it means that the question has not been parsed sufficiently. In this case, similar cases can be obtained from the historical vector library and used as a supplement to the parsing results. These similar cases are then input into the large language model to obtain the corresponding SQL, ensuring that accurate SQL can be generated in most cases. This avoids frequent startup of the large language model and also ensures the accuracy of the generated response text, meeting the user's needs.
[0070] Figure 1 This is an architecture diagram of a data analysis system provided in this application, such as... Figure 1 As shown, the architecture may include a client 100, a data analysis system 200, and a database 300. Figure 1 As shown, the architecture may include a client 100, a data analysis system 200, and a database 300. The number of clients 100 and databases 300 that establish communication connections with the data analysis system 200 can be one or more. Figure 1 The example provided uses one client 100 as an illustration, and this application does not impose specific limitations. The aforementioned communication connection can be a wired connection or a wireless connection. Wired connections include Ethernet, wired lines, cables, etc., while wireless connections include wireless local area networks (Wi-Fi), cellular networks, etc. It may also include the Internet, local area networks (LANs), etc., which simultaneously support wired and wireless connections, and of course, other connection types may also be included, which this application does not impose specific limitations on.
[0071] Client 100 is deployed on terminal devices, computing devices, or edge computing devices. Terminal devices include personal computers, smartphones, wearable devices, handheld processors, tablets, mobile laptops, augmented reality (AR) devices, virtual reality (VR) devices, smart conferencing devices, etc., without specific limitations. Computing devices can be bare metal servers (BMS), virtual machines, or containers. BMS refers to a general-purpose physical server, such as an ARM server or an x86 server; a virtual machine refers to a complete computer system simulated by software, possessing full hardware system functionality and running in a completely isolated environment. Any task that can be performed on a physical computer can also be performed in a virtual machine. When creating a virtual machine on a computing device, a portion of the physical machine's hard drive and memory capacity needs to be used as the virtual machine's hard drive and memory capacity. Each virtual machine has its own independent basic input / output system (BIOS), hard drive, and operating system, allowing it to be operated like a physical machine. A container is a portable software unit that combines an application and all its dependencies into a single software package. This package is not limited by the underlying host operating system, eliminating the need to build complex environments and simplifying the application development and deployment process. Edge computing devices are hardware devices located close to the data source or data user.
[0072] The data analysis system 200 can be a computing device or a cluster of computing devices, or a chip or a chip system. The description of the computing device is as described above, and this application does not impose specific limitations. The chip can be implemented using a central processing unit (CPU), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), a system-on-a-chip (SoC), or any combination thereof, and this application does not impose specific limitations. It may also include processors or accelerator cards that have good performance when performing machine learning tasks and can improve the speed and efficiency of neural network training, such as graphics processing units (GPUs), neural network processing units (NPUs), data processing units (DPUs), tensor processing units (TPUs), etc., which are not specifically limited in this application.
[0073] Database 300 can be deployed on computing devices or clusters of computing devices, or on storage devices or storage arrays composed of multiple storage devices. The descriptions of computing devices and computing device clusters are as described above and will not be repeated here. Storage devices can be hard disk drives (HDDs), solid-state drives (SSDs), mechanical hard disks (HDDs), USB flash drives (universal serial buses, USB), flash memory, SD cards (secure digital memory cards, SD cards), Memory Sticks, etc., and this application does not impose specific limitations. Storage arrays can be redundant arrays of independent disks (RAID), network attached storage (NAS), storage area networks (SANs), etc., and this application does not impose specific limitations.
[0074] Optionally, the client 100 and the data analysis system 200 may be deployed on the same computing device, or the client 100 and the data analysis system 200 may be deployed on different computing devices in the same computing device cluster, or the client 100 and the data analysis system 200 may be deployed on different computing devices in different computing device clusters. This application does not make any specific limitations.
[0075] Optionally, the database 300 and the data analysis system 200 may be deployed on the same computing device, or on different computing devices in the same computing device cluster, or on different computing device clusters. Alternatively, the database 300 may be deployed on a storage device and the data analysis system may be deployed on a computing device. The storage device and the computing device may belong to the same or different computing device clusters. This application does not make any specific limitations.
[0076] Optionally, client 100 can be software or an application running on a user-controlled terminal device or computing device, such as a personal computer (PC) client, a web client accessed via a browser, an application (APP) client running on a mobile terminal, or a cloud platform console; this application does not impose specific limitations. Users holding client 100 can be users who need to complete data queries or data analysis through natural language, such as financial staff, IT staff, and business personnel of an enterprise; this application does not impose specific limitations.
[0077] In practice, Client 100 is applied to fields with data analysis and query needs, such as data analysis, data mining, data exploration, and data querying. These include, but are not limited to, the biomedical field (e.g., epidemiological research, drug development), the financial field (business data analysis, tax case analysis, risk assessment, market forecasting), the social media field (personalized recommendation, advertising positioning, sentiment analysis), and the sales field (pricing strategy, inventory management, customer relationship management). It can also be applied to many other fields with data analysis needs, which will not be listed here.
[0078] Optionally, client 100 may be a client specifically designed for database querying and / or data analysis. The type of client 100 and the type of user may differ across different data analysis fields. For example, in the biomedical field, client 100 may be a bioinformatics tool, statistical analysis software, etc., used to process and analyze biological data such as genomics, proteomics, and gene expression. In the social media field, client 100 may be a data mining tool, social media analysis platform, etc., used to discover public opinion trends, user interactions, and sentiment analysis from social media data. In the financial field, client 100 may be a financial modeling tool, risk analysis software, etc., used for market analysis, portfolio optimization, and risk management. In the sales field, client 100 may be an inventory management tool, pricing analysis software, etc., used for optimizing inventory, supply chain analysis, and formulating product pricing strategies. It should be understood that the above examples are for illustrative purposes only and this application does not impose specific limitations.
[0079] In specific implementation, the client 100 can be a separate client specifically designed for implementing data analysis / query functions, such as a client for data analysis software or a database client. It can also be a data analysis / query function module or plugin within comprehensive software, a data analysis and query module within data mining software, or a data analysis assistant or data query assistant in commonly used enterprise (office automation, OA) clients. This application does not impose any specific limitations.
[0080] Optionally, client 100 can also be a client for a conversational chatbot, which can be a chatbot for scenarios with data query needs, such as an OA office assistant chatbot, a financial analysis assistant chatbot, etc. This application does not make specific limitations.
[0081] As one possible implementation method, Figure 1 In addition to the above-described architecture, the data analysis system shown can also be deployed through data centers or cloud platforms. Specifically, client 100 can also be a client of a cloud platform, used for users to purchase and rent various cloud services. The data analysis method provided in this application can be one of these cloud services, such as database cloud services, BI data retrieval cloud services, BI analysis cloud services, or other cloud services used to implement natural language-based data querying and analysis. Examples are not provided here.
[0082] The preceding text has described in detail the possible deployment methods for the data analysis system 200, database 300, and client 100. In actual deployment, any of the above methods can be flexibly adopted based on specific application scenarios and business needs. The following section provides an exemplary illustration of the actual deployment methods for the data analysis system 200, database 300, and client 100 using specific application scenarios.
[0083] As an example of an application scenario where the data analysis system 200 is deployed on a local device, the client 100 can be BI analysis software or BI data retrieval software. Enterprise employees can use the client 100 to perform data queries, real-time problem solving, technical support, data analysis, and other operations. In this scenario, the database 300, the data analysis system 200, and the client 100 can be deployed on the enterprise's internal office equipment. For example, the data analysis system 200 and the database 300 can be deployed on a service or server cluster purchased by the enterprise, and the client 100 can be deployed on the enterprise's office computers. Enterprise employees, as users, can use their office computers to run the client. Client 100 sends the user-inputted question to data analysis system 200. Data analysis system 200 can execute the data analysis method provided in this application to generate an SQL statement corresponding to the input question. Using the SQL statement, it searches the database 300 to obtain the query results corresponding to the question. Then, based on the query results, it generates a reply text and sends it back to the client. Client 100 displays the reply text to the user, enabling enterprise employees to complete BI data retrieval or BI analysis based on natural language, and realize data query or other functions based on data query, such as market analysis, portfolio optimization, and risk management.
[0084] As an example of an application scenario where a data analysis system 200 is deployed on a cloud platform, the data analysis system 200 can be deployed on a cloud platform, for example... Figure 2 This is an example diagram of a data analysis system deployed on a cloud platform, as provided in this application. Figure 2 As shown, a user can initiate a purchase request for a database cloud service through client 100. This database cloud service includes a data query sub-service based on natural language. After client 100 sends the purchase request to the cloud platform, the cloud platform can provide client 100 with access to the cloud services of data analysis system 200 and database 300. This allows the user to send a question to data analysis system 200 through client 100. Data analysis system 200 can use the data analysis method provided in this application to convert the question into an SQL statement, and then use the SQL statement to query in database 300 to obtain the query results. Based on the query results, it obtains the corresponding answer text for the question and returns it to client 100.
[0085] The cloud platform also maintains various basic resources, including computing resources, storage resources, network resources, and security resources, to meet the computing needs of the data analysis system 200 under different scales and loads. Furthermore, these computing resources can be dynamically scaled according to the usage needs of the data analysis system 200 to ensure the stable operation of the data analysis system 200 and provide users with reliable data query services.
[0086] Optionally, the database 300 and the data analysis system 200 can be services provided by the same cloud platform. Figure 2 The cloud platform shown includes a database 300 and a data analysis system 200. Alternatively, the database 300 and the data analysis system 200 may be services provided by different cloud platforms. In this case, a hybrid cloud architecture can be used to achieve data communication between the data analysis system 200 and the database 300. That is, the data analysis system 200 is deployed in data center A, and the database 300 is deployed in data center B. Data center A and data center B communicate with each other through their respective cloud platforms to achieve data communication between the data analysis system 200 and the database 300, thereby implementing the data analysis method provided in this application.
[0087] It is worth noting that, Figure 2 In the example shown, the data analysis system 200 is deployed and implemented in a cloud platform. Figure 2 This is merely an exemplary description of the data analysis system involved in this application, and this application does not impose any specific limitations.
[0088] Alternatively, the data analysis system 200 can also be deployed across multiple cloud platforms, for example, Figure 1 The thesaurus 210 and query rules 220 shown are deployed on the first cloud platform, the historical vector library 230 is deployed on the second cloud platform, and the dialogue model 240, the first model 250 and the second model 260 are deployed on the third cloud platform. The above examples are for illustration only and are not specifically limited in this application.
[0089] Alternatively, the data analytics system 200 can also be deployed across multiple non-cloud platforms, for example, Figure 1 The thesaurus 210, query rules 220, and historical vector library 230 shown are deployed on the internal office server of Company A, while the dialogue model 240, the first model 250, and the second model 260 are deployed on the internal office server of Company B. Company A and Company B have a cooperative relationship. The above example is for illustration only and is not specifically limited in this application.
[0090] Optionally, the data analytics system 200 can also be deployed across multiple cloud platforms and non-cloud platforms. For example, Figure 1 The thesaurus 210, query rules 220, and historical vector library 230 shown are deployed on the enterprise's internal office server. The dialogue model 240 is deployed on the first cloud platform, and the first model 250 and the second model 260 are deployed on the second cloud platform. The above examples are for illustration only and are not specifically limited in this application.
[0091] It should be understood that this application does not limit the deployment methods of the thesaurus 210, query rules 220, historical vector library 230, dialogue model 240, first model 250, and second model 260. For ease of description, the following embodiments use... Figure 2 The system structure shown is used as an example for explanation.
[0092] It should be understood that the above application scenarios are for illustrative purposes only. The data analysis system 200, database 300, and client 100 can be flexibly deployed according to actual business needs. These will not be illustrated one by one here.
[0093] The possible system architecture of this application has been described above. The following is a brief explanation of how this system architecture implements the data communication method provided in this application.
[0094] In this embodiment, the data analysis system 200 can receive user requests sent by the client 100. These requests include associated data, such as text, voice, or images, used to indicate user input. Then, based on whether the question includes a distinguishing field, the system filters multiple candidate tables from the database 300. Next, based on the thesaurus 210, each candidate table is parsed to obtain a parsing result. This parsing result includes the mapping relationship between word segmentation in the question and fields in the candidate tables. Finally, based on the parsing result, a query form is selected from the multiple candidate tables.
[0095] Furthermore, determine whether the form to be queried conforms to query rule 220. If it does not conform, determine that the question is a non-data query type question (that is, a question that does not require querying database 300, such as "Hello" or "The weather is nice today"), and the user intent is non-data query type. In this case, the dialogue model 240 can be used to generate the response text for the non-data query type question. If it conforms, determine that the question is a data query type question (that is, a question that requires querying database 300, such as "Please give me the profit statement for Department A in 2013"), and the user intent is data query type.
[0096] Furthermore, for data query questions that require data to be retrieved from the database, the information ratio corresponding to the parsing results of the query form is determined. The information ratio indicates the proportion of word segments that have completed mapping in the question displayed in the parsing results. If the information ratio is greater than a threshold, it means that most word segments in the parsing results have completed mapping between the fields in the candidate table. The parsing results can be input into the first model 250 to generate the corresponding database query statement (e.g., SQL statement). If the information ratio is less than a threshold, it means that most word segments in the parsing results have not completed mapping. Based on the parsing results and the question, similar case data can be obtained from the historical vector library 230. Then, the similar case data and the parsing results are input into the second model 260 to generate SQL. Finally, after obtaining the SQL corresponding to the question, the data analysis system 200 can send the SQL to the database 300 for execution to obtain the query results, and obtain the response text for the query question based on the query results.
[0097] In practice, determining the information ratio corresponding to the parsing result of the query form refers to determining the information ratio based on the number of words that have completed mapping in the parsing result and the total number of words contained in the question. This information ratio may include the ratio between the number of words that have completed mapping and the total number of words.
[0098] In its implementation, query rule 220 can determine whether a query conforms to the rules based on the number of calculated fields and dimensions in the query form. The purpose of the query rule is to ensure that the parsed results of the query form meet the standards for data querying. Specifically, the query rule can determine the type of user intent based on whether the query form includes calculated fields and the number of dimensions. It should be understood that data query type questions typically require data to be segmented, grouped, aggregated, or analyzed in multiple dimensions within the database. To answer these questions, the query form needs to have certain dimensions and calculated fields. If the structure of the query form determined after parsing the question is very simple, such as having no calculated fields and only one dimension, or having calculated fields but only one other dimension, it indicates that the form cannot support multi-dimensional analysis and querying, and cannot answer query type questions. Therefore, the question is likely not a data query type question.
[0099] It should be understood that this application parses the candidate table through the thesaurus 210 to obtain the query form, and then determines whether the query form conforms to the rules based on the query rules 220, thereby classifying the questions. This ensures that after the data analysis system receives a question, it does not directly start the large language model for intent recognition. The large language model is only started after it is determined to be a query statement. This enables the large language model to be started on demand, thereby reducing the number of times the large language model is started and reducing the memory overhead caused by frequent startup of the large language model.
[0100] Meanwhile, this application evaluates the quality of the parsing results by determining the information ratio in the parsing results. When the information ratio is greater than the threshold, it means that most of the word segments in the question have been mapped. At this time, SQL statements can be directly generated based on the parsing results. When the information ratio is less than the threshold, it means that many word segments in the question have not been mapped and have not been parsed thoroughly. At this time, similar case data can be generated based on the historical vector library 230. Then, SQL statements can be generated based on the similar case data and the parsing results, so that questions in most cases can be completely parsed and accurate SQL statements can be obtained.
[0101] Optionally, the thesaurus 210 may include a mapping relationship between keywords and synonyms. Keywords are obtained based on table data in the database, including table names, field names, and enumeration values corresponding to the field names. Synonyms refer to near-synonyms, industry terms, colloquialisms, etc., that have the same meaning as the keywords, and this application does not impose specific limitations on them.
[0102] For example, the keywords "invoice" in the database have the same meaning as "reimbursement voucher" and "tax document," and the keyword "invoice" can be mapped to the synonyms "reimbursement voucher" and "tax document." Similarly, the keyword "amount" in the database has the same meaning as "price," "value," and "amount," and the keyword "amount" can be mapped to these three synonyms. The above examples are for illustrative purposes only and are not intended to impose specific limitations in this application.
[0103] Furthermore, when matching the question with a thesaurus, the question can be divided into multiple segments. If a keyword matches a segment, that keyword becomes the first keyword corresponding to that segment. If a synonym matches a segment, the keyword corresponding to that synonym becomes the first keyword corresponding to that segment. If no keyword or synonym matches a segment, a semantic similarity algorithm can be used to determine the closest keyword or synonym to that segment, thus obtaining the first keyword corresponding to that segment. Semantic similarity algorithms may include, but are not limited to, edit distance algorithms, Jaccard similarity algorithms, cosine similarity algorithms, etc., and this application does not impose specific limitations.
[0104] Optionally, the data analysis system 200 can determine the hierarchical mask vector corresponding to the parsing result, and then match the hierarchical mask vector with the historical vector library 230, which includes historical hierarchical mask vectors corresponding to the parsing results of historical cases. In this way, by matching the hierarchical mask vectors, similar historical cases related to the question can be filtered out.
[0105] In practice, a hierarchical mask vector can be obtained by labeling the word segments in a question with mask tags to obtain a mask result, and then vectorizing the mask result. The mask tags indicate the data type of the table to which the word segment belongs, such as the word belonging to the table name, table dimension, table field, table enumeration value, or a synonym of the enumeration value. Thus, the mask result obtained after labeling the question can be a question composed of multiple mask tags, allowing the mask result to contain information about the sentence structure. Using the sentence structure for similar case retrieval can retrieve more historical cases. Vectorizing the mask result not only preserves the information about the sentence structure but also improves retrieval efficiency because the vectorized data is easier to compute, such as calculating cosine similarity or Euclidean distance for rapid similarity matching, reducing text complexity and resulting in higher retrieval efficiency.
[0106] For example, if a user enters the question: "Query the sales revenue and regional distribution for 2023 in the sales revenue table", then the masked result obtained after using mask labels could be: "Query"< / metric> < / dimension> < / metric> Tag segmentation can help the system quickly locate the table information being queried. <value>of <metric>and <dimension>The parentheses contain the mask label. The result of the mask can be vectorized to obtain the hierarchical mask vector, such as word embedding vectorization or other vectorization operations. This application does not make any specific limitations.
[0107] Furthermore, a hierarchical relationship can exist between mask labels. Mask labels at different levels indicate varying levels of detail regarding the table data type information. In other words, different levels of mask labels can reflect their importance and priority in database queries. For example, a mask label indicating "table name" has a higher level than a mask label indicating "dimension," because the target table can be directly retrieved based on the table name, while multiple tables meeting the criteria may be filtered based on the dimension, from which the target table still needs to be determined. Therefore, the table name has higher importance and priority than the dimension, and correspondingly, its mask label has a higher level. Similarly, multiple mask labels and their corresponding levels can be determined based on historical issues and the business requirements of actual application scenarios.
[0108] For example, mask labels may include tables, dimensions, calculated metrics, values, synonyms, etc. These mask labels are ordered according to their hierarchy, with tables having the highest hierarchy and values the lowest. Based on the mask labels containing hierarchy information, queries can be marked. For example, a query like "Query the sales revenue and regional distribution for 2023 in the sales revenue table" can be processed into a query.< / dimension> < / metric> < / value> middle <value>of <metric>and <dimension>The parentheses contain the mask label. The mask result is then vectorized to obtain a hierarchical mask vector. This hierarchical mask vector is then matched against a historical vector database to obtain similar case data with the same question structure.
[0109] It should be understood that setting different levels of mask labels according to the importance and priority of data queries can help the model better understand the structure of the question when faced with different types of queries, thereby obtaining more accurate and high-quality similar case data. For example,< / dimension> < / metric> < / value> middle <metric>Tag segmentation helps the system locate the calculation metrics for queries, while <dimension>Tag-based word segmentation helps the system locate the dimensional information of the query. By identifying word segments with different levels of mask tags, the system can better understand the structure of the question. Simultaneously, word segments with different semantics but belonging to the same level can also be recognized by the system. This allows for the retrieval of cases with different content but similar structure, improving the model's generalization ability. For example, "sales revenue" and "price" are different indicators, but grammatically belong to the same level and can both be classified as such. <metric>Labels, these structured labels, help improve the model's generalization ability in different scenarios, making the final obtained similar case data more accurate and richer.
[0110] It should be noted that, Figure 1 In the example shown, dialogue model 240, first model 250, and second model 260 are different models. In some possible implementations, dialogue model 240, first model 250, and second model 260 can be the same model, such as a large language model. Alternatively, dialogue model 240, first model 250, and second model 260 can be combined into one model in pairs. For example, first model 250 and second model 260 can be a large language model, and dialogue model 240 can be another AI model. The specific model can be determined according to the actual business scenario, and this application does not impose any specific limitations.
[0111] It should be noted that, in Figure 1 In the example shown, the first model 250 and the second model 260 can be the same model, such as a large language model. Alternatively, the first model 250 and the second model 260 can be different models, where the second model 260 is a large language model and the first model is an AI model or a model based on a query statement template. The query statement template may include fixed positions and fill positions. The fill positions are filled according to the mapping relationship between word segments and fields in the parsing result to obtain a complete SQL statement. It should be understood that when the information ratio is greater than the threshold, since the parsing result includes a relatively complete mapping between word segments and fields, the corresponding SQL statement can be generated through some simple SQL templates or other AI models. Therefore, the first model can also be a mapping relationship model that stores simple SQL templates, or it can be some AI model other than a large language model. When the information ratio is less than the threshold, the mapping results included in the parsing result are incomplete, and many word segments in the question have not been mapped. In this case, a large language model can be used to generate the corresponding SQL based on the parsing result and similar case data. This application does not make specific limitations.
[0112] In specific implementations, the aforementioned large language model may include, but is not limited to, generative pre-trained transformers (GPT), bidirectional encoder representations from transformers (BERT), and text-to-text transformers (T5), etc., and this application does not impose any specific limitations.
[0113] In summary, the data analysis system provided in this application can, after receiving a question from a user, first obtain multiple candidate tables through simple initial screening, then determine the parsing results of each candidate table based on a thesaurus, completing the mapping between word segmentation in the question and fields in the candidate tables, then locate the form to be queried corresponding to the question based on the parsing results, and then classify the user intent according to whether the form to be queried meets the query rules, determining whether the user intent is a data query type or a non-data query type. This method can complete the intent recognition of the question without starting a large language model, avoiding the situation where a large language model needs to be started for intent recognition every time a user enters a question, thereby reducing the resource overhead caused by frequently starting a large language model.
[0114] Meanwhile, after determining that the question is a query-type question, the information ratio in the parsing results can be determined. When the information ratio is high, SQL is generated based on the parsing results to complete the data query and generate the corresponding response text. When the information ratio is low, similar cases are obtained from the historical vector library and used as a supplement to the parsing results. These similar cases are then input into the large language model to obtain the corresponding SQL, ensuring that accurate SQL can be generated in most cases. This improves the accuracy of the generated response text and enhances the user experience.
[0115] The above text combined Figure 1 and Figure 2 The data analysis system to which the technical solution to be protected in this application is applicable has been described by way of example. Next, in conjunction with... Figure 3 This application further describes the data analysis methods that are to be protected. Figure 3 This is a flowchart illustrating the steps of a data analysis method provided in this application, as shown below. Figure 3 As shown, the method may include the following steps:
[0116] S301: Client 100 sends a user request with user input to data analysis system 200.
[0117] Optionally, the user request includes associated data of a question entered by the user. This associated data includes at least the aforementioned question, which can include any type of natural language text entered by the user through client 100. This includes not only traditional interrogative sentences but also various types of natural language text such as requests, commands, statements, emotional expressions, and suggestions. For example, a request-type question could be: "Query the number of people in Department A." A command-type question could be: "Set a reminder for the 8 o'clock meeting." A statement-type question could be: "I am very happy today." Emotional or social interaction-type questions could be: "Hello," "What is your name?" etc. A suggestion-type question could be: "Recommend a good movie," and there can be many other types of questions, such as confirmation or clarification questions like: "Did you give me the sales data for Department A in January?" Examples are not provided here.
[0118] It should be understood that for the data analysis system 200, any text input by the user needs to provide an answer to the question. Therefore, any text input by the user can be regarded as a question. However, from the user's perspective, the natural language text sent to the data analysis system 200 is not limited to interrogative sentences. It can also be declarative sentences or chat-type statements. For the sake of convenience and uniformity, this application refers to the text input by the user as a question, but the actual meaning expressed is not limited to interrogative sentences.
[0119] In specific implementation, the above-mentioned question can be natural language text input by the user through the client 100, natural language text generated by the client 100 based on speech recognition technology after the user inputs voice through the client 100, text extracted by image recognition, natural language text extracted by video text extraction technology, or other formats of user question data. This application does not make specific limitations.
[0120] Optionally, the question can be a data query question, that is, a question that requires querying table data in database 300. Since this type of question requires querying database 300, it needs to include descriptions of some query conditions, such as the range of table data to be queried (table name, column names, etc.), the operations to be performed on the table data (sorting, filtering, etc.), the visualization requirements for the table data to be viewed (line chart, table, bar chart, etc.), and may also include descriptions of more query conditions, which are not listed here. For example, the question could be "What is the total sales revenue of product A today?" or "What was the total revenue of department B last year?" The above examples are for illustrative purposes only and are not intended to limit the scope of the query.
[0121] Optionally, the question can also be unrelated to data query, that is, a question that does not require querying data from tables in database 300. For example, the question could be "Hello" or "What is today's date?", to meet the user's dialogue needs in various scenarios. The above examples are for illustration only and are not specifically limited in this application.
[0122] Optionally, the associated data may include not only the question mentioned above, but also multimodal data such as contextual information related to the question, audio, video, images, and sensor data. The multimodal data is used to assist in expressing the question. For example, the question may include: "Can this invoice be used for travel expense reimbursement?" and an image of an invoice. It should be understood that the above examples are for illustration only, and this application provides specific limitations.
[0123] Optionally, the associated data may also include user identity information, such as user account information, device information, and geographical location. This information helps the system more accurately understand user requests and obtain more accurate response text. The associated data may also include time information to support user questions involving time requirements, such as "tomorrow's weather." User requests may also include additional parameters or instructions, such as the user setting a preference for "brief language response" or "providing detailed technical instructions." These additional parameters or instructions enable the system to generate response text that better meets the user's preferences, improving the user experience. The above examples are for illustrative purposes; the associated data may include much more content, which will not be listed here.
[0124] It should be understood that traditional data analysis or data retrieval software (such as BI analysis software and BI data retrieval software) requires users to input database query statements (such as SQL) to complete data querying and analysis. Therefore, users need to learn relevant database knowledge in advance before conducting data analysis, resulting in a high learning threshold. The data analysis system provided in this application can complete data querying and analysis through a dialogue, allowing users to easily perform data queries without needing database knowledge, thus reducing the user's learning cost. For example, the table name of a balance sheet may be a string. If using traditional data analysis software, users need to write SQL statements based on this string when using SQL queries. Using the method of this application, users can directly input: "I need a balance sheet," which is more efficient.
[0125] S302: Data analysis system 200 obtains multiple candidate tables based on questions.
[0126] Optionally, the data analysis system 200 can identify distinct fields in the query and filter multiple candidate tables from the database based on these distinct fields. These candidate tables are forms that include the distinct fields in the query. Distinctive fields are fields that can distinguish different data records or tables, or fields that can be used to narrow down the query scope. It should be understood that forms generally include common fields and distinct fields. Common fields are fields shared across a large number of forms; these fields usually appear in different forms. Filtering based on common fields will result in an excessive number of candidate tables, wasting subsequent computational resources. Distinctive fields, on the other hand, appear in a small number of forms and may even be unique fields, such as primary keys. Distinctive fields are fields that can explicitly specify the query scope or conditions during the query. Filtering based on distinct fields results in a smaller number of candidate tables, reducing the waste of subsequent computational resources. For example, form 1 includes the fields: time, order number, and revenue; form 2 includes the fields: time, product type, and cost. Here, time is a common field, while order number and product type can be distinct fields. The examples above are for illustrative purposes only and are not intended to be specific limitations in this application.
[0127] In specific implementation, distinguishable fields can include dimension fields and calculated indicator fields. Dimension fields are used to describe the dimensions or categories of data and can be used to group, sort, and filter data. Dimension fields can be determined based on the segmentation or filtering conditions that data analysis may require. Typically, dimension fields can include time dimensions, geographical dimensions, business dimensions, etc. Time dimensions refer to dates, such as year, month, quarter, etc. Business dimensions can include product categories, departments, customers, etc., and may include more dimension fields, which are not specifically limited in this application. Calculated indicator fields are fields that include numerical attributes and are used for mathematical calculations or statistical analysis. Calculated indicator fields can be determined based on the quantitative indicators that data analysis may require. Typically, calculated indicator fields can include numerical fields, metric fields, dynamic fields, etc. Numerical fields include numerical data and can be used for mathematical operations, such as summation, averaging, counting, etc. Metric fields are used to quantify various metrics in the business process, such as sales revenue, number of orders, profit, cost, etc. Dynamic fields change dynamically with time and different business processes. In simple terms, dimension fields are used to describe the classification and grouping of data, such as time, location, product category, etc. Calculated indicator fields are used to describe the quantity or measurement of data, such as sales, quantity, cost, etc. Differentiating fields may include more types, which are not specifically limited in this application.
[0128] For example, if the question is "What was the total sales in China in 2023?", the distinguishing fields identified could be: "2023", "China", and "total sales". Here, "2023" is the time dimension field, "China" is the region dimension field, and "total sales" is the calculation indicator field. The above example is for illustrative purposes only and is not intended to impose specific limitations.
[0129] Optionally, the system can identify distinguishable fields in questions based on a preset distinguishable field library. After segmenting the question into words, multiple words are obtained. These multiple words are then matched with the distinguishable field library to determine the distinguishable fields among them. The distinguishable field library may include some pre-stored distinguishable fields, including dimension fields and calculated indicator fields. Dimension fields may include indicators such as time dimension, location dimension, and product dimension. Calculated indicator fields may include some commonly used calculated indicators, such as sales, profit, total amount, and revenue. Specifically, some commonly used distinguishable fields can be configured and added to the distinguishable field library according to the actual business scenario, and the distinguishable fields in the question can be obtained through simple matching.
[0130] Optionally, the system can also identify discriminative fields in the question based on machine learning algorithms. The question is input into a named entity recognition (NER) model, which can identify named entities in the question and label them as specific categories. In this embodiment, the named entity is the discriminative field, and the specific category can be a dimension field, a calculated indicator field, or other fields among the discriminative fields mentioned above.
[0131] In practice, the NER network can be trained using a sample set to obtain a trained NER model. The sample set includes a large number of samples, each containing a question labeled with discriminative fields (such as dimension fields and calculated metric fields). The model can include long short-term memory (LSTM) models, conditional random field (CRF) models, bidirectional encoder representations from transformers (BERT) models, etc., and this application does not impose specific limitations.
[0132] It should be understood that the above examples provide two methods for identifying distinctive fields. In specific implementations, other methods may exist to identify distinctive fields, and this application does not impose any specific limitations.
[0133] S303: The data analysis system 200 parses multiple candidate tables to obtain the parsing results for each candidate table.
[0134] In one possible implementation, the data analysis system 200 can determine at least one keyword based on a question, and then match the keyword against multiple candidate forms to obtain a parsing result. This parsing result includes the fields corresponding to the keyword in the multiple candidate forms. The keyword includes a primary keyword and a secondary keyword. The primary keyword is obtained by matching the word segmentation with a preset thesaurus, and the secondary keyword is obtained by parsing the word segmentation using a rule-based parsing method.
[0135] It should be understood that traditional solutions primarily rely on LLM (Liquidity Management Model) to perform detailed semantic recognition and analysis of questions, obtaining parsing results—that is, the mapping relationship between word segments in the question and fields in the database. Unlike traditional LLM-based semantic parsing processes, this solution, based on keyword matching, can obtain the mapping relationship between word segments and database fields from a thesaurus, directly obtaining parsing results without needing to start LLM for semantic recognition and analysis. This reduces the resource consumption associated with starting LLM. Furthermore, the thesaurus in this application can store richer synonyms, near-synonyms, industry slang, etc., resulting in more accurate parsing results compared to traditional LLM-based solutions.
[0136] The first and second keywords will be explained below.
[0137] First, the first keyword is explained. In this embodiment, the data analysis system 200 first determines the word segmentation in the question, and then matches the word segmentation with a preset thesaurus to obtain the first keyword corresponding to the word segmentation. Specifically, the thesaurus may include a mapping relationship between keywords and synonyms. Keywords are obtained based on table data in a database, including table names, field names, and enumeration values corresponding to the field names. Synonyms refer to near-synonyms, industry terms, colloquialisms, etc., that have the same meaning as the keyword, and this application does not impose specific limitations on them.
[0138] For example, the keywords "invoice" in the database have the same meaning as "reimbursement voucher" and "tax document," and the keyword "invoice" can be mapped to the synonyms "reimbursement voucher" and "tax document." Similarly, the keyword "amount" in the database has the same meaning as "price," "value," and "amount," and the keyword "amount" can be mapped to these three synonyms. The above examples are for illustrative purposes only and are not intended to impose specific limitations in this application.
[0139] Furthermore, when matching the word segment in the question with a thesaurus, if a keyword matching the word segment exists, that keyword becomes the first keyword corresponding to the word segment in the question; if a synonym matching the word segment exists, the keyword corresponding to that synonym can be used as the first keyword corresponding to the word segment in the question; if no keyword or synonym matching the word segment exists, the keyword or synonym closest to the word segment can be determined based on a semantic similarity algorithm, thus obtaining the first keyword corresponding to the word segment. Semantic similarity algorithms may include, but are not limited to, edit distance algorithms, Jaccard similarity algorithms, cosine similarity algorithms, etc., and this application does not impose specific limitations.
[0140] In specific implementation, the meaning represented by the above word segmentation matching can include being the same as the word segmentation, or it can include having a semantic similarity to the word segmentation that is higher than a threshold. For example, the keyword matching the word segmentation can refer to the keyword that is exactly the same as the word segmentation, or it can refer to the keyword that has a semantic similarity to the word segmentation that is higher than a threshold. This application does not make any specific limitations.
[0141] In specific implementation, before S301, the data analysis system 200 can import information such as table names, field names, and corresponding enumeration values from the database into a thesaurus to obtain multiple keywords. Then, it determines the synonyms of these keywords and establishes a mapping relationship between keywords and synonyms. If enumeration values from different fields are duplicated, deduplication can be performed. Specifically, duplicate enumeration values can be retained, and the mapping relationship between duplicate enumeration values and tables, fields, etc., can be recorded. When determining synonyms based on keywords, it can be implemented through algorithms or user configuration; this application does not impose specific limitations. For example, when determining synonyms based on algorithms, synonyms for each keyword can be determined based on existing thesaurus and thesaurus, or semantic similarity algorithms (such as similarity calculations based on pre-trained models like Word2Vec, GloVe, and BERT) can be used to determine keyword synonyms. When implementing based on user configuration, multiple keywords can be displayed to the user, who can then configure some corresponding industry terms or colloquialisms. The above examples are for illustration only and this application does not impose specific limitations.
[0142] For example, a database includes form X, named "Transaction Record Table," with the following fields: "Transaction ID," "Transaction Type," and "Transaction Amount." The enumerated values under "Transaction Type" include "Buy," "Sell," and "Transfer." After importing form X into a thesaurus, the mapping between word segmentation and synonyms can be obtained as shown in Table 1 below. In the example shown in Table 1, the keywords are the original table name, fields, and enumerated values of the database. In some possible implementations, the original table name, fields, and enumerated values of the database can also be processed to obtain keywords, such as through translation, deduplication, or word segmentation. This application does not impose specific limitations on this.
[0143] Table 1. Examples of keywords and corresponding synonyms
[0144] < / metric> < / dimension> < / metric> Tag segmentation can help the system quickly locate the table information being queried. Keywords Synonyms Transaction ID Transaction number, order ID Transaction type Transaction methods and operation types Buy Purchase, buy, buy operation Sell Sell, selling operation, selling, sales transfer Remittance, transaction, and transfer operations Transaction amount Amount, transaction volume, price Transaction record sheet Transaction statements, financial data statements, and buy / sell record statements
[0145] Optionally, the above-mentioned thesaurus can be implemented using a trie, which is a tree-like data structure that includes multiple nodes, each node representing a character. All characters on the path from the root node to each node can form a keyword. In this way, keywords with the same prefix can share prefix characters in the trie, thereby saving storage space. At the same time, it can also respond quickly when querying data, improving the efficiency of keyword retrieval.
[0146] In practical implementation, after determining the keywords and their corresponding synonyms, the keywords can be written into a trie, and the synonyms of the keywords can be stored in a synonym list. Each keyword is associated with its corresponding synonym list, thus achieving the storage of keywords and their corresponding synonyms. Specifically, taking the first keyword as an example, starting from the root node of the trie, multiple characters of the first keyword can be inserted into the trie in order from first to last. When inserting each character into the trie, it is necessary to first check whether the child node of the current node already has a node corresponding to the character to be inserted. If not, a new child node is created in the current node, and the character to be inserted is used as the key value of the new child node. If it exists, the next character is obtained and inserted into the trie, and so on, until the last character is inserted into the trie. After that, the node corresponding to the last character can be determined as the terminal node, and then the synonyms of the first keyword are written into the synonym field of the terminal node, such as the synonyms field. Alternatively, the synonyms can be written into a synonym list, and then the position information of the synonyms of the first keyword in the synonym list can be written into the synonyms field. This application does not make specific limitations. Alternatively, synonyms or their position information in the list can be written into the leaf nodes of the terminal node. Synonyms can also be stored in other ways, which are not specifically limited in this application.
[0147] For example, assuming the primary keyword is "cat" and synonyms are "kitty" and "kitten", when inserting "cat" into the trie, the characters include c, a, and t. Starting from the root node, it checks if a child node with the key "c" exists among the multiple child nodes connected to the root node. If not, a new child node is created at the root node to store the key "c". If it exists, the next character "a" is inserted, and the process continues. It checks if a child node with the key "a" exists among the child nodes of "c". If not, a new child node is created among the child nodes of "c" to store the key "a". If it exists, the last character "t" is inserted, and the process continues. It checks if a child node with the key "t" exists among the child nodes of "a". If not, a new child node is created among the child nodes of "a" to store the key "t". If it exists, the character insertion operation ends, and the child node "t" is set as the terminal node, storing ["kitty", "kitten"] in the synonyms field of that node. The above example is for illustration only and is not intended to be specific.
[0148] Furthermore, after creating the trie, the word segments in the question are matched against the trie to obtain the first keyword corresponding to the word segment. Taking the first word segment as an example, starting from the root node of the trie, the system checks if the first character of the first word segment exists in the child nodes of the root node. If it exists, the system checks if the second character of the first word segment exists in the next child node, and so on, until the first keyword corresponding to the first word segment is found. If no keyword matches the word segment, the word segment can be matched with a list of synonyms, or the word segment can be matched with the synonym field of each terminal node. After obtaining the synonyms that match the word segment, the keyword corresponding to the synonym is determined as the first keyword corresponding to the word segment. If neither the synonym nor the keyword matches the word segment, a matching failure message can be returned. Matching can refer to two words being completely identical, or their semantic similarity being higher than a threshold; this application does not impose specific limitations.
[0149] Furthermore, if the enumeration value data volume is large, some general rules can be used to perform semantic parsing on the enumeration values and convert them into codes. For example, the item code contains 7 characters, consisting of numbers and letters, without having to store a large amount of data in a trie. In this way, after the user inputs a question, the word segmentation in the question can use the trie to look up the database-matching keywords. Such keywords can help the model parse the correct semantics and avoid the situation where the model has difficulty correctly understanding the actual semantics of the user's question due to the diversity of language habits and industry practices of different users.
[0150] For example, Figure 4 This is a sample dictionary diagram of a thesaurus provided in this application. Figure 4An example is given based on the mapping relationship between the keywords and synonyms shown in Table 1. To better understand this application, in this example, each character uses Chinese characters as an example for distance. In the actual processing process, Chinese characters or English characters can be converted into encoded forms and stored in the trie, which can further reduce the occupation of storage space.
[0151] In Figure 4 the example, a trie demonstration is established with multiple keywords containing the character "交" in Table 1 as examples. Other keywords such as "buy", "sell", "transfer", etc. can also establish tries in a similar way, which will not be repeated here. Among them, as the first leaf node of the root node, the leaf nodes of the character "交" include the character "易", and the leaf nodes of the character "易" include "金", "记", "类", "I", and so on. The established trie can store the following keywords: "transaction amount", "transaction record table", "transaction type", and "transaction ID". This storage method can store keywords with the same prefix in the way of prefix sharing, thus saving storage space.
[0152] Among them, the terminal node corresponding to each keyword, that is, the node corresponding to the last character of the keyword, can record the synonyms corresponding to the keyword or the position information of the synonyms. Figure 4 In Figure 4 the example, the synonyms are recorded in the synonym field of the terminal node, such as the synonyms field. If there are many synonyms for a keyword, a synonym list can be recorded separately, and the position of the synonym in the list is recorded in the synonym field of the terminal node. This application does not make specific limitations.
[0153] It should be understood that the trie is a possible implementation method of the above synonym library. The synonym library provided by this application can also be implemented through other data structures, such as data structures like hash table, graph, index, etc. This application does not limit this.
[0154] Secondly, the second keyword is explained. In the embodiment of this application, the second keyword can be obtained after processing the question sentence using one or more rule parsing algorithms. The rule parsing algorithm is used to determine the important words in the question sentence.
[0155] Optionally, the rule parsing algorithm may include a time parsing algorithm to determine the time information involved in the question, such as "January 1st" or "2018," and the second keyword may include the aforementioned time information. In specific implementations, the time parsing algorithm can extract time information through methods such as number recognition, context analysis, and time entity recognition. Number recognition refers to recognizing numbers in the text and mapping them to specific numerical values such as dates and times; for example, recognizing "0103" as January 3rd. Context analysis refers to understanding the contextual meaning of relative time expressions such as "tomorrow" or "yesterday," and combining this with the current date or time to determine the time information involved in the question; for example, recognizing "tomorrow" as November 13th. Time entity recognition refers to recognizing and extracting time-related entities, such as May 1st, 2024, 3 PM, and every Wednesday. The above examples are for illustration; time parsing algorithms can include many other methods, which will not be listed here.
[0156] Optionally, the rule parsing algorithm may include a word segmentation algorithm to divide the question into multiple words, and the second keyword may include multiple words. Word segmentation is the process of dividing a continuous text into multiple meaningful words or phrases. Word segmentation algorithms may include, but are not limited to, dictionary-based maximum matching methods, hidden markov models (HMMs), CRF, LSTM, BERT, etc., and this application does not impose specific limitations.
[0157] Optionally, the rule parsing algorithm may also include a preprocessing algorithm, which refers to cleaning and standardizing the multiple word segments obtained by the above word segmentation algorithm to improve the subsequent effect, including removing stop words, removing special characters, removing spelling errors, etc. The second keyword may include multiple preprocessed word segments.
[0158] It should be noted that the above examples provide some possible rule parsing algorithms. In specific implementations, more types of rule parsing algorithms can be used in combination with actual business scenarios. This application does not impose any specific limitations.
[0159] It should be understood that this application matches the first keyword in the question by using a pre-set thesaurus, and uses some rule parsing algorithms to parse data not stored in the thesaurus (such as project codes, contract numbers, etc.) to determine the field names corresponding to these word segments. This allows most of the word segments in the question to be parsed accordingly, completing the mapping with the fields in the database. The parsing results obtained in this way are more accurate, enabling the subsequent large model to understand the semantics of the question more accurately.
[0160] In this embodiment of the application, after obtaining the first keyword based on the thesaurus and the second keyword based on the rule parsing algorithm, the fields in the database corresponding to the keywords can be obtained through fuzzy matching, and then the parsing results can be obtained. The parsing results include the mapping relationship between the word segmentation in the question and the fields in multiple candidate tables in the database.
[0161] In specific implementations, the algorithms used for fuzzy matching may include semantic-based matching algorithms such as edit distance (Levenshtein algorithm), TF-IDF algorithm, cosine similarity algorithm, BERT / transformer, etc., and may include more algorithms. This application does not make specific limitations.
[0162] For example, Table 2 is an example of the parsing results of the candidate tables provided in this application. As shown in Table 2, the parsing results of each candidate table may include the mapping relationship between the keywords in the question and the fields in the candidate table. It should be understood that Table 2 is for illustrative purposes only and this application does not impose any specific limitations.
[0163] Example of parsing results for candidate tables in Table 2
[0164]
[0165] S304: The data analysis system 200 retrieves the query form from multiple candidate tables based on the parsing results of each candidate table.
[0166] In a specific implementation, the data analysis system 200 can determine the score of each candidate form based on the parsing results, and then determine the form to be queried based on the score. The voting algorithm may include weighted voting, ranking voting, etc., and this application does not make specific limitations.
[0167] Optionally, the scoring process for the candidate forms can be achieved by counting the number of fields in each candidate form that match the keywords, and determining the score for each candidate form based on the number of fields. Alternatively, the score can be determined by counting the matching degree between the fields matching the keywords in each candidate form and the keywords themselves. Alternatively, the score for each candidate form can be determined by combining both the number of fields and the matching degree. Of course, more parameters can be combined to determine the score of the candidate forms; this application does not impose specific limitations on this.
[0168] To facilitate understanding, the following will be combined with... Figure 5 The process of locating the form to be queried in S302 to S304 above will be illustrated with an example.
[0169] Figure 5 This is a flowchart illustrating the steps involved in determining the form to be queried in an application scenario using a data analysis method provided in this application. For example... Figure 5As shown, assuming the user's question is: "In January, which main products in Department A's projects had the highest LV2 revenue?", after obtaining this question, we can first execute S302 to determine the distinguishing fields in the question. Based on these distinguishing fields, we can filter out multiple candidate tables from the database. These candidate tables are forms that include the distinguishing fields in the question. For example, Table 1 is the project revenue details table, and Table 2 is the project profit and loss table.
[0170] Next, step S303 can be executed to obtain the first keyword based on the thesaurus, including "Department A" and "Main Product LV2". Then, the second keyword is obtained based on the rule parsing algorithm. The time-related parsing algorithm can obtain time-related second keywords, including "January" and "202401". The word segmentation and preprocessing algorithm can obtain other second keywords, including "January", "Department A", "Project", "Main Product LV2", "Revenue", and "Highest". Then, the first and second keywords are fuzzy matched with the candidate table to obtain the fuzzy matching results, completing the mapping between keywords and fields in the candidate table. For example, the keyword "Project" can be mapped to the candidate table fields "Project Code" and "Project Name" to obtain the parsing results. Figure 5 In the example, the keywords "department" and "accounting period" in the parsing results of Tables 1 and 2 were mapped to the fields in the candidate tables.
[0171] Finally, S304 can be executed to score the parsing results of the two candidate tables. For example, by calculating 'a' as the percentage of fields matching the keyword in each candidate table out of the total number of words in the question, and 'b' as the sum of the matching degrees of each matched field, the score of the parsing result is determined based on 'a' and 'b'. For example, (a+b) can be used as the score of the parsing result; this application does not specify a specific value. Then, a vote is held based on the scores to select the final form to be queried. For a detailed description, please refer to the relevant description in S304; it will not be repeated here. Figure 5 In this example, the final form to be queried is Table 1. It should be understood that... Figure 5 This application provides an example where, through S302 to S304, the query form corresponding to the question can be quickly located. The process of determining the query form does not require starting the large language model. Subsequently, the large language model can be started on demand based on the query form, avoiding the problem of high resource consumption caused by starting the large language model for all questions.
[0172] S305: The data analysis system 200 determines the type of user intent based on the parsing results of the query form.
[0173] Specifically, user intent types include data query type and non-data query type, which can also be understood as question types being data query type and non-data query type. Data query type refers to questions that require generating SQL to complete a database query, while non-data query type refers to questions that do not require generating SQL to complete a database query, such as a question like "Hello". When the user intent type is data query type, S306 is executed; when the user intent type is non-data query type, S312 is executed.
[0174] In its implementation, the data analysis system 200 can determine the type of user intent based on query rules. If the parsed result of the form to be queried satisfies the query rules, it indicates that the question is a data query question, or in other words, the user intent is a data query type. If the parsed result of the form to be queried does not conform to the rules, it indicates that the question is a non-data query question, or in other words, the user intent is a non-data query type. The query rules can be determined based on the number of dimensions that have been mapped in the parsed result; specifically, the user intent can be determined based on whether the number of dimensions exceeds a dimension threshold. The purpose of the query rules is to ensure that the parsed result of the form to be queried meets the standards for data querying.
[0175] Optionally, the query rules may include: determining the type of user intent based on the dimension information of the mapping field in the parsing results; for user intent queries of the data query type, the number of dimensions to which the mapping field belongs in the parsing results is greater than the dimension threshold. Conversely, for user intent queries of the non-data query type, the number of dimensions to which the mapping field belongs in the parsing results is not greater than the dimension threshold.
[0176] Furthermore, query rules can determine the type of user intent based on whether the query form includes calculated fields and the number of dimensions. It should be understood that query-type questions typically require data segmentation, grouping, aggregation, or multi-dimensional analysis in the database. To answer these questions, the query form needs to have certain dimensions and calculated fields. If the query form structure determined after parsing the question using S301–S303 is very simple—for example, having no calculated fields and only one dimension, or having calculated fields but only one of other dimensions—it indicates that the form cannot support multi-dimensional analysis and querying, and therefore cannot answer query-type questions. In this case, the question is likely a non-data query type question.
[0177] In specific implementation, the dimension threshold can include a first quantity and a second quantity. The query rule can determine the type of user intent in the following way: when the mapping fields in the parsing result include calculated fields and non-calculated fields, and the number of dimensions to which the non-calculated fields belong is greater than the first quantity, the user intent is determined to be a data query intent; or, when the mapping fields in the parsing result do not include calculated fields, and the total number of dimensions to which the mapping fields belong is greater than the second quantity, the user intent is determined to be a data query intent.
[0178] For example, Figure 6 This is an example diagram of a query rule provided in this application. For example... Figure 6 As shown, after determining the form to be queried, it can be determined whether the mapped fields in the parsed results of the form include calculated fields. If calculated fields are included, it is determined whether the number of other dimensions besides the calculated fields in the mapped fields is less than 1. If it is not less than 1, the user intent type is determined to be a data query intent. If calculated fields are included and the number of other dimensions is less than 1, the user intent type is determined to be a non-data query type. If calculated fields are not included and the total number of dimensions is not less than 1, the user intent type is determined to be a data query intent. If calculated fields are not included and the total number of dimensions is less than 1, the user intent type is determined to be a non-data query type.
[0179] It should be understood that Figure 6 This is an example of a query rule provided in this application. Figure 6 In the example, both the first and second quantities are 1. This application does not limit the specific values. In the specific implementation, other query rules can be combined to determine whether the user intent is a data query type based on the parsing results of the form to be queried. For user intents that are not data query types, the corresponding question can be determined based on the dialogue model to determine the corresponding response text.
[0180] S306: Determine whether the information ratio of the parsed results of the form to be queried exceeds the threshold. If it exceeds the threshold, execute S309; otherwise, execute S307.
[0181] In practice, if the parsed result of the query form contains a high amount of information (i.e., the information ratio exceeds a threshold), the large language model can be skipped, and the corresponding SQL can be generated based on the parsed result of the query form. If the information content is insufficient (i.e., the information ratio does not exceed the threshold), the large language model can be activated to further parse and generate the corresponding SQL. It should be understood that by comparing the information ratio with the threshold, the large language model can be invoked on demand, thus avoiding the need to activate the large language model for every query, reducing the system overhead caused by frequent activation of the large language model, and improving the performance of the data analysis system.
[0182] Optionally, the parsing results of the query form include the mapping relationship between the keywords of the question and the fields in the query form. Based on the parsing results, the effective word segmentation length that completes the mapping in the question, as well as the total length of the question after removing stop words, can be determined. The information ratio can then be determined based on the effective word segmentation length and the total length. Specifically, the specific value of the information ratio can be obtained by calculating the ratio of the effective word segmentation length to the total length.
[0183] For example, suppose the query is: "Query the names and positions of all employees older than 30". Based on the parsing results, the effective word segments for mapping include "age", "30", "name", and "position", with a total effective word segment length of 8. After removing stop words, the query becomes: "query", "age", "greater than", "30", "employee", "name", and "position", with a total word segment length of 14 and an information ratio of 8 / 14. The above example is for illustration only and is not intended to be specific.
[0184] Optionally, the threshold can be determined by analyzing historical data from the data analysis system 200, combined with the precision and recall of historical labeled data. Specifically, the information ratio of the historical query can be determined based on the parsing results of the query form for the historical query. Then, the precision and recall of the SQL query determined by rule parsing for that historical query can be determined. Based on the relationship between different information ratios and precision and recall, the minimum information ratio is determined, which is the threshold. This minimum value indicates that if the information ratio is lower than the threshold, the precision and recall of the rule parsing results cannot meet the actual needs. In this way, by selecting the threshold based on the information ratios of different parsing results of historical data, combined with business scenarios and actual needs, the system can maintain an ideal balance between precision and recall.
[0185] S307: The data analysis system 200 matches the hierarchical mask vector corresponding to the question with the historical vector database to obtain similar case data corresponding to the question.
[0186] Optionally, the data analysis system 200 can determine the hierarchical mask vector corresponding to the question, and then match the hierarchical mask vector with a historical vector library, which includes historical hierarchical mask vectors corresponding to historical questions. In this way, by matching the historical vector library, historical similar case data related to the question can be obtained.
[0187] In its implementation, the data analysis system 200 matches questions with mask labels, marks the word segments in the question with mask labels to obtain mask results, and then performs vector transformation on the question based on the mask results to obtain hierarchical mask vectors. The mask labels indicate the data type of the table to which the word segment belongs, such as the word belonging to the table name, table dimension, table field, table enumeration value, or a synonym of the enumeration value. Thus, the mask results obtained after labeling the question can be composed of multiple mask labels, allowing the mask results to contain information about the sentence structure. Using the sentence structure for similar case retrieval can retrieve more historical cases. Vectorizing the mask results not only preserves the information about the sentence structure but also improves retrieval efficiency because the vectorized data is easier to compute, such as calculating cosine similarity or Euclidean distance for rapid similarity matching, reducing text complexity and making retrieval more efficient.
[0188] For example, if a user enters the question: "Query the sales figures and regional distribution for 2023 in the sales figures table," then the masked result obtained after using mask labels could be: "Query..." <value>of <metric>and <dimension>The parentheses contain the mask label. The result of the mask can be vectorized to obtain the hierarchical mask vector, such as word embedding vectorization or other vectorization operations. This application does not make any specific limitations.
[0189] Furthermore, a hierarchical relationship can exist between mask labels. Different levels of mask labels indicate different levels of detail in the table data type information, or in other words, different levels of mask labels can reflect their importance and priority in database queries. For example, the mask label indicating "table name" has a higher level than the mask label indicating "dimension," because the target table can be directly retrieved based on the table name, while multiple tables meeting the conditions may be filtered based on the dimension, and the target table still needs to be determined from among them. Therefore, the table name has a higher importance and priority than the dimension, and the corresponding mask label has a higher level. Similarly, multiple mask labels and their corresponding levels can be determined based on historical issues and the business requirements of actual application scenarios.
[0190] For example, mask labels may include tables, dimensions, calculated metrics, values, synonyms, etc. These mask labels are ordered according to their hierarchy, with tables having the highest hierarchy and values the lowest. Based on the mask labels containing hierarchy information, queries can be marked. For example, a query like "Query the sales revenue and regional distribution for 2023 in the sales revenue table" can be processed into a query.< / dimension> < / metric> < / value> middle <value>of <metric>and <dimension>The parentheses contain the mask label. The mask result is then vectorized to obtain a hierarchical mask vector. This hierarchical mask vector is then matched against a historical vector database to obtain similar case data with the same question structure.
[0191] It should be understood that setting different levels of mask labels according to the importance and priority of data queries can help the model better understand the structure of the question when faced with different types of queries, thereby obtaining more accurate and high-quality similar case data. For example,< / dimension> < / metric> < / value> middle <metric>Tag segmentation helps the system locate the calculation metrics for queries, while <dimension>Tag-based word segmentation helps the system locate the dimensional information of the query. By identifying word segments with different levels of mask tags, the system can better understand the structure of the question. Simultaneously, word segments with different semantics but belonging to the same level can also be recognized by the system. This allows for the retrieval of cases with different content but similar structure, improving the model's generalization ability. For example, "sales revenue" and "price" are different indicators, but grammatically belong to the same level and can both be classified as such. <metric>Labels, these structured labels, help improve the model's generalization ability in different scenarios, making the final obtained similar case data more accurate and richer.
[0192] For example, Figure 7 This is an example image of a mask label provided in this application, such as... Figure 7 As shown, mask labels can include tables, dimensions, calculated metrics, values, and synonyms. Tables have the highest hierarchy, and values have the lowest. Based on mask labels containing hierarchy information, questions can be labeled. For example, if the question is "What is the straight-line revenue of Department A from January to present, as determined by contract parsing?", after labeling with mask labels, the following can be obtained: Figure 7 The mask result is shown, and then the mask result is vectorized, such as by embedding vectorization, to obtain a hierarchical mask vector. Then, the hierarchical mask vector is matched with the historical vector library to obtain similar case data with the same question structure.
[0193] It should be understood that the process involves identifying the components of a question through masking labels, marking these components with their corresponding table structure types, and then performing vector transformation to obtain a hierarchical mask vector. This hierarchical mask vector contains both the question structure information and the corresponding table structure information. Based on this structural information, matching can be performed in a historical vector database to find similar cases with similar structural information. Using the above example, if the question "Query the sales revenue and regional distribution for 2023 in the sales revenue table" is used to search the historical case database, there may not be an exact match. However, if the question can be transformed into: "Query...", the search results will be much more accurate.< / metric> < / dimension> < / metric> Tag segmentation can help the system quickly locate the table information being queried. <value>of <metric>and <dimension>Then, other query cases with the same structure can be searched, such as: "Query the salary and department of employees who joined in March in the employee table", which makes the search accuracy of similar case data higher, and thus can improve the processing accuracy of the subsequent large language model.
[0194] In specific implementation, the data analysis system 200 can generate a historical vector library based on historical data, mark the historical questions in the historical data according to the above mask labels, obtain the historical mask results corresponding to the historical questions, and then perform vector transformation on the historical mask results in the same way to obtain the hierarchical mask vectors corresponding to the historical questions. Then, a mapping relationship is established between the hierarchical mask vectors and the historical data, and stored in the historical vector library. In this way, when a new question arrives, the new question can complete the retrieval of historical cases based on the question structure.
[0195] Optionally, before determining the hierarchical mask vector, the question can be rewritten based on a thesaurus to make the word segmentation in the question more compatible with the fields in the database, facilitating the understanding of the semantics of the question by the large language model. (Still using...) Figure 7 Taking the example shown, suppose the question is: "What is the straight-line revenue of Department A from January to now?" This question lacks sufficient information. It can be rewritten using a thesaurus. The keyword for "straight-line" is determined to be "contract parsing result is straight-line". Therefore, the rewritten result is: "What is the straight-line revenue of Department A from January to now, based on contract parsing results?" This makes the question more information-rich, facilitating the generation of corresponding SQL by the large language model.
[0196] As mentioned above, the thesaurus stores the mapping relationship between keywords and synonyms. Keywords are determined based on the table data in the database, including information such as table names, field names, and enumeration values. Therefore, rewriting questions based on the thesaurus and replacing some insufficiently informative word segments with keywords can not only increase the amount of information expressed in the questions, but also make the questions more compatible with the field names in the database, reducing the understanding difficulty of large language models.
[0197] In practice, similar case data may include historical questions and corresponding database query statements, as well as intermediate results of the large language model based on historical questions and corresponding database query statements. The specific content included in the similar case data can be determined based on the actual business scenario, and will not be listed here.
[0198] In the specific implementation, the vector library includes historical hierarchical mask vectors corresponding to each similar case data. In the specific implementation, after obtaining the hierarchical mask vector corresponding to the parsing result of the question, the hierarchical mask vector can be matched with multiple historical hierarchical mask vectors in the vector library to obtain historical hierarchical mask vectors that match the hierarchical mask vector. Then, the similar case data corresponding to the historical hierarchical mask vector is obtained, and thus the similar case data corresponding to the question is obtained.
[0199] Optionally, if the hierarchical mask vector corresponding to the parsed result is matched with the historical vector database, and the number of successfully matched case data is multiple, each case data can be scored based on the degree of matching of the hierarchical mask vector in each case data, as well as the quality of the case data (such as the accuracy of the query results, the precision of the model, the recall rate, etc.). The best case data is then selected as the similar case data based on the scoring results. This application does not limit the TOPK recall method used for scoring or selecting the best case.
[0200] S308: The data analysis system 200 obtains the database query statement corresponding to the question based on the parsing results and similar case data.
[0201] In specific implementation, the parsing results and similar case data can be input into the second model 260 to generate the SQL corresponding to the question. The second model 260 can be a large language model, such as GPT, QWEN, T5, BERT, etc., and this application does not impose specific limitations. It should be understood that a large language model, trained on a large amount of text data, can understand complex language structures, semantic relationships, and contextual relationships. Utilizing its language generation capabilities, it converts natural language into database query statements. Here, database query statements refer to query statements that the database can execute, such as SQL statements.
[0202] It should be understood that, when the parsing results are found to be insufficient, this application supplements the parsing results with similar case data, so that the large language model can obtain sufficient information and the generated SQL statements are more accurate.
[0203] Optionally, the large language model can generate updated parsing results based on the parsing results and similar case data, and then generate database query statements based on the updated parsing results. The large language model may include a correction module to check whether the updated parsing results generated by the large language model are reasonable and accurate. If the check result is unsatisfactory, the correction module can return a corrected version or mark the error information, requiring the model to perform further reasoning or supplementation. The correction module can interact with the large language model in multiple rounds until the check result of the updated parsing results generated by the large language model is satisfactory. This ensures that the final updated parsing results are correct and reasonable, and the generated SQL can be more accurate.
[0204] In its implementation, the correction module can determine the validity of the parsing result based on the semantic consistency between the mapped word segments and the fields. It can also determine the validity based on whether the mapped word segments and fields meet the query conditions, and further, based on whether the field types match or whether field constraints conflict. For example, if a field is of type "date," the correction module can verify whether the user's query meets the semantic requirement of a "date range query." The above examples are for illustrative purposes; the correction module can also determine the validity of the parsing result based on many more rules, which are not specifically limited in this application.
[0205] S309: The data analysis system 200 obtains the database query statement corresponding to the question based on the parsing results.
[0206] In a specific implementation, the parsing results can be input into the first model 250 to generate the SQL corresponding to the question. The first model 250 can be the same model as the second model 260, such as the same large language model. The large language model can generate SQL statements based on the parsing results, or it can generate SQL statements based on the parsing results and similar case data.
[0207] Optionally, the first model 250 can be a model based on a query statement template. The query statement template may include templates of some SQL statements, which may include some empty spaces. Filling these empty spaces based on the parsing results yields a complete SQL statement. For example, if a user queries the maximum value of a certain field, the system can select the template `select max(column)` and then fill in the parameters of that template based on the parsing results. Furthermore, some optimization algorithms can be combined to optimize the generated SQL statement, such as avoiding redundant join operations and selecting appropriate indexes for querying. This application does not impose specific limitations on these optimizations.
[0208] Optionally, the first model 250 can also be an AI model other than a large language model, such as a Seq2Seq (Sequence-to-Sequence) model. This model first converts the natural language question into a fixed-length vector representation, and then generates an SQL statement through a decoder. This method learns the mapping from natural language to SQL statements through a large amount of training data. The SQL statement can also be obtained through other AI models; this application does not impose specific limitations on this.
[0209] S310: Data analysis system 200 sends a database query statement to database 300 and obtains the query results.
[0210] In practice, database 300 can receive the database query statement, i.e., SQL, execute the SQL to obtain the corresponding query results, and return them to the data analysis system 200.
[0211] S311: Data analysis system 200 obtains the response text corresponding to the question based on the query results.
[0212] Optionally, the data analysis system 200 can utilize the natural language generation capabilities of a large language model to obtain the corresponding response text based on the query results. The query results and the question are input into the large language model, which then generates a context-appropriate response text. For example, if the query result is 10000 and the question is "What is today's sales volume?", the large language model can generate natural and diverse response texts based on the user's tone and emotion, as well as specific contextual scenarios. For instance, the response text could be: "Today's sales volume exceeded 10,000 yuan; please continue your efforts." These examples are for illustrative purposes only and are not intended to impose specific limitations.
[0213] Optionally, the data analysis system 200 can also use a script template to populate the query results and obtain the corresponding response text. For example, the script template is: "Today's sales are {sales_amount} yuan". Based on this script template, the query result 1000 is populated into the template to obtain the response text: "Today's sales are ten thousand yuan".
[0214] It should be understood that in the specific application of the technical solution, the dialogue template can be a pre-set expression of the answer framework based on the questions involved in the data retrieval or data analysis scenario. In this way, the accuracy and compliance of the answer content are standardized through the template form. In the specific implementation process, other templates of expression forms can also be pre-set in the data analysis system 200 to achieve similar functions based on business needs. The data analysis system 200 generates the answer text by combining the query results. This application does not specifically limit the specific form of the dialogue template or other template methods.
[0215] S312: The data analysis system 200 determines that the user's intent is a non-data query type and generates the corresponding response text based on the dialogue model.
[0216] Optionally, when the data analysis system 200 determines that the user's intent is a non-data query type, and there is no need to generate SQL statements or perform retrieval in the database, it can use some dialogue models to generate the response text corresponding to the question. The dialogue model can be a large language model or other types of models, and this application does not make specific limitations.
[0217] S313: Data analysis system 200 sends a reply text to client 100.
[0218] Specifically, the data analysis system 200 can send a reply text to the client, which can then display the reply text to the user or play it to the user in other languages or videos. This application does not impose any specific limitations on this.
[0219] In summary, the data analysis method provided in this application can, after receiving a question from a user, first obtain multiple candidate tables through simple initial screening, then determine the parsing result of each candidate table based on a thesaurus, completing the mapping between word segmentation in the question and fields in the candidate tables, then locate the form to be queried corresponding to the question based on the parsing result, and then classify the user intent according to whether the form to be queried meets the query rules, determining whether the user intent is a data query type or a non-data query type. This method can complete the intent recognition of the question without starting a large language model, avoiding the situation where a large language model needs to be started for intent recognition every time a user enters a question, thereby reducing the resource overhead caused by frequently starting a large language model.
[0220] Meanwhile, after determining that the question is a query-type question, the information ratio in the parsing results can be determined. When the information ratio is high, SQL is generated based on the parsing results to complete the data query and generate the corresponding response text. When the information ratio is low, similar cases are obtained from the historical vector library and used as a supplement to the parsing results. These similar cases are then input into the large language model to obtain the corresponding SQL, ensuring that accurate SQL can be generated in most cases. This improves the accuracy of the generated response text and enhances the user experience.
[0221] The data analysis method provided in this application has been described in detail above. The following section will combine... Figure 8 The software structure of the data analysis system provided in this application will be explained. This data analysis system can be... Figures 1-7 The data analysis system 200 shown.
[0222] Figure 8 This is a schematic diagram of the software structure of a data analysis system provided in this application, such as... Figure 8 As shown, the data analysis system 200 includes a question acquisition unit 710, a candidate table acquisition unit 720, a parsing unit 730, a classification unit 740, a second response unit 750, an information ratio judgment unit 760, a first response unit 770, and a case retrieval unit 780. It should be understood that... Figure 8 This is an exemplary division method. The data analysis system 200 can be divided into more or fewer unit modules, and this application does not make any specific limitations.
[0223] The question acquisition unit 710, candidate table acquisition unit 720, parsing unit 730, classification unit 740, second response unit 750, information ratio judgment unit 760, first response unit 770, and case retrieval unit 780 can all be implemented in software or hardware. For example, the implementation of parsing unit 730 will be described below. Similarly, the implementation of question acquisition unit 710, candidate table acquisition unit 720, classification unit 740, second response unit 750, information ratio judgment unit 760, first response unit 770, and case retrieval unit 780 can refer to the implementation of parsing unit 730.
[0224] As an example of a software functional unit, the parsing unit 730 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the aforementioned computing instance may be one or more. For example, the parsing unit 730 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0225] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0226] As an example of a hardware functional unit, the parsing unit 730 may include at least one computing device, such as a server. Alternatively, the parsing unit 730 may be implemented using a central processing unit (CPU), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), a data processing unit (DPU), a neural network processing unit (NPU), a system-on-a-chip (SoC), an offload card, an inference card, or any combination thereof.
[0227] The multiple computing devices included in the parsing unit 730 can be distributed in the same region or in different regions. Similarly, the multiple computing devices included in the parsing unit 730 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the parsing unit 730 can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, GALs, DPUs, NPUs, SoCs, offload cards, and inference cards.
[0228] It should be noted that, in other embodiments, the steps implemented by the question acquisition unit 710, candidate table acquisition unit 720, parsing unit 730, classification unit 740, second response unit 750, information ratio judgment unit 760, first response unit 770, and case retrieval unit 780 can be specified as needed. The question acquisition unit 710, candidate table acquisition unit 720, parsing unit 730, classification unit 740, second response unit 750, information ratio judgment unit 760, first response unit 770, and case retrieval unit 780 respectively implement different steps in the data analysis method to achieve all the functions of the data analysis system 200.
[0229] The functions of the question acquisition unit 710, the candidate table acquisition unit 720, the parsing unit 730, the classification unit 740, the second response unit 750, the information ratio judgment unit 760, the first response unit 770, and the case retrieval unit 780 are explained below.
[0230] Question acquisition unit 710 is used to acquire user requests sent by the client. The user request includes associated data of the user-input question, and is specifically used to implement... Figure 3 S301 and its optional steps in the embodiments.
[0231] Classification unit 740 is used to determine the type of user intent based on the user request. The type of user intent is obtained based on the parsing result of the question, which includes the mapping relationship between word segmentation in the question and mapping fields in the form to be queried. This is specifically used to implement... Figure 3 S302 to S305 and their optional steps in the embodiments.
[0232] The information ratio judgment unit 760 is used to calculate the information ratio of the parsing result when the type is a data query. The information ratio indicates the number of words that have completed mapping in the question. Specifically, it is used to implement... Figure 3 S306 and its optional steps in the embodiments.
[0233] The first response unit 770 is used to select the corresponding model based on the information ratio to obtain the response text corresponding to the question. Specifically, it is used to implement... Figure 3 S307 to S312 and their optional steps in the embodiments.
[0234] In one possible implementation, the first response unit 770 is used to input the parsing result into the first model to obtain the database query statement corresponding to the question when the information ratio is greater than a threshold. The first response unit 770 is also used to obtain the response text corresponding to the question based on the database query statement. The threshold is determined based on multiple historical data sets, each of which includes the information ratio of historical parsing results for historical questions and the accuracy of the database query statement generated by the first model based on the historical parsing results. Specifically, it is used to implement... Figure 3 S309 to S311 and their optional steps in the embodiments.
[0235] In one possible implementation, the case retrieval unit 780 is used to obtain similar case data of the question when the information ratio is not greater than a threshold, and the first response unit 770 is used to input the parsing result and similar case data into the second model to obtain the database query statement corresponding to the question. Specifically, it is used to implement... Figure 3 S307, S308, S310, S311 and their optional steps in the embodiments.
[0236] In one possible implementation, the parsing unit 730 is used to determine the parsing result of the question based on the associated data of the question. The parsing result includes the mapping relationship between the word segmentation in the question and the mapping field in the form to be queried. The classification unit 740 is used to determine the type of user intent based on the dimension information to which the mapping field belongs in the parsing result. Specifically, it is used to implement... Figure 3 S302 to S305 and their optional steps in the embodiments.
[0237] In one possible implementation, the parsing unit 730 is used to match the word segments in the question with a thesaurus to obtain a first keyword that matches the word segments. The thesaurus includes keywords and their corresponding synonyms. The first keyword includes keywords that match the word segments, or keywords corresponding to synonyms that match the word segments. The keywords are obtained based on table data in a database, which includes one or more of table names, table fields, and enumerated values. The parsing unit 730 is used to complete the mapping relationship between the word segments and the mapping fields in the query form based on the first keyword, obtaining the parsing result of the question. Specifically, it is used to implement... Figure 3 S303 and its optional steps in the embodiments.
[0238] In one possible implementation, the case retrieval unit 780 is used to mark the word segments in the question using mask labels to obtain mask results. The mask labels are used to indicate the table data type corresponding to the word segments. The mask labels include multiple levels of mask labels, and the level of detail of the table data type information indicated by the mask labels at different levels is different. The mask labels include one or more of the following: table, dimension, metric, value, and synonym. The case retrieval unit 780 is used to vectorize the mask results to obtain the hierarchical mask vector corresponding to the question. The case retrieval unit 780 is used to match the hierarchical mask vector with the historical vector library to obtain similar case data of the question. The historical vector library includes historical hierarchical mask vectors corresponding to historical questions in the similar case data.
[0239] In one possible implementation, the parsing unit 730 is used to determine the parsing result of the question based on the associated data of the question, and to determine the type of user intent based on the dimension information of the mapping field in the parsing result. The number of dimensions of the parsing result of the question corresponding to the user intent of the data query type is greater than the dimension threshold.
[0240] In one possible implementation, the dimension threshold includes a first quantity and a second quantity. The classification unit 740 is used to determine the user's intent as a data query intent when the mapping fields in the parsing result include both computed and non-computed fields, and the number of dimensions to which the non-computed fields belong is greater than the first quantity; or, when the mapping fields in the parsing result do not include computed fields, and the total number of dimensions to which the mapping fields belong is greater than the second quantity, the user's intent as a data query intent is determined.
[0241] In one possible implementation, the candidate table acquisition unit 720 is used to acquire multiple candidate tables corresponding to the question based on the distinguishing fields in the question, match the first keyword with the candidate fields in the multiple candidate tables, establish a mapping relationship between the word segmentation and the candidate fields in each candidate table based on the matching first keyword and candidate fields, and obtain the parsing result of each candidate table.
[0242] In one possible implementation, the case retrieval unit 780 is used to rewrite the question based on a thesaurus to obtain the rewritten question, wherein at least one word in the rewritten question is replaced with at least one second keyword matching the word, and similar case data of the question is obtained based on the rewritten question.
[0243] In one possible implementation, the first model and the second model are the same model, with the first model including a large language model; or, the first model and the second model are different models, with the first model including an artificial intelligence (AI) model or a model based on a query statement template, and the second model including a large language model. The query statement template includes fixed positions and fill positions, and the query statement template is used to fill the fill positions according to the mapping relationship between word segmentation and fields in the parsing results to obtain the query statement.
[0244] In one possible implementation, the second response unit 750 is used to generate the response text corresponding to the question in the dialogue model when the classification unit 740 determines that the user intent is a non-data query type. Optionally, when the data analysis system 200 determines that the user intent is a non-data query type, and there is no need to generate an SQL statement or perform a retrieval in the database, it can use some dialogue model to generate the response text corresponding to the question. The dialogue model can be a large language model or other types of models, and this application does not make specific limitations.
[0245] In summary, this application provides a data analysis system that, upon receiving a user's question, first obtains multiple candidate tables through simple initial screening, then determines the parsing result of each candidate table based on a thesaurus, completing the mapping between word segmentation in the question and fields in the candidate tables. Next, based on the parsing results, it locates the query form corresponding to the question, and then classifies the user's intent based on whether the query form meets the query rules, determining whether the user's intent is a data query type or a non-data query type. This method can achieve intent recognition of questions without activating a large language model, avoiding the need to activate a large language model for intent recognition every time a user inputs a question, thereby reducing the resource overhead caused by frequently activating a large language model.
[0246] Meanwhile, after determining that the question is a data query question, the information ratio in the parsing results can be determined. If the information ratio is greater than the threshold, it means that the question has been parsed sufficiently, and SQL can be directly generated based on the parsing results to complete the data query and generate the corresponding response text. If the information ratio is not greater than the threshold, it means that the question has not been parsed sufficiently. In this case, similar cases can be obtained from the historical vector library and used as a supplement to the parsing results. These similar cases are then input into the large language model to obtain the corresponding SQL, ensuring that accurate SQL can be generated in most cases. This avoids frequent startup of the large language model and also ensures the accuracy of the generated response text, meeting the user's needs.
[0247] The data analysis methods and systems provided in this application have been described in detail above. The following section will combine... Figures 9-11 The computing device provided in this application will be explained.
[0248] Figure 9 This is a schematic diagram of the structure of a computing device provided in this application, such as... Figure 9 As shown, the computing device 800 includes a bus 802, a processor 804, a memory 806, and a communication interface 808. The processor 804, memory 806, and communication interface 808 communicate with each other via the bus 802. The computing device 800 can be a server. It should be understood that this application does not limit the number of processors, memory, and accelerator cards in the computing device 800. The computing device 800 can be used to deploy the aforementioned... Figures 1-11 The data analysis system 200 in this embodiment includes a memory 806 for storing instructions and a processor 804 for executing the instructions stored in the memory 806. The memory 806 stores program code, and the processor 804 can call the program code stored in the memory 806 to perform the following operations:
[0249] Retrieve user requests sent by the client, which include associated data of the user-input question;
[0250] The type of user intent is determined based on the user request. The type of user intent is obtained based on the parsing result of the question, which includes the mapping relationship between the word segmentation in the question and the mapping field in the form to be queried.
[0251] When the type is a data query type, the information ratio of the parsed result is calculated, where the information ratio is used to indicate the number of words that have completed the mapping in the question;
[0252] Based on the information ratio, the corresponding model is selected to obtain the response text for the question.
[0253] It should be understood that the memory 806 stores executable program code, and the processor 804 executes the executable program code to achieve the above. Figures 3-7 The embodiments describe the operational steps of the data analysis method. The program code may include the code of one or more software units, which may be... Figure 8 The diagram shows a question acquisition unit, a candidate table acquisition unit, a parsing unit, a classification unit, a second response unit, an information ratio judgment unit, a first response unit, and a case retrieval unit. The question acquisition unit is used to implement… Figure 3 In the embodiment of S301 and its optional steps, the candidate table acquisition unit is used to implement... Figure 3 S302 of the embodiment and its optional steps, the parsing unit is used to implement Figure 3 In the embodiment of S303 and its optional steps, the classification unit is used to implement... Figure 3 S304 of the embodiment and its optional steps, the second response unit is used to implement Figure 3 In the embodiments S312, S313 and their optional steps, the information ratio judgment unit is used to implement... Figure 3 In embodiment S306 and its optional steps, the first response unit is used to implement... Figure 3 S311, S313 and their optional steps in the embodiment, the case retrieval unit is used to implement Figure 3 The steps S307 and its optional steps in the embodiment will not be repeated here.
[0254] The 802 bus can be a Peripheral Component Interconnect Express (PCIe) bus, an Extended Industry Standard Architecture (EISA) bus, a Unified Bus (Ubus or UB), a Compute Express Link (CXL) bus, a Cache Coherent Interconnect for Accelerators (CCIX) bus, etc. The Unified Bus is also known as the Lingqu bus. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 9 The bus 802 is represented by only one line, but this does not mean that there is only one bus or one type of bus. The bus 802 may include a path for transmitting information between various components of the computing device 800 (e.g., memory 806, processor 804, communication interface 808). The unified bus may also be called the Lingqu bus.
[0255] The processor 804 may include any one or more computing devices such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP) or a digital signal processor (DSP), an ASIC, an FPGA, a CPLD, an NPU, a SoC, an offload card, or an accelerator card.
[0256] Memory 806 may include volatile memory, such as random access memory (RAM). Memory 806 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD). Furthermore, memory 806 may also be implemented using storage class memory (SCM), phase change memory (PCM), or other types of storage media.
[0257] It is worth noting that the same type of storage medium can be configured in the same computing device to realize the function of memory 806, or two or more types of storage media can be configured to realize the function of memory 806. This application does not limit this.
[0258] The communication interface 808 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 800 and other devices or communication networks.
[0259] It should be understood that the computing device 800 described above in this application may correspond to this application. Figures 1-8 The data analysis system 200 in the present application can be used to perform data analysis according to the present application. Figures 3 to 7 The corresponding entities in the method, and the above and other operations and / or functions of each module in the computing device 800, are respectively for the purpose of implementing Figures 3 to 7 For the sake of brevity, the corresponding processes of each method in the code will not be elaborated here.
[0260] As one possible implementation method, Figures 3 to 7 The method described herein can be implemented either by the processor in the computing device 800 executing program code in the memory, or by the accelerator card 807 in the computing device 800. The accelerator card 807 can be implemented by computing devices such as DPU, NPU, GPU, XPU, SoC, or AI chips; this application does not specifically limit its implementation. The accelerator card 807 includes a processing unit and a power supply circuit. The power supply circuit supplies power to the processing unit, enabling the processing unit to execute the above-described... Figures 3 to 7 The operational steps of the data analysis method described in each embodiment are as follows.
[0261] As one possible implementation method, Figures 3 to 7 The method described above can be implemented either by the processor in the computing device 800 executing program code in memory, or by the accelerator card 807, or by a combination of the processor 804 and the accelerator card 807 in the computing device 800. Figures 3 to 11 The data analysis method described herein refers to the operational steps performed by the corresponding entity. Specifically, the program code stored in memory 806 includes... Figure 8 The partial unit modules shown enable the processor 804 to execute the program code to implement some operation steps of the data analysis method, and the power supply circuit in the accelerator card 807 supplies power to the processing unit, enabling the processing unit to execute another part of the operation.
[0262] This application also provides a cluster of computing devices. For example... Figure 10 As shown, Figure 10 This is a schematic diagram of a computing device cluster provided in this application, which includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0263] As one possible implementation, the same implementation can be stored in the memory 806 of one or more computing devices 800 in a computing device cluster. Figures 3 to 11 The instructions for the operational steps of the described data analysis method. Alternatively, different implementations may be stored separately in the memory 806 of one or more computing devices 800. Figures 3 to 7 The instructions for the operational steps of the described data analysis method; in other words, a combination of one or more computing devices 800 can jointly execute the instructions for the operational steps required to implement the data analysis method.
[0264] As one possible implementation, the same implementation can be stored in the accelerator cards 807 of one or more computing devices 800 in a computing device cluster. Figures 3 to 11 The instructions for the operational steps of the described data analysis method. Alternatively, different implementations may be stored in one or more accelerator cards 807 of the computing device 800. Figures 3 to 7 The instructions for the operational steps of the described data analysis method; in other words, a combination of one or more computing devices 800 can jointly execute the instructions for the operational steps required to implement the data analysis method.
[0265] As one possible implementation, the same implementation is stored in the memory 806 of one or more computing devices 800 in the computing device cluster. Figures 3 to 11 The accelerator card 807 stores the same instructions for implementing one part of the operation steps in the described data analysis method, while the accelerator card 807 stores the same instructions for implementing another part of the operation steps. Alternatively, different implementations may be stored in the memory 806 of one or more computing devices 800. Figures 3 to 7 The accelerator card 807 contains instructions for implementing one part of the operation steps of the data analysis method, and different instructions for implementing another part of the operation steps are stored in the data analysis method. In other words, a combination of one or more computing devices 800 can jointly execute instructions for implementing the operation steps required by the data analysis method.
[0266] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN), a local area network (LAN), or similar. Figure 11 One possible implementation is shown. For example... Figure 11 As shown, Figure 11 This is a schematic diagram of another computing device cluster structure provided in this application. Two computing devices, 800A and 800B, are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this possible implementation, the memory 806 in computing device 800B stores instructions for a question retrieval unit, a parsing unit, a candidate table retrieval unit, and a classification unit. Meanwhile, the accelerator card 807 in computing device 800A is used to implement the functions described by the first and second response units, and the memory 806 stores instructions for executing a case retrieval unit and an information ratio judgment unit.
[0267] Figure 11 The connection method between the computing device clusters shown can be based on the fact that data analysis systems are usually distributed systems. In order to reduce the processing pressure of each device, the unit modules are distributed on different computing devices.
[0268] It should be understood that Figure 11 The functions of the computing device 800A shown can also be performed by multiple computing devices 800. Similarly, the functions of the computing device 800B can also be performed by multiple computing devices 800.
[0269] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to execute a reasoning method based on a large language model.
[0270] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute a reasoning method based on a large language model, or instruct the computing device to execute a reasoning method.
[0271] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.< / dimension> < / metric> < / value> middle
Claims
1. A data analysis method, characterized by, The method is executed by a data analysis system, and comprises: obtaining a user request sent by a client, the user request comprising associated data of a question sentence input by a user; determining a type of a user intention according to the user request, wherein the type of the user intention is obtained based on a parsing result of the question sentence, and the parsing result comprises a mapping relationship between words in the question sentence and mapping fields in a form to be queried; when the type is a data query type, calculating an information ratio of the parsing result, wherein the information ratio is used to indicate a number of words in the question sentence that are successfully mapped; selecting a corresponding model based on the information ratio to obtain a reply text corresponding to the question sentence.
2. The method of claim 1, wherein, The step of selecting a corresponding model based on the information ratio to obtain a reply text corresponding to the question sentence comprises: when the information ratio is greater than a threshold value, inputting the parsing result into a first model to obtain a database query statement corresponding to the question sentence; obtaining a reply text corresponding to the question sentence based on the database query statement, wherein the threshold value is determined according to a plurality of historical data, each historical data comprising an information ratio of a historical parsing result of a historical question sentence, and a correctness of a database query statement generated by the first model based on the historical parsing result.
3. The method according to claim 1 or 2, characterized in that, The step of selecting a corresponding model based on the information ratio to obtain a reply text corresponding to the question sentence comprises: when the information ratio is not greater than the threshold value, obtaining similar case data of the question sentence; inputting the parsing result and the similar case data into a second model to obtain a database query statement corresponding to the question sentence.
4. The method according to any one of claims 1 to 3, characterized in that, The step of determining a type of a user intention according to a user request comprises: determining a parsing result of a question sentence according to associated data of the question sentence, and determining the type of the user intention based on dimension information to which mapping fields in the parsing result belong, wherein a number of dimensions of a parsing result of a question sentence corresponding to a data query type of user intention is greater than a dimension threshold value.
5. The method of claim 4, wherein, The dimension threshold value comprises a first number and a second number, and the step of determining the type of the user intention based on dimension information to which mapping fields in the parsing result belong comprises: when the mapping fields in the parsing result comprise a calculation field and a non-calculation field, and a number of dimensions to which the non-calculation field belongs is greater than the first number, determining that the intention of the user is a data query intention; or when the mapping fields in the parsing result do not comprise the calculation field, and a total number of dimensions to which the mapping fields belong is greater than the second number, determining that the intention of the user is a data query intention.
6. The method according to claim 4 or 5, characterized in that, The step of determining a parsing result of a question sentence according to associated data of the question sentence comprises: matching words in the question sentence with a synonym library to obtain a first keyword matched with the words, wherein the synonym library comprises a keyword and a synonym corresponding to the keyword, the first keyword comprises a keyword matched with the words, or a keyword corresponding to a synonym matched with the words, and the keyword is obtained based on table data in a database, the table data comprising one or more of a table name, a table field, and an enumeration value. The mapping relationship between the first keyword and a mapping field in a form to be queried is completed based on the first keyword, and an analysis result of the question sentence is obtained.
7. The method of claim 6, wherein, The mapping relationship between the first keyword and a mapping field in a form to be queried is completed based on the first keyword, and an analysis result of the question sentence is obtained. Based on the distinctive field in the question sentence, a plurality of candidate tables corresponding to the question sentence are obtained; The first keyword is matched with a candidate field in the plurality of candidate tables, and a mapping relationship between the first keyword and the candidate field in each candidate table is established based on the matching consistent first keyword and candidate field, and an analysis result of each candidate table is obtained; Based on the analysis result of each candidate table, the form to be queried is determined, and the mapping relationship is obtained based on the analysis result of the form to be queried.
8. The method according to any one of claims 3 to 7, characterized in that, The similar case data of the question sentence includes: The tokens in the question sentence are marked using a mask label to obtain a mask result, the mask label is used to indicate the table data type corresponding to the token, the mask label includes a plurality of hierarchical mask labels, the information detail of the table data type indicated by the mask labels of different levels is different, and the mask label includes one or more of a table, a dimension, a metric, a value, and a synonym; The mask result is vectorized to obtain a hierarchical mask vector corresponding to the question sentence; The hierarchical mask vector is matched with a historical vector library to obtain similar case data of the question sentence, wherein the historical vector library includes historical hierarchical mask vectors corresponding to historical question sentences in the similar case data.
9. The method according to any one of claims 3 to 8, characterized in that, The similar case data of the question sentence includes: The question sentence is rewritten based on the synonym library to obtain a rewritten question sentence, at least one token in the rewritten question sentence is replaced by a second keyword matched with the at least one token; Similar case data of the question sentence is obtained based on the rewritten question sentence.
10. The method according to any one of claims 3 to 9, characterized in that, The first model and the second model are the same model, and the first model includes a large language model; or The first model and the second model are different models, the first model includes an artificial intelligence AI model or a model based on a query statement template, the second model includes a large language model, the query statement template includes a fixed position and a filling position, and the query statement template is used to fill the filling position according to the analysis result to obtain a query statement.
11. A data analysis system, characterized by The data analysis system includes: A question sentence acquisition unit configured to acquire a user request sent by a client, the user request including associated data of a question sentence input by a user; A classification unit configured to determine a type of user intent based on the user request, wherein the type of user intent is obtained based on an analysis result of the question sentence, and the analysis result includes a mapping relationship between tokens in the question sentence and mapping fields in a form to be queried; An information ratio determination unit configured to calculate an information ratio value of the analysis result when the type is a data query type, wherein the information ratio value is used to indicate the number of tokens in the question sentence that complete mapping; The first reply unit is configured to obtain the reply text corresponding to the question based on the information ratio and the corresponding model.
12. The system of claim 11, wherein, The first reply unit is configured to input the analysis result into a first model to obtain a database query statement corresponding to the question when the information ratio is greater than a threshold value. The first reply unit is configured to obtain the reply text corresponding to the question based on the database query statement, wherein the threshold value is determined according to a plurality of historical data, each historical data includes an information ratio of a historical analysis result of a historical question, and a correctness of a database query statement generated by the first model based on the historical analysis result.
13. The system of claim 11 or 12, wherein, The system further comprises a case retrieval unit, The case retrieval unit is configured to obtain similar case data of the question when the information ratio is not greater than the threshold value. The first reply unit is configured to input the analysis result and the similar case data into a second model to obtain a database query statement corresponding to the question.
14. The system of any of claims 11 to 13, wherein, The system further comprises an analysis unit, The analysis unit is configured to determine an analysis result of the question according to associated data of the question, the analysis result including a mapping relationship between a word in the question and a mapping field in a table to be queried. The classification unit is configured to determine the type of the user intent based on dimension information to which the mapping field in the analysis result belongs.
15. The system of claim 14, wherein, The analysis unit is configured to match the word in the question with a synonym library to obtain a first keyword matched with the word, wherein the synonym library includes a keyword and a synonym corresponding to the keyword, the first keyword including a keyword matched with the word, or a keyword corresponding to a synonym matched with the word, the keyword being obtained based on table data in a database, the table data including one or more of a table name, a table field, and an enumeration value. The analysis unit is configured to complete the mapping relationship between the word in the question and the mapping field in the table to be queried based on the first keyword to obtain the analysis result of the question.
16. The system of any one of claims 13 to 15, wherein, The case retrieval unit is configured to mark the word in the question using a mask label to obtain a mask result, the mask label being used to indicate a table data type corresponding to the word, the mask label including a plurality of levels of mask labels, different levels of mask labels indicating different levels of detail of information of the table data type, the mask label including one or more of a table, a dimension, a metric, a value, and a synonym. The case retrieval unit is configured to vectorize the mask result to obtain a hierarchical mask vector corresponding to the question. The case searching unit is configured to match the hierarchical mask vector with a historical vector library to obtain similar case data of the question sentence, wherein the historical vector library comprises historical hierarchical mask vectors corresponding to historical question sentences in the similar case data.
17. A computing device, comprising: The computing device comprises a processor and a memory, the memory being configured to store code, the code being executed by the processor, so that the computing device implements the operation steps of the method according to any one of claims 1 to 10.
18. A computer-readable storage medium, characterized in that, Computer program instructions are included, when the computer program instructions are executed by a computing device, the computing device executes the operation steps of the method according to any one of claims 1 to 10.
19. A computer program product comprising instructions, characterized in that, When the instructions are run by a computing device, the computing device executes the operation steps of the method according to any one of claims 1 to 10.
Citation Information
Cited By
Method and system for integrating retrieval enhancement generation capability
CN122045226A