Entity relationship extraction method and device, equipment and storage medium

By constructing a two-dimensional matrix and using the BIOES annotation method, combined with a supervised learning model, the problem of entity relationship extraction errors and redundancy in the existing technology is solved, and accurate extraction and correlation analysis of entities and relationships in sentences are achieved, improving the efficiency of identification efficiency.

CN118780283APending Publication Date: 2024-10-15HARBIN ENG UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410860229.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

When extracting entity relationships, the prior art sequentially leads to error propagation and information redundancy, and fails to effectively consider the correlation between entities and relationships in sentences, resulting in relationship entity matching errors.

Method used

By constructing a two-dimensional matrix, using the BIOES annotation method and Mask operation, extract subject-object, subject-relation and relationship-object pairs, combine the supervised learning model and machine learning model to determine the relevance of entities and relationships, and generate entity relationships. triplet.

Benefits of technology

It solves the problem of entity and relationship extraction errors, improves recognition efficiency, comprehensively considers the relationship between entities in the sentence, and reduces information redundancy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118780283A_ABST
    Figure CN118780283A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an entity relationship extraction method and device, equipment and a storage medium, and the method comprises the steps: obtaining a sentence text from a preset corpus; performing word segmentation processing on the sentence text to obtain a sentence text sequence; constructing a two-dimensional matrix according to the sentence text sequence and a preset potential relation data set sequence; rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relation in the relation data set sequence, and columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relation in the relation data set sequence; obtaining a subject-object two-tuple according to the two-dimensional matrix; based on a preset machine learning model, obtaining a subject-relation two-tuple and a relation-object two-tuple according to the two-dimensional matrix; and obtaining an entity relationship triple according to the subject-object two-tuple, the subject-relationship two-tuple and the relationship-object two-tuple. The problems that error propagation and information redundancy exist in an extraction mode, and the internal relation between entities and the relation is ignored are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the field of knowledge engineering, and in particular to an entity relationship extraction method, device, equipment and storage medium. Background Art

[0002] The purpose of entity recognition and relationship extraction is to identify and extract the relationship between two or more entities from text. In various fields, a large amount of data is generated and collected. These data usually exist in unstructured forms, such as text, images, etc., which makes it very difficult to extract useful information from them. In addition, since the relationships between these data are complex and diverse, it is even more difficult to effectively analyze and understand these data. Therefore, how to accurately extract entities and relationships from unstructured data becomes very important.

[0003] When extracting entity relationships, the prior art usually first performs entity recognition, then performs relationship extraction, and then performs entity relationship matching.

[0004] However, due to the order of entities and relations in the existing technology, errors in the extraction of relations and entities occur, and the existence of certain associations between entities and relations in a sentence is not taken into account, resulting in error propagation and relationship entity matching errors caused by not considering the association between entities and relations in the sentence; and the existing technology usually performs relationship pairing on all identified entities, which causes information redundancy problems. Summary of the invention

[0005] In view of the above solutions, the present application aims to propose an entity relationship extraction method and device to solve at least one of the above technical problems.

[0006] In a first aspect, one or more embodiments of this specification provide an entity relationship extraction method, including:

[0007] Get sentence text from a preset corpus;

[0008] Performing word segmentation processing on the sentence text to obtain a sentence text sequence;

[0009] According to the sentence text sequence and the preset potential relationship data set sequence, a two-dimensional matrix is ​​constructed; the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence;

[0010] According to the two-dimensional matrix, the subject-object tuple is obtained;

[0011] Based on the preset machine learning model, subject-relation bigrams and relation-object bigrams are obtained according to the two-dimensional matrix;

[0012] According to the subject-object bigram, the subject-relation bigram and the relation-object bigram, an entity relation triplet is obtained.

[0013] Furthermore, based on the supervised learning model, the sentence text corresponding area in the two-dimensional matrix is ​​filled using the BIOES annotation method and Mask operation;

[0014] According to the filled two-dimensional matrix, subject-object bigrams are extracted.

[0015] Further, determining a region to be filled, wherein the region to be filled is an upper triangular region or a lower triangular region in the region corresponding to the sentence text in the two-dimensional matrix;

[0016] Based on the BIOES annotation method, annotate the entity head and entity tail of the entity in the sentence text;

[0017] Based on the supervised learning model, fill the entity head and entity tail in the corresponding area in the two-dimensional matrix;

[0018] The Mask operation is used to assign 0 to the unfilled portion of the area corresponding to the sentence text in the two-dimensional matrix.

[0019] Further, based on the machine learning model, a relationship region to be filled is determined; the relationship region to be filled is a region having an association relationship with the entity in the region corresponding to the relationship text in the two-dimensional matrix;

[0020] According to the binary classification, the area with relationship in the two-dimensional matrix is ​​assigned 1; the area without relationship is assigned 0;

[0021] In a two-dimensional matrix, identify the subject and object;

[0022] Determining the subject-relation dyad according to the intersection area of ​​the subject and the relation in the two-dimensional matrix;

[0023] The relation-object tuple is determined according to the intersection area between the object and the relation in the two-dimensional matrix.

[0024] Furthermore, the machine learning model includes a binary cross entropy loss function and a sigmoid activation function;

[0025] The calculation formula of the binary cross entropy loss function is as follows:

[0026]

[0027] in, Represents y i and The degree of proximity between

[0028] is the predicted value;

[0029] y i The value of is 0 or 1;

[0030] M represents the number of words in the sentence text;

[0031] M represents the number of potential relationships;

[0032] The sigmoid activation function calculation formula is as follows:

[0033]

[0034] Among them, P rel Indicates the prediction result;

[0035] W r represents weight;

[0036] b r Indicates the offset.

[0037] Further, according to the subject-relation bigram and the relation-object bigram, searching for the subject-object bigram;

[0038] If the subject-object bigram exists, the subject-relation bigram, the relation-object bigram and the subject-object bigram are concatenated to obtain the entity relation triplet.

[0039] In a second aspect, an embodiment of the present application provides an entity relationship extraction device, the device comprising: an acquisition module, a processing module, a first generation module, a second generation module, a third generation module and an entity relationship module;

[0040] The acquisition module is used to acquire sentence text from a preset corpus;

[0041] The processing module is used to perform word segmentation processing on the sentence text to obtain a sentence text sequence;

[0042] The first generating module is used to construct a two-dimensional matrix according to the sentence text sequence and the preset potential relationship data set sequence; the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence;

[0043] The second generation module is used to obtain a subject-object tuple according to the two-dimensional matrix;

[0044] The third generation module is used to obtain subject-relation bigrams and relation-object bigrams according to the two-dimensional matrix based on the preset machine learning model;

[0045] The entity relationship module is used to obtain entity relationship triples according to the subject-object bigram, the subject-relation bigram and the relation-object bigram.

