DSL-based intelligent dialogue implementation method, device and equipment for generating SQL (Structured Query Language)

By converting the user's natural language into a specific domain language script in an intelligent dialogue tool, and then converting it to SQL scripts to obtain data from the database, the problem of insufficient data query accuracy and complex query support capabilities in the existing technology is solved, and the further implementation is achieved Efficient data query and accuracy of query results.

CN119293068AActive Publication Date: 2025-01-10BEIJING LINGYI VISION TECH CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

Existing intelligent conversational analysis tools have 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 obtaining user conversation data in the smart dialogue instructions of the user terminal, intent recognition and generating specific domain language scripts, then converting them into SQL scripts using the preset script conversion strategy, obtaining query results from the local database and sending them to the user terminal .

Benefits of technology

It improves the support capabilities of complex queries and the accuracy of data queries, enhances the ability to process complex queries, and reduces the error rate caused by direct use of NL2SQL technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293068A_ABST
    Figure CN119293068A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent dialogue implementation method, device and equipment for generating SQL based on DSL, and the method comprises the steps: responding to an intelligent dialogue instruction of a user terminal, obtaining current user dialogue data corresponding to the intelligent dialogue instruction, and carrying out the intention recognition to obtain a current intention recognition result; correspondingly generating a current DSL script based on the current intention recognition result and a specific domain language script generation strategy; correspondingly generating a current SQL script based on the current DSL script and the script conversion strategy; and obtaining a current query result in 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. According to the embodiment of the invention, the dialogue data of the current user can be firstly subjected to intention recognition and converted into the DSL script and then converted into the SQL script, so that the SQL script obtains the corresponding data from the database, and the support capability of complex query and the accuracy rate of data query are improved.
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 to generate SQL. Background Art

[0002] With the development of big data and artificial intelligence technologies, intelligent conversational analysis tools have been widely used in multiple business fields due to their convenience and efficiency. Intelligent conversational analysis tools allow users to obtain complex data analysis results by asking simple natural language questions. However, the current mainstream ChatBI solution (a solution that combines chatbot technology and business intelligence functions, using natural language processing and generation technology to allow users to interact with business intelligence systems in a conversational manner) mainly relies on NL2SQL technology, which directly converts natural language into SQL query statements (i.e., structured query statements, SQL stands for Structured Query Language) through a large language model. Although the above method simplifies the query process to a certain extent, it has limitations in the accuracy of data queries and the ability to support complex queries, especially in cross-table or multi-table association queries. Summary of the invention

[0003] The embodiments of the present invention provide a method, apparatus and device for realizing intelligent dialogue based on DSL to generate SQL, aiming to solve the problem that the intelligent dialogue analysis tool in the prior art uses NL2SQL technology to convert the user's natural language into SQL query statements, which has limitations in the accuracy of data query and the ability to support complex queries.

[0004] In a first aspect, an embodiment of the present invention provides a method for realizing intelligent dialogue based on DSL to generate SQL, which includes: 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; 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.

[0005] In a second aspect, an embodiment of the present invention further provides an intelligent dialogue implementation device for generating SQL based on DSL, which includes: 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; The display result feedback unit is used to obtain the current query result in the local database based on the current SQL script, generate the current display result corresponding to the current query result, and send the current display result to the user terminal.

[0006] In a third aspect, an embodiment of the present invention further provides a computer device, which includes 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.

[0007] 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 above can be implemented.

[0008] The embodiment of the present invention provides 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 to the intelligent dialogue instruction, and performing intent recognition on the current user dialogue data to obtain the current intent recognition result; based on the current intent recognition result and the preset specific domain language script generation strategy, correspondingly generating the current DSL script; wherein the current DSL script is the current specific domain language script, and the specific domain language script generation strategy is used to generate the DSL script according to the current intent recognition result and a number of pre-configured business models; based on the current DSL script and the preset script conversion strategy, correspondingly generating the current SQL script; wherein the current SQL script is the current structured query language 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. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0010] Figure 1 A schematic diagram of an application scenario of a method for realizing an intelligent dialogue based on DSL to generate SQL provided in an embodiment of the present invention; Figure 2 A flowchart of a method for realizing intelligent dialogue based on DSL to generate SQL provided in an embodiment of the present invention; Figure 3 A schematic diagram of a sub-flow of a method for realizing intelligent dialogue based on DSL to generate SQL provided in an embodiment of the present invention; Figure 4 Another flowchart of the method for realizing intelligent dialogue based on DSL to generate SQL provided by an embodiment of the present invention; Figure 5 A schematic diagram of another sub-flow of the method for realizing intelligent dialogue based on DSL to generate SQL provided in an embodiment of the present invention; Figure 6 A schematic diagram of another sub-flow of the method for realizing intelligent dialogue based on DSL to generate SQL provided in an embodiment of the present invention; Figure 7A schematic block diagram of an intelligent dialogue implementation device for generating SQL based on DSL provided by an embodiment of the present invention; Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0011] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0012] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

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

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

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

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

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

