Intelligent dialogue implementation method, device and equipment based on DSL to generate SQL

By introducing a DSL-based SQL generation method in intelligent conversational analysis tools, the limitations of NL2SQL technology in data query accuracy and complex query support capabilities are solved, and more efficient cross-table or multi-table association query is achieved.

CN119293068BActive Publication Date: 2025-03-14BEIJING LINGYI VISION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411813645.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-14
Estimated Expiration
2044-12-11

AI Technical Summary

Technical Problem

When existing intelligent conversational analysis tools use NL2SQL technology, there are limitations in the accuracy of data queries and the ability to support complex queries, especially in poor performance in cross-table or multi-table association queries.

Method used

By responding to the intelligent dialogue instructions of the user terminal, user dialogue data is obtained and intent recognition is performed, a domain-specific language script (DSL) is generated, and SQL scripts are generated based on the DSL script, and query results are obtained from the local database and displayed.

Benefits of technology

It improves the support capabilities of complex queries and the accuracy of data queries, and can more effectively handle query requirements across tables or multiple tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293068B_ABST
    Figure CN119293068B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and equipment for realizing intelligent dialogue based on DSL to generate SQL. The method includes: in response to the intelligent dialogue instruction of the user terminal, obtaining the current user dialogue data corresponding thereto and performing intent recognition to obtain the current intent recognition result; based on the current intent recognition result and the domain-specific language script generation strategy, correspondingly generating the current DSL script; based on the current DSL script and the script conversion strategy, correspondingly generating the current SQL script; based on the current SQL script, obtaining the current query result in the local database, generating the current display result corresponding to the current query result, and sending the current display result to the user terminal. The embodiment of the present invention can convert the current user dialogue data into a DSL script by first performing intent recognition and then into an SQL script, so that the SQL script can obtain the corresponding data from the database, thereby improving the support capability of complex queries and the accuracy of data queries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device and equipment for realizing intelligent dialogue based on DSL-generated SQL. Background Art

[0002] With the development of big data and artificial intelligence technologies, intelligent conversational analytics tools have gained widespread adoption across multiple business sectors due to their convenience and efficiency. These tools allow users to obtain complex data analysis results through simple natural language questions. However, current mainstream ChatBI solutions (which combine chatbot technology with business intelligence capabilities, leveraging natural language processing and generation techniques to enable users to interact with business intelligence systems in a conversational manner) primarily rely on NL2SQL technology, which directly converts natural language into SQL queries (Structured Query Language) using a large language model. While this approach simplifies the query process to some extent, it has limitations in data query accuracy and support for complex queries, particularly for cross-table or multi-table join queries. Summary of the Invention

[0003] The embodiments of the present invention provide a method, apparatus, and device for implementing intelligent conversation based on DSL to generate SQL, aiming to solve the problem that in the prior art, intelligent conversational analysis tools use NL2SQL technology to convert users' natural language into SQL query statements, which has limitations in data query accuracy and support for complex queries.

[0004] In a first aspect, an embodiment of the present invention provides a method for implementing intelligent dialogue based on DSL-based SQL generation, which includes:

[0005] In response to an intelligent dialogue instruction from a user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain a current intent recognition result;

[0006] Based on the current intent recognition result and a preset domain-specific language script generation strategy, a current DSL script is generated accordingly; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to the current intent recognition result and a plurality of pre-configured business models;

[0007] Based on the current DSL script and the preset script conversion strategy, a current SQL script is generated accordingly; wherein the current SQL script is a current structured query language script;

[0008] A current query result is obtained in a local database based on the current SQL script, a current display result corresponding to the current query result is generated, and the current display result is sent to the user terminal.

[0009] In a second aspect, an embodiment of the present invention further provides an intelligent dialogue implementation device for generating SQL based on DSL, comprising:

[0010] A user intention recognition unit is configured to respond to an intelligent dialogue instruction of a user terminal, obtain current user dialogue data corresponding to the intelligent dialogue instruction, and perform intention recognition on the current user dialogue data to obtain a current intention recognition result;

[0011] A first script generation unit is configured to generate a current DSL script based on the current intent recognition result and a preset domain-specific language script generation strategy; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is configured to generate a DSL script based on the current intent recognition result and a plurality of pre-configured business models;

[0012] A second script generating unit, configured to generate a current SQL script based on the current DSL script and a preset script conversion strategy; wherein the current SQL script is a current structured query language script;

[0013] The display result feedback unit is used to obtain the current query result in the local database based on the current SQL script, generate a current display result corresponding to the current query result, and send the current display result to the user terminal.

[0014] In a third aspect, an embodiment of the present invention further provides a computer device comprising a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method described in the first aspect can be implemented.

