Database operation method, device and medium

By mapping the training text set to a Chinese-English mapping space, a shared representation vector is generated. The accuracy of converting Chinese text into SQL statements is improved by using English training text, which solves the problem of low accuracy in Chinese-to-SQL models and enables user-friendly database operations.

CN115409200BActive Publication Date: 2025-12-05INST OF MICROELECTRONICS CHINESE ACAD OF SCI LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211162217.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2025-12-05
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of Chinese-to-SQL conversion models is not high, causing users to rely on manually writing SQL statements when operating the database, which requires a high level of computer expertise.

Method used

By acquiring a training text set, including Chinese and English text, mapping it to a Chinese-English mapping space, generating a shared representation vector, using English training text to improve the accuracy of converting Chinese text into SQL statements, and then using a natural language model for operation.

Benefits of technology

It improves the accuracy of converting Chinese text into SQL statements, making it more convenient for users to operate the database and reducing the reliance on writing SQL statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115409200B_ABST
    Figure CN115409200B_ABST
Patent Text Reader

Abstract

The application discloses a database operation method, for each training text in a training text set, mapping the text representation vector of the training text into a Chinese-English mapping space to obtain a shared representation vector of the training text; using the shared representation vector of each training text for model training to obtain a trained natural language model as a target natural language model; obtaining a target text for operating a SQL database; mapping the text representation vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text; inputting the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text; and operating the SQL database using the target SQL statement. The database operation method, device and medium disclosed by the application can improve the accuracy of converting a Chinese text into a SQL statement by using an English training text, so that a user can operate a database more conveniently.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular to a database operation method and device and medium. BACKGROUND

[0002] In the prior art, the access and operation of a business database are extremely dependent on manually writing SQL statements, which puts high requirements on the computer professional level of business personnel in various fields. In order to enable more users to operate the business database, a natural language processing technology is used to automatically convert Chinese text into SQL statements, so that users can access or operate the database without relying on writing SQL statements, thereby facilitating user operation of the database.

[0003] In the prior art, when Chinese text is converted into SQL statements by using a natural language processing technology, a Chinese-to-SQL model is usually obtained by training a specific field Chinese database, and since the Chinese database is internally composed of Chinese text and the finally generated SQL statement is in English, the accuracy of the Chinese-to-SQL model obtained by model training is not high. SUMMARY

[0004] The embodiments of the present application provide a database operation method, device and medium, which can improve the accuracy of converting Chinese text into SQL statements by using English training text, so as to make it more convenient for users to operate the database.

[0005] The first aspect of the embodiments of the present application provides a database operation method, which comprises:

[0006] obtaining a training text set for operating a SQL database, wherein the training text set comprises a training Chinese text set and a training English text set;

[0007] mapping a text representation vector of each training text in the training text set into a Chinese-English mapping space to obtain a shared representation vector of the training text;

[0008] training a model by using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model;

[0009] obtaining a target text for operating the SQL database;

[0010] mapping a text representation vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text;

[0011] inputting the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text;

[0012] Perform an operation on the SQL database using the target SQL statement.

[0013] Optionally, the mapping, for each training text in the training text set, of the text representation vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text comprises:

[0014] For each training text, if the training text is a Chinese text, obtaining a Chinese text vector of the training text and mapping the Chinese text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text; if the training text is an English text, obtaining an English text vector of the training text and mapping the English text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text.

[0015] Optionally, the obtaining, if the training text is an English text, of an English text vector of the training text comprises:

[0016] If the training text is an English text, obtaining an English word vector of the training text, inputting the English word vector of the training text into a first language representation model to obtain the English text vector of the training text.

[0017] Optionally, the obtaining, if the training text is a Chinese text, of a Chinese text vector of the training text comprises:

[0018] If the training text is a Chinese text, obtaining a Chinese word vector of the training text, inputting the Chinese word vector of the training text into a second language representation model to obtain the Chinese text vector of the training text.

[0019] Optionally, the model training using the shared representation vector of each training text to obtain a trained natural language model as the target natural language model comprises:

[0020] Model training using the shared representation vector of each training text and the SQL label corresponding to the training text to obtain the target natural language model.

[0021] Optionally, the obtaining of the training text set for operating the SQL database comprises:

[0022] Obtaining the training English text set;

[0023] Obtaining an original Chinese text set;