[0046] Furthermore, the device further comprises: an extraction module;

[0047] The extraction module is used to fill the sentence text corresponding area in the two-dimensional matrix based on the supervised learning model using the BIOES annotation method and the Mask operation; and extract the subject-object tuple according to the filled two-dimensional matrix.

[0048] In a third aspect, an embodiment of the present application provides a computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the entity relationship extraction method described in any one of the first aspects when executing the computer instructions.

[0049] In a fourth aspect, an embodiment of the present application provides a storage medium, including:

[0050] Used to store computer executable instructions, which, when executed, implement the steps of any one of the entity relationship extraction methods in the first aspect.

[0051] Compared with the prior art, this application can at least achieve the following technical effects:

[0052] The present application can simultaneously annotate entities and relations in a two-dimensional matrix, and obtain subject-object dyads, subject-relation dyads, and relation-object dyads, thereby solving the problem of extraction errors caused by extracting entities and relations in sequence; and then further explore the connection between entities and relations by using preset potential relations, thereby solving the problem of relation entity matching errors caused by not considering the association between entities and relations in the sentence; finally, entity-relationship triples are obtained, which can fully consider the relationship between entities in the sentence and improve the recognition efficiency. . BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate one or more embodiments of this specification 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, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0054] Figure 1 A flowchart of an entity relationship extraction method provided for one or more embodiments of this specification;

[0055] Figure 2 A two-dimensional matrix schematic diagram of an entity relationship extraction method provided for one or more embodiments of this specification;

[0056] Figure 3 A two-dimensional matrix diagram of a PTRE model of an entity relationship extraction method provided in one or more embodiments of this specification;

[0057] Figure 4 A two-dimensional matrix diagram of an LSTM-PTRE model of an entity relationship extraction method provided by one or more embodiments of this specification;

[0058] Figure 5 A schematic diagram of the accuracy of the PTRE model, LSTM-PTRE model, and Tiny-PTRE model provided for one or more embodiments of this specification on the NYT dataset and the WebNLG dataset, respectively;

[0059] Figure 6 Schematic diagram of the recall rates of the PTRE model, LSTM-PTRE model and Tiny-PTRE model provided for one or more embodiments of this specification on the NYT dataset and the WebNLG dataset respectively;

[0060] Figure 7 The PTRE model, LSTM-PTRE model and Tiny-PTRE model provided in one or more embodiments of this specification are respectively used for the NYT dataset and the WebNLG dataset. 1 Value diagram;

[0061] Figure 8 A schematic diagram of the structure of an entity relationship extraction device provided for one or more embodiments of this specification. DETAILED DESCRIPTION

[0062] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will be combined with the drawings in one or more embodiments of this specification to clearly and completely describe the technical solutions in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.

[0063] At present, when farmers encounter problems during the planting process, they usually use browsers to search, consult professionals or look up books. However, since the Internet is just messy and the knowledge in books is obscure and difficult to understand, it is difficult to obtain accurate planting information from them, which affects the subsequent planting results.

[0064] Embodiment 1

[0065] To solve the above technical problems, this application proposes an entity relationship extraction method, such as Figure 1 As shown, the specific steps are as follows:

[0066] Step S1, obtaining sentence text from a preset corpus.

[0067] In the embodiment of the present application, the preset corpus is composed of agricultural-related published books, documents, expert knowledge and relevant agricultural data on the Internet; and is obtained after deduplication, noise reduction and formatting processing.

[0068] For example, after deduplication, noise reduction, formatting and other processing, we collected 15,126 pieces of professional agricultural data, such as "Questions and Answers on High-quality and High-yield Soybeans", "Soybean Production and Practical Processing Technology", "Soybean Production Practical Technology Manual", literature and expert knowledge, and obtained the soybean knowledge corpus.

[0069] Step S2, performing word segmentation processing on the sentence text to obtain a sentence text sequence.

[0070] In the embodiment of the present application, at the encoding stage, the input sentence text is preprocessed, that is, the sentence text W={w 1 ,w 2 ,…,w N}Perform word segmentation operation to obtain sentence text sequence.

[0071] Step S3, constructing a two-dimensional matrix according to the sentence text sequence and the preset potential relationship data set sequence.

[0072] In the embodiment of the present application, the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relations in the relational dataset sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relations in the relational dataset sequence. 1 ,r 2 ,…,r M} performs word segmentation, and then concatenates the sentence text sequence after word segmentation and the preset potential relationship dataset sequence, wherein [SEP] is used to distinguish the sentence text sequence and the preset potential relationship dataset sequence, so as to construct the final input text sequence T = {[CLS], w 1 ,w2 ,…,w N ,[SEP],[CLS],r 1 ,r 2 ,…,r M ,[SEP]}, and finally input into BERT, so that BERT can fully learn the intrinsic connection between entities and relations and obtain word vectors. Among them, CLS is one of the special tags of the input sequence, which is used to represent the semantic information of the entire sequence and is usually used as the input of the classifier for classification tasks; the SEP tag is used to separate the two sentences or sequence tags of the sentence to help the model understand the different parts of the input sequence. Then all the word vectors are spliced ​​together to form a (N+M) 2 In the two-dimensional table of size, a square two-dimensional table is constructed with the sum of the number of tokens in sentence W and the number of tokens in the potential relationship set R as the edge to complete the construction of the two-dimensional matrix. N is the number of entities, M is the number of potential relationships,

[0073] Step S4, obtaining subject-object dyads according to the two-dimensional matrix.

[0074] In an embodiment of the present application, based on a supervised learning model, the area corresponding to the sentence text in the two-dimensional matrix is ​​filled using the BIOES annotation method and the Mask operation; and the subject-object tuple is extracted based on the filled two-dimensional matrix.

[0075] Specifically, in the two-dimensional matrix, potential relationship filtering, head entity-tail entity, head entity-relationship, and relationship-tail entity filling operations are performed simultaneously. In the sentence text corresponding area in the two-dimensional matrix, each cell is used to represent the relationship between two entities. The two-dimensional table is annotated using the three annotation methods BIE in the BIOES annotation method, where B represents the beginning of the entity; I represents the inside of the entity; E represents the end of the entity; and there are nine types of relationships in the two-dimensional table: HB-TB (HeadBegin-TailBegin) represents the head of the annotated head entity and the head of the tail entity, HB-TI (HeadBegin-TailInside) represents the middle part of the head of the annotated head entity and the tail entity, HB-TE (HeadBegin-TailEnd) represents the head of the annotated head entity and the tail of the tail entity, HI-TB (HeadInside -TailBegin) is expressed as the middle part of the labeled head entity and the head of the tail entity, HI-TI (HeadInside-TailInside) is expressed as the middle part of the labeled head entity and the middle part of the tail entity, HI-TE (HeadInside-TailEnd) is expressed as the middle part of the labeled head entity and the tail of the tail entity, HE-TB (HeadEnd-TailBegin) is expressed as the tail of the labeled head entity and the head of the tail entity, HE-TI (HeadEnd-TailInside) is expressed as the tail of the labeled head entity and the middle part of the tail entity, and HE-TE (HeadEnd-TailEnd) is expressed as the tail of the labeled head entity and the tail of the tail entity.