[0016] Embodiments of the present invention provide a method, apparatus, and device for implementing intelligent dialogue based on DSL (Structured Query Language) to generate SQL. The method includes: in response to an intelligent dialogue instruction from a user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, performing intent recognition on the current user dialogue data to obtain a current intent recognition result; generating a current DSL script based on the current intent recognition result and a preset domain-specific language script generation strategy; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate the DSL script based on the current intent recognition result and several pre-configured business models; generating a current SQL script based on the current DSL script and a preset script conversion strategy; wherein the current SQL script is a current structured query language script; obtaining a current query result from a local database based on the current SQL script, generating a current display result corresponding to the current query result, and sending the current display result to the user terminal. Embodiments of the present invention can convert the current user dialogue data into a DSL script through intent recognition and then into an SQL script, so that the SQL script can retrieve corresponding data from the database, thereby improving the support capability for complex queries and data query accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A schematic diagram of an application scenario of the method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0019] Figure 2 A flowchart of a method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0020] Figure 3 A schematic diagram of a sub-flow of a method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0021] Figure 4 Another flowchart of the method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of another sub-flow of the method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0023] Figure 6A schematic diagram of another sub-flow of the method for implementing intelligent dialogue based on DSL-based SQL generation provided by an embodiment of the present invention;

[0024] Figure 7 A schematic block diagram of an intelligent dialogue implementation device for generating SQL based on DSL provided by an embodiment of the present invention;

[0025] Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0027] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0028] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0029] It should be further understood that the term "and / or" used in the present description and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0030] Please also refer to Figure 1 and Figure 2 ,in Figure 1 This is a scenario diagram of a method for implementing an intelligent dialogue based on DSL to generate SQL according to an embodiment of the present invention. Figure 2 This is a flow chart of a method for implementing an intelligent dialogue based on DSL-generated SQL provided by an embodiment of the present invention. Figure 1 As shown, the intelligent dialogue implementation method for generating SQL based on DSL provided by the embodiment of the present invention is applied to a server 10 , and the server 10 is communicatively connected to a user terminal 20 .

[0031] like Figure 2As shown, the method includes the following steps S110-S140.

[0032] S110. In response to an intelligent dialogue instruction of a user terminal, obtain current user dialogue data corresponding to the intelligent dialogue instruction, and perform intent recognition on the current user dialogue data to obtain a current intent recognition result.

[0033] In this embodiment, the technical solution is described with the server as the execution entity. An intelligent dialogue implementation platform is deployed on the server. This platform incorporates chatbot technology and converts natural language input from a user terminal into a DSL script (DSL stands for Domain-Specific Language) and then an SQL script. Ultimately, based on the SQL script, the query results are retrieved from the server's database and fed back to the user terminal. Specifically, the user first uses their user terminal to log in to the intelligent dialogue implementation platform on the server and trigger an intelligent dialogue instruction. They then enter the current user dialogue data into the user interaction interface corresponding to the intelligent dialogue implementation platform (e.g., a chat box). The intelligent dialogue instruction and the current user dialogue data corresponding to the intelligent dialogue instruction are then sent to the server for intent recognition, thereby obtaining the current intent recognition result.

[0034] In one embodiment, if Figure 3 As shown, step S110 includes:

[0035] S111, obtaining a pre-stored bag-of-words model, and obtaining a current semantic vector corresponding to the current user conversation data based on the bag-of-words model;

[0036] S112: Input the current semantic vector into a pre-trained intent classification model to obtain the current intent recognition result.

[0037] In this embodiment, the bag-of-words model corresponds to a preset vocabulary, which contains all words that have appeared in a corpus (a collection of texts used for training or analysis). The bag-of-words model can be used to quickly obtain the current semantic vector corresponding to the current user conversation data.

[0038] After obtaining the current semantic vector, it is necessary to analyze the corresponding user intention more accurately. Specifically, the current semantic vector can be input into a pre-trained intent classification model. For example, the intent classification model uses a machine learning model (such as a naive Bayes classification model, a support vector machine, a decision tree model, etc.) or a deep learning model (such as a recurrent neural network, a long short-term memory network, etc.) to finally obtain the current intent recognition result.

[0039] It should be noted that the intelligent dialogue implementation platform deployed in the server is more focused on specific fields (such as financial technology, business intelligence, etc., and the business intelligence field can also include sub-fields such as marketing, financial management and customer service). After performing intent recognition on the current user dialogue data (such as corresponding to a brief user demand description, more specifically such as "trend analysis of XX3 user data of XX1 object within XX2 time interval is required") and obtaining the current intent recognition result, it is equivalent to analyzing the user needs and abstracting and sorting them out, so as to determine the user's query intention and the required query type.

[0040] S120: Generate a current DSL script based on the current intent recognition result and a preset domain-specific language script generation strategy.

[0041] The current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to a current intent recognition result and a plurality of pre-configured business models.

[0042] In this embodiment, when the current intent recognition result corresponding to the current user conversation data is obtained, the current intent recognition result is not directly converted into an SQL statement (i.e., a structured query statement) based on the NL2SQL technology, but a current DSL script (i.e., the current domain-specific language script) corresponding to the current intent recognition result is generated based on the domain-specific language script generation strategy. Because the current DSL script obtained cannot directly obtain the corresponding data from the database, it needs to be further converted into an SQL script before the corresponding data can be obtained from the database. Among them, because the current user conversation data is first accurately identified for intent and converted into a DSL script, the DSL script can accurately restore the user's actual data processing needs. After other processing, such as conversion into an SQL script for result query, it can not only effectively improve the accuracy of data query, but also enhance the ability to handle complex queries.