[0024] Obtaining a translated Chinese text set corresponding to part of the training English text set in the training English text set;

[0025] Adding the translated Chinese text set and the original Chinese text set to the training Chinese text set;

[0026] According to the training English text and the training Chinese text set, the training text set is obtained.

[0027] Optionally, the mapping of the text representation vector of the target text into the English-Chinese mapping space to obtain the shared representation vector of the target text comprises:

[0028] If the target text is an English text, an English word vector of the target text is obtained, the English word vector of the target text is input into the first language representation model to obtain an English text vector of the target text, and then the English text vector of the target text is mapped into the English-Chinese mapping space to obtain the shared representation vector of the target text, wherein the English text vector of the target text is the text representation vector of the target text.

[0029] If the target text is a Chinese text, a Chinese word vector of the target text is obtained, the Chinese word vector of the target text is input into the second language representation model to obtain a Chinese text vector of the target text, and then the Chinese text vector of the target text is mapped into the English-Chinese mapping space to obtain the shared representation vector of the target text, wherein the Chinese text vector of the target text is the text representation vector of the target text.

[0030] The second aspect of the embodiment of the application further provides a database operation device, and the device comprises:

[0031] a training data acquisition unit configured to acquire a training text set for operating a SQL database, wherein the training text set comprises a training Chinese text set and a training English text set;

[0032] a training text vector acquisition unit configured to map a text representation vector of a training text into an English-Chinese mapping space to obtain a shared representation vector of the training text for each training text in the training text set;

[0033] a model training unit configured to perform model training by using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model;

[0034] a target text acquisition unit configured to acquire a target text for operating a SQL database;

[0035] a target text vector acquisition unit configured to map a text representation vector of the target text into the English-Chinese mapping space to obtain a shared representation vector of the target text;

[0036] The sentence obtaining unit is configured to input the shared representation vector of the target text into the target natural language model to obtain a target SQL sentence corresponding to the target text.

[0037] The database operation unit is configured to operate the SQL database by using the target SQL sentence.

[0038] The third aspect of the embodiment of the present application provides an electronic device, which comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to perform the operation instructions included in the one or more programs for performing the database operation method provided in the first aspect.

[0039] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to perform the steps corresponding to the database operation method provided in the first aspect.

[0040] The one or at least one technical solution provided in the embodiment of the present application has at least the following technical effects:

[0041] According to the above technical solution, in the training process, for each training text, the text representation vector of the training text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the training text, and then the shared representation vector of each training text is used for model training to obtain the target natural language model. The above technical solution makes the English text and the Chinese text both mapped into the Chinese-English mapping space to obtain the shared representation vector of the training text to generate the SQL sentence. Compared with directly using the Chinese text to train the natural language model, since the English text does not have the problem of Chinese-English conversion when generating the SQL sentence, the accuracy of the English text generating the SQL sentence is higher, and the performance of the target natural language model obtained by training is stronger. In the SQL sentence obtaining process, the Chinese target text in the target text set is mapped into the Chinese-English mapping space, and the shared representation vector obtained can also be used for the natural language model trained by the English training text set, thereby improving the accuracy of the Chinese text converted into the SQL sentence and making the user operation of the database more convenient. BRIEF DESCRIPTION OF DRAWINGS

[0042] Figure 1 A flowchart of the database operation method provided by the embodiment of the present application is shown;

[0043] Figure 2 A flowchart of the training steps of the target natural language model provided by the embodiment of the present application is shown;

[0044] Figure 3A block diagram of an operation device of a database provided by an embodiment of the present application is shown in the figure;

[0045] Figure 4 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0046] The main implementation principles, specific implementation manners and corresponding beneficial effects of the technical solutions of the embodiments of the present application are described in detail below in combination with the accompanying drawings.

[0047] EMBODIMENT

[0048] Please refer to Figure 1 The embodiment of the present application provides a database operation method, which comprises the following steps:

[0049] S101, acquiring a training text set for operating an SQL database, wherein the training text set comprises a training Chinese text set and a training English text set;

[0050] S102, mapping a text representation vector of each training text in the training text set into a Chinese-English mapping space to obtain a shared representation vector of the training text;

[0051] S103, training a model by using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model;

[0052] S104, acquiring a target text for operating an SQL database;

[0053] S105, mapping a text representation vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text;

