SQL (Structured Query Language) database query method, question and answer method and system with intention recognition

By identifying and correcting the intent of user questions, generating a database field content dictionary, and combining it with a large language model to generate SQL query statements, the problem of user intent identification and data alignment in the database intelligent question and answer method is solved, query accuracy and efficiency are improved, and Provides data drill-down processing to improve data credibility.

CN118708604APending Publication Date: 2024-09-27SHANDONG EVAYINFO TECH CO LTD
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202410724226.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

The database intelligent question and answer method based on the large language model lacks automatic recognition and correction methods for user intentions, resulting in the retrieved data being missing or not meeting user needs. It also lacks an accurate understanding of the database structure and field information, resulting in statistical results that cannot be traced and cannot be traced. The data cannot be trusted.

Method used

By identifying and correcting the intention in the user's question, a dictionary of database fields to the fields involved in the user's question is generated, combined with the large language model to generate SQL query statements that meet the requirements, and through data drill-down processing to improve query accuracy and efficiency.

Benefits of technology

It achieves accurate alignment of user questions and SQL database, generates SQL query statements that meet the requirements, improves query accuracy and efficiency, and provides detailed information display of data through data drill-down processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708604A
    Figure CN118708604A
Patent Text Reader

Abstract

The invention provides an SQL (Structured Query Language) database query method, question and answer method and system with intention recognition, and belongs to the technical field of data processing. Identifying and correcting intentions in the user questions to obtain a field content dictionary from the aligned database fields to the user questions; generating a database supplementary information description according to the field content dictionary, and combining the database supplementary information description with a standardized database description to form context information; obtaining an SQL (Structured Query Language) query statement corresponding to the user question according to the context information and a preset large language model, and obtaining to-be-queried content according to an SQL database queried by the SQL query statement; according to the method, the alignment problem of the user problem and the actual data of the SQL database is effectively solved, the field content related to the user problem can be accurately found, the SQL query statement meeting the requirement is generated, and the query precision and the query efficiency are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to an SQL database query method with intent recognition, an SQL database query system with intent recognition, an SQL database question and answer method with intent recognition, an SQL database question and answer system with intent recognition, a computer device and a computer-readable storage medium. Background Art

[0002] The statements in this section merely provide background art related to the present invention and do not necessarily constitute prior art.

[0003] Database intelligent question-answering technology is a technology that uses natural language dialogue to query structured data stored in relational databases (such as MySQL). Database intelligent question-answering technology does not require manual writing of professional and complex SQL structured query statements, and enables direct interaction between ordinary users and data, avoiding secondary development of data and improving data utilization efficiency.

[0004] Generative large-scale pre-trained language model, referred to as Large Language Model, is a neural network model based on Transformer architecture. It is a language model with rich prior knowledge, small sample learning, code writing and logical reasoning capabilities trained by using a large amount of unsupervised text data, supervised dialogue data and reinforcement learning with human feedback. The Large Language Model transforms traditional database intelligent question-answering technology into an end-to-end task, that is, inputting user questions and directly outputting corresponding results.

[0005] Compared with traditional technologies, the database intelligent question-answering technology based on the large language model first uses the LoRA fine-tuning technology to fine-tune the model to adapt to specific scenarios; then, with the help of the large language model prompt project, the natural language data analysis requirements and the textual description of the database are input into the large language model as prompt words. The large language model generates SQL statements that meet the requirements, and finally queries the final results through the SQL statement query.

[0006] The inventors have found that, currently, the database intelligent question answering method based on a large language model still has the following problems:

[0007] (1) There is a lack of automated identification and correction methods for user intent, that is, the target database fields cannot be aligned with user intent, resulting in the retrieved data being missing or not meeting user needs; (2) There is a lack of database description specifications optimized for large language models, and large language models cannot accurately understand database structures and field information; (3) There is a lack of data drill-down processing for statistical results, and the statistical analysis results cannot be traced, resulting in unreliable data. Summary of the invention