[0043] In one embodiment, if Figure 4 As shown, before step S110, the following steps are also included:

[0044] S101: Acquire business model requirement data, and construct several business initial models corresponding to the business model requirement data;

[0045] S102: configuring business semantic layer data for each of the plurality of business initial models to obtain corresponding plurality of business intermediate models;

[0046] S103 : For each of the plurality of business intermediate models, corresponding configuration description definition data is generated to obtain corresponding plurality of business models.

[0047] Among them, the business semantic layer data of each business initial model in the several business initial models at least includes business attributes, business indicators and business labels; the description definition data of each business initial model in the several business intermediate models at least includes the association relationship with the associated business model, the attributes of the association relationship and the type of the association relationship.

[0048] In this embodiment, when pre-building a domain-specific language script generation strategy in the server, business model requirement data for a specific domain is first obtained. The specific domain may refer to a specified domain such as the financial technology domain or the business intelligence domain. The business model requirement data includes several business initialization models, such as a business initialization model A1 for querying data in the first dimension of the financial technology domain, a business initialization model A2 for performing a summation operation on data in the second dimension of the financial technology domain, a business initialization model A3 for performing an averaging operation on data in the third dimension of the financial technology domain, a business initialization model B1 for querying data in the first dimension of the business intelligence domain, a business initialization model B2 for performing a summation operation on data in the second dimension of the business intelligence domain, and a business initialization model B3 for performing an averaging operation on data in the third dimension of the business intelligence domain. Of course, in specific implementations, the business initialization models included in the business model requirement data are not limited to the above examples and can be flexibly set according to the actual needs of the user. Furthermore, they can be expanded based on new needs to support new analysis needs that may arise in the future.

[0049] After determining several business initial models based on the business model requirement data, you can further configure business semantic layer data for each business initial model to obtain the corresponding business intermediate model. For example, referring to the above example, taking the description and definition of data configuration for business initial model A1 as an example, you can specifically configure business initial model A1's business attributes (such as the common attributes datasource, table, filters, dimensions, function, metrics, aggregate, conditions, sorts, page, etc. in a specific domain language script), business indicators (such as the field name of the first dimension data in the FinTech field), and business tags (such as the query of the first dimension data in FinTech), thereby obtaining a business intermediate model. At this point, the relationship between the obtained business intermediate model and other business intermediate models has not yet been established. It is still considered a relatively isolated business intermediate model, and the relationship between business intermediate models will need to be completed later.

[0050] The business attributes configured in the business initialization model are commonly used attributes in a specific domain language script. The commonly used attributes in a specific domain language script specifically include the following attributes:

[0051] 1) Property name: datasource; Property description: data source; Required: Required; Function description: global data source configuration;

[0052] 2) Attribute name: table; Attribute description: table model; Required: required; Function description: table model name;

[0053] 3) Property name: filters; Property description: Filter configuration; Required: Optional; Function description: Filter configuration;

[0054] 4) Attribute name: dimensions; Attribute description: Dimension configuration; Required: Required; Function description: Aggregation and grouping;

[0055] 5) Attribute name: function; Attribute description: dimension field function; Required: Optional; Function description: Unrestricted function;

[0056] 6) Attribute name: metrics; Attribute description: Metric configuration; Required: Required; Function description: Aggregation function is required;

[0057] 7) Attribute name: aggregate; Attribute description: indicator aggregation function; Required: Required; Function description: aggregate functions such as sum and cout;

[0058] 8) Attribute Name: conditions; Attribute Description: Condition configuration; Required: Optional; Function Description: Requires matching aggregation function;

[0059] 9) Property name: sorts; Property description: Sorting configuration; Required: Optional; Function description: None;

[0060] 10) Attribute name: page; Attribute description: Paging configuration; Required: Optional; Function description: None.

[0061] Finally, based on actual business needs, the relationships, attributes, and types of relationships between the various business intermediate models must be determined, ultimately yielding corresponding business models. This allows the construction and configuration of a domain-specific language script generation strategy. Furthermore, each business model can be quickly converted into a corresponding domain-specific language script.

[0062] In one embodiment, if Figure 5 As shown, step S120 includes:

[0063] S121. Acquire several business models corresponding to the domain-specific language script generation strategy;

[0064] S122. Obtain a matching similarity between the current intent recognition result and a business tag of each of the multiple business models, determine a business tag having the greatest matching similarity with the current intent recognition result as a target business tag, and obtain a business model corresponding to the target business tag as the target business model;

[0065] S123. Based on the associated business model of the target business model, obtain a current model relationship link with the target business model as the link starting point;

[0066] S124: Generate the current DSL script accordingly based on the business models included in the current model relationship link and the arrangement order of the business models.

