Entity relationship classification method and related equipment

By using a one-way gated recurrent network and attention mechanism in the entity relationship classification method, combined with global and local attention weights, the problem of inaccurate entity relationship classification in the existing technology is solved, and a more accurate entity relationship classification is achieved.

CN119721036APending Publication Date: 2025-03-28BEIJING CHINA POWER INFORMATION TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411618617.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, the entity relationship classification method cannot guarantee the accuracy of entity relationship classification, especially when the sentences are long or the structure is complex, keyword recognition is inaccurate due to the existence of noise words.

Method used

A method of entity relationship classification is proposed. The embedded vectors of the target entity pair are processed through a pre-constructed one-way gated recurrent network to obtain the attention vector, and combined with global and local attention weights, it is processed through a weight mixing algorithm. Finally, the target entity pair is classified and predicted based on the mixed attention weights.

Benefits of technology

By integrating global and local attention mechanisms, real keywords can be effectively screened out and the accuracy of entity relationship classification can be improved, especially when dealing with long sentences or complex structures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119721036A_ABST
    Figure CN119721036A_ABST
Patent Text Reader

Abstract

The invention provides an entity relationship classification method and related equipment, and the method comprises the steps: achieving the integration of an attention mechanism into entity relationship classification from a global range in a manner of processing an embedded vector of a target entity pair through a pre-constructed one-way gated loop network, obtaining an attention vector, and achieving the classification of the entity relationship. Secondly, in order to avoid the problem that when sentences are long and complex, the accuracy of entity relation classification is affected by noise caused by irrelevant words, potential keywords of local attention are recognized through a hard local mechanism algorithm or a soft local mechanism algorithm, the attention weight of the real keywords is improved, and the accuracy of entity relation classification is improved; according to the method, the attention weight of the noise word is reduced, so that a real keyword can be screened out, effective entity relationship classification can be realized on the basis, and the accuracy of a relationship classification result of the target entity pair can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to an entity relationship classification method and related equipment. Background Art

[0002] Entity relationship classification is one of the important tasks of information extraction, which involves identifying and classifying the semantic relationships between entities in text. It can transform complex natural language text into structured knowledge representation, providing a basis for building domain ontology, knowledge graph, developing question-answering system, information retrieval system, etc.

[0003] Based on the above situation, the entity relationship classification method in the prior art cannot guarantee the accuracy of entity relationship classification. Summary of the invention

[0004] In view of this, the purpose of this application is to propose an entity relationship classification method and related equipment to solve the above technical problems.

[0005] Based on the above purpose, the first aspect of the present application provides an entity relationship classification method, comprising:

[0006] Determining an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs;

[0007] Taking each entity pair of the multiple entity pairs as a target entity pair, and processing the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network to obtain an attention vector;

[0008] Processing the attention vector and the pre-built bidirectional gated recurrent network through a global attention weight algorithm to obtain a global attention weight;

[0009] Processing the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight;

[0010] Processing the global attention weight and the local attention weight through a weight mixing algorithm to obtain a mixed attention weight;

[0011] Based on the mixed attention weights, relationship classification prediction is performed on the target entity pair to obtain a relationship classification result of the target entity pair.

[0012] Optionally, determining the embedding vector of the target text data includes:

[0013] Mapping each word in the target text data to a vector of a preset dimension to obtain a plurality of word embedding vectors, wherein the word corresponding to each word embedding vector corresponds to two entities respectively;

[0014] Using each word embedding vector in the multiple word embedding vectors as a target word embedding vector, determining the position indexes of two entities corresponding to the target word embedding vector, and mapping the position indexes of the two entities corresponding to the target word embedding vector to a vector of a preset dimension to obtain a position embedding vector;

[0015] The target word embedding vector is combined with the position embedding vector to obtain the embedding vector.

[0016] Optionally, the processing of the embedding vector of the target entity pair by a pre-constructed unidirectional gated recurrent network to obtain an attention vector includes:

[0017] Using a pre-constructed unidirectional gated recurrent network to perform feature extraction on the embedding vector of the target entity pair, to obtain association information corresponding to the target entity, and in the feature extraction process, to update the hidden state of each network layer of the unidirectional gated recurrent network;

[0018] When the association information is obtained, the updated hidden states of each network layer of the unidirectional gated recurrent network are obtained, and based on the updated hidden states of each network layer, the updated hidden state of the target network layer is determined, and the updated hidden state of the target network layer is used as the attention vector, wherein the target network layer is the last network layer in the unidirectional gated recurrent network according to the data transmission direction.

[0019] Optionally, the attention vector and the pre-constructed bidirectional gated recurrent network are processed by a global attention weight algorithm to obtain a global attention weight, including:

[0020] Determine the hidden states of each network layer of the bidirectional gated recurrent network

[0021] Based on the attention vector c and the hidden states of each network layer of the bidirectional gated recurrent network The global attention weight α is obtained by the following formula gi :

[0022]

[0023] Optionally, the using a hard local mechanism algorithm or a soft local mechanism algorithm to process the global attention weight to obtain a local attention weight includes:

[0024] In response to determining that a target dependency path can be generated based on the target entity pair, based on whether the word corresponding to the target entity pair is on the shortest dependency path, the localization weight m is determined by the following formula: i :

[0025] or,

[0026] In response to determining that a target dependency path cannot be generated based on the target entity, obtaining a hidden state H generated by the bidirectional gated recurrent unit in a pre-trained localized network. l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l ;