[0018] In this embodiment, the technical solution is described with the server as the execution subject. An intelligent dialogue implementation platform is deployed in the server. The intelligent dialogue implementation platform combines chatbot technology, and converts the natural language input by the user using the user terminal into DSL script (DSL stands for Domain-Specific Language, which means a specific domain language) and SQL script in sequence, and finally obtains the query results in the server database based on the SQL script and feeds back to the user terminal used by the user. Specifically, the user first uses the user terminal to log in to the intelligent dialogue implementation platform in the server and triggers the generation of intelligent dialogue instructions, and enters the current user dialogue data in the user interaction interface corresponding to the intelligent dialogue implementation platform (such as a chat box), and then sends the intelligent dialogue instruction and the current user dialogue data corresponding to the intelligent dialogue instruction to the server for intent recognition, thereby obtaining the current intent recognition result.

[0019] In one embodiment, if Figure 3 As shown, step S110 includes: 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; S112: Input the current semantic vector into a pre-trained intent classification model to obtain the current intent recognition result.

[0020] 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.

[0021] 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 adopts 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.) and finally obtains the current intent recognition result.

[0022] Among them, 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 the current user dialogue data (such as corresponding to a short description of user needs, more specifically "it is necessary to perform trend analysis on XX3 user data of XX1 object within XX2 time interval") is recognized and the current intention recognition result is obtained, 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.

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

[0024] 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 number of pre-configured business models.

[0025] In this embodiment, when the current intention recognition result corresponding to the current user conversation data is obtained, the current intention recognition result is not directly converted into a SQL statement (i.e., a structured query statement) based on the NL2SQL technology, but a current DSL script (i.e., the current specific domain language script) corresponding to the current intention recognition result is generated based on the specific domain 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 recognized for its intent and converted into a DSL script, the DSL script can accurately restore the user's actual data processing needs, and then undergo other processing such as conversion into an SQL script for result query, which can not only effectively improve the accuracy of data query, but also enhance the ability to process complex queries.

[0026] In one embodiment, if Figure 4 As shown, before step S110, it also includes: S101, obtaining business model requirement data, and constructing a plurality of business initial models corresponding to the business model requirement data; S102, configuring business semantic layer data for each of the plurality of business initial models, and obtaining a plurality of corresponding business intermediate models; S103: For each of the plurality of business intermediate models, corresponding configuration description definition data is generated to obtain a plurality of corresponding business models.

[0027] 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.

[0028] In this embodiment, when pre-building a domain-specific language script generation strategy in the server, first obtain the business model requirement data for the specific domain, wherein the specific domain may refer to a specified domain such as the financial technology domain, the business intelligence domain, etc., and the business model requirement data includes several business initial models, such as a business initial model A1 for querying the first dimension data in the financial technology domain, a business initial model A2 for summing the second dimension data in the financial technology domain, a business initial model A3 for averaging the third dimension data in the financial technology domain, a business initial model B1 for querying the first dimension data in the business intelligence domain, a business initial model B2 for summing the second dimension data in the business intelligence domain, a business initial model B3 for averaging the third dimension data in the business intelligence domain, etc. Of course, the business initial models included in the business model requirement data during specific implementation are not limited to the above examples, and can be flexibly set according to the actual needs of the user, and can also be expanded according to new needs to support new analysis needs that may arise in the future.

[0029] After determining several business initial models based on the business model requirement data, the business semantic layer data can be further configured for each business initial model to obtain the corresponding business intermediate model. For example, still referring to the above example, taking the description and definition data configuration for the business initial model A1 as an example, the business attributes of the business initial model A1 can be specifically configured (such as the configuration of common attributes such as datasource, table, filters, dimensions, function, metrics, aggregate, conditions, sorts, page, etc. in the specific domain language script), business indicators (such as the field name of the first dimension data in the financial technology field, etc.) and business tags (such as the query of the first dimension data of financial technology) to obtain the business intermediate model. At this time, the association relationship between the obtained business intermediate model and other business intermediate models has not been established, and it is still regarded as a relatively isolated business intermediate model. The association relationship between the business intermediate models needs to be completed later.

