Conversational methods and systems
By determining the relationship between user questions and database tables, and constructing SQL query statements, the error problem of generating multi-table combined SQL query statements in the intelligent customer service system was solved, achieving higher response accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-09
- Publication Date
- 2026-03-27
AI Technical Summary
Existing intelligent customer service systems are prone to errors when generating SQL query statements that combine multiple data tables, resulting in insufficient response accuracy.
By determining the relationship between user questions and multiple columns of a database table, an SQL query statement is constructed, and an accurate SQL query statement is generated using a self-attention mechanism and greedy search or cluster search.
It improved the accuracy of generated SQL query statements, thereby enhancing the accuracy and efficiency of the intelligent customer service system's responses.
Smart Images

Figure CN114610741B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of natural language processing, and in particular, to a dialogue method and system. BACKGROUND
[0002] In the prior art, some intelligent customer service systems generate a database operable SQL query statement according to a natural language input by a user, and then execute the SQL query statement to obtain data from a database and generate a user response. Among them, generating a SQL query statement according to a natural language input by a user is a key operation of an intelligent customer service system. The usual way of this operation is to model the relationship between the user input text and the database table / column, and to obtain the corresponding relationship between the user input and the SQL query statement in the model using an attention mechanism, but using the attention mechanism can generate a simple SQL query statement, but when it comes to generating a SQL query statement of multiple database table combinations (such as multi-table union, join, etc.), errors are prone to occur. SUMMARY
[0003] Therefore, the purpose of the present disclosure is to provide a dialogue method and system to solve the problem that generating a SQL query statement of multiple database table combinations is prone to errors.
[0004] In a first aspect, the embodiments of the present disclosure provide a dialogue method, comprising:
[0005] obtaining a user question;
[0006] determining a first association relationship between the user question and a plurality of columns of at least one database table, constructing a SQL query statement according to the first association relationship, and
[0007] executing the SQL query statement to obtain a response to the user question.
[0008] Optionally, the dialogue method further comprises determining a topic of the user question, and selecting the at least one database table from a plurality of database tables according to the topic.
[0009] Optionally, the determining of the first association relationship between the user question and the plurality of columns of the at least one database table, and the constructing of the SQL query statement according to the first association relationship, comprise:
[0010] constructing a word feature vector corresponding to each of a plurality of words in the user question;
[0011] constructing a column feature vector corresponding to a plurality of column information of the at least one database table;
[0012] constructing a relationship feature vector according to the word feature vector and the column feature vector; and
[0013] obtaining the SQL query statement according to the relationship feature vector.
[0014] Optionally, the determining the first association relationship between the user question and the plurality of columns of the at least one database table, and constructing the SQL query statement according to the first association relationship, comprises:
[0015] constructing a word feature vector corresponding to each of the plurality of words in the user question;
[0016] constructing a column feature vector corresponding to each of the plurality of column information of the at least one database table;
[0017] constructing a relationship feature vector according to the word feature vector and the column feature vector; and
[0018] obtaining a plurality of candidate SQL query statements according to the relationship feature vector;
[0019] determining, from the plurality of candidate SQL query statements, a candidate SQL query statement that is most matched with the user question as the SQL query statement.
[0020] Optionally, the dialogue method further comprises:
[0021] performing a self-attention operation on the word feature vector;
[0022] performing a self-attention operation on the column feature vector;
[0023] obtaining the SQL query statement according to the relationship feature vector, comprises:
[0024] obtaining the SQL query statement according to the self-attention operation result of the word feature vector, the self-attention operation result of the column feature vector, and the relationship feature vector.
[0025] Optionally, the SQL query statement is obtained by using a greedy search.
[0026] Optionally, the top K candidate SQL query statements arranged from high to low in probability are obtained by using a beam search, and K is an integer greater than 1.
[0027] Optionally, the dialogue method further comprises: determining a second association relationship between the plurality of columns of the plurality of database tables;
[0028] obtaining the SQL query statement according to the relationship feature vector, comprises:
[0029] constructing the SQL query statement according to the first association relationship and the second association relationship.
[0030] In a second aspect, the embodiments of the present disclosure provide a dialogue system, comprising:
[0031] a question collection module, configured to obtain a user question;
[0032] a query statement construction module, configured to determine a first association relationship between the user question and each column of at least one database table, and construct a SQL query statement according to the first association relationship;
[0033] a query statement execution module, configured to execute the SQL query statement to obtain an answer to the user question.
[0034] Optionally, the query statement construction module performs the following operations:
[0035] constructing a word feature vector corresponding to each word in the user question;
[0036] constructing a column feature vector corresponding to each column information of the at least one database table;
[0037] constructing a relationship feature vector according to the word feature vector and the column feature vector; and
[0038] obtaining the SQL query statement according to the relationship feature vector.
[0039] Optionally, the query statement construction module performs the following operations:
[0040] constructing a word feature vector corresponding to each word in the user question;
[0041] constructing a column feature vector corresponding to each column information of the at least one database table;
[0042] constructing a relationship feature vector according to the word feature vector and the column feature vector; and
[0043] obtaining a plurality of candidate SQL query statements according to the relationship feature vector;
[0044] determining, from the plurality of candidate SQL query statements, a candidate SQL query statement that is most matched with the user question as the SQL query statement.
[0045] Optionally, the query statement construction module further performs the following operations:
[0046] performing a self-attention operation on the word feature vector;
[0047] performing a self-attention operation on the column feature vector;
[0048] the query statement construction module obtains the SQL query statement according to the relationship feature vector is:
[0049] The self-attention operation result of the word feature vector, the self-attention operation result of the column feature vector, and the relationship feature vector are input into the relationship generator to obtain the SQL query statement.
[0050] Optionally, the query statement construction module adopts bundle search to obtain K candidate SQL query statements arranged from high to low in probability, K being an integer greater than 1.
[0051] Optionally, the query statement construction module further comprises determining a second association relationship between each column of the plurality of database tables,
[0052] The query statement execution module comprises constructing an SQL query statement according to the first association relationship and the second association relationship.
[0053] In a third aspect, an electronic device is provided, comprising a memory and a processor, the memory further storing computer instructions executable by the processor, and the computer instructions, when executed, implement the dialogue method of any of the above.
[0054] In a fourth aspect, a computer readable medium is provided, the computer readable medium storing computer instructions executable by an electronic device, and the computer instructions, when executed, implement the dialogue method of any of the above.
[0055] According to the embodiments of the present disclosure, before constructing the SQL query statement, the association relationship between the user question and each column of at least one database table is determined, so as to form a priori and constraint for the SQL query statement, and the accuracy of the SQL query statement obtained is higher. BRIEF DESCRIPTION OF DRAWINGS
[0056] The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure, taken in conjunction with the accompanying drawings, in which:
[0057] Figure 1 is a schematic diagram of application deployment of a dialogue system;
[0058] Figure 2 is a schematic diagram of a graphical interface of an intelligent customer service system;
[0059] Figures 3a-3b are flowcharts of dialogue methods of an embodiment of the present disclosure, respectively;
[0060] Figure 4 is a schematic diagram of a network structure used by an embodiment of the present disclosure;
[0061] Figure 5 is an example diagram of an association relationship between a user question and a database table and each column in the database table.
[0062] Figure 6 is a schematic diagram of a network structure used by another embodiment of the present disclosure;
[0063] Figure 7 is a structural schematic diagram of a reordering model in Figure 6
[0064] Figure 8 is a schematic diagram of a dialogue system of an embodiment of the present disclosure;
[0065] Figure 9 is a structural diagram of an electronic device used by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0066] The present disclosure is described below based on embodiments, but the present disclosure is not limited to only these embodiments. In the following detailed description of the present disclosure, some specific details are described in detail. The present disclosure can also be fully understood without the description of these details by those skilled in the art. In order to avoid confusion of the essence of the present disclosure, well-known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.
[0067] Figure 1 is a deployment schematic diagram of a dialogue system. As shown in Figure 1 , various terminals 101 establish communication with a server 102 through a network 103. The terminal 101 is various electronic devices using a computer system, such as a personal computer, a mobile phone, a notebook, a tablet computer, various terminal devices providing public services, and the like. The network 103 can be based on one or a combination of various communication technologies implemented by exchanging signals, including but not limited to wired technologies using electrical and / or optical conductive cables, and wireless technologies using infrared, radio frequency, and / or other forms. In different application scenarios, the network 103 can be the Internet, a wide area network, or a local area network, such as a proprietary network for a company. The network 103 can also be a wired network or a wireless network. The server 102 can be a physical server or a cloud server. The cloud server can integrate hardware and software resources of the physical server based on virtualization technology, and then provide computing power, storage capacity, or various application services based on user needs. According to the present disclosure, the server 102 deploys and runs a dialogue system that responds to user queries of various terminals.
[0068] Figure 2 is a schematic diagram of a graphical interface of an intelligent customer service system. As shown in the figure, the display screen of terminal 101 displays a question and answer window 21, in which the user inputs questions 1 and 2. Question 1 is a question asking "What are the top five cities in China in terms of GDP?", and the system generates a SQL query statement similar to this: select name from cities order by gdp desc limit 5. After the execution of this SQL query statement, the city names including Shanghai, Beijing, Shenzhen, Guangdong, etc. are returned. Question 2 is a question asking "What are the respective GDPs of these cities?", and the system generates a SQL query statement similar to this: select name, gdp from cities order by gdp desc limit 5. After the execution of this SQL query statement, the city names and gdp values are returned. The answers to questions 1 and 2 are as shown in the figure.
[0069] Such an intelligent customer service system is suitable for answering some questions with fixed answers, such as questions about company business, company products, order logistics, preferential policies, encyclopedic information, etc. If these questions are answered by artificial customer service, a large amount of human cost is consumed, and the answering efficiency is low. However, if an intelligent customer service system is used, not only is the efficiency high, but also the cost is low. However, this requires that the answering accuracy of the intelligent customer service system be high. To improve the answering accuracy of the intelligent customer service system, the key is to improve the accuracy of the SQL query statement generated according to the user question.
[0070] Based on this, the embodiment of the present disclosure provides a dialogue method. Figures 3a-3b are flowcharts of dialogue methods of an embodiment of the present disclosure.
[0071] Figure 3a The flowchart shown includes the following steps.
[0072] In step S301, a user question is obtained.
[0073] In step S302, an association relationship between the user question and a plurality of columns of at least one database table is determined.
[0074] In step S303, a SQL query statement is constructed according to the association relationship.
[0075] In step S304, the SQL query statement is executed to obtain an answer to the user question.
[0076] Figure 3bThe flow chart shown further comprises steps S401 and S402 between steps S301 and S302, in addition to the steps described above. Steps S401 and S402 are used to select at least one database table related to the current user question from a plurality of database tables, specifically, the subject to which the user question belongs is determined according to the user question, and then at least one database table is selected from the plurality of database tables according to the subject. Then only the at least one database table is used to construct the SQL query statement for the current user question. For hundreds of database tables, the database tables can be sorted under different subjects respectively and the subject information can be stored as metadata of the corresponding database tables. For example, the database table countries which introduces specific information of various countries, the subject of which is set as: country. In addition, when a database table is located through a subject, other database tables having an associated relationship with the database table are also included. For example, the database table countries has a primary-foreign key relationship with the database table cities, and the cities are also included as the database table determined according to the user question.
[0077] After the at least one database table is determined, the association between the user question and each column of the at least one database table is determined according to the user question and the column information of each column in the at least one database table. For example, the question "What are the top five cities in China in terms of GDP" corresponds to the database tables countries and cities, the columns included in the database table countries are: name, city_id, and the columns included in the database table cities are: city_id, city_name, and gdps. First, "China" is matched with "name", "city" is matched with "city_id", and then "gdp" is matched with "gdps". If the user question is in English, the words contained in the user question can be matched with the column names in the database table to determine whether there is an association; if the user question is in Chinese, the user question can be matched with the remark information of each column in the database table to determine whether there is an association. Usually, the column names of the database table are English abbreviations, but in order to match the Chinese question, Chinese remarks can be set for multiple columns.
[0078] After determining the association between the user question and the columns of the at least one database table, a SQL query statement is constructed according to the association. For example, based on the user question in the above example, the SQL query statement obtained is: select cities.city_name, cities.gdps from country, cities where country.city_id = cities.city_id and country.name = 'China' order by cities.gdps desc 5. Executing the SQL query statement can obtain the answer to the user question.
[0079] In some embodiments, the trained model is used to construct a SQL query statement for a user question. The trained model is usually an end-to-end model, Figure 4 A network structure diagram of an exemplary model is shown. Referring to Figure 4 As shown, the network structure 400 includes an encoder 401, an encoder 402, an attention module 403, an attention module 404, a relation generator 405, connection modules 406 and 407, an encoder 408, and a decoder 409.
[0080] The encoder 401 is configured to receive a natural language-based user question, encode the user question, extract keywords from the user question, and obtain at least one word feature vector representing a word in the user question and semantic information of the word in the user question.
[0081] The three questions input to the encoder 401 in the figure are: What are all the flight number?; Of these, which are arrival flights; and Which land in Aberdeen?. The encoder 401 obtains at least one word feature vector according to the three questions.
[0082] The encoder 402 is configured to receive database table / column information, encode the database table / column information, and obtain at least one column feature vector. The three database tables input to the encoder 402 in the figure are airlines, airports, and flights. Airlines stores airline information. Airports stores airport information. Flights stores flight information. The encoder 402 obtains at least one column feature vector according to the columns of airlines, airports, and flights.
[0083] The at least one word feature vector output by the encoder 401 is input to the attention module 403 and the relationship generator 405 respectively.
[0084] The at least one column feature vector output by the encoder 402 is input to the attention module 404 and the relationship generator 405 respectively.
[0085] The attention modules 403 and 404 perform self-attention operations. By introducing the self-attention mechanism, the focus can be placed on specific words or phrases in the sentence, and the relationship between any two words or phrases can be established by calculation to obtain the mutual dependence between the words.
[0086] The relationship generator 405 receives the at least one word feature vector output by the encoder 401 and the at least one column feature vector output by the encoder 402 respectively, and constructs the association relationship between them.
[0087] In some embodiments, the relationship generator mainly adds relationship information in the traditional Transformer structure, and the relationship information is represented by the expression of the relationship matrix. The network structure of the relationship generator can be represented as the following expression:
[0088]
[0089] x i and x j are the word feature vector and the column feature vector with indexes i and j respectively, W is a mapping matrix, a is a relationship matrix to be learned, Q represents a query indication in the Transformer structure, K represents a key indication in the Transformer structure, T represents the transpose of the matrix, d z represents the length of the current input feature vector, e ij represents the final output. This relationship matrix can represent multiple relationships.
[0090] Figure 5 is an example diagram of the association relationship between a user question and a database table and each column in the database table.
[0091] As shown in the figure, the user question QS is: for the cars with 4 cylinders, which model has the largest horsepower. From the figure, it can be seen that QS is about cars, so the data table cars_data and car_name are located, and then the model in QS and the model in cars_names are associated, and the horsepower in QS and the horsepower in cars_data are associated. Cars_names and model_list have a foreign key relationship, and model_list and car_makes have a foreign key relationship. Based on this example, it can be understood that the goal of the relationship generator is to identify the relationship between the user question and the database table column and output a vector representing the relationship. Alternatively, the relationship generator stores the pre-set relationship classification and the corresponding rules in the memory unit and uses them when identifying the relationship.
[0092] In one example, the following 10 different relationships are defined. Among them, 1 and 2 represent the relationship between columns, and 3 to 10 represent the relationship between the words in the question and the classes of the database table.
[0093] 2. Both are database foreign key relationships;
[0094] 3. Both are text - the word in the question and the table name are completely matched;
[0095] 4. Both are text - the word in the question and the table name have 3 letter matches
[0096] 5. Both are text - the word in the question and the table name have 4 letter matches
[0097] 6. Both are text - the word in the question and the table name have 5 letter matches
[0098] 7. Both are text - the word in the question and the column name are completely matched;
[0099] 8. Both are text - the word in the question and the column name have 3 letter matches
[0100] 9. Both are text - the word in the question and the column name have 4 letter matches
[0101] 10. Both are text - the word in the question and the column name have 5 letter matches
[0102] However, it should be noted that the 10 relationships are for English question and answer, and are not applicable to Chinese question and answer.
[0103] In summary, by predefining multiple different relationship types and classifying the association between the user question and each column in the database table as one of the relationship types through sample training, the specific relationship between the user question and the database table / column can be captured in model inference, providing guidance and constraints for constructing the SQL query statement.
[0104] Of course, based on the embodiments of the present disclosure, developers can predefine various different relationships according to various practical application scenarios and input them into the model for training to obtain a trained model. In the training phase of the model, the developers can also collect training samples based on the predefined relationships. In addition, even for the same model to be trained, the trained model is not the same due to different predefined relationships.
[0105] With reference to Figure 4 As shown, the connection module 306 is configured to connect the word feature vector after the self-attention operation and the relationship feature vector output by the relationship generator 305 to output a first connection vector; and the connection module 307 is configured to connect the column feature vector after the self-attention operation and the relationship feature vector output by the relationship generator 305 to form a second connection vector.
[0106] The decoder 409 receives the first connection vector and the second connection vector, and constructs the SQL query statement according to the first connection vector and the second connection vector. The decoder 409 can adopt a greedy search decoding manner to generate the final SQL query statement, and the greedy search selects the one with the maximum probability as the final SQL query statement.
[0107] Optionally, the user question includes not only the current user question but also the historical user question before the current user question, and the current user question and the historical user question are input to the model 400 together, so that the trained model can integrate multiple historical user questions into the construction of the SQL query statement, thereby more effectively capturing the relationship between the words in the user question and the tables / columns in the database, benefiting from the modeling of such relationship, thereby more accurately hitting the tables and columns in the database. For example, as shown in the figure, the current user question refers to "Which land in Aberdeen?", the historical user question refers to "Of these, which are arrival flights" and "What are all the flight number?", and the historical user question before the current user question is usually the user question in the last round or several rounds of dialogue. Here we define a round of dialogue as one question and one answer between the questioner and the answerer.
[0108] Accordingly, during the model training phase, multiple user questions are collected and combined into a training sample, and the model is trained based on such a training sample. This enables the trained model to integrate current user questions and historical user questions, and to more effectively capture the relationship between words in user questions and tables / columns in the database.
[0109] To obtain more accurate SQL query statements, such as Figure 4 As shown, the network structure 400 also includes an encoder 408. The input to the encoder 408 is one or more historical SQL query statements corresponding to previous user questions. Since historical user questions and user questions are in the same dialogue and are usually semantically related, the SQL query statement to be generated now also has a semantic relationship with the previously generated historical SQL query statements. Therefore, the encoder 408 encodes the historical SQL statements into an input vector and inputs it to the decoder 409, enabling the decoder 409 to refer to the historical SQL query statements and generate an SQL query statement for the current user question. Figure 4 As shown, the final SQL query statement should be: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport=T2.AirportCode.
[0110] Figure 6 Another exemplary model network structure diagram is shown. As shown in the figure, network structure 600 and... Figure 4 The difference lies in decoder 601 and reordering model 602. Decoder 601 receives the same input as decoder 409, but it uses beam search to generate K candidate SQL queries. These K candidate SQL queries are the top K most probable SQL queries, where K is an integer greater than 1. Beam search outperforms greedy search in various natural language tasks; therefore, replacing the model with beam search will generate multiple candidate SQL queries within a beam. The validation set shows that the final SQL query has a 67.7% probability in the candidate set, but only a 60.8% probability as the first candidate. Therefore, the added reordering model 602 is used to select the best-matching SQL query from the K SQL queries output by decoder 601. Optionally, the reordering model of reordering model 602 can be constructed using the pre-trained language model Roberta.
[0111] In some embodiments, the encoder and the decoder are constructed based on an RNN (Recurrent Neural Network, RNN) model LSTM (Long Short Term Memory networks) network. RNN is a recursive neural network that takes sequence data as input, recurses in the evolution direction of the sequence, and all nodes (loop units) are connected in a chain. The LSTM-RNN model can be regarded as a variant of RNN. Both RNN model and LSTM-RNN model are suitable for sequence application scenarios, and thus can be applied to the present embodiments.
[0112] Based on the above network structure, training samples need to be collected for training. The training sample is, for example, a combination of a user question and a correct SQL query statement. The training sample is input to the model to be trained, a SQL query statement is generated according to the user question in the training sample, then the error is calculated using the correct SQL query statement in the training sample, and the weight parameters in the model to be trained are continuously adjusted based on the error until the error can meet the requirements.
[0113] Alternatively, the intelligent customer service system Figure 2 can be used to collect training samples. Since the logs of the intelligent customer service system usually record user questions and SQL query statements generated for the user questions, the logs can be parsed to extract user questions and SQL query statements to organize training samples. However, it should be noted that the SQL query statements recorded in the logs of the intelligent customer service system are not necessarily correct SQL query statements, and therefore correct SQL query statements need to be selected. Since the intelligent customer service system continuously generates new logs, it can also be used to continuously obtain new training samples, and periodically train the model based on the new training samples.
[0114] Figure 7 is Figure 6 the structure diagram of the reordering model in the . As shown in the figure, the input is the current user question and a candidate SQL query statement connected by the [SEP] connector. The network structure of the reordering model 700 includes a network structure RoBERTa 701 and a binary classifier 702. The network 701 performs encoding and decoding, and the binary classifier 702 outputs a classification result. If the input candidate SQL query statement is the real SQL of the current user question, the output is the first classification, otherwise the output is the second classification.
[0115] The reordering model is also an end-to-end model, which needs to build a training set and a validation set for training, and update the weight parameters of the reordering model through back propagation. The finally trained reordering model can be used to sort the multiple candidate SQL query statements output by the decoder, and obtain the most matched candidate SQL query statement as the final result.
[0116] Figure 8 is a schematic diagram of a dialog system according to an embodiment of the present disclosure. As shown in the figure, the dialog system comprises:
[0117] The question collection module 701 is configured to obtain a user question.
[0118] The query statement construction module 702 is configured to determine an association relationship between the user question and multiple columns of at least one database table, and construct a SQL query statement according to the association relationship.
[0119] The query statement execution module is configured to execute the SQL query statement to obtain an answer to the user question.
[0120] The question collection module 701 can collect the user question through a user graphical interface, such as a browser-based user graphical interface or a user graphical interface based on C / S structure client software.
[0121] Optionally, the query statement construction module 702 can use a trained deep learning model to determine the association relationship between the user question and the multiple columns of the at least one database table, and construct the SQL query statement according to the association relationship. The network structure of the model is as shown in FIG. Figure 4 or 6.
[0122] Optionally, before constructing the SQL query statement, the query statement construction module 702 not only determines the association relationship between the user question and each column of the at least one database table, but also determines the association relationship between each column in the at least one database table. Determining the association relationship between the user question and each column of the at least one database table is to determine whether each word in the user question has a relationship with each column of the database table, and whether a mapping can be established between the word and the column name. The association relationship between two database tables can be one of the following: one-to-one single-direction primary key association, one-to-one single-direction foreign key association, one-to-one bidirectional foreign key association, etc. These are all association relationships supported by structured query statements. The association relationship between the columns of the structured database table is determined in advance, and these association relationships can be input to the relationship generator in the training stage to facilitate learning of the relationship matrix.
[0123] The model is enabled to determine, via training, at least one database table related to the user question from a plurality of database tables, and the rest of the database tables are irrelevant to the user question, and to establish an association between the user question and each column of the database table in the relevant database table. Optionally, topic information is obtained according to semantic analysis of the user question, and then at least one database table is selected from the plurality of database tables according to the topic information by the computer program.
[0124] It should be understood that, since Figure 8 The dialog system shown corresponds to the dialog method introduced above, and thus the dialog system is briefly introduced here. The model used by the dialog system is described above in combination with Figures 5-6 Detailed description is not repeated here.
[0125] In summary, the dialog method and the dialog system provided by the embodiments of the present disclosure determine the association between the user question and each column of at least one database table before constructing the SQL query statement, to form a priori and constraint for the SQL query statement to be constructed, so that the accuracy of the SQL query statement obtained is higher.
[0126] The embodiments of the present disclosure also provide an electronic device 900, such as Figure 9 As shown, at the hardware level, the electronic device 900 includes a memory 902 and a processor 901, and in some cases, further includes an input / output device 903 and other hardware 904. The memory 902 is, for example, a high-speed random access memory (RAM), and can also be a non-volatile memory, such as at least one disk memory. The input / output device 903 is, for example, a display, a keyboard, a mouse, a network controller, and the like. The processor 901 can be constructed based on various models of processors on the market. The processor 901, the memory 902, the input / output device 903, and the other hardware 904 are connected to each other through a bus, which can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one line is shown in the figure, but it does not mean that there is only one bus or only one type of bus.
[0127] The memory 902 is configured to store programs. Specifically, the programs can include program codes including computer instructions. The memory can include an internal memory and a non-volatile memory, and provide the computer instructions and data to the processor 901. The processor 901 reads the corresponding computer programs from the memory 902 into the internal memory and then runs, and realizes the conversation method provided by the above-mentioned embodiments at a logical level.
[0128] Those skilled in the art can understand that the present disclosure can be implemented as a system, a method and a computer program product. Therefore, the present disclosure can be embodied in the form of entire hardware, entire software (including firmware, resident software, microcode), and also in the form of a combination of software and hardware. In addition, in some embodiments, the present disclosure can also be embodied in the form of a computer program product in one or more computer readable media, which includes computer readable program codes.
[0129] Any combination of one or more computer readable medium can be employed. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the above. More specific examples of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this context, a computer readable storage medium can be any tangible medium that contains or stores a program for use by or in connection with a processing unit, device or apparatus.
[0130] The computer readable signal medium can include a data signal propagated in a baseband or propagated as part of a carrier wave, in which computer readable program codes are carried. Such propagated data signal can take many forms, including but not limited to electromagnetic signal, optical signal or any suitable combination. The computer readable signal medium can also be any computer readable medium other than the computer readable storage medium, which can send, propagate or transmit programs for use by or in connection with an instruction system, device or apparatus.
[0131] The program codes contained in the computer readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., and any suitable combination of the above.
[0132] Computer program code for carrying out operations of embodiments of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++, or a conventional procedural programming language, such as the C programming language. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0133] The specific embodiments of the present disclosure described above are illustrative, and not intended to limit the scope of the present disclosure. Various modifications and changes can be made therein and alternatives can be substituted without departing from the spirit and scope of the present disclosure as recited in the claims.
Claims
1. A method for dialogue, comprising: obtaining a user question; determining a first association between the user question and a plurality of columns of at least one database table; constructing a SQL query statement according to the first association; and executing the SQL query statement to obtain an answer to the user question; wherein the method further comprises determining a topic to which the user question belongs, and determining the at least one database table from a plurality of database tables based on the topic, wherein the at least one database table comprises a first database table associated with the topic and a second database table having an association with the first database table; determining the first association between the user question and the plurality of columns of the at least one database table comprises encoding the user question to obtain a word feature vector and encoding column information of the columns to obtain a column feature vector, and constructing a relation feature vector based on the word feature vector and the column feature vector, wherein the relation feature vector is used to represent the first association; the method further comprises performing a self-attention operation on the word feature vector and performing a self-attention operation on the column feature vector. the determining the first association between the user question and the plurality of columns of the at least one database table and the constructing the SQL query statement according to the first association comprise:
2. The dialog method according to claim 1, wherein, constructing word feature vectors corresponding to a plurality of words in the user question respectively; constructing column feature vectors corresponding to a plurality of column information of the at least one database table respectively; constructing a relation feature vector according to the word feature vectors and the column feature vectors; and obtaining a plurality of candidate SQL query statements according to the relation feature vector; determining a candidate SQL query statement that is most matched with the user question from the plurality of candidate SQL query statements as the SQL query statement. 3.The method for dialogue according to claim 1, further comprising: performing a self-attention operation on the word feature vector; performing a self-attention operation on the column feature vector; then the obtaining the SQL query statement according to the relation feature vector comprises: obtaining the SQL query statement according to a result of the self-attention operation on the word feature vector, a result of the self-attention operation on the column feature vector and the relation feature vector. obtaining the SQL query statement by using a greedy search.
4. The dialog method of claim 1, wherein, obtaining a plurality of candidate SQL query statements arranged in a descending order of probability by using a beam search, K being an integer greater than 1.
5. The dialog method according to claim 2, wherein, determining a second association between a plurality of columns of the plurality of database tables; 6. The dialog method of claim 1, further comprising: then the constructing the SQL query statement according to the first association comprises: constructing the SQL query statement according to the first association and the second association. 7.A dialogue system, comprising: a question collecting module configured to obtain a user question; a query statement constructing module configured to determine a first association between the user question and each column of at least one database table and to construct a SQL query statement according to the first association; and a query statement executing module configured to execute the SQL query statement to obtain an answer to the user question. The system is further configured to determine a topic to which the user question belongs, and determine the at least one database table from a plurality of database tables based on the topic, wherein the at least one database table comprises a first database table associated with the topic and a second database table associated with the first database table. The query statement construction module is configured to determine the first association relationship by encoding the user question using an encoder to obtain a word feature vector and encoding column information of the columns using the encoder to obtain a column feature vector, and constructing a relationship feature vector based on the word feature vector and the column feature vector using a relationship generator, wherein the relationship feature vector is used to represent the first association relationship. The system is further configured to perform self-attention operations on the word feature vector and the column feature vector.
8. The dialog system of claim 7, wherein, The query statement construction module is configured to perform the following operations: constructing word feature vectors corresponding to a plurality of words in the user question respectively; constructing column feature vectors corresponding to a plurality of column information of the at least one database table respectively; constructing a relationship feature vector based on the word feature vectors and the column feature vectors; and obtaining a plurality of candidate SQL query statements based on the relationship feature vector; and determining a candidate SQL query statement that is most matched with the user question from the plurality of candidate SQL query statements as the SQL query statement.
9. The dialog system of claim 7, wherein the query statement construction module is further configured to perform the following operations: performing self-attention operations on the word feature vector; performing self-attention operations on the column feature vector; the query statement construction module obtains the SQL query statement based on the relationship feature vector as follows: inputting results of the self-attention operations on the word feature vector, results of the self-attention operations on the column feature vector, and the relationship feature vector into the relationship generator to obtain the SQL query statement. The query statement construction module adopts bundle search to obtain a top K candidate SQL query statement in descending order of probability, K being an integer greater than 1.
10. The dialog system of claim 8, wherein, determining a second association relationship between each column of the plurality of database tables, 11. The dialog system of claim 7, the query sentence construction module further comprising: The query statement execution module comprises constructing a SQL query statement based on the first association relationship and the second association relationship.
12. An electronic device comprising a memory and a processor, the memory further storing computer instructions executable by the processor, the computer instructions being executed to implement the dialog method of any one of claims 1 to 6.
13. A computer readable medium storing computer instructions executable by an electronic device, the computer instructions being executed to implement the dialog method of any one of claims 1 to 6.