[0067] In this embodiment, several business models included in the pre-built domain-specific language script generation strategy can be obtained first. At this time, the business semantic layer data and description definition data of each business model are known.

[0068] Afterwards, the matching similarity between the current intent recognition result and the business label of each business model in the several business models can be calculated. Specifically, the cosine similarity between the semantic vector corresponding to the current intent recognition result and the semantic vector corresponding to the business label of the business model can be calculated as the matching similarity between the two, and the business label semantic vector with the maximum cosine similarity with the semantic vector corresponding to the current intent recognition result is determined, and the business label corresponding to the business label semantic vector is used as the target business label, and the business model corresponding to the target business label is obtained as the target business model.

[0069] Then, after determining the target business model, you can also obtain a business model that has a specific association with the target business model from several business models pre-built in the specific domain language script generation strategy, thereby forming a current model relationship link with the target business model as the starting point of the link.

[0070] Finally, because the order of the business models included in the current model relationship link is known, and the DSL script corresponding to each business model is also known, the current DSL script can be generated by combining the DSL scripts of the business models and the order of the business models. This approach allows for rapid determination of the current DSL script corresponding to the current intent recognition result.

[0071] In one embodiment, step S124 includes:

[0072] The DSL scripts corresponding to the service models in the current model relationship link are obtained, and they are combined in the arrangement order to obtain the current DSL script.

[0073] In this embodiment, the DSL scripts corresponding to the business models in the current model relationship link can be combined in the order of their arrangement to obtain the current DSL script. If different business models target different data tables, linking multiple business models through the model relationship link enables cross-table or multi-table data processing.

[0074] S130: Generate a corresponding current SQL script based on the current DSL script and a preset script conversion strategy.

[0075] In this embodiment, after obtaining the current DSL script, it cannot directly retrieve data from the server database. Instead, it must be converted into the current SQL script using a script conversion strategy. Finally, the current SQL script is executed to retrieve the corresponding data from the server database. The script conversion strategy not only quickly converts the DSL script into a SQL script but also flexibly adapts to different database architectures.

[0076] In one embodiment, if Figure 6 As shown, step S130 includes:

[0077] S131. Acquire a current DSL abstract syntax tree corresponding to the current DSL script based on the abstract syntax tree extraction sub-strategy in the script conversion strategy;

[0078] S132. Based on the keyword mapping sub-strategy in the script conversion strategy, convert the DSL script keywords in the current DSL abstract syntax tree into SQL script keywords to obtain a current SQL abstract syntax tree;

[0079] S133: Generate the current SQL script corresponding to the current SQL abstract syntax tree based on the abstract syntax tree traversal sub-strategy in the script conversion strategy.

[0080] In this embodiment, when converting a DSL script into a SQL script, the current DSL script is sequentially subjected to abstract syntax tree extraction, keyword mapping, and abstract syntax tree traversal, ultimately completing the script conversion process quickly. The script conversion strategy can be considered a script translator. Based on its abstract syntax tree extraction sub-strategy, keyword mapping sub-strategy, and abstract syntax tree traversal sub-strategy, it converts the current DSL script into the current SQL script. The script conversion strategy must be highly flexible and intelligent, adapting to different database architectures and query requirements. Furthermore, the design of the DSL script improves the maintainability and scalability of query statements, effectively reducing the error rate associated with directly using NL2SQL technology.

[0081] S140: Obtain a current query result in a local database based on the current SQL script, generate a current display result corresponding to the current query result, and send the current display result to the user terminal.

[0082] In this embodiment, after the server determines the current SQL script corresponding to the current user conversation data, it further determines the target database corresponding to the current SQL script. The server then executes the current SQL script to retrieve the corresponding current query result from the target database. This current query result is not necessarily a comprehensive result with good visualization effects. In this case, a corresponding current display result can be generated based on the current query result and sent to the user terminal for visual display, allowing the user to intuitively view the current display result.

[0083] In one embodiment, step S140 includes:

[0084] A pre-stored query result aggregation strategy is obtained, and the current display result is generated based on the query result aggregation strategy and the current query result.

[0085] In this embodiment, if the current query result obtained from the target database by executing the current SQL script on the server includes multiple dispersed sub-results, the multiple dispersed sub-results included in the current query result can be aggregated into a data container corresponding to the query result aggregation strategy based on the query result aggregation strategy for centralized display, thereby obtaining the current display result. It can be seen that the above approach can more intelligently and centrally aggregate the current query result to achieve a better aggregated visual display effect.

[0086] It can be seen that the embodiment of implementing this method can first perform intent recognition on the current user conversation data and convert it into a DSL script and then into an SQL script, so that the SQL script can obtain the corresponding data from the database, thereby improving the support capability for complex queries and the accuracy of data queries.

