Relationship-enhanced retrieval method, device, and readable medium based on graph database

Through the relationship-enhanced retrieval method based on graph database, the self-attention mechanism and encoder-decoder model are used to convert natural language into AQL query statements, solving the problem of user interaction between graph databases and improving query accuracy and user experience.

CN117194723BActive Publication Date: 2025-08-26XIAMEN MEIYA PICO INFORMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311065212.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-23
Publication Date
2025-08-26
Estimated Expiration
2043-08-23

AI Technical Summary

Technical Problem

The existing technology lacks the ability to automatically convert natural language to AQL query statements for graph databases, resulting in high difficulty in user interaction and poor experience.

Method used

A relationally enhanced search method based on graph database is adopted to generate word vector features through pre-training language models, and a deep relationship fusion feature is generated using the self-attention mechanism to build a Text2AQL model of the encoder-decoder, and AQL query statements are generated.

Benefits of technology

It reduces the difficulty of interaction between users and graph databases, and improves the execution accuracy and user experience of query statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117194723B_ABST
    Figure CN117194723B_ABST
Patent Text Reader

Abstract

The present invention discloses a relation-enhanced retrieval method, device and readable medium based on a graph database. The method obtains a natural language question and performs word segmentation processing to obtain a word sequence, and uses a pre-trained language model to generate word vector features of the words in the question, word vector features of table names and word vector features of column names; a graph database is constructed based on the word vector features of the table names and the word vector features of the column names, and a self-attention mechanism is used to generate deep relation fusion features based on the word vector features of the words in the question and the graph database; the word vector features of the words in the question, the word vector features of the table names, the word vector features of the column names and the deep relation fusion features are spliced ​​to obtain a joint feature vector, and the joint feature vector is input into a trained Text2AQL model to obtain a syntax tree. According to the syntax tree, an AQL query statement is obtained by using the abstract syntax description language specification mapping, which can reduce the difficulty of interaction between users and the graph database and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language analysis, and in particular to a relationship-enhanced retrieval method, device and readable medium based on a graph database. Background Art

[0002] A graph database is a database based on graph theory. A graph consists of nodes and edges, corresponding to the nodes and relationships in a graph database. Graph databases enable efficient querying of related data and are widely used in the big data era. User interaction with a graph database is achieved through a query language. For ordinary users unfamiliar with databases, writing query statements is challenging. Automatically converting natural language into database query language has become a research hotspot in recent years, leading to the emergence of Text2SQL technology. Text2SQL (Text to SQL) aims to directly convert user natural language into corresponding SQL statements to perform database query tasks. Early research on Text2SQL focused on rule-based template matching methods. With the development of deep learning technology, an encoder-decoder framework has been adopted to build end-to-end models, with the decoder generating query statements. Methods such as syntax trees and multi-task training have been introduced to improve model performance. Graph neural networks and reinforcement learning have been used to improve the accuracy of SQL statement execution.

[0003] Currently, Text2SQL technology lacks research on graph databases, which increases the difficulty of interaction between users and graph databases. In addition, although the AQL query language is similar to SQL, its syntax is different, so the Text2SQL model cannot be directly applied, resulting in a poor user experience. Summary of the Invention

[0004] In response to the technical problems mentioned above, the purpose of the embodiments of this application is to propose a relationship-enhanced retrieval method, device and readable medium based on a graph database to solve the technical problems mentioned in the above background technology section, which can automatically convert the user's natural language into AQL query statements to implement database query operations.

[0005] In a first aspect, the present invention provides a relationship-enhanced retrieval method based on a graph database, comprising the following steps:

[0006] Obtain natural language questions and perform word segmentation to obtain word sequences. Based on the word sequences, use the pre-trained language model to generate word vector features for the words in the questions, the table names, and the column names.

[0007] A graph database is constructed based on the word vector features of table names and column names. A self-attention mechanism is used to generate deep relational fusion features based on the word vector features of the words in the question and the graph database. The word vector features of the words in the question, the word vector features of the table names, the word vector features of the column names, and the deep relational fusion features are concatenated to obtain a joint feature vector.