[0008] In order to address the deficiencies in the prior art, the present invention provides a SQL database query method, a question-and-answer method, and a system with intent recognition, which effectively solves the problem of aligning user questions with actual data in the SQL database, can accurately find the field content involved in the user questions, and generate SQL query statements that meet the requirements, greatly improving the query accuracy and efficiency.

[0009] In order to achieve the above object, the present invention adopts the following technical solution:

[0010] In a first aspect, the present invention provides a SQL database query method with intent recognition.

[0011] A SQL database query method with intent recognition includes the following processes:

[0012] Identify and correct the intent in the user's question, and obtain the aligned database field to the field content dictionary involved in the user's question;

[0013] generating a database supplementary information description according to the field content dictionary, and combining the database supplementary information description with the standardized database description to form context information;

[0014] According to the context information and the preset large language model, an SQL query statement corresponding to the user question is obtained, and the SQL database is queried according to the SQL query statement to obtain the content to be queried.

[0015] As a further limitation of the first aspect of the present invention, the intent in the user question is identified and corrected to obtain an aligned database field to a field content dictionary R involved in the user question, including:

[0016] Extract the database fields involved in the user's question and the content corresponding to the database fields. The extracted result is field x :[c′1,c′2,...,c′ x ,...,c′ m' ],c′ x Field extracted from user questions x The text content corresponding to the field;

[0017] If field x ∈(EE e′ ), and c′ x ∈C x Then {field x :[c′ x ]} is added to the result set R; if fieldx ∈E e′ If so, perform the next step, where E is an enumerable data field;

[0018] Convert c′ x into a vector Convert the data set C x of the field x ={c1, c2,..., c m} into a vector set And set the basic similarity threshold threshold2 and the complete similarity threshold threshold3;

[0019] For each vector in and calculate the similarity. If the similarity > threshold3, add the field content corresponding to the vector to the complete similarity list L′. If threshold3 > similarity > threshold2, add the field content corresponding to the vector to the basic similarity list L;

[0020] If then add {field x : L′} to the field content dictionary R. If then add {field x : L} to the field content dictionary R. If then perform the next step;

[0021] Use the large language model and prompt engineering to generate the description text of c′ x and replace c′ x . Use the newly generated c′ x to execute the above judgment process until or

[0022] As a further limitation of the first aspect of the present invention, for each enumerable data field if m < threshold1, then take the data field as the value of the data data in the form of a list, otherwise define it as an intent recognition field

[0023] As a further limitation of the first aspect of the present invention, generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information, including:

[0024] Fill the prompt template with the background of the problem, the description of the SQL statement generation task, some special provisions for specific tasks, a small sample of tasks, user questions, a description of basic database information, a description of supplementary database information, and a list of optional chart types;

[0025] The prompt template is input into the large language model to generate SQL query statements for user questions, chart type names, and query field names corresponding to the chart's XY axes.

[0026] As a further limitation of the first aspect of the present invention, the SQL database queried according to the SQL query statement to obtain the content to be queried includes:

[0027] If the user's question only involves a numerical query, the large language model is used to directly output the data; otherwise, the pre-customized Echart chart template and table template are filled in according to the generated chart type name, the query field name corresponding to the chart XY axis, and the queried data for front-end WEB display.

[0028] As a further limitation of the first aspect of the present invention, the data table queried by the SQL statement is converted into a two-dimensional coordinate axis;

[0029] When a piece of data in a table on a web page is clicked, the XY axis of the data is located through the two-dimensional coordinate axis, and then the number of columns and rows of the data in the table is obtained, triggering the data drill-down process;

[0030] The SQL statement, data table, number of columns and number of rows are input as restriction conditions into the prompt project template to obtain filled prompt words. Based on the filled prompt words and the preset large language model, the SQL statement for data drilling is obtained, and the query is performed based on the SQL statement for data drilling.

[0031] In a second aspect, the present invention provides a SQL database question-answering method with intent recognition.

[0032] A SQL database question answering method with intent recognition, applied to a database server, includes the following processes:

[0033] Receiving a user question input by a user, or receiving a user question converted from a user's voice, or converting the user's voice input into a user question;