[0087] Figure 7 This is a schematic block diagram of an intelligent dialogue implementation device for generating SQL based on DSL provided by an embodiment of the present invention. Figure 7 As shown, corresponding to the above-mentioned intelligent dialogue implementation method based on DSL to generate SQL, the present invention also provides an intelligent dialogue implementation device 100 based on DSL to generate SQL. The intelligent dialogue implementation device 100 based on DSL to generate SQL includes a unit for executing the above-mentioned intelligent dialogue implementation method based on DSL to generate SQL. Figure 7 The intelligent dialogue implementation device 100 for generating SQL based on DSL includes: a user intention recognition unit 110, a first script generation unit 120, a second script generation unit 130 and a display result feedback unit 140.

[0088] The user intention recognition unit 110 is used to respond to the intelligent dialogue instruction of the user terminal, obtain current user dialogue data corresponding to the intelligent dialogue instruction, and perform intention recognition on the current user dialogue data to obtain a current intention recognition result.

[0089] In this embodiment, the technical solution is described with the server as the execution entity. An intelligent dialogue implementation platform is deployed on the server. This platform incorporates chatbot technology and converts natural language input from a user terminal into a DSL script and then an SQL script. Ultimately, based on the SQL script, the platform retrieves query results from the server's database and feeds them back to the user terminal. Specifically, the user first uses their user terminal to log in to the intelligent dialogue implementation platform on the server and trigger an intelligent dialogue instruction. They then enter the current user dialogue data into the user interaction interface corresponding to the intelligent dialogue implementation platform (e.g., a chat box). The intelligent dialogue instruction and the current user dialogue data corresponding to the intelligent dialogue instruction are then sent to the server for intent recognition, thereby obtaining the current intent recognition result.

[0090] In one embodiment, the user intention recognition unit 110 is specifically configured to:

[0091] Obtaining a pre-stored bag-of-words model, and obtaining a current semantic vector corresponding to the current user conversation data based on the bag-of-words model;

[0092] The current semantic vector is input into a pre-trained intent classification model to obtain the current intent recognition result.

[0093] In this embodiment, the bag-of-words model corresponds to a preset vocabulary, which contains all words that have appeared in a corpus (a collection of texts used for training or analysis). The bag-of-words model can be used to quickly obtain the current semantic vector corresponding to the current user conversation data.

[0094] After obtaining the current semantic vector, it is necessary to analyze the corresponding user intention more accurately. Specifically, the current semantic vector can be input into a pre-trained intent classification model. For example, the intent classification model uses a machine learning model (such as a naive Bayes classification model, a support vector machine, a decision tree model, etc.) or a deep learning model (such as a recurrent neural network, a long short-term memory network, etc.) to finally obtain the current intent recognition result.

[0095] It should be noted that the intelligent dialogue implementation platform deployed in the server is more focused on specific fields (such as financial technology, business intelligence, etc., and the business intelligence field can also include sub-fields such as marketing, financial management and customer service). After performing intent recognition on the current user dialogue data (such as corresponding to a brief user demand description, more specifically such as "trend analysis of XX3 user data of XX1 object within XX2 time interval is required") and obtaining the current intent recognition result, it is equivalent to analyzing the user needs and abstracting and sorting them out, so as to determine the user's query intention and the required query type.

[0096] The first script generating unit 120 is configured to generate a current DSL script based on the current intent recognition result and a preset domain-specific language script generation strategy.

[0097] The current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to a current intent recognition result and a plurality of pre-configured business models.

[0098] In this embodiment, when the current intent recognition result corresponding to the current user conversation data is obtained, the current intent recognition result is not directly converted into an SQL statement (i.e., a structured query statement) based on the NL2SQL technology, but a current DSL script (i.e., the current domain-specific language script) corresponding to the current intent recognition result is generated based on the domain-specific language script generation strategy. Because the current DSL script obtained cannot directly obtain the corresponding data from the database, it needs to be further converted into an SQL script before the corresponding data can be obtained from the database. Among them, because the current user conversation data is first accurately identified for intent and converted into a DSL script, the DSL script can accurately restore the user's actual data processing needs. After other processing, such as conversion into an SQL script for result query, it can not only effectively improve the accuracy of data query, but also enhance the ability to handle complex queries.

[0099] In one embodiment, the apparatus 100 for implementing intelligent dialogue based on DSL-based SQL generation further includes:

[0100] A business initial model building unit, configured to obtain business model requirement data and build a plurality of business initial models corresponding to the business model requirement data;

[0101] A business intermediate model construction unit is used to configure business semantic layer data corresponding to each of the several business initial models to obtain several corresponding business intermediate models;

[0102] The business model construction unit is used to configure the description definition data corresponding to each of the plurality of business intermediate models to obtain the corresponding plurality of business models.

[0103] Among them, the business semantic layer data of each business initial model in the several business initial models at least includes business attributes, business indicators and business labels; the description definition data of each business initial model in the several business intermediate models at least includes the association relationship with the associated business model, the attributes of the association relationship and the type of the association relationship.