[0008] Build and train an encoder-decoder-based Text2AQL model to obtain a trained Text2AQL model.

[0009] The joint feature vector is input into the trained Text2AQL model to obtain a syntax tree, and the AQL query statement is mapped according to the syntax tree using the Abstract Syntax Description Language specification.

[0010] As a preference, the word sequence is Q = q1, ..., q |Q| , the word vector features of the words in the question are The word vector feature of the table name is The word vector features of the column name are in d e represents the word vector dimension, |Q| represents the length of the word sequence of the question, |T| represents the length of the table name sequence, and |C| represents the length of the column name sequence; Represents the word vector of the i-th word in the question, The word vector representing the j-th table name, The word vector representing the k-th column name.

[0011] Preferably, each node in the graph database represents a table name or column name, and the edge between two nodes is represented by a relational feature vector obtained by fusing the word vector of the corresponding table name and the word vector of the column name. A self-attention mechanism is used to generate deep relational fusion features based on the relational feature vector with correlation between the word vectors of the words in the question and the words.

[0012] Preferably, the relation feature vector is expressed as:

[0013]

[0014] Among them, FC represents the fully connected layer, and the output scale is d e , and Represent the word vectors of the nodes at both ends of the edge.

[0015] Preferably, a self-attention mechanism is used to generate deep relational fusion features based on the word vectors of the words in the question and the relational feature vectors with correlation therewith, specifically including:

[0016] Calculate the deep relationship r between the word vector of the i-th word in the question and the relationship feature vector related to the i-th word i :

[0017]

[0018] Among them, Att represents the self-attention mechanism, concat represents vector concatenation, Represents the word vector of the i-th word in the question, Represents the relational feature vector related to the i-th word;

[0019] The deep relationship fusion feature is represented as E r ={r1,...,r |Q|}.

[0020] Preferably, the Text2AQL model includes an encoder and a decoder, the encoder includes a graph neural network model, and the decoder includes an AST-based decoder. The joint feature vector is input into the encoder to obtain the encoded feature X L :

[0021] X L =Encoder(X 0 );

[0022] Where L represents the number of encoder layers;

[0023] Input the encoded features into the decoder and decode to obtain the syntax tree z of the AQL sequence:

[0024] z=Decoder(X L ).

[0025] Preferably, in the Abstract Syntax Description Language specification, the basic paradigm of an AQL query statement is defined as: FORitem IN{table}(KEYWORDS{column}OP{value})*RETURN{column};

[0026] Among them, FOR item IN{table} and RETURN{column} are fixed sentence patterns, {table}, {column}, and {value} represent the table name, column name, and value in the graph database; (KEYWORDS{column}OP{value}) represents a keyword clause, OP represents aggregation operations, conditional judgments, and / or numerical operations, and * represents the nesting of multiple layers of keyword clauses; the syntax tree is constructed according to the abstract syntax description language specification.

[0027] In a second aspect, the present invention provides a relationship-enhanced retrieval device based on a graph database, comprising the following steps:

[0028] The word vector representation module is configured to obtain natural language questions and perform word segmentation processing to obtain word sequences. Based on the word sequences, the pre-trained language model is used to generate word vector features for the words in the question, the table name, and the column name.

[0029] The feature fusion module is configured to build a graph database based on the word vector features of the table names and the column names, generate deep relationship fusion features based on the word vector features of the words in the question and the graph database using a self-attention mechanism, and concatenate the word vector features of the words in the question, the word vector features of the table names, the word vector features of the column names, and the deep relationship fusion features to obtain a joint feature vector.

[0030] A model building module is configured to build and train an encoder-decoder-based Text2AQL model to obtain a trained Text2AQL model;

[0031] The parsing module is configured to input the joint feature vector into the trained Text2AQL model to obtain a syntax tree, and obtain an AQL query statement according to the syntax tree using the abstract syntax description language specification mapping.

[0032] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0033] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

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