[0054] S106, inputting the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text;

[0055] S107, operating the SQL database by using the target SQL statement.

[0056] The database operation method in the embodiments of the present application is generally applied in a server or a user terminal. The server may be, for example, a desktop computer, a notebook computer, an all-in-one machine or a tablet computer, and the user terminal may be, for example, a desktop computer, a notebook computer, an all-in-one machine, a tablet computer or a smart phone.

[0057] In step S101, a training English text set can be obtained first, and then a set of translated Chinese texts corresponding to part of the training English texts in the training English text set is obtained; a training Chinese text set is obtained according to the set of translated Chinese texts; and a training text set is obtained according to the training English text set and the training Chinese text set. At this time, the training text set includes the training English text set and the training Chinese text set.

[0058] In an embodiment, the training English text set can be obtained from the database English word library corresponding to the SQL database. Since a large amount of English texts in the database English word library are annotated with SQL, manual annotation of English texts during later training can be reduced or avoided. English texts annotated with SQL can be added to the training English text set. Of course, there are also English texts without SQL annotation in the training English text set.

[0059] In an embodiment, when obtaining the set of translated Chinese texts corresponding to part of the training English texts in the training English text set, part of the training English texts includes at least two English texts annotated with SQL. Generally, the number of English texts annotated with SQL in part of the training English texts is greater than the number of English texts without SQL annotation, so that the accuracy of the target natural language model obtained by subsequent training is higher.

[0060] Specifically, part of the training English texts can be translated into Chinese to obtain a set of translated Chinese texts, and then a set of original Chinese texts is obtained from the database Chinese word library corresponding to the SQL database. The training Chinese text set is composed of the set of translated Chinese texts and the set of original Chinese texts.

[0061] In an embodiment, the target natural language model is a natural language processing (NLP) model, which includes a multi-layer perceptron, a CNN model, a transformer model, a better model, and a RoBERTa model, etc.

[0062] After obtaining the training text set, step S102 is performed.

[0063] In step S102, when training the model using the training text set, all training texts in the training text set or part of the training texts can be used, and thus, when training the model using all training texts in the training text set, for each training text in the training text set, the text representation vector of the training text is first obtained, and then the text representation vector of the training text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the training text. When training the model using part of the training texts in the training text set, at this time, for each training text in the part of the training texts in the training text set, the shared representation vector of the training text is obtained in the above manner. Hereinafter, an example of training the model using all training texts in the training text set is taken.

[0064] In an embodiment, for each training text in the training text set, if the training text is a Chinese text, the Chinese text vector of the training text is obtained, and the Chinese text vector of the training text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the training text, wherein the Chinese text vector of the training text is taken as the text representation vector of the training text; if the training text is an English text, the English text vector of the training text is obtained, and the English text vector of the training text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the training text, wherein the English text vector of the training text is taken as the text representation vector of the training text.

[0065] Specifically, for each training text, if the training text is an English text, the English word vector of the training text is obtained, and the English word vector of the training text is input into the first language representation model to obtain the English text vector of the training text. If the training text is a Chinese text, the Chinese word vector of the training text is obtained, and the Chinese word vector of the training text is input into the second language representation model to obtain the Chinese text vector of the training text.

[0066] In an embodiment, when obtaining the Chinese word vector and the English word vector of the training text, a bag-of-words model and a Skip-gram model, etc. can be used to obtain the Chinese word vector and the English word vector of the training text.

[0067] In an embodiment, the first language representation model can be based on a Bidirectional Encoder Representations from Transformer (Bert) model, etc., and the second language representation model can be a Bert-base-chinese model, etc., which are not specifically limited in the present specification.

[0068] In an embodiment, for each training text, after obtaining the text representation vector of the training text, the text representation vector of the training text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the target text. At this time, the text representation vectors obtained by the first language representation model and the second language representation model can be mapped into the Chinese-English mapping space, so that the multiple languages have shared representation vectors in the same representation space (i.e. the Chinese-English mapping space). In the same representation space, natural languages with the same semantic task of text to SQL have the same or similar representation vectors.