[0027] Based on the preset activation function parameter σ, the hidden state H l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l The localization weight m is determined by the following formula i :

[0028] m i =σ(W l H l +b l );

[0029] Based on the localization weight m i The global attention weight α is calculated by the following formula gi Perform hard localization processing to obtain the local attention weight α li ;

[0030]

[0031] in, c represents the attention vector, Represents the hidden states of each network layer of a bidirectional gated recurrent network.

[0032] Optionally, the localized network is trained by the following loss function J:

[0033] J=J cls +J loc ;

[0034] in, l represents the length of the sentence corresponding to the target entity pair, i represents the position of the word in the sentence, j represents the order of the entity in the entire corpus, N represents the number of entities containing the word in the entire corpus, and m i Represents the localization weight, sdp i represents the Diess loss function, y i represents the probability of the correct value of the classification, represents the probability of the predicted entity classification, and N' represents the total number of entity classification categories.

[0035] Optionally, the processing the global attention weight and the local attention weight by a weight mixing algorithm to obtain a mixed attention weight includes:

[0036] Based on the preset constant parameter γ, the global attention weight α gi and the local attention weight α li The mixed attention weight α is determined by the following formula i :

[0037] α i =f(α gi , α li )=γα gi +(1-γ)α li .

[0038] Optionally, performing relationship classification prediction on the target entity pair based on the hybrid attention weight to obtain a relationship classification result of the target entity pair includes:

[0039] Get the hidden state H of the bidirectional gated recurrent network i , the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c ;

[0040] Based on the hybrid attention weight α corresponding to the target entity i and the hidden state H of the bidirectional gated recurrent network i The target hidden state s is determined by the following formula:

[0041] s=∑ i α i H i ;

[0042] Based on the target hidden state s, the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c The normalized probability P(y|x) is determined by the following formula:

[0043] P(y|x)=softmax(W c s+b c );

[0044] Based on the normalized probability P(y|x), the relationship classification result of the target entity pair is determined by the following formula:

[0045]

[0046] Based on the same inventive concept, the second aspect of the present application provides an entity relationship classification device, comprising:

[0047] An embedding vector determination module, configured to determine an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs;

[0048] an attention vector determination module, taking each entity pair of the plurality of entity pairs as a target entity pair, and processing the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network to obtain an attention vector;

[0049] A global processing module, which processes the attention vector and a pre-built bidirectional gated recurrent network through a global attention weight algorithm to obtain a global attention weight;

[0050] A local processing module processes the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight;

[0051] A hybrid processing module processes the global attention weight and the local attention weight through a weight hybrid algorithm to obtain a hybrid attention weight;

[0052] A classification prediction module performs relationship classification prediction on the target entity pair based on the mixed attention weight to obtain a relationship classification result of the target entity pair.

[0053] Based on the same inventive concept, the third aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the method described in the first aspect above when executing the computer program.

[0054] From the above, it can be seen that the entity relationship classification method and related equipment provided by the present application process the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network, so as to integrate the attention mechanism into the entity relationship classification from a global scope and obtain the attention vector. Then, in order to avoid the problem of affecting the accuracy of entity relationship classification due to the influence of noise caused by irrelevant words when the sentence is relatively long and complex, a hard local mechanism algorithm or a soft local mechanism algorithm is used to identify potential keywords of local attention, increase the attention weight of the real keywords, and reduce the attention weight of the noise words. In this way, the real keywords can be screened out, so that effective entity relationship classification can be achieved based on this, which can improve the accuracy of the relationship classification results of the target entity pairs. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0056] Figure 1 A flowchart of an entity relationship classification method according to an embodiment of the present application;

[0057] Figure 2 A structural block diagram of an entity relationship classification device according to an embodiment of the present application;

[0058] Figure 3 A schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0060] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0061] It is understandable that before using the technical solutions of each embodiment of the present application, the type, scope of use, usage scenarios, etc. of the personal information involved will be informed to the user in an appropriate manner, and the user's authorization will be obtained.

[0062] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can independently choose whether to provide personal information to the electronic device, application, server, storage medium or other software or hardware that performs the operation of the technical solution of the present application according to the prompt message.

[0063] As an optional but non-limiting implementation, in response to receiving the user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0064] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation method of this application. Other methods that meet relevant laws and regulations may also be applied to the implementation method of this application.

[0065] Entity relation classification is the most important part of entity relation extraction, which involves identifying all the connections between entities. Moreover, relation classification, as a subset of relation extraction, is applied in various fields such as information retrieval, question answering, etc. due to its usefulness in identifying semantic relations between entities. Of particular note is its role in retrieval augmented generation (RAG) of large language models, where the identified relations form the well-known backbone as knowledge graph. The use of knowledge graphs in large language models helps enrich the model's understanding of information and its contextual associations. These graph-like structures represent the relations between entities as nodes and edges, thus providing a nuanced contextual framework for the model. When dealing with large text datasets and knowledge bases, knowledge graphs help models infer connections between entities, thereby promoting a deeper and more comprehensive understanding of the context. This structured representation enhances the model's ability to answer queries, generate consistent responses, and navigate complex information.

[0066] The present application finds that one of the reasons why the accuracy of entity relationship classification cannot be guaranteed is that the entity relationship classification method of the related technology mainly focuses on integrating the attention mechanism into the entity relationship classification from a global perspective, which ignores the importance of local contextual relationships in entity relationship classification. When the sentence is very long or the composition structure is very complex, the presence of a large number of noise words will hinder the accuracy of keyword recognition.