[0035] (1) The relation-enhanced retrieval method based on graph database proposed in this invention designs a relation-enhanced Text2AQL model according to the characteristics of graph database, completes database query tasks through natural language, greatly reduces the difficulty of interaction between users and graph database, and improves the user experience.

[0036] (2) The relation-enhanced retrieval method based on graph database proposed in the present invention specifically designs an ASDL specification based on the ArangoDB query language AQL to generate an AST syntax tree. Under the guidance of the encoder-decoder framework, a Text2AQL model is constructed. The encoder encodes the input features, and then the decoder generates an AQL syntax tree. Finally, the AQL query statement is decoded according to the formulated ASDL specification.

[0037] (3) The relation-enhanced retrieval method based on graph database proposed in this invention takes into account the characteristics of graph database, uses the association information of node attributes to generate deep relation features, enhances the association between natural language question sequences and key information of the database through the self-attention mechanism, improves the ability of the Text2AQL model to capture association features, and helps to improve the execution accuracy of AQL query statements. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] Figure 1 is a diagram of an exemplary device architecture to which an embodiment of the present application may be applied;

[0040] Figure 2 A flowchart of a relationship-enhanced retrieval method based on a graph database according to an embodiment of the present application;

[0041] Figure 3 This is a structural diagram of the Text2AQL model of the relation-enhanced retrieval method based on a graph database according to an embodiment of the present application;

[0042] Figure 4 A schematic diagram of a relationship-enhanced retrieval device based on a graph database according to an embodiment of the present application;

[0043] Figure 5 It is a structural diagram of a computer device suitable for implementing the electronic device of the embodiment of the present application. DETAILED DESCRIPTION

[0044] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.

[0045] Figure 1 An exemplary device architecture 100 is shown to which a graph database-based relationship-enhanced retrieval method or a graph database-based relationship-enhanced retrieval device according to an embodiment of the present application can be applied.

[0046] like Figure 1As shown, the device architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0047] Users can use terminal devices 101, 102, 103 to interact with server 105 via network 104 to receive or send messages, etc. Various applications, such as data processing applications and file processing applications, can be installed on terminal devices 101, 102, 103.

[0048] Terminal devices 101, 102, and 103 can be hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices, including but not limited to smartphones, tablet computers, laptop computers, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or they can be implemented as a single software or software module. No specific limitations are given here.

[0049] The server 105 may be a server that provides various services, such as a background data processing server that processes files or data uploaded by the terminal devices 101, 102, and 103. The background data processing server may process the acquired files or data and generate processing results.

[0050] It should be noted that the relationship-enhanced retrieval method based on the graph database provided in the embodiment of the present application can be executed by the server 105 or by the terminal devices 101, 102, and 103. Accordingly, the relationship-enhanced retrieval device based on the graph database can be set in the server 105 or in the terminal devices 101, 102, and 103.

[0051] It should be understood that Figure 1 The number of terminal devices, networks, and servers in the above description is merely illustrative. Any number of terminal devices, networks, and servers may be provided as needed. If the processed data does not need to be acquired remotely, the above-described apparatus architecture may not include a network, but only require servers or terminal devices.

[0052] Figure 2 The embodiment of the present application provides a relationship-enhanced retrieval method based on a graph database, comprising the following steps:

[0053] S1: Obtain a natural language question and perform word segmentation to obtain a word sequence. Based on the word sequence, a pre-trained language model is used to generate word vector features for the words in the question, the table name, and the column name.

[0054] In a specific embodiment, the word sequence is Q=q1,...,q |Q| , the word vector features of the words in the question are The word vector feature of the table name is The word vector features of the column name are in d e represents the word vector dimension, |Q| represents the length of the word sequence of the question, |T| represents the length of the table name sequence, and |C| represents the length of the column name sequence; Represents the word vector of the i-th word in the question, The word vector representing the j-th table name, The word vector representing the k-th column name.

[0055] Specifically, in the text preprocessing stage, first, the natural language question raised by the user is segmented and the text content is converted into a word sequence Q = q1, ..., q |Q| Then, the pre-trained language model PLM is used to represent the words, table names, and column names in the question as feature vectors, generating word vector features for the words in the question, word vector features for the table names, and word vector features for the column names.

