A method, device, equipment and readable medium for obtaining word vector representation
By constructing a word dependency graph and training it in a directed graph neural network, the problem of word vector representation in directed graphs that cannot be applied to existing technologies is solved, thus improving the word vector representation and computation speed of directed graphs.
Patent Information
- Application Number
- CN202010962795.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-09-14
AI Technical Summary
Existing graph algorithms are not suitable for embedding representations of directed graph nodes, and the GCN model requires recalculating the entire graph when a new node is added, resulting in slow computation speed.
A word dependency graph is constructed and input into a graph neural network model suitable for directed graphs. The model is trained by the in-chain and out-chain embedding representations of the target node, the feature vector representations of the out-chain and in-chain neighbor nodes, and the feature vector representations of the out-chain and in-chain neighbor nodes, resulting in a word vector graph structure model for graph embedding processing.
It implements word vector representation for directed graphs, improves computation speed, and expands the applicability of graph algorithms, applicable to embedding representations of both undirected and directed graphs.
Smart Images

Figure CN112069822B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and readable medium for obtaining word vector representation. Background Art
[0002] With the rapid development of the Internet era, data storage has become more convenient and faster, and graph algorithms have also been further developed. The graph structure itself has associations, among which the links that define the data structure represent the relationship between the linked entities.
[0003] However, the application scope of some graph algorithms in the prior art has certain limitations. For example, the graphsage model in the prior art is for isotropic network structures and is only applicable to the embedding representation of undirected graph nodes, but cannot be applied to the embedding representation of directed graph nodes.
[0004] For the GCN (Graph Convolutional Network) model, when a new node enters the graph, all the nodes in the entire graph need to be recalculated, which requires the calculation of all quantifiers, resulting in slow calculation speed. Summary of the invention
[0005] In order to overcome at least the technical problems raised by the background technology, the present application provides a method and device for obtaining word vector representation.
[0006] In a first aspect, the present application provides a method for obtaining a word vector representation, the method comprising:
[0007] Construct a word dependency graph corresponding to the corpus;
[0008] Inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, and obtaining a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node;
[0009] The word vector graph structure model is used to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph.
[0010] Optionally, the step of inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training to obtain a word vector graph structure model includes:
[0011] Extracting entity features of the word dependency graph and edge features between entities;
[0012] The entity features of the word dependency graph and the edge features between entities are input into the graph neural network model applicable to the directed graph for training to obtain the word vector graph structure model.
[0013] Optionally, before constructing the embedding representation of the in-and-out links of the target node of the graph neural network model, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-link neighbor nodes, the acquisition method further includes:
[0014] Initialize the target node of the graph neural network model and obtain the embedding representation of the in-and-out links of the target node;
[0015] Get the neighbor nodes of the target node;
[0016] Performing vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain feature vector representation of the out-link neighbor nodes;
[0017] A vector aggregation operation is performed on the in-link neighbor nodes of the target node's neighbor nodes to obtain a feature vector representation of the in-link neighbor nodes.
[0018] Optionally, before performing a vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the out-link neighbor nodes; and performing a vector aggregation operation on the in-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the in-link neighbor nodes, the acquisition method further includes:
[0019] Determine the sampling ratio according to the ratio of outbound nodes to inbound nodes in the graph neural network;
[0020] The neighbor nodes of the target node are sampled according to the sampling ratio to obtain out-link neighbor nodes and in-link neighbor nodes.
[0021] Optionally, the using the word vector graph structure model to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph includes:
[0022] Extracting features of neighboring words of the target word in the word dependency graph to obtain graph features;
[0023] The graph features are aggregated to determine a word vector representation of each word in the word dependency graph.
[0024] Optionally, aggregating the graph features to determine the word vector representation of each word in the word dependency graph includes:
[0025] Get the edge weight between the target word and its neighbor words;
[0026] The vector representations of the neighbor nodes of the word vector graph structure model are weighted using the edge weights between the target word and the neighbor words of the target word.
[0027] In a second aspect, the present application provides a device for obtaining a word vector representation, comprising:
[0028] The construction module is used to construct the word dependency graph corresponding to the corpus;
[0029] A training module is used to input the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, so as to obtain a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node;
[0030] The word vector determination module is used to use the word vector graph structure model to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph.
[0031] Optionally, the training module is used to perform the following operations:
[0032] Extracting entity features of the word dependency graph and edge features between entities;
[0033] The entity features of the word dependency graph and the edge features between entities are input into the graph neural network model applicable to the directed graph for training to obtain the word vector graph structure model.
[0034] In a third aspect, the present application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and wherein the processor implements the steps of any one of the acquisition methods described in the first aspect when executing the computer program.
[0035] In a fourth aspect, the present application provides a computer-readable medium having a non-volatile program code executable by a processor, characterized in that the program code enables the processor to execute any acquisition method of the first aspect above.
[0036] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0037] The present invention utilizes a word vector graph structure model applicable to a directed graph to perform graph embedding processing on a word dependency graph to determine the word vector representation of each word in the word dependency graph. Compared with the graph structure model in the prior art, the present invention can not only apply the word vector graph structure model to an undirected graph to obtain the word vector representation of the undirected graph, but also apply it to a directed graph to obtain the word vector representation of the directed graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1 A schematic diagram of a hardware environment for a method for obtaining word vector representation according to an embodiment of the present application;
[0041] Figure 2 A flowchart of a method for obtaining a word vector representation provided in an embodiment of the present application;
[0042] Figure 3 A schematic diagram of the structure of a device for acquiring word vector representation provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0044] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0045] Optionally, in the embodiment of the present application, the above-mentioned method for obtaining word vector representation can be applied to Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1As shown, the server 103 is connected to the terminal 101 via a network, and can be used to provide services for the terminal or a client installed on the terminal. A database 105 can be set on the server or independently of the server to provide data storage services for the server 103. The above-mentioned network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 includes but is not limited to a robot.
[0046] A method for obtaining a word vector representation in an embodiment of the present application can be executed by the server 103, or can be executed jointly by the server 103 and the terminal 101, such as Figure 2 As shown, the acquisition method may include the following steps:
[0047] S202: construct a word dependency graph corresponding to the corpus;
[0048] S204: Inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, and obtaining a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node;
[0049] S206: Perform graph embedding processing on the word dependency graph using the word vector graph structure model to determine the word vector representation of each word in the word dependency graph.
[0050] Compared with the prior art, the method for obtaining word vector representation in this embodiment constructs the embedded representation of the in-and-out links of the target node of the graph neural network model, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-link neighbor nodes. The resulting graph neural network model is not only applicable to the embedded representation of undirected graphs, but also to the embedded representation of directed graphs. Therefore, the word vector graph structure model obtained after training is also applicable to directed graphs, and the word vector representation of each word in the word vector graph of the directed graph can be determined.
[0051] It should be noted that the graph neural network model in this embodiment can be a graphsage model, or it can be other graph neural network models that can utilize steps S202-S206 to construct a graph neural network model suitable for directed graphs.
[0052] Optionally, in S202, the word segmentation results of the natural language of the corpus are used as nodes, and the words with dependency relationships are used as edges to construct a word dependency graph corresponding to the corpus;
[0053] The natural language characters or words of the corpus are used as nodes, and the words with dependency relationships are used as edges to construct a word dependency graph corresponding to the corpus, including:
[0054] S21: segmenting the natural language sentences in the corpus to obtain segmented characters or words;
[0055] S22: Taking the word segmentation results of the natural language of the corpus as nodes and the words with dependency relationships as edges, the syntactic dependency relationship of the words or words after word segmentation is analyzed to obtain a weighted directed dependency graph; specifically: calculating the PMI of each word or word after word segmentation to obtain the dependency syntactic structure of each word or word, and obtaining the weighted directed dependency graph according to the dependency syntactic structure of each word or word;
[0056] S23: Construct the word dependency graph according to the weighted directed dependency graph.
[0057] In this embodiment, the analysis of the syntactic dependency relationship of the word or phrase after word segmentation is mainly to reveal its syntactic structure through the dependency relationship between the components in the language unit of the sentence. For example, the dependency syntactic dependency analysis identifies the grammatical components such as "subject, predicate, object", "attributive, adverbial, complement" in the sentence, and analyzes the relationship between the components. In general, the dependency syntactic analysis marks the relationship between words or phrases (for example: the 15 types of relationship in Table 1) and the meaning of the relationship type;
[0058] Table 1
[0059] Relationship Type Tag Description Example Subject-Predicate Relationship SBV subject-verb I gave her a bunch of flowers (I <-- gave) Verb-Object Relationship VOB direct object, verb-object I gave her a bunch of flowers (gave --> flowers) Indirect Object Relationship IOB indirect object, indirect-object I gave her a bunch of flowers (gave --> her) Fronted Object FOB fronting-object He reads all kinds of books (books <-- reads) Double Object DBL double He invited me to dinner (invited --> me) Attribute-Head Relationship ATT attribute red apple (red <-- apple) Adverbial-Head Structure ADV adverbial very beautiful (very <-- beautiful) Verb-Complement Structure CMP complement finished the homework (did --> finished) Coordinate Relationship COO coordinate mountains and seas (mountains --> seas) Preposition-Object Relationship POB preposition-object within the trade area (within --> area) Left Adjunct Relationship LAD left adjunct mountains and seas (and <-- seas) Right Adjunct Relationship RAD right adjunct children (child --> ren) Independent Structure IS independent structure Two simple sentences are structurally independent of each other Punctuation WP punctuation 。 Core Relationship HED head Refers to the core of the entire sentence
[0060] From the above description, each word can be regarded as a node in the graph neural network, and the dependency relationship is the edge between the nodes. The edge weight calculation method uses pointwise mutual information (PMI, Pointwise Mutual Information, which describes the probability of two entities appearing together). The specific calculation formula is as follows:
[0061]
[0062] In the above formula, PMI(w i , w j ) represents the mutual information between word i and word j; i, j represents a node in the network, i.e., a word, where p(w i ) represents the proportion of word i in the total number of words in all texts, p(w j ) represents the proportion of word j in the total number of words in all texts; p(w i , w j ) represents the ratio of the dependency relationship between two words in the text. The direction of the edge in the graph can be confirmed based on the dependency type.
[0063] Optionally, in step 204, inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training to obtain a word vector graph structure model includes:
[0064] Extracting entity features of the word dependency graph and edge features between entities; wherein the entity features may include target word features of the word dependency graph and features of neighboring words of the target word;
[0065] Inputting entity features of the word dependency graph nodes and edge features between entities into the graph neural network model applicable to the directed graph for training, thereby obtaining the word vector graph structure model;
[0066] By inputting the node features and edge features of the extracted word dependency graph into the graph neural network model applicable to directed graphs, the obtained word vector graph structure model can also be applicable to directed graphs.
[0067] Optionally, before constructing the embedding representation of the in-and-out links of the target node of the graph neural network model, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-link neighbor nodes, the acquisition method further includes:
[0068] Initialize the in-and-out links of the target node of the graph neural network model to obtain the embedded representation of the in-and-out links of the target node;
[0069] Get the neighbor nodes of the target node;
[0070] Performing vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain feature vector representation of the out-link neighbor nodes;
[0071] Performing vector aggregation operation on the in-chain neighbor nodes of the target node's neighbor nodes to obtain feature vector representations of the in-chain neighbor nodes;
[0072] Through the above method, a graph neural network model suitable for directed graphs can be constructed by using the embedded representation of the target node's in- and out-links, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-link neighbor nodes.
[0073] Optionally, before performing a vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the out-link neighbor nodes; and performing a vector aggregation operation on the in-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the in-link neighbor nodes, the acquisition method further includes:
[0074] Determine the sampling ratio according to the ratio of outbound nodes to inbound nodes in the graph neural network;
[0075] Sampling neighbor nodes of the target node according to the sampling ratio to obtain out-link neighbor nodes and in-link neighbor nodes;
[0076] By using the above method, the chain neighbor nodes and the in-chain neighbor nodes obtained according to the sampling ratio reduce the calculation speed, making the calculation faster.
[0077] Optionally, the using the word vector graph structure model to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph includes:
[0078] Extracting features of neighboring words of the target word in the word dependency graph to obtain graph features;
[0079] Aggregating the graph features to determine a word vector representation of each word in the word dependency graph;
[0080] Through the above method, if a new word appears in the vocabulary, the word vector representation of the new word can be directly generated based on the calculated vector representation of the known neighbor words. It is unnecessary to calculate the full range of words in the word dependency graph, which improves the speed of calculating the word vector representation.
[0081] Optionally, aggregating the graph features to determine the word vector representation of each word in the word dependency graph includes:
[0082] Get the edge weight between the target word and its neighbor words;
[0083] The vector representations of the neighbor nodes of the word vector graph structure model are weighted using the edge weights between the target word and the neighbor words of the target word.
[0084] Optionally, a maximum pooling method is used to aggregate the graph features to determine the word vector representation of each word in the word dependency graph, including:
[0085] Set the parameter k to the number of aggregations of the graph neural network of the word vector graph structure model;
[0086] The edge weights between the target word i and the neighbor word j are weighted to the kth aggregation calculation to the vector representation of the neighbor word j, and the pooling operation is performed to obtain the vector representation of the neighbor word j of the target word i;
[0087]
[0088] Performing a nonlinear transformation on the vector representation of the neighbor word j of the target word i;
[0089]
[0090] Perform a maximum pooling operation to obtain the vector representation of the randomly selected neighboring words of the target word i;
[0091]
[0092] The vector representation of the randomly selected neighboring words of the target word i is concatenated with the vector representation of the target word i calculated by the k-1th aggregation to obtain a concatenation result;
[0093]
[0094] Performing a nonlinear transformation on the concatenation result to obtain a word vector representation of the k-th layer of the target word i;
[0095]
[0096] in, represents the vector representation of the neighboring word j calculated by the kth aggregation; l ji′ represents the weight of the edge between the target word i and the neighboring word j. If the target word i is not a direct neighbor of the neighboring word j, it is the edge weight between the target word i and the neighbor of the neighboring word j. k+1 represents the penalty for the degree of the neighboring word j. N(i) represents the set of nodes sampled from the neighboring nodes of the target word i.
[0097] σ() is a nonlinear transformation function; Represents the vector representation of the randomly selected neighbor nodes of the target word i after aggregation; Calculate the vector representation of the target word i for the k-1th aggregation;
[0098] W k represents the weight matrix; Calculate the vector representation of the target word i for the kth aggregation.
[0099] Optionally, aggregating the spectral features using a mean aggregation function to determine the word vector representation of each word in the word dependency graph includes:
[0100] Set the parameter k to the number of aggregations of the graph neural network of the word vector graph structure model;
[0101] The weight of the edge between the target word i and the neighbor word j is weighted to the embedding of the neighbor word j in the k-1th aggregation calculation to obtain the weighted result;
[0102]
[0103] Performing a union operation on the weighted result and the vector representation of the target word i calculated for the k-1th aggregation to obtain a union result;
[0104]
[0105] Performing a mean operation on the union result and the vector representation of the target word i calculated by the k-1th aggregation to obtain a mean result;
[0106]
[0107] Performing a nonlinear transformation on the weight matrix of the target word i and the mean result to obtain a word vector representation of the k-th layer of the target word i;
[0108]
[0109] in, represents the vector representation of the target word i after the k-th aggregation calculation; W represents the weight matrix; σ() is a nonlinear transformation function. Calculate the vector representation of the target word i for the k-1th aggregation; Represents the vector representation of the neighbor word j calculated by the k-1th aggregation;
[0110] l ji′ represents the weight of the edge between the target word i and the neighbor connection j. If the target word i is not the direct neighbor of the neighbor connection j, it is the edge weight of the target word i and the neighbor of the neighbor connection j. k+1 represents the penalty for the degree of the neighbor connection j. N(i) represents the set of neighbor connections sampled from the neighbor connections of the target word i.
[0111] According to another aspect of the embodiment of the present application, Figure 3 As shown, a device for obtaining word vector representation is provided, including:
[0112] A construction module 302 is used to construct a word dependency graph corresponding to the corpus;
[0113] The training module 304 is used to input the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, so as to obtain a word vector graph structure model; wherein the graph neural network model applicable to the directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node;
[0114] The word vector determination module 306 is used to perform graph embedding processing on the word dependency graph using the word vector graph structure model to determine the word vector representation of each word in the word dependency graph.
[0115] Optionally, the training module 304 is used to perform the following operations:
[0116] Extracting entity features of the word dependency graph and edge features between entities;
[0117] The entity features of the word dependency graph and the edge features between entities are input into the graph neural network model applicable to the directed graph for training to obtain the word vector graph structure model.
[0118] It should be noted that the construction module 302 in this embodiment can be used to execute step S202 in the embodiment of the present application, the robot control module 304 in this embodiment can be used to execute step S204 in the embodiment of the present application, and the determination module 306 in this embodiment can be used to execute step S206 in the embodiment of the present application.
[0119] Optionally, the acquisition device further includes:
[0120] The initialization module is used to initialize the target node of the graph neural network model and obtain the embedding representation of the in-and-out links of the target node;
[0121] An acquisition module is used to acquire neighbor nodes of a target node;
[0122] A first aggregation module, configured to perform a vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the out-link neighbor nodes;
[0123] The second aggregation module is used to perform a vector aggregation operation on the in-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the in-link neighbor nodes.
[0124] Optionally, the acquisition device further includes:
[0125] A ratio determination module, used to determine the sampling ratio according to the ratio of outbound nodes to inbound nodes in the graph neural network;
[0126] The sampling module is used to sample the neighbor nodes of the target node according to the sampling ratio to obtain out-link neighbor nodes and in-link neighbor nodes.
[0127] Optionally, the word vector determination module 306 is used to perform the following operations:
[0128] Extracting features of neighboring words of the target word in the word dependency graph to obtain graph features;
[0129] The graph features are aggregated to determine a word vector representation of each word in the word dependency graph.
[0130] Optionally, the word vector determination module 306 is further configured to perform the following operations:
[0131] Get the edge weight between the target word and its neighbor words;
[0132] The vector representations of the neighbor nodes of the word vector graph structure model are weighted using the edge weights between the target word and the neighbor words of the target word.
[0133] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware.
[0134] According to another aspect of the embodiments of the present application, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the above steps are implemented when the processor executes the computer program.
[0135] The memory and processor in the above-mentioned computer device communicate through a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0136] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0137] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0138] According to another aspect of the embodiments of the present application, a computer-readable medium having a non-volatile program code executable by a processor is provided.
[0139] Optionally, in an embodiment of the present application, the computer-readable medium is configured to store program codes for the processor to perform the following steps:
[0140] Construct a word dependency graph corresponding to the corpus;
[0141] Inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, and obtaining a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node;
[0142] The word vector graph structure model is used to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph.
[0143] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0144] When the embodiments of the present application are specifically implemented, reference may be made to the above-mentioned embodiments, which have corresponding technical effects.
[0145] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0146] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0147] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0148] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0149] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0152] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk. It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.
[0153] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A method for obtaining a word vector representation, characterized in that: The acquisition method comprises: Construct a word dependency graph corresponding to the corpus; Inputting the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, and obtaining a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node; Using the word vector graph structure model to perform graph embedding processing on the word dependency graph to determine the word vector representation of each word in the word dependency graph; Before constructing the embedded representation of the in- and out-links of the target node of the graph neural network model, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-link neighbor nodes, the acquisition method also includes: initializing the target node of the graph neural network model to obtain the embedded representation of the in- and out-links of the target node; obtaining the neighbor nodes of the target node; performing a vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain the feature vector representation of the out-link neighbor nodes; performing a vector aggregation operation on the in-link neighbor nodes of the neighbor nodes of the target node to obtain the feature vector representation of the in-link neighbor nodes.
2. The acquisition method according to claim 1, characterized in that: The inputting of the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training to obtain a word vector graph structure model includes: Extracting entity features of the word dependency graph and edge features between entities; The entity features of the word dependency graph and the edge features between entities are input into the graph neural network model applicable to the directed graph for training to obtain the word vector graph structure model.
3. The acquisition method according to claim 1, characterized in that: Before performing a vector aggregation operation on the out-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the out-link neighbor nodes; and performing a vector aggregation operation on the in-link neighbor nodes of the neighbor nodes of the target node to obtain a feature vector representation of the in-link neighbor nodes, the acquisition method further includes: Determine the sampling ratio according to the ratio of outbound nodes to inbound nodes in the graph neural network; The neighbor nodes of the target node are sampled according to the sampling ratio to obtain out-link neighbor nodes and in-link neighbor nodes.
4. The acquisition method according to claim 1, characterized in that: The step of performing graph embedding processing on the word dependency graph using the word vector graph structure model to determine the word vector representation of each word in the word dependency graph includes: Extracting features of neighboring words of the target word in the word dependency graph to obtain graph features; The graph features are aggregated to determine a word vector representation of each word in the word dependency graph.
5. The acquisition method according to claim 4, characterized in that: The step of aggregating the graph features to determine the word vector representation of each word in the word dependency graph includes: Get the edge weight between the target word and its neighbor words; The vector representations of the neighbor nodes of the word vector graph structure model are weighted using the edge weights between the target word and the neighbor words of the target word.
6. A device for acquiring word vector representation, characterized in that: include: The construction module is used to construct the word dependency graph corresponding to the corpus; A training module is used to input the text features of the word dependency graph into a graph neural network model applicable to a directed graph for training, so as to obtain a word vector graph structure model; wherein the graph neural network model applicable to a directed graph is obtained by constructing an embedding representation of the in-and-out links of the target node of the graph neural network model, a feature vector representation of the out-link neighbor node, and a feature vector representation of the in-link neighbor node; A word vector determination module, used to perform graph embedding processing on the word dependency graph using the word vector graph structure model to determine the word vector representation of each word in the word dependency graph; The method further includes a module for initializing the target node of the graph neural network model before constructing the embedding representation of the in-and-out chains of the target node of the graph neural network model, the feature vector representation of the out-link neighbor nodes, and the feature vector representation of the in-chain neighbor nodes, to obtain the embedding representation of the in-and-out chains of the target node; obtaining the neighbor nodes of the target node; performing vector aggregation operations on the out-link neighbor nodes of the neighbor nodes of the target node to obtain the feature vector representation of the out-link neighbor nodes; performing vector aggregation operations on the in-chain neighbor nodes of the neighbor nodes of the target node to obtain the feature vector representation of the in-chain neighbor nodes.
7. The acquisition device according to claim 6, characterized in that: The training module is used to perform the following operations: Extracting entity features of the word dependency graph and edge features between entities; The entity features of the word dependency graph and the edge features between entities are input into the graph neural network model applicable to the directed graph for training to obtain the word vector graph structure model.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the steps of the acquisition method described in any one of claims 1 to 5 are implemented.
9. A computer-readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the acquisition method according to any one of claims 1 to 5.