[0076] The training process of the supervised model is as follows: using the supervised learning method, with the sentence text in the training set, the sentence text with entity annotations, and the text expressing the relationship between entities as input, and the annotated relationship between entities as output, to train the supervised model; then using the test set to test the supervised model to ensure that the supervised model is more accurate when filling in the relationship.

[0077] In an embodiment of the present application, an area to be filled is determined, and the area to be filled is an upper triangular area or a lower triangular area in an area corresponding to the sentence text in a two-dimensional matrix; based on the BIOES annotation method, an entity head and an entity tail of an entity in the sentence text are annotated; based on a supervised learning model, the entity head and the entity tail are filled in the corresponding area in the two-dimensional matrix; and a Mask operation is used to assign 0 to the unfilled part of the area corresponding to the sentence text in the two-dimensional matrix.

[0078] Specifically, since the manifestation of the relation triple in the two-dimensional table is actually a regional annotation, a new annotation strategy is proposed, that is, directly annotating the upper left corner and the lower right corner of the region without introducing other redundant regional annotation labels. This method makes the annotation matrix more sparse, which brings the following advantages: First, only two special labels are used when classifying, which effectively reduces the potential search space. Secondly, the number of negative samples is increased, which is easier to train. Finally, the corresponding decoding rules are relatively simple. The labels of the lower right corner and the upper left corner of the region are directly matched one by one to form a labeled region. If the head and tail entities have only a single word triple, they are directly decoded, thereby ensuring the decoding speed.

[0079] Since the labeling process in the two-dimensional matrix is ​​similar to the handshake logic in the real world, the matrix is ​​called the handshake matrix, which is specifically the entity-entity handshake matrix and the entity-relationship handshake labeling. The handshake matrix contains two forms: entity-entity handshake and entity-relationship handshake. In the entity-entity handshake matrix, if Figure 2 As shown, the intersection area of ​​the head entity and the tail entity in the matrix is ​​marked out, and the corresponding entity-entity can be located by simply using the diagonal marking method. The entity-entity handshake judgment function is as follows:

[0080]

[0081] Among them, H (Handshake) represents the name of the marking function;

[0082] (e 1 ,r,e 2 ) represents a relation triple;

[0083] e 1 Represents the head entity;

[0084] r indicates relationship;

[0085] e 2 Represents the tail entity.

[0086] In the corresponding two-dimensional table, for e 1 and e 2 The corresponding intersection area is marked diagonally. For example, in the sentence "A certain university is located in a certain city, the capital of a certain province", there is a triple (a certain university, located in, a certain city). Then "a certain university" and "a certain city" are marked diagonally. Figure 2 The intersection area in the figure is annotated diagonally. This annotation method helps to clearly identify the relationship between the two entities. This area in the figure is called the entity-entity area. 1 ,e 2 )=H(e 2 ,e 1), so the upper triangle is mirror-symmetric to the lower triangle in the solid-solid region.

[0087] Finally, the entity-entity regions in the two-dimensional matrix are decoded to extract subject-object bigrams.

[0088] Step S5, based on the preset machine learning model and according to the two-dimensional matrix, obtain subject-relation bigrams and relation-object bigrams.

[0089] In an embodiment of the present application, based on a machine learning model, a relationship area to be filled is determined; the relationship area to be filled is the area in the corresponding area of ​​the relationship text in the two-dimensional matrix that has an association relationship with the entity; according to binary classification, the area with a relationship in the two-dimensional matrix is ​​assigned a value of 1; in the two-dimensional matrix, a subject and an object are determined; according to the intersection area of ​​the subject and the relationship in the two-dimensional matrix, a subject-relationship tuple is determined; according to the intersection area of ​​the object and the relationship in the two-dimensional matrix, a relationship-object tuple is determined.

[0090] Specifically, the specific method of entity-relationship handshake marking is as follows Figure 2 The entity-entity handshake mark is removed from the entity-relationship annotation method, and the entity-relationship annotation method is combined with the "subject-verb-object" idea in natural language. Because the relationship triple actually has a sequential logic, the relationship triple can be divided into two bigrams, namely the subject-relationship bigram (e 1 ,r) and the relation object tuple (r,e 2 ). The entity-relationship handshake decision function is as follows:

[0091]

[0092] in, Yes 1 's head;

[0093] Yes 1 The tail of

[0094] T begin,tail It is a relation triple based on BIE notation;

[0095] Relation triples (e 1 ,r,e 2 )'s BIE triples have

[0096] The self-attention mechanism is used to determine whether the corresponding area in the matrix needs to be marked. Specifically, it directly uses the output of the transformer of the 11th layer of BERT The scaled dot product is averaged, and then the sigmoid activation function is used as the final result, as shown below:

[0097]

[0098] Where H is (N+M) 2 The handshake matrix of size , T is the number of self-attention heads, and It is a trainable weight. When H exceeds the threshold σ, it is considered that the row and column Token corresponding to the position has a handshake process.

[0099] The relations marked as positive in the potential relation extraction module are handshaked and annotated with the subject-relation region and the object-relation region; then a matrix masking operation (Mask) is performed on the two-dimensional matrix to cover the filtered relations. The potential relation determination function is as follows:

[0100]

[0101] Among them, P(r) indicates whether there is a potential relationship in the sentence;

[0102] Potential relation extraction module (T) = 1 means that the relation may be a relation in the sentence;

[0103] Potential relation extraction module (T) = 0 means that the relation cannot be a relation in the sentence.

[0104] For example, when the input sentence text is "a certain university is located in a certain city, the capital of a certain province", combined with the preset potential relationship data set "located in, capital, city, residence, ...", the expanded input sequence "a certain university is located in a certain city, the capital of a certain province + located in, capital, city, residence, ..." is obtained. After BERT encoding and the potential relationship extraction module, "located in", "capital" and "city" in the preset potential relationship data set can be marked with positive labels, and joint extraction with entities can be continued based on these potential relationships. In this sentence, the relation word "owns" does not appear in the sentence, so the potential relationship is marked as 0; and the relation word "located in" appears in the sentence, so the potential relationship is marked as 1.

[0105] The entire handshake process is carried out in a complete two-dimensional table. Finally, only the table needs to be used to extract the relationship triples. Therefore, the binary cross entropy loss in the potential relationship extraction module can be used for training. The specific formula is as follows:

[0106]

[0107] in, yes With H i,j the degree of proximity;

[0108] N is the number of tokens in the sentence;

[0109] M is the number of tokens in the potential relationship set;

[0110] H i,j is the prediction matrix of the label matrix;

[0111] Yes H i,j Ground Truth Matrix.

[0112] Finally, the relation-object and subject-relation regions in the two-dimensional matrix are decoded to extract subject-relation bigrams and relation-object bigrams.

[0113] Among them, the potential relationship extraction module is specifically, for the sentence text W = {w 1 ,w 2 ,…,w N} (N represents the number of words) to perform word segmentation, that is, to divide a text or sentence into individual words or tokens to obtain a sequence T s ={[CLS],t 1 ,t 2 ,…,t N ,[SEP]}, "CLS" is one of the special tags of the input sequence, which is used to represent the semantic information of the entire sequence. It is usually used as the input of the classifier for classification tasks. The "SEP" tag is used to separate the tags of two sentences or sequences to help the model understand the different parts of the input sequence. 1 ,r 2 ,…,r M The processing method of} (M represents the number of potential relations) is the same as that of sentence text, and the sequence T is obtained after processing. r ={[CLS],t 1 ,t 2 ,…,t M ,[SEP]}. The text is processed to obtain the input of the BERT model, and the calculation method is as follows:

[0114] T=Concat(T s ,T r )

[0115] H=E[T]

[0116] Among them, T represents the final input sequence, T s and T r They are the Token Id of the input sentence and the Token Id of the relationship, Represents the vector matrix input to the BERT model, d hRepresents the dimension of the hidden layer, and E represents the embedding table in the BERT model.

[0117] In the encoding stage, the BERT encoder uses the self-attention mechanism to allow the model to focus on the relevant parts of each word in the entire input sequence when processing each word, so that it can effectively capture long-distance dependencies, thereby improving the ability to understand the text. Specifically, BERT first adds position encoding to the word embedding of each position in H, and then in the self-attention layer, each word generates a query (Query), key (Key) and value (Value), that is, Q, K, V, and then calculates the attention weight between word pairs through the Softmax-normalized Dot Production of Q and K, and then merges with V to obtain the final attention score Attention(Q,K,V), which is calculated as follows:

[0118]

[0119] In order to stabilize the calculation process, the attention score is usually multiplied by a scaling factor, usually where d h is the dimension of the vector, and then the Softmax function is used to obtain the attention weight. In the BERT model, there are multiple (for example, 12 or 24) Transformer encoder layers, each of which contains two main sublayers: a self-attention sublayer and a feedforward neural network sublayer. The self-attention sublayer is passed as input to the feedforward neural network, which further extracts and refines the features in the word unit representation. Since H contains both potential relationships and entities, the output H of each layer of the Transformer i The rich correlation of intrinsic relationships between entities and potential relationships is fully learned, solving the problem of ignoring the intrinsic connection between entities and relationships in existing calculations.

[0120] In the decoding stage, in order to solve the problem of redundant relationship prediction, only two possibilities need to be considered: a potential relationship or not a potential relationship. Therefore, this application models the potential relationship extraction problem as a multi-label binary classification task. Specifically, if the probability predicted by the model exceeds a certain threshold λ (set to 0.5 in this patent), the corresponding relationship is marked as a positive class (label 1), indicating that it is a potential relationship; if the probability is lower than the threshold λ, it is marked as a negative class (label 0), indicating that it is not a potential relationship.

[0121] Then, by taking the negative sign, the maximization problem is transformed into a minimization problem, and finally the binary cross entropy loss function used for the binary classification problem is obtained. The formula is as follows:

[0122]

[0123] in, Represents y i and The degree of proximity between

[0124] is the predicted value, and y i The value of is 0 or 1;

[0125] represents the likelihood value;

[0126] is the maximum likelihood estimate;

[0127] N represents the number of words in the sentence text;

[0128] M represents the number of potential relationships.

[0129]

[0130] The training method is through the Sigmoid function, the formula is as follows:

[0131]

[0132] Among them, P rel Represents the prediction results

[0133] W r represents weight;

[0134] b r Indicates the offset.

[0135] Step S6, obtaining entity relationship triples according to the subject-object bigram, the subject-relation bigram and the relation-object bigram.

[0136] In an embodiment of the present application, a subject-object bigram is searched for based on a subject-relation bigram and a relation-object bigram; if a subject-object bigram exists, the subject-relation bigram, the relation-object bigram and the subject-object bigram are concatenated to obtain an entity relation triplet.

[0137] Specifically, to decode the triples again, extracting the triples from the handshake matrix requires collecting the handshake tag information of entity-entity and entity-relationship.

[0138] The decoding method can solve the problems of single entity overlap (SEO) and entity pair overlap (EPO), such as Figure 3As shown, all valid bigrams can be extracted from the handshake matrix: subject-relation bigrams (a certain university, located in) and (a certain province, provincial capital), subject-object bigrams (a certain university, a certain province), (a certain university, a certain city) and (a certain province, a certain city), object-relation bigrams (located in, a certain province), (located in, a certain city) and (provincial capital, a certain city). After obtaining several bigrams as above, they are spliced ​​together through the "subject-verb-object" logic. For example: for the subject-relation bigram (a certain university, located in), its corresponding object-relation bigrams are (located in, a certain province) and (located in, a certain city). Through the subject-relation bigrams and object relationship bigrams, we can find two bigrams (a certain university, a certain province) and (a certain university, a certain city) from the subject-object bigrams. Finally, we can extract two relationship triplets (a certain university, located in, a certain province) and (a certain university, located in, a certain city), which effectively solves the problem that a single relationship is related to multiple entities. In the same way, we can extract two triplets (a certain province, provincial capital, a certain city) and (a certain province, city, a certain city), which solves the problem that entity pairs are difficult to extract when they overlap.

[0139] Embodiment 2

[0140] In the embodiment of the present application, when training the Potential Relation And Table-filling Based Entity and Relation Extraction (PTRE), it is found that the GPU video memory occupies a large amount and the training takes a long time. Its training resource requirements are huge and it is not suitable for some special environments, such as embedded devices, mobile devices, and wearable devices. Therefore, the knowledge distillation technology and Bi-LSTM network are used to optimize the entity relationship extraction model to obtain a lightweight entity relationship extraction model (Tiny-PTRE).

[0141] Specifically, the construction process of the lightweight entity relationship extraction model is to transfer the knowledge learned from the PTRE model to the LSTM-PTRE model based on the knowledge distillation technology, so that the PTRE model can pass its prediction ability and generalization ability to the LSTM-PTRE model to obtain the Tiny-PTRE model.