[0034] According to the user question, the SQL database query method with intent recognition described in the first aspect of the present invention is used to perform content query;

[0035] The queried content is converted into a set format for display, or the queried content is sent to a terminal specified by the user, or the content converted into a set format is sent to a terminal specified by the user, or the queried content and the content converted into a set format are sent together to a terminal specified by the user.

[0036] In a third aspect, the present invention provides a SQL database query system with intent recognition.

[0037] A SQL database query system with intent recognition, comprising:

[0038] The field content dictionary generating unit is configured to: identify and correct the intention in the user question, and obtain an aligned database field to a field content dictionary involved in the user question;

[0039] A context information generating unit is configured to: contextually generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information;

[0040] The content query unit is configured to: obtain the SQL query statement corresponding to the user question according to the context information and a preset large language model, and obtain the content to be queried by querying the SQL database according to the SQL query statement.

[0041] In a fourth aspect, the present invention provides a SQL database question-answering system with intent recognition.

[0042] An SQL database question-answering system with intent recognition, applied to a database server, comprising:

[0043] The question receiving unit is configured to: receive a user question input by a user, or receive a user question converted from a user's voice, or convert the user's voice input into a user question;

[0044] A data query unit is configured to: perform content query according to the user question using the SQL database query method with intent recognition described in the first aspect of the present invention;

[0045] The data display unit is configured to: convert the queried content into a set method for display, or send the queried content to a terminal specified by a user, or send the content converted into a set method to a terminal specified by a user, or send the queried content and the content converted into a set method together to a terminal specified by a user.

[0046] In a fifth aspect, the present invention provides a computer device, comprising: a processor and a computer readable storage medium;

[0047] a processor adapted to execute a computer program;

[0048] A computer-readable storage medium having a computer program stored therein, wherein when the computer program is executed by the processor, the SQL database query method with intent recognition as described in the first aspect of the present invention is implemented, or the SQL database question-and-answer method with intent recognition as described in the second aspect of the present invention is implemented.

[0049] In a sixth aspect, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program is suitable for being loaded by a processor and executing the SQL database query method with intent recognition as described in the first aspect of the present invention, or implementing the SQL database question and answer method with intent recognition as described in the second aspect of the present invention.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] 1. The present invention innovatively proposes an SQL database query method, question-answering method and system with intent recognition, which effectively solves the problem of aligning user questions with the actual data of the SQL database, can accurately find the field content involved in the user questions, and generate SQL query statements that meet the requirements, greatly improving the query accuracy and efficiency.

[0052] 2. The present invention corrects the user intent based on the actual field content in the database and obtains feedback. The query statement prompting project combines the aligned and corrected user intent with the standardized database description to form a large language model context information, which is input into the large language model to obtain an SQL query statement that meets the requirements, thereby improving the query accuracy.

[0053] 3. The present invention automatically determines the appropriate display format based on the query results. For the displayed data charts, the data drill-down prompt project is used to automatically generate data drill-down statements, so that the system can display detailed data information.

[0054] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0056] Figure 1 A flowchart of a SQL database query method with intent recognition provided in Example 1 of the present invention;

[0057] Figure 2 A pseudo code diagram of the intention recognition step provided in Example 1 of the present invention;

[0058] Figure 3 A schematic diagram of an SQL database query system with intent recognition provided in Example 2 of the present invention;

[0059] Figure 4 A schematic diagram of an SQL database question-answering method with intent recognition provided in Embodiment 3 of the present invention;

[0060] Figure 5 A schematic diagram of an SQL database question-answering system with intent recognition provided by Embodiment 4 of the present invention;

[0061] Figure 6 This is a schematic diagram of an electronic device provided in Example 5 of the present invention. DETAILED DESCRIPTION

[0062] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0063] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0064] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0065] Embodiment 1:

[0066] like Figure 1 As shown, this implementation proposes a SQL database query method with intent recognition, including the following process:

[0067] S1: Generate basic description of database.