[0056] S2, builds a graph database based on the word vector features of the table name and the word vector features of the column name, and uses the self-attention mechanism to generate deep relationship fusion features based on the word vector features of the words in the question and the graph database. The word vector features of the words in the question, the word vector features of the table name, the word vector features of the column name and the deep relationship fusion features are spliced ​​to obtain a joint feature vector.

[0057] In a specific embodiment, each node in the graph database represents a table name or column name, and the edge between two nodes is represented by a relational feature vector obtained by fusing the word vector of the corresponding table name and the word vector of the column name. A self-attention mechanism is used to generate deep relational fusion features based on the relational feature vector with correlation between the word vectors of the words in the question and the words.

[0058] Specifically, in order to explore the deep correlation between natural language sequences and graph database information, the embodiments of the present application design deep relationship fusion features based on the self-attention mechanism to help the text2AQL model capture deep correlations and output more accurate AQL query statements.

[0059] In a graph database, each node represents a table name or column name, and the edge represents the relationship between tables and columns. The edge relationship feature vector is represented by fusing the word vectors of the two nodes. node The word vector for the table or column name. This requires traversing each table to calculate the pairwise relationship features between the table name and all column names in that table.

[0060] In a specific embodiment, the relationship feature vector is expressed as:

[0061]

[0062] Among them, FC represents the fully connected layer, and the output scale is d e , and Represent the word vectors of the nodes at both ends of the edge.

[0063] Specifically, in order to mine the association information between question sequences and graph databases, the self-attention mechanism is used to generate deep relational fusion features.

[0064] In a specific embodiment, a self-attention mechanism is used to generate deep relational fusion features based on the word vectors of the words in the question and the relational feature vectors with correlation therewith, specifically including:

[0065] Calculate the deep relationship r between the word vector of the i-th word in the question and the relationship feature vector related to the i-th word i :

[0066]

[0067] Among them, Att represents the self-attention mechanism, concat represents vector concatenation, Represents the word vector of the i-th word in the question, Represents the relational feature vector related to the i-th word;

[0068] The deep relationship fusion feature is represented as E r ={r1,...,r |Q|}.

[0069] Specifically, the cosine similarity is used to measure the correlation between vectors. Two vectors with a similarity greater than a set threshold τ are determined to be related vectors. Only the top n related vectors with the highest similarity are taken as relationship feature vectors, where n is the number of self-defined relationship feature vectors. Q , word vector feature E of table name T , word vector feature E of column name C and deep relation fusion feature E r Concatenate to form a joint feature vector Here, N = 2 × |Q| + |T| + |C|. The embodiments of this application utilize the characteristics of graph databases, combine attribute relationships in the graph with question sequences to mine deep associations, and generate deep relationship fusion features based on the self-attention mechanism. This can improve the query accuracy of sentences generated by the Text2AQL model and address the low prediction accuracy of the FILTER clause.

[0070] S3: Build and train an encoder-decoder-based Text2AQL model to obtain a trained Text2AQL model.

[0071] In a specific embodiment, the Text2AQL model includes an encoder and a decoder, the encoder includes a graph neural network model, and the decoder includes an AST-based decoder.

[0072] Specifically, the Text2AQL model uses the cross entropy loss function during training:

[0073]

[0074] Among them, N represents the total number of training samples, y i and z i They represent the true label and decoder predicted label of the i-th sample respectively.

[0075] S4: Input the joint feature vector into the trained Text2AQL model to obtain a syntax tree, and then map the syntax tree using the Abstract Syntax Description Language specification to obtain an AQL query statement.

[0076] In a specific embodiment, the joint feature vector is input into the encoder to obtain the encoded feature X L :

[0077] X L =Encoder(X 0 );

[0078] Where L represents the number of encoder layers;

[0079] Input the encoded features into the decoder and decode to obtain the syntax tree z of the AQL sequence:

[0080] z=Decoder(X L ).