[0142] First, based on the knowledge distillation technology, the PTRE model is trained with the preset data set to obtain the teacher model. The matrix handshake labeling module of PTRE and the last layer network output of the potential relationship extraction module are retained, and Softmax is used to warm them up and smooth the output category probability to obtain soft predictions with richer information. In the teacher model, the last layer network output of the handshake matrix labeling module is set to hi , the last layer network output of the potential relationship extraction module is p j , its i The soft prediction value h i _Soft_Prediction and p j The soft prediction value p j The calculation formula of _Soft_Prediction is as follows:

[0143]

[0144] Among them, h i _Soft_Prediction means h i Soft prediction value of

[0145] p j _Soft_Prediction indicates p j Soft prediction value of

[0146] h i Represents the last layer network output of the handshake matrix marking module;

[0147] p j Represents the last layer network output of the potential relationship extraction module;

[0148] N represents the number of tokens in the sentence;

[0149] M represents the number of tokens in the potential relationship set;

[0150] T represents the distillation temperature and its value is 1.

[0151] Secondly, the LSTM-PTRE student model is trained using the same preset data set, and then Softmax is used to heat it up to obtain the soft prediction of the student model, and then the ordinary Softmax, that is, Softmax with T=1, is used to process it to obtain the hard prediction of the student model. Then the soft prediction of the teacher model is used to perform cross entropy with the soft prediction of the student model to obtain the soft loss L so f t , the formula is as follows:

[0152] L soft =CE(T softPrediciton , S softPrediction )

[0153] Among them, L soft Indicates soft loss;

[0154] T softPrediciton is the soft prediction of the teacher model;

[0155] S softPredictionis the soft prediction of the student model;

[0156] CE is the cross entropy function.

[0157] In the student model branch, set T to 1 to get the hard prediction, and then calculate the loss between the hard label and the soft prediction, which is called the hard loss L hard , where the hard label is the ground truth, and the calculation formula is as follows:

[0158] L hard =CE(S hardPrediction , Target hard )

[0159] Among them, S hardPrediction Hard predictions for the output of the student model;

[0160] Target hard For hard tags;

[0161] L hard Hard loss.

[0162] In order to obtain the soft loss L soft and hard loss L hard After that, we can perform weighted summation to get the total loss L total , the calculation formula is as follows:

[0163] L total =λL soft +(1-λ)L hard

[0164] Among them, L soft Indicates soft loss;

[0165] L hard Indicates hard loss;

[0166] λ represents the weight parameter.

[0167] Then we get the total loss L total , returned to the student model for reverse parameter transfer.

[0168] By learning the PTRE model, we get the LSTM-PTRE model; and by applying knowledge distillation technology to the LSTM-PTRE model, we get the Tiny-PTRE model. Compared with the original PTRE model, the Tiny-PTRE model occupies less GPU memory during training and can run more model instances simultaneously under the same hardware environment, thereby improving resource utilization efficiency. The training time of Tiny-PTRE is relatively short, which can significantly reduce training time and cost in scenarios with large-scale data sets or where models need to be trained frequently.

[0169] In the embodiment of the present application, the construction process of the LSTM-PTRE model is that the LSTM-PTRE model is a lightweight model that combines PTRE and a bidirectional long short-term memory network (Bi-LSTM). By adopting a Bi-LSTM structure with only one layer of network, LSTM-PTRE shows lower requirements in terms of training time, memory usage, and GPU resource requirements, giving it certain advantages. However, at the same time, due to the limited number of parameters and learning ability, LSTM-PTRE may not be able to fully mine the hidden knowledge in the data, and its generalization ability is poor.

[0170] Specifically, in the task of entity relationship extraction, most current models directly use BERT or LSTM as encoders and decoders for training. However, although the model using BERT has better effect, it is more complex, requires more training resources and is slow. The total number of parameters of the BERT model is 108808704; while the LSTM-based model is relatively simple, the total number of parameters of the LSTM model is 4((n+m)m+m), where n is the input feature length, m is the output length, the training speed is fast, but the training effect of LSTM is relatively poor. Therefore, LSTM-PTRE is used as the student model in knowledge distillation, and PTRE is used as the teacher model. In this way, the rich semantics and deep understanding of the teacher model can be passed to the student model, thereby making up for the student model's lack of learning ability. Overall, the LSTM-PTRE model has a simple structure, and at the same time can obtain rich knowledge from the PTRE model, which makes the LSTM-PTRE model have certain advantages in lightweight scenarios. Such as Figure 4 shown.

[0171] In the encoding stage, for a given sentence W = {w 1 ,w 2 ,…,w N},w i Represents the i-th word vector in the text, and the potential relationship set R = {r 1 ,r 2 ,…,r M}, r j represents the jth relation vector in the potential relation set, concatenating W and R to obtain X = {w 1 ,w 2 ,…,w N ,r 1 ,r 2 ,…,r M}={x 1 ,x 2 ,…,x N+M}, and input it into the Bi-LSTM encoder to obtain its encoding representation O = {o 1 ,o2 ,…,o N+M}, the calculation formula is as follows:

[0172]

[0173] Among them, i Represents x i Bi-LSTM encoding;

[0174] Represents the output of the previous state from left to right;

[0175] Indicates the output of the next state from right to left;

[0176] x i Represents the i-th Token in the input sequence;

[0177] and Distinguish between LSTMs that represent rightward and LSTMs that represent leftward;

[0178] In the decoding stage, first use O as the edge to construct a (N+M) 2 A filling-in matrix is ​​constructed with the sum of the number of tokens in sentence W and the number of tokens in the potential relationship set R as the edge to construct a square two-dimensional table. This matrix is ​​the handshake matrix.

[0179] The handshake matrix contains two forms: entity-entity handshake and entity-relationship handshake. In the entity-entity handshake matrix, the intersection area of ​​the head entity and the tail entity in the matrix is ​​marked out. The corresponding entity-entity can be located by simply using the diagonal marking method. The entity-entity handshake judgment function is as follows:

[0180]

[0181] Among them, H (Handshake) represents the name of the marking function;

[0182] (e 2 ,r,e 2 ) represents a relation triple;

[0183] e 1 Represents the head entity;

[0184] r indicates relationship;

[0185] e 2 Represents the tail entity.

[0186] In the corresponding two-dimensional table, for e 1 and e 2The corresponding intersection area is marked diagonally. For example, in the sentence "The Summer Palace is located in Beijing, the capital of China", there is a triple (Summer Palace, located in, China), then "Summer Palace" and "China" are marked diagonally. Figure 4 The intersection area in the figure is annotated diagonally. This annotation method helps to clearly identify the relationship between the two entities. This area in the figure is called the entity-entity area. 1 ,e 2 )=H(e 2 ,e 1 ), so the upper triangle is mirror-symmetric to the lower triangle in the solid-solid region.