[0069] For example, taking the training text as an English text C and a Chinese text D, for the English text C, first, the English word vector of C is obtained by the bag-of-words model, denoted as C1, then C1 is input into the Bert model to obtain the English text vector of C, denoted as C11, and then C11 is mapped into the Chinese-English mapping space to obtain the shared representation vector of C, denoted as C111; correspondingly, for the Chinese text D, first, the Chinese word vector of D is obtained by the bag-of-words model, denoted as D1, then D1 is input into the Bert-base-chinese model to obtain the Chinese text vector of D, denoted as D11, and then D11 is mapped into the Chinese-English mapping space to obtain the shared representation vector of D, denoted as D111.

[0070] And if D is the translated Chinese text of C, C111 and D111 should be the same or similar representation vectors. When the gap between C111 and D111 is large, the feature mapping parameters of the Chinese-English mapping space are adjusted so that the C111 and D111 obtained by the adjusted Chinese-English mapping space are the same or similar representation vectors. In this way, the Chinese text in the translated Chinese text set and the original English text can be trained specifically through the Chinese-English mapping space, so that the Chinese-English mapping space can more accurately identify Chinese texts and English texts with the same or similar representation vectors, and the accuracy of the predicted SQL statements of the trained target natural language model will also be improved, thereby improving the accuracy of the conversion of Chinese text into SQL statements, and making it more convenient for users to operate the database.

[0071] After obtaining the shared representation vector of each training text, step S103 is performed.

[0072] In step S103, the shared representation vector of each training text and the SQL label corresponding to the training text can be used for model training to obtain the target natural language model.

[0073] In an embodiment, part of the training texts in the text set can have SQL labels, the shared representation vector of the training text is taken as the model input, and the SQL label is taken as the model output for model training, at this time, during model training, the pre-training can be first performed by using rich English data with SQL labels, and then only a small amount of Chinese data with SQL labels is needed to fine-tune the pre-trained model, so that the model training process can benefit from transfer learning to enable the Chinese text generation SQL model under the training Chinese text set to benefit from the rich labeled data of the English data set, which can effectively reduce or avoid the task of SQL labeling of Chinese text, so as to improve the efficiency of model training and ensure the accuracy of model prediction.

[0074] In an embodiment, during the model training process of model training by using the shared representation vector of each training text and the SQL label corresponding to the training text, the first language representation model and the second language representation model can be fine-tuned, and the English-Chinese mapping space is trained again, so that the target natural language model is finally obtained.

[0075] In actual application, referring to Figure 2 , first, the training English text set 20 and the training Chinese text set 21 are obtained, wherein the training English text set 200 corresponds to the bert model 200, the English word vector of each English text in the training English text set can be input into the bert model 200 to obtain the English text vector of each English text, and the English text vector of each English text is represented by a vector in the English text representation vector space 201; and the training Chinese text set 21 corresponds to the Bert-base-chinese model 210, the Chinese word vector of each Chinese text in the training Chinese text set can be input into the Bert-base-chinese model 210 to obtain the Chinese text vector of each Chinese text, wherein the Chinese text vector of each Chinese text is represented by a vector in the Chinese text representation vector space 211.

[0076] Wherein, after obtaining the English text vector of each English text from the English text representation vector space 201, the English text vector of each English text is mapped by the English text representation vector mapping layer 221 in the English-Chinese mapping layer 22 to obtain the shared representation vector of each English text represented in the shared vector representation space 23. Accordingly, after obtaining the Chinese text vector of each Chinese text from the Chinese text representation vector space 211, the Chinese text vector of each Chinese text is mapped by the Chinese text representation vector mapping layer 222 in the English-Chinese mapping layer 22 to obtain the shared representation vector of each Chinese text represented in the shared vector representation space 23.

[0077] After obtaining the shared representation vector of each training text, the shared representation vector of each training text is input into the SQL generation layer 24, and the SQL generation layer 24 finally outputs the SQL statement. In this way, in the training, the pre-training is first performed by using the rich English data with SQL annotation, and then only a small amount of Chinese data with SQL annotation is needed to fine-tune the pre-trained model, so that the text-to-SQL model under the Chinese data set can be assisted by the rich annotation data of the English data set by means of transfer learning.

[0078] In an embodiment, the model can be trained by using the English text in the training English text set and the corresponding SQL statement. This process will fine-tune the Bert model, train the English text representation vector mapping layer 221, and pre-train the SQL generation layer 24. The SQL generation layer 24 is used to convert Chinese text into SQL statements and convert English text into SQL statements.