[0081] In a specific embodiment, in the Abstract Syntax Description Language specification, the basic paradigm of an AQL query statement is defined as: FOR item IN{table}(KEYWORDS{column}OP{value})*RETURN{column};

[0082] Among them, FOR item IN{table} and RETURN{column} are fixed sentence patterns, {table}, {column}, and {value} represent the table name, column name, and value in the graph database; (KEYWORDS{column}OP{value}) represents a keyword clause, OP represents aggregation operations, conditional judgments, and / or numerical operations, and * represents the nesting of multiple layers of keyword clauses; the syntax tree is constructed according to the abstract syntax description language specification.

[0083] Specifically, the Text2AQL model is built on an encoder-decoder framework. It uses any graph neural network model (GCN, GAT, etc.) as the encoder to encode the input joint feature vector to obtain encoded features. It then uses any AST-based decoder to decode the encoded features to obtain a syntax tree for the AQL sequence. This is then decoded according to the ASDL syntax rules to output the AQL query statement. The ASDL specification is developed based on the AQL syntax rules, and the AQL language description is further converted into a syntax tree to facilitate semantic parsing.

[0084] In order to guide the Text2AQL model to generate graph database standard syntax, the embodiment of the present application designs an ASDL (abstract syntax description language) specification based on the AQL syntax rules, that is, the abstract syntax description language specification. Every AQL query statement in the graph database meets this specification. As shown in Table 1, the basic components of an AQL statement are composed of four parts: keywords, aggregation operations, conditional judgments, and numerical operations. Combining the basic components of the statement with the table name, column name, and numerical value in the graph database can be combined into a complete query statement. The graph database schema includes table T and column C. All table names in the database are represented as a sequence T = {t1,...,t T}, the column names of all tables are represented as a sequence C = {c1,...,c C}. Construct a syntax tree AST (abstract syntax tree) according to the abstract syntax description language specification. Since the abstract syntax description language specification is a basic paradigm constructed according to the grammatical rules of AQL, it is convenient to map the decoding results of the model and construct AQL statements. Based on the basic specifications of the AQL query statement, KEYWORD and OP are obtained from the syntax tree obtained according to the decoding results of the model, and are replaced with the basic components of the AQL statement in Table 1 to form the final query statement. OP can represent aggregation operations, conditional judgments, and numerical operations. In one example, OP can select conditional judgments, such as: FILTER number>10.

[0085] Table 1 Basic components of AQL statements

[0086]

[0087] As an example, assume there's a database that records student information, with a table named "students" and columns named "name" and "age." Enter the query "Names of students under 12 years old." The trained Text2AQL model calculates the syntax tree (AST), which parses the table name value "student" in FOR item IN{table}, the column name value "name" in RETURN{column}, and the value of a keyword clause KEYWORDS{column}OP{value}, where KEYWORDS is FILTER, the column name is "age," OP is <, and value is 12. This allows us to construct the following AQL query:

[0088] FOR item IN students FILTER item.age<12RETURN item.name.

[0089] The above steps S1-S4 do not represent the order of the steps, but are only step symbols.

[0090] Further references Figure 4 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a relationship-enhanced retrieval device based on a graph database. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0091] The embodiment of the present application provides a relationship-enhanced retrieval device based on a graph database, comprising the following steps:

[0092] The word vector representation module 1 is configured to obtain a natural language question, perform word segmentation processing, obtain a word sequence, and use a pre-trained language model to generate word vector features for the words in the question, the table name, and the column name based on the word sequence;

[0093] Feature fusion module 2 is configured to build a graph database based on the word vector features of the table name and the column name, generate deep relationship fusion features based on the word vector features of the words in the question and the graph database using a self-attention mechanism, and concatenate the word vector features of the words in the question, the word vector features of the table name, the word vector features of the column name, and the deep relationship fusion features to obtain a joint feature vector;

[0094] A model building module 3 is configured to build and train an encoder-decoder-based Text2AQL model to obtain a trained Text2AQL model;