[0187] The specific method of entity-relationship handshake marking is as follows Figure 4 The entity-entity handshake mark is removed from the entity-relationship annotation method, and the entity-relationship annotation method is combined with the "subject-verb-object" idea in natural language. Because the relationship triple actually has a sequential logic, the relationship triple can be divided into two bigrams, namely the subject-relationship bigram (e 1 ,r) and the relation object tuple (r,e 2 ). The entity-relationship handshake decision function is as follows:

[0188]

[0189] in, Yes 1 's head;

[0190] Yes 1 The tail of

[0191] T begin,tail It is a relation triple based on BIE notation;

[0192] Relation triples (e 1 ,r,e 2 )'s BIE triples have

[0193] The LSTM-PTRE model replaces the encoder from BERT to LSTM, so the self-attention of the token in the input sequence encoded by Bi-LSTM is used to concatenate the forward hidden state and the backward hidden state together to represent the contextual hidden state. The specific formula is as follows:

[0194]

[0195] in, Represents the contextual hidden state of the i-th Token;

[0196] Represents the Bi-LSTM encoding of the input sequence;

[0197] Represents the contextual hidden state for the entire input sequence.

[0198] Then introduce the self-attention mechanism to obtain its query vector (Q), key vector (K) and value vector (V) representation. First, set the weight matrix W q , W k and W v , updated through learning, the calculation formula is as follows:

[0199]

[0200] Among them, Q i A query vector representing each context hidden state;

[0201] K i represents the key vector;

[0202] V i Represents a vector of values.

[0203] Then, the query vector and key vector are used to determine whether the area corresponding to the matrix in the table needs to be marked. The calculation formula is as follows:

[0204]

[0205] Among them, H(i, j) represents the marking result;

[0206] is the scaling factor, the purpose is to stabilize the calculation process;

[0207] Q i is the query vector of the i-th context hidden state;

[0208] K j is the query vector of the jth context hidden state. When the value of H exceeds the threshold σ, it is determined that the Token of the corresponding row and column has a handshake process.

[0209] W i Q and Q i and K j The trainable weights of .

[0210] In the handshake process of subject-relation and relation-object, we only need to focus on the relations filtered by the potential relation extraction module. The judgment formula is as follows:

[0211]

[0212] Then use the binary cross entropy to Hi,j Training, extracting relation triplets, the formula is as follows:

[0213]

[0214] in, express and the degree of proximity;

[0215] N is the number of tokens in the sentence;

[0216] M is the number of tokens in the potential relationship set;

[0217] H i , j is the handshake matrix;

[0218] is the Ground Truth matrix of the handshake matrix.

[0219] In the embodiment of this application, in order to verify the entity relationship extraction performance of Tiny-PTRE, Tiny-PTRE is compared with two baseline models PTRE and LSTM-PTRE. The evaluation indicators include precision, recall, F 1 The dataset still uses NYT and WebNLG. During the experiment, the maximum memory usage of each model during training was recorded, and the GPU memory requirements of Tiny-PTRE and the baseline model were compared when performing entity relationship extraction tasks. In terms of the time required for training, the total time required for Tiny-PTRE and the baseline model to complete the same training process was calculated and compared. Finally, the impact of the knowledge distillation technology used by Tiny-PTRE on the model performance was analyzed. The experimental environment and parameter settings are shown in Tables 1 and 2.

[0220] Table 1 Experimental environment

[0221]

[0222]

[0223] Table 2 Parameter list

[0224]

[0225] Table 3 GPU memory usage and training time records

[0226]

[0227] As shown in Table 3, the video memory usage of the teacher model PTRE when processing the NYT and WebNLG datasets is 32.2GB and 22.4GB, respectively, which is significantly higher than the 17.9GB and 10.1GB of the student model LSTM-BERT. The difference is mainly due to the fact that PTRE uses BERT as the basic model, which has more parameters and a complex network structure. In contrast, LSTM-PTRE uses a lighter LSTM with fewer layers and parameters, resulting in lower video memory usage. Through knowledge distillation technology, the Tiny-PTRE model significantly reduces the video memory requirements, so that its training on the NYT and WebNLG datasets only requires 22.6GB and 13.7GB, respectively. Knowledge distillation technology successfully reduces the complexity of the teacher model and achieves significant resource optimization. In practical applications, Tiny-PTRE can more efficiently utilize GPU resources and improve training efficiency, especially when GPU video memory resources are limited.

[0228] In terms of training time, the training of the teacher model PTRE on the NYT dataset took about 46 hours, while it took nearly 13 hours to complete on the WebNLG dataset. In comparison, its training time is almost twice that of LSTM-PTRE and 1.5 times that of Tiny-PTRE. The main reason is that the complex structure and large number of parameters of PTRE make the training process relatively time-consuming. In comparison, LSTM-PTRE and Tiny-PTRE have better efficiency in the training process, which significantly shortens the training time. The training time of Tiny-PTRE is comparable to that of LSTM-PTRE, mainly because Tiny-PTRE uses LSTM-PTRE as a student model for knowledge distillation, effectively transferring the information of the teacher model to the student model. Through knowledge distillation, Tiny-PTRE significantly reduces the training time while maintaining performance. This improvement is more critical in practical applications, especially in scenarios that require fast iteration and model tuning, which can effectively shorten the training time and improve work efficiency.

[0229] In summary, Tiny-PTRE based on knowledge distillation has several significant advantages. First, compared with the original PTRE model, it occupies less GPU memory during training, which means that more model instances can be run simultaneously under the same hardware environment, thereby improving resource utilization efficiency. Second, Tiny-PTRE takes relatively short time to train. This advantage is particularly evident in scenarios with large-scale data sets or where models need to be trained frequently, which can significantly reduce training time and cost.

[0230] In the same experimental environment, the PTRE model, LSTM-PTRE model and Tiny-PTRE model were trained on the NYT dataset and WebNLG dataset respectively. After 100 trainings, the optimal F 1 The values, as well as the accuracy and recall of the corresponding training rounds, are shown in Table 4.

[0231] Table 4 Model performance records

[0232]

[0233] In order to observe the performance data of each model more intuitively, the above table is visualized, as shown in the following figure: Figure 5 , 6 As shown in 7, Figure 5 Represents the accuracy of the PTRE model, LSTM-PTRE model, and Tiny-PTRE model on the NYT dataset and WebNLG dataset respectively; Figure 6 Represents the recall rates of the PTRE model, LSTM-PTRE model, and Tiny-PTRE model on the NYT dataset and WebNLG dataset respectively; Figure 7 represents the F scores of the PTRE model, LSTM-PTRE model, and Tiny-PTRE model on the NYT dataset and WebNLG dataset, respectively. 1 value.