[0079] Further, the Chinese text in the translated Chinese text set in the training English text set can be trained with the corresponding SQL statement label, so that the model can be trained by using the Chinese text in the translated Chinese text set and the original English text corresponding to the same SQL statement, to improve the accuracy of the model prediction.

[0080] In addition, the original Chinese text in the training text set and the corresponding SQL label can also be used to train the model, at this time, the Bert-base-chinese model will be fine-tuned, and the Chinese text representation vector mapping layer 222 will be trained, and the SQL generation layer 24 pre-trained by the training English text set will be fine-tuned.

[0081] After the target natural language model is trained, step S104 is performed.

[0082] In step S104, the user input text for operating the SQL database is obtained, and the user input text is taken as the target text. At this time, the target text can be English text or Chinese text.

[0083] Next, step S105 is performed. First, the text representation vector of the target text is obtained, and then the text representation vector of the target text is mapped into the Chinese-English mapping space to obtain the shared representation vector of the target text.

[0084] Specifically, if the target text is an English text, an English word vector of the target text is obtained, the English word vector of the target text is input into the first language representation model to obtain an English text vector of the target text, and then the English text vector of the target text is mapped into the Chinese-English mapping space to obtain a shared representation vector of the target text, wherein the English text vector of the target text is a text representation vector of the target text; if the target text is a Chinese text, a Chinese word vector of the target text is obtained, the Chinese word vector of the target text is input into the second language representation model to obtain a Chinese text vector of the target text, and then the Chinese text vector of the target text is mapped into the Chinese-English mapping space to obtain a shared representation vector of the target text, wherein the Chinese text vector of the target text is a text representation vector of the target text.

[0085] After obtaining the text representation vector of the target text, the text representation vector of the target text is mapped into the Chinese-English mapping space to obtain a shared representation vector of the target text, and the specific implementation manner can refer to the description of step S102.

[0086] After obtaining the shared representation vector of the target text, step S106 is performed.

[0087] In step S106, the shared representation vector of the target text is input into the target natural language model to obtain a target SQL statement corresponding to the target text.

[0088] Specifically, after obtaining the shared representation vector of the target text, the shared representation vector of the target text can be input into the SQL generation layer 24, and the output result of the SQL generation layer 24 is the target SQL statement.

[0089] After obtaining the target SQL statement, step S107 is performed.

[0090] In step S107, after obtaining the target SQL statement, the target SQL statement is executed to perform a corresponding operation on the SQL database. If the target SQL statement is a data query statement, a data query operation is performed on the SQL database; if the target SQL statement is a data deletion statement, a data deletion operation is performed on the SQL database; if the target SQL statement is a data addition statement, a data addition operation is performed on the SQL database; and if the target SQL statement is a data modification statement, a data modification operation is performed on the SQL database, which is not specifically limited in the specification.

[0091] The one or at least one technical solutions in the embodiments of the application have at least the following technical effects:

[0092] Based on the above technical scheme, in the training process, for each training text, the text representation vector of the training text is mapped into the English-Chinese mapping space to obtain a shared representation vector of the training text, and then the shared representation vector of each training text is used for model training to obtain a target natural language model. The above technical scheme makes the English text and the Chinese text both mapped into the English-Chinese mapping space to obtain the shared representation vector of the training text to generate the SQL statement. Compared with directly training the natural language model by using the Chinese text, since the English text does not have the problem of English-Chinese conversion when generating the SQL statement, the accuracy of the English text generating the SQL statement is higher, and the performance of the target natural language model obtained by training is stronger. In the SQL statement obtaining process, the Chinese target text in the target text set is mapped into the English-Chinese mapping space, and the shared representation vector obtained can also be used for the natural language model trained by using the English training text set, thereby improving the accuracy of the Chinese text converted into the SQL statement, and making the user operation of the database more convenient.

[0093] An operation method of a database is provided for the above embodiment, and an operation device of a database is also provided in the embodiments of the present application. Please refer to Figure 3 The device comprises:

[0094] A training data acquisition unit 301 is configured to acquire a training text set for operating an SQL database, wherein the training text set comprises a training Chinese text set and a training English text set.

[0095] A training text vector acquisition unit 302 is configured to map, for each training text in the training text set, a text representation vector of the training text into an English-Chinese mapping space to obtain a shared representation vector of the training text.