[0104] In this embodiment, when pre-building a domain-specific language script generation strategy in the server, business model requirement data for a specific domain is first obtained. The specific domain may refer to a specified domain such as the financial technology domain or the business intelligence domain. The business model requirement data includes several business initialization models, such as a business initialization model A1 for querying data in the first dimension of the financial technology domain, a business initialization model A2 for performing a summation operation on data in the second dimension of the financial technology domain, a business initialization model A3 for performing an averaging operation on data in the third dimension of the financial technology domain, a business initialization model B1 for querying data in the first dimension of the business intelligence domain, a business initialization model B2 for performing a summation operation on data in the second dimension of the business intelligence domain, and a business initialization model B3 for performing an averaging operation on data in the third dimension of the business intelligence domain. Of course, in specific implementations, the business initialization models included in the business model requirement data are not limited to the above examples and can be flexibly set according to the actual needs of the user. Furthermore, they can be expanded based on new needs to support new analysis needs that may arise in the future.

[0105] After determining several business initial models based on the business model requirement data, you can further configure business semantic layer data for each business initial model to obtain the corresponding business intermediate model. For example, referring to the above example, taking the description and definition of data configuration for business initial model A1 as an example, you can specifically configure business initial model A1's business attributes (such as the common attributes datasource, table, filters, dimensions, function, metrics, aggregate, conditions, sorts, page, etc. in a specific domain language script), business indicators (such as the field name of the first dimension data in the FinTech field), and business tags (such as the query of the first dimension data in FinTech), thereby obtaining a business intermediate model. At this point, the relationship between the obtained business intermediate model and other business intermediate models has not yet been established. It is still considered a relatively isolated business intermediate model, and the relationship between business intermediate models will need to be completed later.

[0106] Finally, based on actual business needs, the relationships, attributes, and types of relationships between the various business intermediate models must be determined, ultimately yielding corresponding business models. This allows the construction and configuration of a domain-specific language script generation strategy. Furthermore, each business model can be quickly converted into a corresponding domain-specific language script.

[0107] In one embodiment, the first script generating unit 120 is specifically configured to:

[0108] Acquire several business models corresponding to the domain-specific language script generation strategy;

[0109] Obtaining a matching similarity between the current intent recognition result and a business tag of each of the multiple business models, determining a business tag with the greatest matching similarity to the current intent recognition result as a target business tag, and obtaining a business model corresponding to the target business tag as a target business model;

[0110] Based on the associated business model of the target business model, obtaining a current model relationship link with the target business model as the link starting point;

[0111] Based on the business models included in the current model relationship link and the arrangement order of the business models, the current DSL script is generated accordingly.

[0112] In this embodiment, several business models included in the pre-built domain-specific language script generation strategy can be obtained first. At this time, the business semantic layer data and description definition data of each business model are known.

[0113] Afterwards, the matching similarity between the current intent recognition result and the business label of each business model in the several business models can be calculated. Specifically, the cosine similarity between the semantic vector corresponding to the current intent recognition result and the semantic vector corresponding to the business label of the business model can be calculated as the matching similarity between the two, and the business label semantic vector with the maximum cosine similarity with the semantic vector corresponding to the current intent recognition result is determined, and the business label corresponding to the business label semantic vector is used as the target business label, and the business model corresponding to the target business label is obtained as the target business model.

[0114] Then, after determining the target business model, you can also obtain a business model that has a specific association with the target business model from several business models pre-built in the specific domain language script generation strategy, thereby forming a current model relationship link with the target business model as the starting point of the link.

[0115] Finally, because the order of the business models included in the current model relationship link is known, and the DSL script corresponding to each business model is also known, the current DSL script can be generated by combining the DSL scripts of the business models and the order of the business models. This approach allows for rapid determination of the current DSL script corresponding to the current intent recognition result.

[0116] In one embodiment, generating the current DSL script based on the business models and the arrangement order of the business models included in the current model relationship link includes:

[0117] The DSL scripts corresponding to the service models in the current model relationship link are obtained, and they are combined in the arrangement order to obtain the current DSL script.

[0118] In this embodiment, the DSL scripts corresponding to the business models in the current model relationship link can be combined in the order of their arrangement to obtain the current DSL script. If different business models target different data tables, linking multiple business models through the model relationship link enables cross-table or multi-table data processing.

[0119] The second script generating unit 130 is configured to generate a corresponding current SQL script based on the current DSL script and a preset script conversion strategy.

[0120] In this embodiment, after obtaining the current DSL script, it cannot directly retrieve data from the server database. Instead, it must be converted into the current SQL script using a script conversion strategy. Finally, the current SQL script is executed to retrieve the corresponding data from the server database. The script conversion strategy not only quickly converts the DSL script into a SQL script but also flexibly adapts to different database architectures.

[0121] In one embodiment, the second script generating unit 130 is specifically configured to:

[0122] Acquire a current DSL abstract syntax tree corresponding to the current DSL script based on the abstract syntax tree extraction sub-strategy in the script conversion strategy;

[0123] Based on the keyword mapping sub-strategy in the script conversion strategy, converting the DSL script keywords in the current DSL abstract syntax tree into SQL script keywords to obtain a current SQL abstract syntax tree;

[0124] Based on the abstract syntax tree traversal sub-strategy in the script conversion strategy, the current SQL script corresponding to the current SQL abstract syntax tree is generated.