[0234] Figure 5 The experimental results of the three models in terms of accuracy are shown. On the NYT dataset and WebNLG dataset, PTRE performs best, with an accuracy significantly better than LSTM-PTRE, which performs less than half of PTRE. It is particularly noteworthy that the Tiny-PTRE model based on knowledge distillation achieves significant performance improvement on the NYT dataset, with an accuracy of 89.2%. Compared with LSTM-PTRE, Tiny-PTRE has improved by 8.6 percentage points. Although it is slightly lower than the PTRE model by 1.5%, it still performs well. On the WebNLG dataset, Tiny-PTRE also shows excellent performance, with an accuracy of 90.8%, an increase of 8.1 percentage points compared to LSTM-PTRE. Although it is slightly lower than the PTRE model by 1.3 percentage points, this result further emphasizes that Tiny-PTRE has significantly improved in accuracy compared to LSTM-PTRE, while still maintaining a level similar to PTRE.

[0235] Figure 6The experimental results of the three models in terms of recall are shown. On the NYT dataset and WebNLG dataset, the PTRE model performed well, achieving a recall of 93% and 94% respectively. In contrast, the recall of the LSTM-PTRE model was even less than half of that of the PTRE model. After knowledge distillation, the Tiny-PTRE model achieved significant performance improvement, with a recall of 91.7% on the NYT dataset, which is only 1.3 percentage points lower than the PTRE model, but 8.3 percentage points higher than the LSTM-PTRE model. On the WebNLG dataset, the recall of the Tiny-PTRE model reached 92.9%, which is slightly lower than the PTRE model by 1.1 percentage points, but 8.8 percentage points higher than the LSTM-PTRE model. Overall, Tiny-PTRE has achieved significant improvements in recall, showing a generalization ability comparable to that of the PTRE model.

[0236] Figure 7 Three models are presented in F 1 The experimental results on the value of PTRE model are shown in Figure 2. 1 The Tiny-PTRE algorithm has shown excellent performance in terms of the value, and Tiny-PTRE has also achieved significant improvement after knowledge distillation. On the NYT dataset, Tiny-PTRE achieved an F value of 90.4. 1 The value is slightly lower than the PTRE model by 1.9, but higher than the LSTM-PTRE model by 7.8. On the WebNLG dataset, Tiny-PTRE achieves an F value of 91.8. 1 The value is slightly lower than 1.3 of the PTRE model, but it is 8.4 higher than the LSTM-PTRE model. This series of results shows that Tiny-PTRE has a better performance in F after knowledge distillation. 1 The values ​​of Tiny-PTRE and LSTM-PTRE have been significantly improved, especially compared with the LSTM-PTRE model, which shows a more obvious superiority. This further verifies the effectiveness of knowledge distillation in improving model performance, making Tiny-PTRE closer to PTRE in terms of comprehensive consideration of accuracy and recall.

[0237] Taking the above three performance indicators into consideration, the Tiny-PTRE model is obviously better than the LSTM-PTRE model, and its performance is close to the level of the PTRE model. Under the guidance of the teacher model, the student model successfully undergoes the knowledge distillation process, making its generalization ability close to the level of the teacher model. Tiny-PTRE not only obtains the advantages of the simplicity and lightness of the student model, but also maintains the generalization ability comparable to that of the teacher model, further proving the effectiveness of knowledge distillation in improving model performance.

[0238] In order to solve the problem that the PTRE model requires a large GPU memory capacity and takes a long time to train, this application proposes a Tiny-PTRE model based on knowledge distillation. The complex and high-performance PTRE model is used as the teacher model, and the simple and low-performance LSTM-PTRE model is used as the student model, so that the LSTM-PTRE model can learn the generalization ability of the PTRE model. Finally, a more lightweight Tiny-PTRE model is obtained. Through experiments, it is found that the Tiny-PTRE model can show significant improvements in GPU memory usage and training time compared to the original PTRE model while maintaining a certain performance.

[0239] The present application embodiment provides an entity relationship extraction device, such as Figure 8 As shown, the device includes: an acquisition module 101, a processing module 102, a first generation module 103, a second generation module 104, a third generation module 105 and an entity relationship module 106;

[0240] The acquisition module 101 is used to acquire sentence text from a preset corpus; the processing module 102 is used to perform word segmentation processing on the sentence text to obtain a sentence text sequence; the first generation module 103 is used to construct a two-dimensional matrix according to the sentence text sequence and a preset potential relationship data set sequence; the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence; the second generation module 104 is used to obtain subject-object bigrams according to the two-dimensional matrix; the third generation module 105 is used to obtain subject-relation bigrams and relation-object bigrams according to the two-dimensional matrix based on a preset machine learning model; the entity relationship module 106 is used to obtain entity relationship triples according to the subject-object bigrams, the subject-relation bigrams and the relation-object bigrams.

[0241] Specifically, the device further includes: an extraction module;

[0242] The extraction module is used to fill the sentence text corresponding area in the two-dimensional matrix using the BIOES annotation method and Mask operation based on the supervised learning model; and extract the subject-object tuple according to the filled two-dimensional matrix.

[0243] The embodiment of the present application provides a knowledge question answering system based on an entity relationship extraction model, including the entity relationship extraction device in the above embodiment;

[0244] In an embodiment of the present application, a soybean planting management knowledge graph is constructed based on an entity relationship extraction model and entity relationship triples.

[0245] Specifically, the entity relationship triples are exported into CSV files, and then the CSV files are imported in batches through Cypher statements to create nodes and relationships in the graph database.

[0246] For example, the knowledge graph is stored in the graph database Neo4j. After construction, it contains 608 entities and 722 relationships. Entities are represented by circular nodes, and edges pointed by arrows represent the relationship between entities.

[0247] In the implementation of this application, based on the TextCNN model, a soybean planting question and answer system is constructed according to the preset question corpus, preset questions and soybean planting management knowledge graph.

[0248] Specifically, the soybean planting question-answering system is based on BERT technology, and word vectors are obtained according to preset questions; based on the TextCNN model, a question classification model is trained according to the preset question corpus; based on the TextCNN model and the question classification model, question category labels are selected according to word vectors; and answers are output based on question category labels, soybean planting management knowledge graph and word vectors.

[0249] The question classification model is systematically trained using the question corpus to ensure that the model can accurately understand and classify user queries. In response to frequently input questions from users, this application sets up 12 types of question templates for questions, including causes, prevention and control methods, symptoms, and treatment measures. Each template covers a variety of question forms for a certain type of question, and expands the data set through two methods: synonym replacement and pest and disease noun supplementation. As shown in Table 5.

[0250]