[0096] A model training unit 303 is configured to perform model training by using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model.

[0097] A target text acquisition unit 304 is configured to acquire a target text for operating the SQL database.

[0098] A target text vector acquisition unit 305 is configured to map a text representation vector of the target text into the English-Chinese mapping space to obtain a shared representation vector of the target text.

[0099] A statement acquisition unit 306 is configured to input the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text.

[0100] A database operation unit 307 is configured to operate the SQL database by using the target SQL statement.

[0101] In an optional implementation, the training text vector obtaining unit 302 is configured to, for each training text, if the training text is a Chinese text, obtain a Chinese text vector of the training text, and map the Chinese text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text; if the training text is an English text, obtain an English text vector of the training text, and map the English text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text.

[0102] In an optional implementation, the training text vector obtaining unit 302 is configured to, if the training text is an English text, obtain an English word vector of the training text, and input the English word vector of the training text into the first language representation model to obtain an English text vector of the training text.

[0103] In an optional implementation, the training text vector obtaining unit 302 is configured to, if the training text is a Chinese text, obtain a Chinese word vector of the training text, and input the Chinese word vector of the training text into the second language representation model to obtain a Chinese text vector of the training text.

[0104] In an optional implementation, the model training unit 303 is configured to perform model training by using the shared representation vector of each training text and a SQL label corresponding to the training text, to obtain the target natural language model.

[0105] In an optional implementation, the training data obtaining unit 301 is configured to obtain the set of training English texts, obtain a set of original Chinese texts, obtain a set of translated Chinese texts corresponding to part of the set of training English texts, count the set of translated Chinese texts and the set of original Chinese texts into the set of training Chinese texts, and obtain the set of training texts according to the set of training English texts and the set of training Chinese texts.

[0106] In an optional implementation, the target text vector acquisition unit 305 is configured to, if the target text is an English text, acquire an English word vector of the target text, input the English word vector of the target text into the first language representation model to obtain an English text vector of the target text, and then map the English text vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text, where the English text vector of the target text is a text representation vector of the target text; or if the target text is a Chinese text, acquire a Chinese word vector of the target text, input the Chinese word vector of the target text into the second language representation model to obtain a Chinese text vector of the target text, and then map the Chinese text vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text, where the Chinese text vector of the target text is a text representation vector of the target text.

[0107] With regard to the apparatus in the above-described embodiments, a specific manner in which each module performs operations has been described in detail in the embodiments of the method, and thus will not be described here in detail.

[0108] Figure 4 FIG. 8 is a block diagram of an electronic device 800 for an operation method of a database according to an example embodiment. The electronic device 800 can be, for example, a mobile phone, a computer, a digital broadcasting terminal, a message communication device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.

[0109] Referring to Figure 4 The electronic device 800 can include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0110] The processing component 802 generally controls the overall operations of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 can include one or more processors 820 to execute instructions to complete all or part of steps of the methods described above. In addition, the processing component 802 can include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0111] The memory 804 is configured to store various types of data to support the operation of the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or nonvolatile memory, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disc or optical disc.

[0112] The power supply component 806 supplies power for various components of the electronic device 800. The power supply component 806 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.

[0113] The multimedia component 808 includes a screen providing an interface for displaying on the electronic device 800 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes the touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and pressure related to the touching or sliding action. In some embodiments, the multimedia component 808 includes a front camera and / or a back camera. The front camera and / or the back camera can receive external multimedia data when the device 800 is in an operation mode, such as a shooting mode or a video mode. Each of the front camera and the back camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0114] The audio component 810 is configured to output and / or input an audio signal. For example, the audio component 810 includes a microphone (MIC) configured to receive an external audio signal when the electronic device 800 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting an audio signal.

[0115] The I / O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which can be a keypad, a click wheel, buttons, and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.

[0116] The sensor component 814 includes one or more sensors for providing status assessments for various aspects of the electronic device 800. For example, the sensor component 814 can detect an open / closed position of the device 800, relative positioning of components, such as a display and a keypad of the electronic device 800, a change in position of the electronic device 800 or a component of the electronic device 800, presence or absence of user contact with the electronic device 800, orientation or acceleration / deceleration / g-force and temperature of the electronic device 800. The sensor component 814 can include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.