[0067] This application aims to solve this problem and proposes a global-local attention mechanism in the entity relationship classification method. The ability of global attention can be improved through localized attention, that is, hard localization mechanism and soft localization mechanism are used to identify potential keywords of local attention. By adopting hard localization strategy and soft localization strategy at the same time, the contextual cues can be understood in a nuanced and more comprehensive way. These contextual cues play an important role in effective entity relationship classification and can classify entity relationships more accurately.

[0068] An embodiment of the present application provides an entity relationship classification method, which utilizes a hard local mechanism algorithm or a soft local mechanism algorithm to identify potential keywords of local attention, increases the attention weight of real keywords, and reduces the attention weight of noise words, so that the real keywords can be screened out, and based on this, effective entity relationship classification can be achieved, which can improve the accuracy of the relationship classification results of the target entity pairs.

[0069] like Figure 1 As shown, the method of this embodiment includes:

[0070] Step 101, determining an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs.

[0071] In this step, the target text data refers to the text information that needs to be processed or analyzed. In this context, the target text data has a specific structure or feature, that is, it contains multiple entity pairs. Entity pairs can be any form of information that appears in pairs, such as goods and categories (such as "apple" and "fruit" in "apple is fruit"), etc.

[0072] In natural language processing, embedding vectors are a technique for converting words, phrases, or entire sentences into fixed-length numerical vectors. These vectors can capture the semantic relationship between words, making similar words closer in the vector space. Embedding vectors enable machine learning models to understand and process text data.

[0073] In this way, entity pairs in the target text data can be converted into numerical forms that can be understood and processed by machine learning models, providing a basis for further analysis, classification, recommendation and other tasks.

[0074] Step 102: taking each entity pair of the multiple entity pairs as a target entity pair, and processing the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network to obtain an attention vector.

[0075] In this step, the unidirectional gated recurrent unit (GRU) is a variant of the recurrent neural network (RNN) for processing sequence data. Compared with the standard RNN, GRU introduces update gates and reset gates to more effectively capture long-term dependencies while reducing computational complexity. Unidirectional means that information can only flow in one direction (usually forward) of the sequence. It is used to process the embedding vectors of entity pairs, which can better capture the potential relationships or features between the target entity pairs.

[0076] Among them, the attention mechanism is an important concept in deep learning, especially when processing sequence data (such as text or time series). It allows the model to "pay attention" to other parts of the input sequence when processing each element (for example, each word in the text). The attention vector is a representation of this attention, usually a score or weight vector that indicates the importance of each element in the sequence to the current processing element.

[0077] Step 103, based on the attention vector and the pre-built bidirectional gated recurrent network, a global attention weight algorithm is used to process the attention vector to obtain a global attention weight.

[0078] In this step, the bidirectional gated recurrent network (BGRU / Bi-GRU) combines GRU (Gated Recurrent Unit) layers in both the forward and backward directions. It is a variant of RNN that aims to solve the difficulties of traditional RNN in long-term dependency problems by introducing reset gates and update gates to control the flow of information. The bidirectional structure enables the network to consider both the forward and backward information of the sequence at the same time, thereby capturing richer contextual information.

[0079] In the attention mechanism, global attention refers to the fact that the model calculates attention weights based on the entire input sequence when processing each time step (or each element in the sequence). This mechanism allows the model to refer to all parts of the input sequence when generating outputs, not just the input of the current time step. The global attention weight algorithm is used to calculate these weights, which usually involves some form of operation (such as dot product, additive attention, etc.) on the attention vector and the output of the BGRU to produce a global attention weight for each time step.

[0080] Finally, based on the attention vector and the output of BGRU, the global attention weight algorithm can be used to calculate the global attention weight of each time step. These weights reflect the importance of each element in the input sequence to the output of the current time step, and are then used to adjust the output of BGRU or perform subsequent processing.

[0081] Step 104: Process the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight.

[0082] In this step, all elements in the input sequence are considered when generating each output. Using a global attention mechanism enables the model to capture long-range dependencies in the input sequence, but it can also be computationally expensive and may introduce irrelevant information because the model needs to process the entire input sequence every time it generates an output.

[0083] In order to overcome some limitations of the global attention mechanism, this application proposes a local attention mechanism, which combines the characteristics of the global attention mechanism and allows the model to focus only on a subset or window of the input sequence when processing the input sequence, rather than the entire sequence. This can be achieved through a hard local mechanism algorithm or a soft local mechanism algorithm:

[0084] Among them, for the hard local mechanism algorithm, the model first determines a fixed window size or range, and then calculates the attention weight within this window. This means that in each output generation step, the model only considers a subset of the input sequence. This method can significantly reduce computational costs and help the model focus more on relevant information.

[0085] For soft local mechanism algorithms, unlike hard local mechanism, soft local mechanism allows the model to dynamically choose the window of attention over a wider range of inputs. This is usually achieved by introducing an additional mechanism, such as a prediction model, which can decide which part of the input sequence to focus on based on the current context. Soft local mechanism provides higher flexibility because it is able to adjust the window of attention based on the specific content of the input sequence.