[0095] The parsing module 4 is configured to input the joint feature vector into the trained Text2AQL model to obtain a syntax tree, and obtain an AQL query statement based on the syntax tree using the Abstract Syntax Description Language specification mapping.

[0096] Reference below Figure 5 , which shows an electronic device (eg Figure 1 A structural diagram of a computer device 500 (a server or terminal device as shown). Figure 5 The electronic device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.

[0097] like Figure 5 As shown, the computer device 500 includes a central processing unit (CPU) 501 and a graphics processing unit (GPU) 502, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 503 or the program loaded from the storage part 509 to the random access memory (RAM) 504. Various programs and data required for the operation of the device 500 are also stored in the RAM 504. The CPU 501, GPU 502, ROM 503 and RAM 504 are connected to each other via a bus 505. An input / output (I / O) interface 506 is also connected to the bus 505.

[0098] The following components are connected to the I / O interface 506: an input section 507 including a keyboard, a mouse, etc.; an output section 508 including a display such as a liquid crystal display (LCD), a speaker, etc.; a storage section 509 including a hard disk, etc.; and a communication section 510 including a network interface card such as a LAN card, a modem, etc. The communication section 510 performs communication processing via a network such as the Internet. A drive 511 may also be connected to the I / O interface 506 as needed. A removable medium 512, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 511 as needed, so that a computer program read therefrom can be installed into the storage section 509 as needed.

[0099] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 510, and / or installed from a removable medium 512. When the computer program is executed by the central processing unit (CPU) 501 and the graphics processing unit (GPU) 502, the above-mentioned functions defined in the method of the present application are performed.

[0100] It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable medium, or any combination thereof. Computer-readable media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor devices, apparatuses, or components, or any combination thereof. More specific examples of computer-readable media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution device, apparatus, or component. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution apparatus, device, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical cable, RF, or any suitable combination thereof.

[0101] Computer program code for performing the operations of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, 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 can be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0102] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of code, and the module, program segment or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based device that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0103] The modules involved in the embodiments described in this application may be implemented in software or hardware, and may also be set in a processor.

[0104] As another aspect, the present application further provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a natural language question and performs word segmentation processing to obtain a word sequence, and uses a pre-trained language model to generate word vector features of the words in the question, word vector features of the table name, and word vector features of the column name based on the word sequence; constructs a graph database based on the word vector features of the table name and the word vector features of the column name, and uses a self-attention mechanism to generate deep relationship fusion features based on the word vector features of the words in the question and the graph database, and splices the word vector features of the words in the question, the word vector features of the table name, the word vector features of the column name, and the deep relationship fusion features to obtain a joint feature vector; constructs and trains a Text2AQL model based on an encoder-decoder to obtain a trained Text2AQL model; inputs the joint feature vector into the trained Text2AQL model to obtain a syntax tree, and uses the abstract syntax description language specification mapping based on the syntax tree to obtain an AQL query statement.

[0105] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A relation-enhanced retrieval method based on a graph database, characterized in that: The following steps are involved: Obtain a natural language question and perform word segmentation processing to obtain a word sequence. Based on the word sequence, a pre-trained language model is used to generate word vector features for the words in the question, word vector features for table names, and word vector features for column names. A graph database is constructed based on the word vector features of the table name and the column name, and a deep relationship fusion feature is generated using a self-attention mechanism based on the word vector features of the words in the question and the graph database. The word vector features of the words in the question, the word vector features of the table name, the word vector features of the column name, and the deep relationship fusion feature are concatenated to obtain a joint feature vector; Construct and train a Text2AQL model based on an encoder-decoder to obtain a trained Text2AQL model, wherein the Text2AQL model includes an encoder and a decoder, wherein the encoder includes a graph neural network model and the decoder includes an AST-based decoder. Input the joint feature vector into the encoder to obtain the encoded feature X L : X L =Encoder(X 0 ); Where L represents the number of encoder layers; The encoding feature is input into the decoder, and the syntax tree z of the AQL sequence is obtained by decoding: z=Decoder(X L ); The joint feature vector is input into a trained Text2AQL model to obtain a syntax tree, and an AQL query statement is obtained according to the syntax tree using the Abstract Syntax Description Language specification mapping.