[0125] In this embodiment, when converting a DSL script into a SQL script, the current DSL script is sequentially subjected to abstract syntax tree extraction, keyword mapping, and abstract syntax tree traversal, ultimately completing the script conversion process quickly. The script conversion strategy can be considered a script translator. Based on its abstract syntax tree extraction sub-strategy, keyword mapping sub-strategy, and abstract syntax tree traversal sub-strategy, it converts the current DSL script into the current SQL script. The script conversion strategy must be highly flexible and intelligent, adapting to different database architectures and query requirements. Furthermore, the design of the DSL script improves the maintainability and scalability of query statements, effectively reducing the error rate associated with directly using NL2SQL technology.

[0126] The display result feedback unit 140 is configured to obtain a current query result from a local database based on the current SQL script, generate a current display result corresponding to the current query result, and send the current display result to the user terminal.

[0127] In this embodiment, after the server determines the current SQL script corresponding to the current user conversation data, it further determines the target database corresponding to the current SQL script. The server then executes the current SQL script to retrieve the corresponding current query result from the target database. This current query result is not necessarily a comprehensive result with good visualization effects. In this case, a corresponding current display result can be generated based on the current query result and sent to the user terminal for visual display, allowing the user to intuitively view the current display result.

[0128] In one embodiment, the display result feedback unit 140 is specifically configured to:

[0129] A pre-stored query result aggregation strategy is obtained, and the current display result is generated based on the query result aggregation strategy and the current query result.

[0130] In this embodiment, if the current query result obtained from the target database by executing the current SQL script on the server includes multiple dispersed sub-results, the multiple dispersed sub-results included in the current query result can be aggregated into a data container corresponding to the query result aggregation strategy based on the query result aggregation strategy for centralized display, thereby obtaining the current display result. It can be seen that the above approach can more intelligently and centrally aggregate the current query result to achieve a better aggregated visual display effect.

[0131] It can be seen that the embodiment of the device can first perform intent recognition on the current user conversation data and convert it into a DSL script and then into an SQL script, so that the SQL script can obtain the corresponding data from the database, thereby improving the support capability for complex queries and the accuracy of data queries.

[0132] The above-mentioned intelligent dialogue realization device based on DSL to generate SQL can be realized in the form of a computer program. The computer program can be used in Figure 8 Runs on the computer device shown.

[0133] See also Figure 8 , Figure 8 This is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device integrates any of the intelligent dialogue implementation devices for generating SQL based on DSL provided by an embodiment of the present invention.

[0134] See Figure 8 The computer device 400 includes a processor 402 , a memory, and a network interface 405 connected via a system bus 401 , wherein the memory may include a storage medium 403 and an internal memory 404 .

[0135] The storage medium 403 may store an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions, which, when executed, may enable the processor 402 to execute a method for implementing intelligent dialogue based on DSL-generated SQL.

[0136] The processor 402 is used to provide computing and control capabilities to support the operation of the entire computer device.

[0137] The internal memory 404 provides an environment for the operation of the computer program 4032 in the storage medium 403. When the computer program 4032 is executed by the processor 402, the processor 402 can execute the above-mentioned intelligent dialogue implementation method based on DSL to generate SQL.

[0138] The network interface 405 is used to communicate with other devices through the network. Figure 8 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present invention and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0139] The processor 402 is configured to execute a computer program 4032 stored in the memory to implement the following steps:

[0140] In response to an intelligent dialogue instruction from a user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain a current intent recognition result;

[0141] Based on the current intent recognition result and a preset domain-specific language script generation strategy, a current DSL script is generated accordingly; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to the current intent recognition result and a plurality of pre-configured business models;

[0142] Based on the current DSL script and the preset script conversion strategy, a current SQL script is generated accordingly; wherein the current SQL script is a current structured query language script;

[0143] A current query result is obtained in a local database based on the current SQL script, a current display result corresponding to the current query result is generated, and the current display result is sent to the user terminal.

[0144] It should be understood that in the embodiment of the present invention, the processor 402 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0145] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.

[0146] Therefore, the present invention also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the following steps:

[0147] In response to an intelligent dialogue instruction from a user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain a current intent recognition result;

[0148] Based on the current intent recognition result and a preset domain-specific language script generation strategy, a current DSL script is generated accordingly; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to the current intent recognition result and a plurality of pre-configured business models;

[0149] Based on the current DSL script and the preset script conversion strategy, a current SQL script is generated accordingly; wherein the current SQL script is a current structured query language script;

[0150] A current query result is obtained in a local database based on the current SQL script, a current display result corresponding to the current query result is generated, and the current display result is sent to the user terminal.

[0151] The storage medium may be any computer-readable storage medium that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.

[0152] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0153] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0154] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.

[0155] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (such as a personal computer, terminal, or network device) to execute all or part of the steps of the method described in various embodiments of the present invention.