[0086] By processing the global attention weights, local attention weights can be obtained using hard local mechanism or soft local mechanism algorithms. These local attention weights reflect the model's attention to specific parts of the input sequence when generating each output. This approach helps improve the efficiency and accuracy of the model, especially when dealing with long sequences or complex tasks.

[0087] Step 105: Process the global attention weight and the local attention weight through a weight mixing algorithm to obtain a mixed attention weight.

[0088] In this step, the global attention weights and local attention weights are combined to generate a mixed attention weight. This is usually achieved through some form of weighted averaging, where the global and local weights are assigned different importances (i.e., mixing coefficients). The choice of mixing coefficients can be determined based on specific tasks, data characteristics, or model architecture. For example, if the task requires the model to pay more attention to global information, the mixing coefficient of the global attention weight may be higher.

[0089] Finally, a hybrid attention weight that combines the global and local attention characteristics is obtained through the weighted hybrid algorithm. The hybrid attention weight takes into account both the global context and the local details, which can help the model capture richer information and improve processing performance.

[0090] Step 106: perform relationship classification prediction on the target entity pair based on the mixed attention weight to obtain a relationship classification result of the target entity pair.

[0091] In this step, relation classification aims to determine the relationship between a given pair of entities.

[0092] Since the hybrid attention weights take into account both the global context and the local details, the relationship classification prediction of the target entity pairs based on this can further improve the accuracy of the relationship classification results of the target entity pairs.

[0093] Through the above scheme, the embedding vector of the target entity pair is processed by a pre-constructed unidirectional gated recurrent network, so as to integrate the attention mechanism into the entity relationship classification from a global scope and obtain the attention vector. Then, in order to avoid the influence of noise caused by irrelevant words when the sentence is relatively long and complex, which may affect the accuracy of entity relationship classification, a hard local mechanism algorithm or a soft local mechanism algorithm is used to identify potential keywords of local attention, increase the attention weight of real keywords, and reduce the attention weight of noise words. In this way, the real keywords can be screened out, so that effective entity relationship classification can be achieved based on this, which can improve the accuracy of the relationship classification results of the target entity pairs.

[0094] In some embodiments, step 101 includes:

[0095] Step A1, mapping each word in the target text data into a vector of a preset dimension to obtain a plurality of word embedding vectors, wherein the words corresponding to each word embedding vector correspond to two entities respectively.

[0096] Step A2, taking each word embedding vector in the multiple word embedding vectors as the target word embedding vector, determining the position indexes of two entities corresponding to the target word embedding vector, mapping the position indexes of the two entities corresponding to the target word embedding vector to a vector of a preset dimension, and obtaining a position embedding vector.

[0097] Step A3, combining the target word embedding vector with the position embedding vector to obtain the embedding vector.

[0098] In the above scheme, each word in the target text data (such as a sentence or a paragraph) is mapped to a high-dimensional vector space. This vector space is usually obtained by training a word embedding model (such as Word2Vec, GloVe or BERT, etc.).

[0099] Each word is converted into a fixed-length vector, which is the word embedding vector of the word. The dimension of the word embedding vector is preset, which means that the vectors of all words have the same length.

[0100] Through this process, each word in the target text data is converted into a corresponding word embedding vector, thereby obtaining multiple word embedding vectors (if the target text data contains multiple words).

[0101] For each word embedding vector (herein referred to as the target word embedding vector), determine the position index of the two entities it corresponds to in the text. Entities can be nouns, verbs, or other meaningful words, depending on the needs of the task.

[0102] The position index refers to the relative position between the target word and the two entities (eg, the distance between the target word and the first entity, and the distance between the target word and the second entity).

[0103] Then, these position indexes are also mapped into a vector space of a preset dimension to obtain the position embedding vector. The purpose of the position embedding vector is to provide the model with information about the relative position between the target word and the entity.

[0104] Finally, the target word embedding vector is combined with the corresponding position embedding vector. This is usually achieved through some form of concatenation or element-wise addition.

[0105] The combined vector is the final embedding vector, which contains both the semantic information of the target word and the position information between the target word and the entity.

[0106] For example, the input word is represented by word embedding and position embedding, and the position embedding is determined according to the relative position between two entities.

[0107] Word embedding: Each word in the input sentence is mapped to a high-dimensional vector.

[0108] Position embedding: In order to highlight the entities in the sentence, the relational classification method embeds the word embedding position into the vector after word embedding. For each word x i , this word is for two entities e 1 and e 2 There are two relative indexes and As with word embedding, each position index is mapped to a high-dimensional vector, and finally the overall input for each word in the input is represented as:

[0109]

[0110] Among them, w i represents the embedding vector, (wv i ) T represents the word embedding vector, and Represents the position embedding vectors of the two entities corresponding to the target word embedding vector.

[0111] By combining the word embedding vector and the position embedding vector, when processing text data, not only the semantic information of the word is considered, but also the position of the word in the text and its relationship with specific entities, which can further ensure the accuracy of subsequent relationship classification predictions.

[0112] In some embodiments, in step 102, the embedding vector of the target entity pair is processed by a pre-constructed unidirectional gated recurrent network to obtain an attention vector, including:

[0113] Step B1, using a pre-constructed unidirectional gated recurrent network to perform feature extraction on the embedding vector of the target entity pair, obtain association information corresponding to the target entity, and update the hidden state of each network layer of the unidirectional gated recurrent network during the feature extraction process.