[0030] The business attributes configured in the business initialization model are commonly used attributes in the specific domain language script. The commonly used attributes in the specific domain language script specifically include the following attributes: 1) Property name: datasource; Property description: data source; Required: required; Function description: global data source configuration; 2) Attribute name: table; Attribute description: table model; Required: required; Function description: table model name; 3) Property name: filters; Property description: filter configuration; Required: optional; Function description: filter configuration; 4) Attribute name: dimensions; Attribute description: dimension configuration; Required: required; Function description: aggregation and grouping; 5) Attribute name: function; Attribute description: dimension field function; Required: optional; Function description: unlimited function; 6) Attribute name: metrics; Attribute description: Metric configuration; Required: Required; Function description: Aggregation function is required; 7) Attribute name: aggregate; Attribute description: indicator aggregation function; Required: Required; Function description: aggregate functions such as sum and cout; 8) Attribute name: conditions; Attribute description: condition configuration; Required: optional; Function description: needs to match the aggregation function; 9) Property name: sorts; Property description: sort configuration; Required: Optional; Function description: None; 10) Property name: page; Property description: Paging configuration; Required: Optional; Function description: None.

[0031] Finally, based on actual business needs, the associations, attributes and types of the associations between several business intermediate models are obtained, and finally several corresponding business models are obtained, so as to complete the construction and configuration of the domain-specific language script generation strategy. Moreover, each business model can be quickly converted into a corresponding domain-specific language script.

[0032] In one embodiment, if Figure 5 As shown, step S120 includes: S121, obtaining a plurality of business models corresponding to the domain-specific language script generation strategy; S122, obtaining the matching similarity between the current intent recognition result and the business label of each business model in the plurality of business models, determining the business label with the maximum matching similarity with the current intent recognition result as the target business label, and obtaining the business model corresponding to the target business label as the target business model; S123, 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; 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.

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

[0034] 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.

[0035] Then, after determining the target business model, the business model with a specific association relationship with the target business model can be obtained 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.

[0036] Finally, since the arrangement order of each business model included in the current model relationship link is known, and the DSL script corresponding to each business model is also known, the DSL script of the business model and the arrangement order of the business model can be combined to generate the current DSL script accordingly. It can be seen that through the above method, the current DSL script corresponding to the current intent recognition result can be quickly determined.

[0037] In one embodiment, step S124 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.

[0038] In this embodiment, the DSL scripts corresponding to the business models in the current model relationship link can be combined in the order of arrangement to obtain the current DSL script. If different business models are for different data tables, the data processing across tables or multi-table associations can be realized by linking multiple business models through the above model relationship link.

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

[0040] In this embodiment, after the current DSL script is obtained, it cannot directly obtain data from the server's database. It needs to be converted into the current SQL script through the script conversion strategy, and finally the current SQL script is executed to obtain the corresponding data from the server's database. The script conversion strategy can not only quickly convert the DSL script into an SQL script, but also flexibly adapt to different database architectures.

[0041] In one embodiment, if Figure 6 As shown, step S130 includes: S131, acquiring 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; 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; 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.

[0042] In this embodiment, when converting a DSL script into a SQL script, the current DSL script is subjected to abstract syntax tree extraction, keyword mapping, and abstract syntax tree traversal in sequence, thereby finally completing the script conversion process quickly. The script conversion strategy can be regarded as a script translator, which can convert the current DSL script into the current SQL script based on the abstract syntax tree extraction sub-strategy, keyword mapping sub-strategy, and abstract syntax tree traversal sub-strategy. The script conversion strategy needs to be highly flexible and intelligent, and can be flexibly adapted to different database architectures to adapt to different database architectures and query requirements. Moreover, through the design of the DSL script, the maintainability and extensibility of the query statement are also improved, effectively reducing the error rate caused by the direct use of the NL2SQL technology.

[0043] S140: 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.

[0044] In this embodiment, after the server determines the current SQL script corresponding to the current user conversation data, it can further determine the target database corresponding to the current SQL script. At this time, the server executes the current SQL script to obtain the corresponding current query result from the target database. This current query result is not necessarily a comprehensive result with a good visualization effect. At this time, the corresponding current display result can be generated based on the current query result, and the current display result with a good visualization effect is sent to the user terminal for visual display, so that the user can intuitively view the current display result.

[0045] In one embodiment, step S140 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.

[0046] In this embodiment, if the current SQL script executed in the server obtains the corresponding current query result from the target database including several scattered sub-results, then the several scattered sub-results included in the current query result can be aggregated in 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 method can be used to perform more intelligent centralized aggregation processing on the current query result to achieve a better aggregated visual display effect.

[0047] It can be seen that the implementation example of the method can convert the current user conversation data into a DSL script by first performing intent recognition and then into a SQL script, so that the SQL script can obtain corresponding data from the database, thereby improving the support capability for complex queries and the accuracy of data queries.