[0156] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A method for realizing intelligent dialogue based on DSL to generate SQL, characterized in that: include: In response to the intelligent dialogue instruction of the user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain a current intent recognition result; Based on the current intent recognition result and a preset domain-specific language script generation strategy, a current DSL script is generated accordingly; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is used to generate a DSL script according to the current intent recognition result and a plurality of pre-configured business models; Based on the current DSL script and the preset script conversion strategy, a current SQL script is generated accordingly; wherein the current SQL script is a current structured query language script; Acquire a current query result in a local database based on the current SQL script, generate a current display result corresponding to the current query result, and send the current display result to the user terminal; The current DSL script is generated based on the current intention recognition result and the preset domain-specific language script generation strategy, including: Acquire a plurality of business models corresponding to the domain-specific language script generation strategy; Obtaining a matching similarity between the current intent recognition result and a business label of each of the multiple business models, determining a business label with the greatest matching similarity with the current intent recognition result as a target business label, and obtaining a business model corresponding to the target business label as a target business model; Based on the associated business model of the target business model, obtaining a current model relationship link with the target business model as the link starting point; Based on the business models included in the current model relationship link and the arrangement order of the business models, the current DSL script is generated accordingly.

2. The method according to claim 1, characterized in that Before the step of responding to the intelligent dialogue instruction of the user terminal, acquiring the current user dialogue data corresponding to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain the current intent recognition result, the method further includes: Acquire business model requirement data, and construct several business initial models corresponding to the business model requirement data; For each of the several business initial models, business semantic layer data is configured correspondingly to obtain several corresponding business intermediate models; wherein the business semantic layer data of each of the several business initial models at least includes business attributes, business indicators and business tags; For each of the several business intermediate models, corresponding description definition data is configured to obtain corresponding several business models; wherein the description definition data of each business initial model in the several business intermediate models at least includes the association relationship with the associated business model, the attributes of the association relationship and the type of the association relationship.

3. The method according to claim 1, characterized in that The performing intent recognition on the current user conversation data to obtain a current intent recognition result includes: Obtaining a pre-stored bag-of-words model, and obtaining a current semantic vector corresponding to the current user conversation data based on the bag-of-words model; The current semantic vector is input into a pre-trained intent classification model to obtain the current intent recognition result.

4. The method according to claim 1, characterized in that: The generating the current DSL script based on the business models and the arrangement order of the business models included in the current model relationship link includes: The DSL scripts corresponding to the service models in the current model relationship link are obtained, and they are combined in the arrangement order to obtain the current DSL script.

5. The method according to claim 1, characterized in that The current SQL script is generated based on the current DSL script and the preset script conversion strategy, including: Based on the abstract syntax tree extraction sub-strategy in the script conversion strategy, obtaining a current DSL abstract syntax tree corresponding to the current DSL script; Based on the keyword mapping sub-strategy in the script conversion strategy, converting the DSL script keywords in the current DSL abstract syntax tree into SQL script keywords to obtain a current SQL abstract syntax tree; Based on the abstract syntax tree traversal sub-strategy in the script conversion strategy, the current SQL script corresponding to the current SQL abstract syntax tree is generated.

6. The method according to claim 1, characterized in that The generating a current display result corresponding to the current query result includes: A pre-stored query result aggregation strategy is obtained, and the current display result is generated based on the query result aggregation strategy and the current query result.

7. An intelligent dialogue implementation device for generating SQL based on DSL, characterized in that: include: A user intention recognition unit, configured to respond to an intelligent dialogue instruction of a user terminal, obtain current user dialogue data corresponding to the intelligent dialogue instruction, and perform intention recognition on the current user dialogue data to obtain a current intention recognition result; A first script generation unit, configured to generate a current DSL script based on the current intent recognition result and a preset domain-specific language script generation strategy; wherein the current DSL script is a current domain-specific language script, and the domain-specific language script generation strategy is configured to generate a DSL script based on the current intent recognition result and a plurality of pre-configured business models; A second script generating unit, configured to generate a current SQL script based on the current DSL script and a preset script conversion strategy; wherein the current SQL script is a current structured query language script; A display result feedback unit, configured to obtain a current query result in a local database based on the current SQL script, generate a current display result corresponding to the current query result, and send the current display result to the user terminal; The second script generating unit is specifically used for: Acquire a plurality of business models corresponding to the domain-specific language script generation strategy; Obtaining a matching similarity between the current intent recognition result and a business label of each of the multiple business models, determining a business label with the greatest matching similarity with the current intent recognition result as a target business label, and obtaining a business model corresponding to the target business label as a target business model; Based on the associated business model of the target business model, obtaining a current model relationship link with the target business model as the link starting point; Based on the business models included in the current model relationship link and the arrangement order of the business models, the current DSL script is generated accordingly.

8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the intelligent dialogue implementation method for generating SQL based on DSL as described in any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method for realizing intelligent dialogue based on generating SQL based on DSL according to any one of claims 1 to 6 can be implemented.

Citation Information

Patent Citations

  • Chart generation method and device, equipment and storage medium

    CN117931929A

  • Intelligent SQL query generation method and system based on large language model

    CN118861081A