[0114] Step B2, obtaining the updated hidden states of each network layer of the unidirectional gated recurrent network when the association information is obtained, and determining the updated hidden state of the target network layer based on the updated hidden states of each network layer, and using the updated hidden state of the target network layer as the attention vector, wherein the target network layer is the last network layer in the unidirectional gated recurrent network according to the data transmission direction.

[0115] In the above scheme, the unidirectional gated recurrent network (GRU) is a deformed recurrent neural network (RNN) that can process sequence data and maintain a "memory" state during the processing, which helps to capture the dependencies in the sequence.

[0116] In this process, the network will perform feature extraction on the embedded vector, that is, by analyzing the characteristics of the embedded vector, it will extract key information related to the target entity.

[0117] In a unidirectional gated recurrent network, each network layer has a hidden state, which is continuously updated when processing sequence data to reflect the currently processed sequence information. Therefore, during the feature extraction process, as the network layer processes the embedded vector, the hidden state of each network layer will also be continuously updated to capture the dynamic changes in the sequence.

[0118] Once feature extraction is completed, the updated hidden states of each network layer can be obtained. These hidden states contain key information of the processed embedding vector. However, in actual applications, it may not be necessary to use the hidden states of all network layers, but rather select the hidden states of one or several specific network layers (i.e., the target network layer) as the final result.

[0119] Among them, the basis for selecting the target network layer may be based on experimental experience, the design of the network architecture, or the demand analysis of a specific task. The target network layer of this application is preferably the last network layer.

[0120] Finally, the updated hidden state of the selected target network layer is used as the attention vector. This attention vector can be regarded as a summary of the key information of the target entity pair and can be used for subsequent relationship classification.

[0121] For example, e1 represents the word / position embedding (i.e., embedding vector) of entity 1, w e2 The word / position embedding (i.e., embedding vector) of entity 2 is represented by the attention vector, which is the last hidden state and is generated by a unidirectional GRU using entity pair information. c = GRU (w e1 , w e2 ).

[0122] In some embodiments, step 103 includes:

[0123] Step C1, determining the hidden state of each network layer of the bidirectional gated recurrent network

[0124] Step C2, based on the attention vector c and the hidden states of each network layer of the bidirectional gated recurrent network The global attention weight α is obtained by the following formulagi :

[0125]

[0126] In the above scheme, the global attention weight for each word is obtained by multiplying the attention vector with each hidden state in the bidirectional gated recurrent network.

[0127] Bidirectional gated recurrent networks (BiGRU / BiLSTM) are able to consider both forward and backward contextual information when processing sequence data.

[0128] “Gating” refers to the use of gates (such as input gate, forget gate, output gate) in the network to control the flow of information, which helps solve the problem of gradient disappearance or explosion in traditional RNNs.

[0129] In addition, the bidirectional gated recurrent network can also be used to extract high-level features from the input. It is a simplified version of the Long Short-Term Memory (LSTM) network that can retain important features over a longer time frame and solve the problem of gradient disappearance in LSTM. The bidirectional gated recurrent network is effective in entity relationship classification, while the standard gated recurrent network is unidirectional.

[0130] Hidden state is the internal state that a recurrent neural network maintains at each time step when processing sequence data. In a bidirectional gated recurrent network, each time step has two hidden states, forward and backward. In order to build forward and backward information together, the forward hidden state and the backward hidden state are combined together. in, represents the forward hidden state, Represents the backward hidden state.

[0131] The global attention weight is obtained by multiplying the attention vector with each hidden state in the bidirectional gated recurrent network.

[0132] The global attention weight is calculated using the attention vector and the hidden state of the bidirectional gated recurrent network, so that more attention can be paid to the important parts when processing sequence data, which can indirectly improve the accuracy of subsequent relationship classification.

[0133] In some embodiments, step 104 includes:

[0134] Step D1, in response to determining that a target dependency path can be generated based on the target entity pair, based on whether the word corresponding to the target entity pair is on the shortest dependency path, determine the localization weight m by the following formula: i :

[0135]

[0136] Step D2, in response to determining that the target dependency path cannot be generated based on the target entity, obtaining a hidden state H generated by the bidirectional gated recurrent unit in a pre-trained localized network l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l .

[0137] Step D3, based on the preset activation function parameter σ, the hidden state H l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l The localization weight m is determined by the following formula i :

[0138] m i =σ(W l H l +b l ).

[0139] Step D4, based on the localization weight m i The global attention weight α is calculated by the following formula gi Perform hard localization processing to obtain the local attention weight α li ;

[0140]

[0141] in, c represents the attention vector, Represents the hidden states of each network layer of a bidirectional gated recurrent network.

[0142] In the above scheme, when the sentence is relatively long and complex, the global attention cannot capture the correct keywords due to the noise caused by irrelevant words. If some potential keywords are localized first, the attention can be improved by considering only these keywords. i The weight of each word indicating whether it is a potential keyword. The local attention weight can be generated by a weighted normalized exponential (softmax) function;

[0143]

[0144] The localization weight m of each word can be generated through hard localization mechanism and soft localization mechanism i .

[0145] Among them, the hard localization mechanism is as follows:

[0146] Although there is no label data to indicate which word may be a keyword, the shortest dependency path between entities contains relatively important information. It is assumed that all words on the shortest dependency path (i.e., the target dependency path) are potential keywords, and words not on the shortest dependency path are not keywords. Based on this theory, the localization weight m i It can be expressed as follows:

[0147]