2. The relationship-enhanced retrieval method based on a graph database according to claim 1, characterized in that: The word sequence is Q=q1,...,q |Q| , the word vector features of the words in the question are The word vector feature of the table name is The word vector feature of the column name is in d e represents the word vector dimension, |Q| represents the length of the word sequence of the question, |T| represents the length of the table name sequence, and |C| represents the length of the column name sequence; Represents the word vector of the i-th word in the question, The word vector representing the j-th table name, The word vector representing the k-th column name.

3. The relationship-enhanced retrieval method based on a graph database according to claim 2, characterized in that: Each node in the graph database represents a table name or column name, and the edge between two nodes is represented by a relational feature vector obtained by fusing the word vectors of the corresponding table name and the word vectors of the column name. A self-attention mechanism is used to generate deep relational fusion features based on the relational feature vectors with correlation between the word vectors of the words in the question and the words.

4. The relationship-enhanced retrieval method based on a graph database according to claim 3, characterized in that: The relationship feature vector is expressed as: Among them, FC represents the fully connected layer, and the output scale is d e , and Represent the word vectors of the nodes at both ends of the edge.

5. The relationship-enhanced retrieval method based on a graph database according to claim 3, characterized in that: The method of generating a deep relational fusion feature using a self-attention mechanism based on the word vectors of the words in the question and the relational feature vectors having correlation therewith specifically includes: Calculate the deep relationship r between the word vector of the i-th word in the question and the relationship feature vector related to the i-th word i : Among them, Att represents the self-attention mechanism, concat represents vector concatenation, Represents the word vector of the i-th word in the question, Represents the relational feature vector related to the i-th word; The deep relationship fusion feature is represented as E r ={r1,...,r |Q| }.

6. The relationship-enhanced retrieval method based on a graph database according to claim 1, characterized in that: In the Abstract Syntax Description Language specification, the basic paradigm of the AQL query statement is defined as: FOR item IN{table}(KEYWORDS{column}OP{value})*RETURN{column}; Among them, FOR item IN{table} and RETURN{column} are fixed sentence patterns, {table}, {column}, {value} represent the table name, column name and value in the graph database; (KEYWORDS{column}OP{value}) represents a keyword clause, OP represents aggregation operation, conditional judgment and / or numerical operation, and * represents the nesting of multiple layers of keyword clauses; a syntax tree is constructed according to the abstract syntax description language specification.

7. A relation-enhanced retrieval device based on a graph database, characterized in that: The following steps are involved: A word vector representation module is configured to obtain a natural language question, perform word segmentation processing, obtain a word sequence, and generate word vector features for the words in the question, the table name, and the column name using a pre-trained language model based on the word sequence; a feature fusion module configured to construct a graph database based on the word vector features of the table name and the word vector features of the column name, generate deep relationship fusion features based on the word vector features of the words in the question and the graph database using a self-attention mechanism, and concatenate the word vector features of the words in the question, the word vector features of the table name, the word vector features of the column name, and the deep relationship fusion features to obtain a joint feature vector; The model construction module is configured to construct and train a Text2AQL model based on an encoder-decoder to obtain a trained Text2AQL model, wherein the Text2AQL model includes an encoder and a decoder, wherein the encoder includes a graph neural network model and the decoder includes an AST-based decoder, and the joint feature vector is input into the encoder to obtain the encoded feature X. L : X L =Encoder(X 0 ); Where L represents the number of encoder layers; The encoding feature is input into the decoder, and the syntax tree z of the AQL sequence is obtained by decoding: z=Decoder(X L ); The parsing module is configured to input the joint feature vector into a trained Text2AQL model to obtain a syntax tree, and obtain an AQL query statement according to the syntax tree using an abstract syntax description language specification mapping.

8. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Intelligent question and answer-based Chinese oral training method and system for foreigners

    CN110083690A

  • Medical query method and apparatus based on graph neural network, and computer device and storage medium

    WO2021213160A1