[0117] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a corresponding communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an example embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an example embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) techniques, infrared data association (IrDA) techniques, ultra-wideband (UWB) techniques, Bluetooth (BT) techniques, and other techniques.

[0118] In an example embodiment, the electronic device 800 can be implemented using one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic elements, to perform the above-described methods.

[0119] In an example embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 804 including instructions, is also provided, which can be executed by the processor 820 of the electronic device 800 to perform the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.

[0120] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the application being indicated by the following claims.

[0121] It is to be understood that the application is not limited to the precise construction hereinafter described and as shown in the attached drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application.

[0122] The above description is intended to be illustrative and not restrictive. Many other modifications within the scope of the application will be apparent to those of skill in the art upon reviewing the above description. The scope of the application should, therefore, be determined not with reference to the above description, but instead with reference to the appended claims, along with their full scope of equivalents.

Claims

1. A method of operating a database, characterized by, The method comprises: obtaining a training text set for operating an SQL database, wherein the training text set comprises a training Chinese text set and a training English text set; mapping a text representation vector of each training text in the training text set into a Chinese-English mapping space to obtain a shared representation vector of the training text; training a model using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model; obtaining a target text for operating the SQL database; mapping a text representation vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text; inputting the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text; and operating the SQL database using the target SQL statement.

2. The operating method of claim 1, wherein, The method comprises: for each training text, if the training text is a Chinese text, obtaining a Chinese text vector of the training text and mapping the Chinese text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text; or if the training text is an English text, obtaining an English text vector of the training text and mapping the English text vector of the training text into the Chinese-English mapping space to obtain a shared representation vector of the training text.

3. The operating method of claim 2, wherein, The method comprises: if the training text is an English text, obtaining an English word vector of the training text, inputting the English word vector of the training text into a first language representation model to obtain an English text vector of the training text.

4. The operating method of claim 3, wherein, The method comprises: if the training text is a Chinese text, obtaining a Chinese word vector of the training text, inputting the Chinese word vector of the training text into a second language representation model to obtain a Chinese text vector of the training text.

5. The operating method of claim 4, wherein, The method comprises: training a model using the shared representation vector of each training text and a SQL label corresponding to the training text to obtain the target natural language model.

6. The operating method of claim 5, wherein, The method comprises: obtaining the training English text set; obtaining an original Chinese text set; obtaining a translated Chinese text set corresponding to part of the training English text set; adding the translated Chinese text set and the original Chinese text set to the training Chinese text set; obtaining the training text set according to the training English text set and the training Chinese text set.

7. The operating method of claim 6, wherein, The method comprises: If the target text is an English text, an English word vector of the target text is obtained, the English word vector of the target text is input into the first language representation model, an English text vector of the target text is obtained, and the English text vector of the target text is mapped into the Chinese-English mapping space to obtain a shared representation vector of the target text, wherein the English text vector of the target text is a text representation vector of the target text. If the target text is a Chinese text, a Chinese word vector of the target text is obtained, the Chinese word vector of the target text is input into the second language representation model, a Chinese text vector of the target text is obtained, and the Chinese text vector of the target text is mapped into the Chinese-English mapping space to obtain a shared representation vector of the target text, wherein the Chinese text vector of the target text is a text representation vector of the target text.

8. An apparatus for operating a database, characterized by The device comprises: a training data acquisition unit configured to acquire a training text set for operating an SQL database, wherein the training text set comprises a training Chinese text set and a training English text set; a training text vector acquisition unit configured to map a text representation vector of a training text into a Chinese-English mapping space to obtain a shared representation vector of the training text for each training text in the training text set; a model training unit configured to perform model training by using the shared representation vector of each training text to obtain a trained natural language model as a target natural language model; a target text acquisition unit configured to acquire a target text for operating an SQL database; a target text vector acquisition unit configured to map a text representation vector of the target text into the Chinese-English mapping space to obtain a shared representation vector of the target text; a sentence acquisition unit configured to input the shared representation vector of the target text into the target natural language model to obtain a target SQL statement corresponding to the target text; a database operation unit configured to operate the SQL database by using the target SQL statement.

9. An electronic device, comprising: The program is executed by the processor to implement the steps corresponding to the method of any one of claims 1-7.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the steps corresponding to the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Database operation method and device

    CN112783921A

  • Method for converting natural language into SQL (Structured Query Language) statement based on deep learning

    CN114880347A