[0148] Soft localization mechanism: In the context of entity relationship classification, the above assumptions are informal and uncertain. First, not all entity pairs can produce a shortest dependency path, and some extracted paths may not be accurate. Second, valuable words that are crucial for entity classification may exceed the limit of the shortest dependency path. In order to improve the localization mechanism, the hard localization method is replaced by soft localization through a localization network structure, which takes the original sentence as input and then generates a localization weight m for each word. i .

[0149] H l =BiGRU l (x).

[0150] m i =σ(W l H l +b l ).

[0151] Unlike hard localization, which uses the shortest dependency path to directly set the localization weight, soft localization uses it as a supervisory signal.

[0152] In some embodiments, the localized network is trained by the following loss function J:

[0153] J=J cls +J loc ;

[0154] in, l represents the length of the sentence corresponding to the target entity pair, i represents the position of the word in the sentence, j represents the order of the entity in the entire corpus, N represents the number of entities containing the word in the entire corpus, and m i Represents the localization weight, sdp i represents the Diess loss function, y i represents the probability of the correct value of the classification, represents the probability of the predicted entity classification, and N' represents the total number of entity classification categories.

[0155] In the above scheme, when soft localization is used, according to the classification of the cross entropy (Sigmoid) loss function, the loss of the localized network is also added, and the total loss function formula is as follows:

[0156] J=J cls +j loc .

[0157] By using the loss function J to train and obtain a localized network, the performance of the localized network can be better improved.

[0158] In some embodiments, step 105 includes:

[0159] Based on the preset constant parameter γ, the global attention weight α gi and the local attention weight α li The mixed attention weight α is determined by the following formula i :

[0160] α i =f(α gi , α li )=γα gi +(1-γ)α li .

[0161] In the above scheme, in deep learning and neural networks, the attention mechanism enables dynamic focus on different parts of the input data when processing the input data. The global attention weight generally indicates the degree of attention of the model to the entire input data, while the local attention weight more specifically indicates the degree of attention of the machine learning model to certain specific areas in the input data.

[0162] Combining global and local attention weights can help machine learning models consider both global and local information when making decisions. To achieve this, a weight blending algorithm can be used, which combines global and local attention weights to produce a blended attention weight:

[0163] α i =f(α gi , α li )=γα gi +(1-γ)α li

[0164] Among them, γ is a preset constant parameter, and its value is between 0 and 1. This parameter is used to control the relative importance of global and local attention weights in mixed attention weights. For example, if the value of γ is close to 1, the mixed attention weight will rely more on the global attention weight; if the value of γ is close to 0, the mixed attention weight will rely more on the local attention weight.

[0165] By combining the global attention weight and the local attention weight, the overall attention mechanism performance can be better improved.

[0166] In some embodiments, step 106 includes:

[0167] Step E1, obtaining the hidden state H of the bidirectional gated recurrent network i , the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c .

[0168] Step E2, based on the mixed attention weight α corresponding to the target entity i and the hidden state H of the bidirectional gated recurrent network i The target hidden state s is determined by the following formula:

[0169] s=∑ i α i H i .

[0170] Step E3, based on the target hidden state s, the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c The normalized probability P(y|x) is determined by the following formula:

[0171] P(y|x)=softmax(W c s+b c ).

[0172] Step E4, based on the normalized probability P(y|x), determine the relationship classification result of the target entity pair by the following formula:

[0173]

[0174] In the above scheme, the final representation of the last sentence is the sum of these hidden states adjusted by the attention weights, and the classifier is a normalized exponential (Softmax) function.

[0175] When processing an input sequence, a bidirectional gated recurrent network generates a series of hidden states that capture the contextual information in the sequence.

[0176] By applying the mixed attention weights to the hidden states of the bidirectional gated recurrent network, a weighted target hidden state s can be obtained, which emphasizes the information that contributes to relation classification.

[0177] Using the target hidden state s as input, the score for each relation category is calculated through a fully connected layer (with weights and bias values ​​applied).

[0178] These scores are then normalized using the Softmax function to obtain the probability distribution of each category, namely the normalized probability P(y|x).

[0179] Finally, the category with the largest normalized probability is selected as the relationship classification result of the target entity pair. This means that this category most likely describes a relationship between two entities.

[0180] By combining the context capturing ability of bidirectional gated recurrent networks and the focusing ability of attention mechanisms, the accuracy and efficiency of relation classification can be improved.

[0181] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0182] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0183] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides an entity relationship classification device.

[0184] refer to Figure 2 , the entity relationship classification device comprises:

[0185] An embedding vector determination module 201 is configured to determine an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs;

[0186] The attention vector determination module 202 takes each entity pair of the plurality of entity pairs as a target entity pair, processes the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network, and obtains an attention vector;

[0187] A global processing module 203 processes the attention vector and the pre-built bidirectional gated recurrent network through a global attention weight algorithm to obtain a global attention weight;

[0188] A local processing module 204 processes the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight;

[0189] A mixing processing module 205 processes the global attention weight and the local attention weight through a weight mixing algorithm to obtain a mixed attention weight;

[0190] The classification prediction module 206 performs relationship classification prediction on the target entity pair based on the mixed attention weight to obtain a relationship classification result of the target entity pair.

[0191] In some embodiments, the embedding vector determination module 201 is specifically configured to:

[0192] Mapping each word in the target text data to a vector of a preset dimension to obtain a plurality of word embedding vectors, wherein the word corresponding to each word embedding vector corresponds to two entities respectively;