[0048] Figure 7 FIG. 1 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.

[0049] The user intention recognition unit 110 is used to respond to the intelligent dialogue instruction of the user terminal, obtain the 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.

[0050] In this embodiment, the technical solution is described with the server as the execution subject. An intelligent dialogue implementation platform is deployed in the server. The intelligent dialogue implementation platform combines the chat robot technology, and converts the natural language input by the user using the user terminal into DSL scripts and SQL scripts in sequence, and finally obtains the query results in the server database based on the SQL script and feeds back to the user terminal used by the user. Specifically, the user first uses the user terminal to log in to the intelligent dialogue implementation platform in the server and triggers the generation of intelligent dialogue instructions, and enters the current user dialogue data in the user interaction interface corresponding to the intelligent dialogue implementation platform (such as a chat box), and then sends the intelligent dialogue instruction and the current user dialogue data corresponding to the intelligent dialogue instruction to the server for intent recognition, thereby obtaining the current intent recognition result.

[0051] In one embodiment, the user intention recognition unit 110 is specifically used for: 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.

[0052] 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.

[0053] 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 adopts 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.) and finally obtains the current intent recognition result.

[0054] Among them, 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 the current user dialogue data (such as corresponding to a short description of user needs, more specifically "it is necessary to perform trend analysis on XX3 user data of XX1 object within XX2 time interval") is recognized and the current intention recognition result is obtained, 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.

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

[0056] 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 number of pre-configured business models.

[0057] In this embodiment, when the current intention recognition result corresponding to the current user conversation data is obtained, the current intention recognition result is not directly converted into a SQL statement (i.e., a structured query statement) based on the NL2SQL technology, but a current DSL script (i.e., the current specific domain language script) corresponding to the current intention recognition result is generated based on the specific domain 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 recognized for its intent and converted into a DSL script, the DSL script can accurately restore the user's actual data processing needs, and then undergo other processing such as conversion into an SQL script for result query, which can not only effectively improve the accuracy of data query, but also enhance the ability to process complex queries.

[0058] In one embodiment, the intelligent dialogue implementation device 100 for generating SQL based on DSL further includes: A business initial model building unit, used to obtain business model requirement data and build a number of business initial models corresponding to the business model requirement data; 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; The business model building unit is used to configure the description definition data corresponding to each of the several business intermediate models to obtain the corresponding several business models.

[0059] 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.

[0060] In this embodiment, when pre-building a domain-specific language script generation strategy in the server, first obtain the business model requirement data for the specific domain, wherein the specific domain may refer to a specified domain such as the financial technology domain, the business intelligence domain, etc., and the business model requirement data includes several business initial models, such as a business initial model A1 for querying the first dimension data in the financial technology domain, a business initial model A2 for summing the second dimension data in the financial technology domain, a business initial model A3 for averaging the third dimension data in the financial technology domain, a business initial model B1 for querying the first dimension data in the business intelligence domain, a business initial model B2 for summing the second dimension data in the business intelligence domain, a business initial model B3 for averaging the third dimension data in the business intelligence domain, etc. Of course, the business initial models included in the business model requirement data during specific implementation are not limited to the above examples, and can be flexibly set according to the actual needs of the user, and can also be expanded according to new needs to support new analysis needs that may arise in the future.

[0061] After determining several business initial models based on the business model requirement data, the business semantic layer data can be further configured for each business initial model to obtain the corresponding business intermediate model. For example, still referring to the above example, taking the description and definition data configuration for the business initial model A1 as an example, the business attributes of the business initial model A1 can be specifically configured (such as the configuration of common attributes such as datasource, table, filters, dimensions, function, metrics, aggregate, conditions, sorts, page, etc. in the specific domain language script), business indicators (such as the field name of the first dimension data in the financial technology field, etc.) and business tags (such as the query of the first dimension data of financial technology) to obtain the business intermediate model. At this time, the association relationship between the obtained business intermediate model and other business intermediate models has not been established, and it is still regarded as a relatively isolated business intermediate model. The association relationship between the business intermediate models needs to be completed later.

[0062] Finally, based on actual business needs, the associations, attributes and types of the associations between several business intermediate models are obtained, and finally several corresponding business models are obtained, so as to complete the construction and configuration of the domain-specific language script generation strategy. Moreover, each business model can be quickly converted into a corresponding domain-specific language script.

[0063] In one embodiment, the first script generating unit 120 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.

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

[0065] 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.

[0066] Then, after determining the target business model, the business model with a specific association relationship with the target business model can be obtained 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.