[0068] S1.1: Define database table T = {field1, field2, ..., field x ,...,field n}, where field n is the data field name, n is the number of data fields, define field x The data set of the field is C x ={c1,c2,...,c m}, m is the length of the set, define the database D = {field1:C1,field2:C2,...,field x :C x,..., field n : C n};

[0069] S1.2: Determine the exhaustive data fields Among them n e is the number of exhaustive fields, defined as The data set of the field is m e is the set length. Define the set of non-exhaustive data fields Among them

[0070] S1.3: Generate the basic information description p of the database base , and the pseudocode is as follows:

[0071]

[0072] For each exhaustive data field If m < threshold1, then take the data field as the value of data in list form, otherwise define it as the intent recognition field and perform intent recognition in step S2.

[0073] S2: Intent recognition.

[0074] Combine the database description p base and to identify and correct the intent in the user's question, and finally obtain the dictionary R that aligns the database fields to the field content involved in the user's question. The detailed pseudocode for steps S2 - S5 is shown in Figure 2 .

[0075] S2.1: Use prompt engineering to utilize the large language model to extract the database fields involved in the user's question and the corresponding content of the field. The extraction result is D′, and the pseudocode is as follows:

[0076]

[0077] Among them, c′ x is the text content corresponding to the field x extracted from the user's question.

[0078] S2.2: Perform content alignment operations on the field names extracted in step S2.1 one by one. If field x ∈(E - E e′ ), and c′ x ∈C x then take {field x:[c′ x ]} is added to the result set R; if field x ∈E e′ , then proceed to step S2.3:.

[0079] S2.3: Use text embedding models such as BGE-m3 and text2vec to embed c′ x Convert to vector Field x Field data set C x ={c1,c2,...,c m}Convert to a vector set And set the basic similarity threshold threshold2 and the complete similarity threshold threshold3;

[0080] Will and Calculate the Cosine similarity for each vector in . If the similarity > threshold3, add the field content corresponding to the vector to the complete similarity list L′. If threshold3 > similarity > threshold2, add the field content corresponding to the vector to the basic similarity list L.

[0081] S2.4: If Then {field x :L′} is added to the result set R, and the following steps are not performed; if Then {field x :L} is added to the result set R, and the following steps are not performed; if Then proceed to the following S2.5:.

[0082] S2.5: Generating c′ using large language models and hint engineering x The description text of , and replace c ′ x , using the newly generated c′ x Proceed to step S2.3-step S2.4.

[0083] Step 3: Generate database supplementary information description p based on the alignment result R sup , the pseudo code is as follows:

[0084]

[0085] S4: SQL statement generation module.

[0086] Using the large language model and prompt engineering, fill the prompt template with the following information:

[0087] Background of the problem b(Related background knowledge such as current time and location); Description of the SQL statement generation task t ; Some special provisions for specific tasks r ; A small sample of examples p for this task e ; User question Q; Basic information description of database p base ; Database Supplementary Information Descriptionp sup ; Optional chart type list L c ;

[0088] Input the prompt template into the large language model to generate the SQL query statement for question Q, the chart type name, and the query field name corresponding to the chart XY axis. The prompt project template format used in this step is as follows:

[0089]

[0090] S5: Data query mode.

[0091] If you only need to query all the data, then directly output the query results in this step and end. If you need to display the data in a chart, proceed to step S6.

[0092] S6: Graph generation.

[0093] Select an appropriate display method. If the problem only involves a numerical query, use the large language model to directly output the data; otherwise, fill in the pre-customized Echart chart template and table template according to the chart type name generated in step S4, the query field name corresponding to the chart XY axis, and the queried data, and finally perform the front-end WEB display.

[0094] S7: Drill down into the data.

[0095] S7.1: convert the data table data queried by the SQL statement sql into a two-dimensional coordinate axis, and each value can be located in the two-dimensional coordinate;

[0096] S7.2: The user clicks on data in the table on the WEB page, locates the XY axis of the data through the two-dimensional coordinate axis, and then obtains the number of columns (col) and rows (row) of the data in the table, thereby triggering the data drill-down process;

[0097] S7.3: Enter the SQL statement sql, the data table data, the number of columns col, and the number of rows row as restriction conditions into the following prompt project template, as shown below:

[0098]

[0099] S7.4: Input the filled prompt words into the large language model, generate SQL statements for data drilling down, and proceed to step S5.

[0100] Embodiment 2:

[0101] like Figure 3 As shown, this implementation provides a SQL database query system with intent recognition, including:

[0102] The field content dictionary generating unit is configured to: identify and correct the intention in the user question, and obtain an aligned database field to the field content dictionary involved in the user question; the specific process of this unit is shown in step S2 in embodiment 1, which will not be repeated here;

[0103] A context information generating unit is configured to: generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information; the specific process of this unit is shown in step S4 in embodiment 1, which will not be repeated here;

[0104] The content query unit is configured to: obtain the SQL query statement corresponding to the user question according to the context information and the preset large language model, and obtain the content to be queried by querying the SQL database according to the SQL query statement; the specific process of this unit is shown in step S4 in Example 1, which will not be repeated here.

[0105] It is understandable that the above-mentioned modules can be respectively or completely merged into one or several other units to constitute, or some of the units can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effect of the embodiment of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of a unit can also be realized by multiple units, or the function of multiple units can be realized by one unit. In other embodiments of the present application, the query system can also include other units. In practical applications, these functions can also be assisted by other units to be realized, and can be realized by the collaboration of multiple units.

[0106] According to another embodiment of the present application, the system described in this embodiment can be constructed and the query method of the embodiment of the present application can be implemented by running a computer program (including program code) capable of executing the steps involved in the corresponding method described in Example 1 on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). The computer program can be recorded on, for example, a computer-readable recording medium, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.

[0107] Embodiment 3:

[0108] like Figure 4 As shown, this implementation provides a SQL database question-answering method with intent recognition, which is applied to a database server and includes the following processes:

[0109] Receiving a user question input by a user, or receiving a user question converted from a user's voice, or converting the user's voice input into a user question;

[0110] According to the user question, the SQL database query method with intent recognition described in Example 1 of the present invention is used to perform content query;

[0111] The queried content is converted into a set format for display, or the queried content is sent to a terminal specified by the user, or the content converted into a set format is sent to a terminal specified by the user, or the queried content and the content converted into a set format are sent together to a terminal specified by the user.

[0112] Embodiment 4:

[0113] like Figure 5 As shown, this implementation provides a SQL database question-answering system with intent recognition, which is applied to a database server and includes:

[0114] The question receiving unit is configured to: receive a user question input by a user, or receive a user question converted from a user's voice, or convert the user's voice input into a user question;

[0115] The data query unit is configured to: perform content query using the SQL database query method with intent recognition described in Embodiment 1 of the present invention according to the user question;

[0116] The data display unit is configured to: convert the queried content into a set method for display, or send the queried content to a terminal specified by a user, or send the content converted into a set method to a terminal specified by a user, or send the queried content and the content converted into a set method together to a terminal specified by a user.

[0117] Embodiment 5:

[0118] like Figure 6 As shown, this implementation provides an electronic device, which includes a processor 1001, a communication interface 1002, and a computer-readable storage medium 1003. The processor 1001, the communication interface 1002, and the computer-readable storage medium 1003 may be connected via a bus or other means.

[0119] Among them, the communication interface 1002 is used to receive and send data, the computer-readable storage medium 1003 can be stored in the memory of the electronic device, the computer-readable storage medium 1003 is used to store a computer program, the computer program includes program instructions, and the processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1003.