[0193] Using each word embedding vector in the multiple word embedding vectors as a target word embedding vector, determining the position indexes of two entities corresponding to the target word embedding vector, and mapping the position indexes of the two entities corresponding to the target word embedding vector to a vector of a preset dimension to obtain a position embedding vector;

[0194] The target word embedding vector is combined with the position embedding vector to obtain the embedding vector.

[0195] In some embodiments, the attention vector determination module 202 is specifically configured to:

[0196] Using a pre-constructed unidirectional gated recurrent network to perform feature extraction on the embedding vector of the target entity pair, to obtain association information corresponding to the target entity, and in the feature extraction process, to update the hidden state of each network layer of the unidirectional gated recurrent network;

[0197] When the association information is obtained, the updated hidden states of each network layer of the unidirectional gated recurrent network are obtained, and based on the updated hidden states of each network layer, the updated hidden state of the target network layer is determined, and the updated hidden state of the target network layer is used as the attention vector, wherein the target network layer is the last network layer in the unidirectional gated recurrent network according to the data transmission direction.

[0198] In some embodiments, the global processing module 203 is specifically configured to:

[0199] Determine the hidden states of each network layer of the bidirectional gated recurrent network

[0200] Based on the attention vector c and the hidden states of each network layer of the bidirectional gated recurrent network The global attention weight α is obtained by the following formula gi :

[0201]

[0202] In some embodiments, the local processing module 204 is specifically configured to:

[0203] In response to determining that a target dependency path can be generated based on the target entity pair, based on whether the word corresponding to the target entity pair is on the shortest dependency path, the localization weight m is determined by the following formula: i :

[0204] In response to determining that a target dependency path cannot be generated based on the target entity, obtaining a hidden state H generated by the bidirectional gated recurrent unit in a pre-trained localized network. l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l ;

[0205] Based on the preset activation function parameter σ, the hidden state H l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l The localization weight m is determined by the following formula i :

[0206] m i =σ(W l H l +b l );

[0207] Based on the localization weight m i The global attention weight α is calculated by the following formula gi Perform hard localization processing to obtain the local attention weight α li ;

[0208]

[0209] in, c represents the attention vector, Represents the hidden states of each network layer of a bidirectional gated recurrent network.

[0210] In some embodiments, the localized network is trained by the following loss function J:

[0211] J=J cls +j loc ;

[0212] in, l represents the length of the sentence corresponding to the target entity pair, i represents the position of the word in the sentence, j represents the order of the entity in the entire corpus, N represents the number of entities containing the word in the entire corpus, and m i Represents the localization weight, sdp i represents the Diess loss function, y i represents the probability of the correct value of the classification, represents the probability of the predicted entity classification, and N' represents the total number of entity classification categories.

[0213] In some embodiments, the mixing processing module 205 is specifically configured as follows:

[0214] Based on the preset constant parameter γ, the global attention weight α gi and the local attention weight α li The mixed attention weight α is determined by the following formula i :

[0215] α i =f(α gi , α li )=γα gi +(1-γ)α li .

[0216] In some embodiments, the classification prediction module 206 is specifically configured to:

[0217] Get the hidden state H of the bidirectional gated recurrent network i , the weight W of the fully connected layer of the bidirectional gated recurrent networkl , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c ;

[0218] Based on the hybrid attention weight α corresponding to the target entity i and the hidden state H of the bidirectional gated recurrent network i The target hidden state s is determined by the following formula:

[0219] s=∑ i α i H i ;

[0220] Based on the target hidden state s, the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c The normalized probability P(y|x) is determined by the following formula:

[0221] P(y|x)=softmax(W c s+b c );

[0222] Based on the normalized probability P(y|x), the relationship classification result of the target entity pair is determined by the following formula:

[0223]

[0224] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0225] The device of the above embodiment is used to implement the corresponding entity relationship classification method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0226] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the entity relationship classification method described in any of the above embodiments is implemented.

[0227] Figure 3A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 301, a memory 302, an input / output interface 303, a communication interface 304, and a bus 305. The processor 301, the memory 302, the input / output interface 303, and the communication interface 304 are connected to each other in communication within the device through the bus 305.

[0228] The processor 301 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0229] The memory 302 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 302 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 302 and called and executed by the processor 301.

[0230] The input / output interface 303 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0231] The communication interface 304 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0232] The bus 305 comprises a pathway for transmitting information between the various components of the device (eg, the processor 301 , the memory 302 , the input / output interface 303 , and the communication interface 304 ).

[0233] It should be noted that, although the above device only shows the processor 301, the memory 302, the input / output interface 303, the communication interface 304 and the bus 305, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0234] The electronic device of the above embodiment is used to implement the corresponding entity relationship classification method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0235] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the entity relationship classification method described in any of the above embodiments.

[0236] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0237] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the entity relationship classification method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0238] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0239] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.

[0240] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0241] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the present application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the protection scope of the present application.

Claims

1. A method for classifying entity relationships, characterized in that: include: Determining an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs; Taking each entity pair of the multiple entity pairs as a target entity pair, and processing the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network to obtain an attention vector; Processing the attention vector and the pre-built bidirectional gated recurrent network through a global attention weight algorithm to obtain a global attention weight; Processing the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight; Processing the global attention weight and the local attention weight through a weight mixing algorithm to obtain a mixed attention weight; Based on the mixed attention weights, relationship classification prediction is performed on the target entity pair to obtain a relationship classification result of the target entity pair.