[0067] Finally, since the arrangement order of each business model included in the current model relationship link is known, and the DSL script corresponding to each business model is also known, the DSL script of the business model and the arrangement order of the business model can be combined to generate the current DSL script accordingly. It can be seen that through the above method, the current DSL script corresponding to the current intent recognition result can be quickly determined.

[0068] In one embodiment, the generating of 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.

[0069] In this embodiment, the DSL scripts corresponding to the business models in the current model relationship link can be combined in the order of arrangement to obtain the current DSL script. If different business models are for different data tables, the data processing across tables or multi-table associations can be realized by linking multiple business models through the above model relationship link.

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

[0071] In this embodiment, after the current DSL script is obtained, it cannot directly obtain data from the server's database. It needs to be converted into the current SQL script through the script conversion strategy, and finally the current SQL script is executed to obtain the corresponding data from the server's database. The script conversion strategy can not only quickly convert the DSL script into an SQL script, but also flexibly adapt to different database architectures.

[0072] In one embodiment, the second script generating unit 130 is specifically used for: 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.

[0073] In this embodiment, when converting a DSL script into a SQL script, the current DSL script is subjected to abstract syntax tree extraction, keyword mapping, and abstract syntax tree traversal in sequence, thereby finally completing the script conversion process quickly. The script conversion strategy can be regarded as a script translator, which can convert the current DSL script into the current SQL script based on the abstract syntax tree extraction sub-strategy, keyword mapping sub-strategy, and abstract syntax tree traversal sub-strategy. The script conversion strategy needs to be highly flexible and intelligent, and can be flexibly adapted to different database architectures to adapt to different database architectures and query requirements. Moreover, through the design of the DSL script, the maintainability and extensibility of the query statement are also improved, effectively reducing the error rate caused by the direct use of the NL2SQL technology.

[0074] The display result feedback unit 140 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.

[0075] In this embodiment, after the server determines the current SQL script corresponding to the current user conversation data, it can further determine the target database corresponding to the current SQL script. At this time, the server executes the current SQL script to obtain the corresponding current query result from the target database. This current query result is not necessarily a comprehensive result with a good visualization effect. At this time, the corresponding current display result can be generated based on the current query result, and the current display result with a good visualization effect is sent to the user terminal for visual display, so that the user can intuitively view the current display result.

[0076] In one embodiment, the display result feedback unit 140 is specifically used for: 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.

[0077] In this embodiment, if the current SQL script executed in the server obtains the corresponding current query result from the target database including several scattered sub-results, then the several scattered sub-results included in the current query result can be aggregated in 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 method can be used to perform more intelligent centralized aggregation processing on the current query result to achieve a better aggregated visual display effect.

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

[0079] 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.

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

[0081] See also 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 .

[0082] The storage medium 403 can store an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions, and when the program instructions are executed, the processor 402 can execute an intelligent dialogue implementation method for generating SQL based on DSL.

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

[0084] 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.

[0085] The network interface 405 is used to communicate with other devices over the network. Figure 8 The structure shown in the figure is only a block diagram of a part 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 those shown in the figure, or combine certain components, or have a different arrangement of components.

[0086] The processor 402 is used to run the computer program 4032 stored in the memory to implement the following steps: 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; 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.

[0087] It should be understood that in the embodiment of the present invention, the processor 402 may be a central processing unit (CPU), and the processor 402 may also 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. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0088] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0089] 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 executes the following steps: 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; 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.

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

[0091] Those of ordinary skill 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 composition and steps of each example have been generally described in terms of function in the above description. 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.

[0092] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0093] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0094] If the integrated unit is implemented in the form of 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 is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0095] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope 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; 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.

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 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.

5. The method according to claim 4, 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.

6. 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.

7. 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.

8. 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; The display result feedback unit is used to obtain the current query result in the local database based on the current SQL script, generate the current display result corresponding to the current query result, and send the current display result to the user terminal.

9. 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 7 when executing the computer program.

10. 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 according to any one of claims 1 to 7 can be implemented.

Citation Information

Patent Citations

  • Chart generation method and device, equipment and storage medium

    CN117931929A

  • Method, system and device for converting natural language to SQL (Structured Query Language) query statement and medium

    CN118779342A

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

    CN118861081A

  • Intelligent interaction method, electronic device, and storage medium

    WO2019153522A1

Cited By

  • SQL generation implementation method, device and equipment based on DSL conversion engine

    CN120277085A

  • Data query method and device based on large language model, program product and medium

    CN120804298A

  • Data query method, device, program product and medium based on large language model

    CN120804298B

  • SQL statement generation method and device based on DSL statement and electronic equipment

    CN122112052A