[0120] Processor 1001 (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to implement corresponding method processes or corresponding functions.

[0121] The processor 1001 is configured to execute the following process:

[0122] The field content dictionary generating unit is configured to: identify and correct the intention in the user question, and obtain an aligned database field to a field content dictionary involved in the user question;

[0123] A context information generating unit is configured to: contextually generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information;

[0124] The content query unit is configured to: obtain the SQL query statement corresponding to the user question according to the context information and a preset large language model, and obtain the content to be queried by querying the SQL database according to the SQL query statement.

[0125] Alternatively, the processor 1001 is configured to perform the following process:

[0126] Receiving a user question input by a user, or receiving a user question converted from a user's voice, or converting the user's voice input into a user question;

[0127] According to the user question, the SQL database query method with intent recognition described in Example 1 of the present invention is used to perform content query;

[0128] The queried content is converted into a set format for display, or the queried content is sent to a terminal specified by the user, or the content converted into a set format is sent to a terminal specified by the user, or the queried content and the content converted into a set format are sent together to a terminal specified by the user.

[0129] Embodiment 6:

[0130] This implementation provides a computer-readable storage medium (Memory), which is a memory device in an electronic device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the electronic device and, of course, extended storage media supported by the electronic device. The computer-readable storage medium provides a storage space that stores the processing system of the electronic device.

[0131] In addition, the storage space also stores one or more instructions suitable for being loaded and executed by the processor, and these instructions may be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage; optionally, it may also be at least one computer-readable storage medium located away from the aforementioned processor.

[0132] In one embodiment, the computer-readable storage medium stores one or more instructions; the processor loads and executes the one or more instructions stored in the computer-readable storage medium to implement the following process:

[0133] The field content dictionary generating unit is configured to: identify and correct the intention in the user question, and obtain an aligned database field to a field content dictionary involved in the user question;

[0134] A context information generating unit is configured to: contextually generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information;

[0135] The content query unit is configured to: obtain the SQL query statement corresponding to the user question according to the context information and a preset large language model, and obtain the content to be queried by querying the SQL database according to the SQL query statement.

[0136] Alternatively, the processor 1001 is configured to perform the following process:

[0137] Receiving a user question input by a user, or receiving a user question converted from a user's voice, or converting the user's voice input into a user question;

[0138] According to the user question, the SQL database query method with intent recognition described in Example 1 of the present invention is used to perform content query;

[0139] The queried content is converted into a set format for display, or the queried content is sent to a terminal specified by the user, or the content converted into a set format is sent to a terminal specified by the user, or the queried content and the content converted into a set format are sent together to a terminal specified by the user.

[0140] A person skilled in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art 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 this application.

[0141] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted by a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (for example, coaxial cable, optical fiber, digital line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data processing device such as a server, a data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state hard disk (SSD)), etc.

[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A SQL database query method with intent recognition, characterized in that: The process includes: Identify and correct the intent in the user's question, and obtain the aligned database field to the field content dictionary involved in the user's question; generating a database supplementary information description according to the field content dictionary, and combining the database supplementary information description with the standardized database description to form context information; According to the context information and the preset large language model, an SQL query statement corresponding to the user question is obtained, and the SQL database is queried according to the SQL query statement to obtain the content to be queried.

2. The SQL database query method with intent recognition as claimed in claim 1, characterized in that: Identify and correct the intent in the user's question, and obtain the aligned database field to the field content dictionary R involved in the user's question, including: Extract the database fields involved in the user's question and the content corresponding to the database fields. The extracted result is field x :[c′1,c′2,...,c′ x ,...,c′ m' ],c′ x Field extracted from user questions x The text content corresponding to the field; If field x ∈(EE e′ ), and c′ x ∈C x Then {field x :[c′ x ]} is added to the result set R; if field x ∈E e′ , then execute the next step, where E is an exhaustible data field; c′ x Convert to vector v c′x , field x Field data set C x ={c1,c2,...,c m }Convert to a vector set And set the basic similarity threshold threshold2 and the complete similarity threshold threshold3; Will and Calculate the similarity for each vector in , if the similarity > threshold3, then add the field content corresponding to the vector to the complete similarity list L′, if threshold3 > similarity > threshold2, then add the field content corresponding to the vector to the basic similarity list L; like Then {field x :L′} is added to the field content dictionary R. If Then {field x :L} is added to the field content dictionary R. If Then execute the next step; Generating c′ using large language models and hint engineering x The description text of , and replace c ′ x , using the newly generated c′ x Execute the above judgment process until or 3. The SQL database query method with intent recognition as claimed in claim 2, characterized in that: For each exhaustible data field If m < threshold1, then the data field Is used as the value of the data in the form of a list, otherwise it is defined as an intention recognition field 4. The SQL database query method with intent recognition as claimed in claim 1, characterized in that: Generating a database supplementary information description according to the field content dictionary, and combining the database supplementary information description with the standardized database description to form context information, including: Fill the prompt template with the background of the problem, the description of the SQL statement generation task, some special provisions for specific tasks, a small sample of tasks, user questions, a description of basic database information, a description of supplementary database information, and a list of optional chart types; The prompt template is input into the large language model to generate SQL query statements for user questions, chart type names, and query field names corresponding to the chart's XY axes.

5. The SQL database query method with intent recognition as claimed in claim 4, characterized in that: The SQL database queried according to the SQL query statement to obtain the content to be queried includes: If the user's question only involves a numerical query, the large language model is used to directly output the data; otherwise, the pre-customized Echart chart template and table template are filled according to the generated chart type name, the query field name corresponding to the chart XY axis and the queried data, and the front-end WEB display is performed; Alternatively, convert the data table queried by the SQL statement into a two-dimensional coordinate axis; When a piece of data in a table on a web page is clicked, the XY axis of the data is located through the two-dimensional coordinate axis, and then the number of columns and rows of the data in the table is obtained, triggering the data drill-down process; The SQL statement, data table, number of columns and number of rows are input as restriction conditions into the prompt project template to obtain filled prompt words. Based on the filled prompt words and the preset large language model, the SQL statement for data drilling is obtained, and the query is performed based on the SQL statement for data drilling.

6. A SQL database question-answering method with intent recognition, characterized in that: Applied to the database server, including the following procedures: Receiving a user question input by a user, or receiving a user question converted from a user's voice, or converting the user's voice input into a user question; According to the user question, use the SQL database query method with intent recognition described in any one of claims 1 to 5 to perform content query; The queried content is converted into a set format for display, or the queried content is sent to a terminal specified by the user, or the content converted into a set format is sent to a terminal specified by the user, or the queried content and the content converted into a set format are sent together to a terminal specified by the user.

7. An SQL database query system with intent recognition, characterized in that: include: The field content dictionary generating unit is configured to: identify and correct the intention in the user question, and obtain an aligned database field to a field content dictionary involved in the user question; A context information generating unit is configured to: contextually generate a database supplementary information description according to the field content dictionary, and combine the database supplementary information description with the standardized database description to form context information; The content query unit is configured to: obtain the SQL query statement corresponding to the user question according to the context information and a preset large language model, and obtain the content to be queried by querying the SQL database according to the SQL query statement.

8. An SQL database question-answering system with intent recognition, characterized in that: Applicable to database servers, including: The question receiving unit is configured to: receive a user question input by a user, or receive a user question converted from a user's voice, or convert the user's voice input into a user question; A data query unit, configured to: perform content query according to the user question using the SQL database query method with intent recognition according to any one of claims 1 to 5; The data display unit is configured to: convert the queried content into a set method for display, or send the queried content to a terminal specified by a user, or send the content converted into a set method to a terminal specified by a user, or send the queried content and the content converted into a set method together to a terminal specified by a user.

9. A computer device, characterized in that: include: a processor and a computer readable storage medium; a processor adapted to execute a computer program; A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the SQL database query method with intent recognition as described in any one of claims 1 to 5 is implemented, or the SQL database question-and-answer method with intent recognition as described in claim 6 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is suitable for being loaded by a processor and executing the SQL database query method with intent recognition as described in any one of claims 1-5, or implementing the SQL database question and answer method with intent recognition as described in claim 6.

Citation Information

Cited By

  • Information query method and device, terminal equipment and storage medium

    CN119357216A

  • Method and device for generating SQL (Structured Query Language) based on semantic alignment and hierarchical Agent

    CN119377255A

  • SQL statement generation method and device

    CN119782340A

  • A method and apparatus for generating SQL statements

    CN119782340B

  • Domain knowledge supplement and SQL generation optimization method and device based on large model

    CN119938891A