2. The method according to claim 1, characterized in that The step of determining the embedding vector of the target text data comprises: Mapping each word in the target text data to a vector of a preset dimension to obtain a plurality of word embedding vectors, wherein the word corresponding to each word embedding vector corresponds to two entities respectively; Using each word embedding vector in the multiple word embedding vectors as a target word embedding vector, determining the position indexes of two entities corresponding to the target word embedding vector, and mapping the position indexes of the two entities corresponding to the target word embedding vector to a vector of a preset dimension to obtain a position embedding vector; The target word embedding vector is combined with the position embedding vector to obtain the embedding vector.

3. The method according to claim 1, characterized in that The embedding vector of the target entity pair is processed by a pre-constructed unidirectional gated recurrent network to obtain an attention vector, including: Using a pre-constructed unidirectional gated recurrent network to perform feature extraction on the embedding vector of the target entity pair, to obtain association information corresponding to the target entity, and in the feature extraction process, to update the hidden state of each network layer of the unidirectional gated recurrent network; When the association information is obtained, the updated hidden states of each network layer of the unidirectional gated recurrent network are obtained, and based on the updated hidden states of each network layer, the updated hidden state of the target network layer is determined, and the updated hidden state of the target network layer is used as the attention vector, wherein the target network layer is the last network layer in the unidirectional gated recurrent network according to the data transmission direction.

4. The method according to claim 1, characterized in that The attention vector and the pre-built bidirectional gated recurrent network are processed by a global attention weight algorithm to obtain a global attention weight, including: Determine the hidden states of each network layer of the bidirectional gated recurrent network Based on the attention vector c and the hidden states of each network layer of the bidirectional gated recurrent network The global attention weight α is obtained by the following formula gi :

5. The method according to claim 1, characterized in that The using of a hard local mechanism algorithm or a soft local mechanism algorithm to process the global attention weight to obtain a local attention weight includes: In response to determining that a target dependency path can be generated based on the target entity pair, based on whether the word corresponding to the target entity pair is on the shortest dependency path, the localization weight m is determined by the following formula: i : or, In response to determining that a target dependency path cannot be generated based on the target entity, obtaining a hidden state H generated by the bidirectional gated recurrent unit in a pre-trained localized network. l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l ; Based on the preset activation function parameter σ, the hidden state H l , the weight W of the fully connected layer of the localized network l , the deviation value b in the fully connected layer of the localized network l The localization weight m is determined by the following formula i : m i =σ(W l H l +b l ); Based on the localization weight m i The global attention weight α is calculated by the following formula gi Perform hard localization processing to obtain the local attention weight α li ; in, c represents the attention vector, Represents the hidden states of each network layer of a bidirectional gated recurrent network.

6. The method according to claim 5, characterized in that The localized network is trained by the following loss function J: J=J cls +J loc . in, l represents the length of the sentence corresponding to the target entity pair, i represents the position of the word in the sentence, j represents the order of the entity in the entire corpus, N represents the number of entities containing the word in the entire corpus, and m i Represents the localization weight, sdp i represents the Diess loss function, y i represents the probability of the correct value of the classification, represents the probability of the predicted entity classification, and N' represents the total number of entity classification categories.

7. The method according to claim 1, characterized in that The global attention weight and the local attention weight are processed by a weight mixing algorithm to obtain a mixed attention weight, including: Based on the preset constant parameter γ, the global attention weight α gi and the local attention weight α li The mixed attention weight α is determined by the following formula i : a i =f(a gi ,a li )=ga gi +(1-c)a li 。 8. The method according to claim 1, characterized in that The performing relationship classification prediction on the target entity pair based on the mixed attention weight to obtain the relationship classification result of the target entity pair includes: Get the hidden state H of the bidirectional gated recurrent network i , the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c ; Based on the hybrid attention weight α corresponding to the target entity i and the hidden state H of the bidirectional gated recurrent network i The target hidden state s is determined by the following formula: s=∑ i a i H i ; Based on the target hidden state s, the weight W of the fully connected layer of the bidirectional gated recurrent network l , and the bias value b in the fully connected layer of the bidirectional gated recurrent network c The normalized probability P(y|x) is determined by the following formula: P(y|x)=softmax(W c s+b c ): Based on the normalized probability P(y|x), the relationship classification result of the target entity pair is determined by the following formula:

9. An entity relationship classification device, characterized in that: include: An embedding vector determination module, configured to determine an embedding vector of target text data, wherein the target text data includes a plurality of entity pairs; an attention vector determination module, taking each entity pair of the multiple entity pairs as a target entity pair, and processing the embedding vector of the target entity pair through a pre-constructed unidirectional gated recurrent network to obtain an attention vector; A global processing module, which processes the attention vector and a pre-built bidirectional gated recurrent network through a global attention weight algorithm to obtain a global attention weight; A local processing module processes the global attention weight using a hard local mechanism algorithm or a soft local mechanism algorithm to obtain a local attention weight; A hybrid processing module processes the global attention weight and the local attention weight through a weight hybrid algorithm to obtain a hybrid attention weight; A classification prediction module performs relationship classification prediction on the target entity pair based on the mixed attention weight to obtain a relationship classification result of the target entity pair.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Entity relationship joint extraction method and system for Chinese text in carbon finance field

    CN120654694A