[0251] Then, the word vectors of the preset questions are obtained through the Bert technology; and the TextCNN model is used to classify the intent of the question. The main structure of TextCNN includes an embedding layer, a convolution layer, a pooling layer, and a fully connected layer. First, the TextCNN model inputs the user's question into the embedding layer and converts each word into a corresponding word vector. Then, the output of the embedding layer is convolved. The convolution process of text is similar to that of image convolution, but in natural language processing, one-dimensional convolution is usually used. The purpose of convolution is to extract local information of the text through a sliding window (also called a convolution kernel or filter) and capture the correlation between words. Next, the pooling operation is used to reduce the dimension of the convolution result to retain the most important information. Finally, the one-dimensional features of sentences of different lengths after convolution kernel processing are obtained through the pooling layer. The maximum vector obtained by integrating these features through the fully connected layer is sent to the Softmax classification layer for normalization processing, and the probability distribution of all categories is obtained. The question category label with the maximum probability is output to complete the classification task of the user's question. The answer is obtained based on the question classification label and the soybean management knowledge graph.

[0252] In an embodiment of the present application, a question-and-answer system front-end page is constructed.

[0253] Specifically, Python is used for development, and the backend is built based on the Flask framework. Flask is a lightweight web application framework written in Python. Flask can be used to easily build simple web applications. After the system is started, the server will be started on the local port. Users only need to click on the link and enter through the browser to access the homepage of the intelligent question-and-answer system for soybean planting information.

[0254] An embodiment of the present application provides a computing device, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the entity relationship extraction method described in any one of the above embodiments when executing the computer instructions.

[0255] The present application provides a storage medium, including:

[0256] Used to store computer executable instructions, which, when executed, implement the steps of the entity relationship extraction method described in any one of the above embodiments.

[0257] It should be noted that the embodiments of the storage medium in this specification and the embodiments of the blockchain-based service provision method in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the aforementioned corresponding implementation of the blockchain-based service provision method, and the repeated parts will not be repeated.

[0258] The above is a description of a specific embodiment of the specification. 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 embodiments and still achieve the desired results. In addition, the processes depicted in the 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.

[0259] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0260] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0261] It should be understood by those skilled in the art that one or more embodiments of this specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0262] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0263] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0264] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0265] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0266] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0267] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules 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, 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. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0268] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0269] One or more embodiments of the present specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0270] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0271] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.

Claims

1. A method for extracting entity relations, characterized in that: include: Get sentence text from a preset corpus; Performing word segmentation processing on the sentence text to obtain a sentence text sequence; According to the sentence text sequence and the preset potential relationship data set sequence, a two-dimensional matrix is ​​constructed; the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence; According to the two-dimensional matrix, the subject-object tuple is obtained; Based on the preset machine learning model, subject-relation bigrams and relation-object bigrams are obtained according to the two-dimensional matrix; According to the subject-object bigram, the subject-relation bigram and the relation-object bigram, an entity relation triplet is obtained.

2. The method according to claim 1, characterized in that: The subject-object tuples are obtained according to the two-dimensional matrix, including: Based on the supervised learning model, the sentence text corresponding area in the two-dimensional matrix is ​​filled using BIOES annotation method and Mask operation; According to the filled two-dimensional matrix, subject-object bigrams are extracted.

3. The method according to claim 2, characterized in that: Based on the supervised learning model, the sentence text corresponding area in the two-dimensional matrix is ​​filled using the BIOES annotation method and the Mask operation, including: Determine a region to be filled, where the region to be filled is an upper triangular region or a lower triangular region in the region corresponding to the sentence text in the two-dimensional matrix; Based on the BIOES annotation method, annotate the entity head and entity tail of the entity in the sentence text; Based on the supervised learning model, fill the entity head and entity tail in the corresponding area in the two-dimensional matrix; The Mask operation is used to assign 0 to the unfilled portion of the area corresponding to the sentence text in the two-dimensional matrix.

4. The method according to claim 1, characterized in that: The method of obtaining subject-relation bigrams and relation-object bigrams based on a preset machine learning model according to a two-dimensional matrix includes: Based on the machine learning model, determine the relationship area to be filled; the relationship area to be filled is the area in the two-dimensional matrix corresponding to the relationship text that has an association relationship with the entity; According to the binary classification, the region with relationship in the two-dimensional matrix is ​​assigned a value of 1; In a two-dimensional matrix, identify the subject and object; Determining the subject-relation dyad according to the intersection area of ​​the subject and the relation in the two-dimensional matrix; The relation-object tuple is determined according to the intersection area between the object and the relation in the two-dimensional matrix.

5. The method according to claim 4, characterized in that: The machine learning model includes a binary cross entropy loss function and a sigmoid activation function; The calculation formula of the binary cross entropy loss function is as follows: in, Represents y i and The degree of proximity between is the predicted value; y i The value of is 0 or 1; N represents the number of words in the sentence text; M represents the number of potential relationships; The sigmoid activation function calculation formula is as follows: Among them, P rel Indicates the prediction result; W r represents weight; b r Indicates the offset.

6. The method according to claim 1, characterized in that: The step of obtaining entity relationship triples according to the subject-object bigram, the subject-relation bigram and the relation-object bigram includes: According to the subject-relation bigram and the relation-object bigram, searching for the subject-object bigram; If the subject-object bigram exists, the subject-relation bigram, the relation-object bigram and the subject-object bigram are concatenated to obtain the entity relation triplet.

7. An entity relationship extraction device, characterized in that: The device comprises: an acquisition module, a processing module, a first generation module, a second generation module, a third generation module and an entity relationship module; The acquisition module is used to acquire sentence text from a preset corpus; The processing module is used to perform word segmentation processing on the sentence text to obtain a sentence text sequence; The first generating module is used to construct a two-dimensional matrix according to the sentence text sequence and the preset potential relationship data set sequence; the rows of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence, and the columns of the two-dimensional matrix correspond to the characters in the sentence text sequence and the relationships in the relationship data set sequence; The second generation module is used to obtain a subject-object tuple according to the two-dimensional matrix; The third generation module is used to obtain subject-relation bigrams and relation-object bigrams according to the two-dimensional matrix based on the preset machine learning model; The entity relationship module is used to obtain entity relationship triples according to the subject-object bigram, the subject-relation bigram and the relation-object bigram.

8. The device according to claim 7, characterized in that: The device also includes: an extraction module; The extraction module is used to fill the sentence text corresponding area in the two-dimensional matrix based on the supervised learning model using the BIOES annotation method and the Mask operation; and extract the subject-object tuple according to the filled two-dimensional matrix.

9. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer instructions, the steps of the entity relationship extraction method described in any one of claims 1-6 are implemented.

10. A storage medium, characterized in that: include: Used to store computer executable instructions, which, when executed, implement the steps of the entity relationship extraction method described in any one of claims 1 to 6.

Citation Information

Cited By

  • Data processing method and device, computer equipment and readable storage medium

    CN119647468A

  • Data processing method and device, computer device and readable storage medium

    CN119647468B