Entity relationship extraction method and device, terminal and storage medium

The entity relation extraction method enhanced by global pointer networks solves the problem of ignoring entity types in existing technologies, improves the accuracy and interpretability of entity relation extraction, and is compatible with existing annotation tools, thus improving efficiency and adaptability.

CN117150047BActive Publication Date: 2026-03-24SUZHOU WEIZHONG DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-13
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing entity relationship extraction schemes ignore entity type information, resulting in insufficient completeness of the extraction results in subsequent applications and an inability to effectively utilize entity type information.

Method used

A global pointer network is used to enhance the entity relation extraction method. Through serialization processing and pre-trained encoding model, the entity span and type are calculated, the position and type of the head and tail entities are predicted, and alignment matching is performed. The cross-entropy loss function is used to optimize the model parameters, thereby improving the accuracy and interpretability of entity relation extraction.

Benefits of technology

It enables detailed processing of entity types, improves the accuracy and interpretability of entity relation extraction, and the output results are compatible with existing annotation tools, reducing the workload of manual review and improving efficiency and adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117150047B_ABST
    Figure CN117150047B_ABST
Patent Text Reader

Abstract

The application relates to an entity relationship extraction method and device, a terminal and a storage medium. The method comprises the following steps: performing serialization processing on text information, obtaining a text coding result through model processing; the head entity span and the tail entity span in the text sequence are calculated according to the text coding result, and then the head position and tail position of the head entity and the corresponding head entity type, the head position and tail position of the tail entity and the corresponding tail entity type are obtained; the head position and tail position of the head entity and the head position and tail position of the tail entity are matched, the relationship between the head entity and the tail entity is determined according to the matching result; the information is summarized to form an entity relationship extraction result, which is output for the text information. The application can accurately process the entity type and accurately predict the associated relationship, and the finally output entity relationship extraction result has high accuracy, practicality and expandability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of natural language processing, and particularly relates to an entity relation extraction method and device based on global pointer network enhancement, a terminal and a storage medium. BACKGROUND

[0002] In the field of natural language processing (NLP), entity relation extraction is a key task aiming to extract entity pairs with specific semantic relations from unstructured text. Entity relation extraction has important application value in many scenarios, such as information extraction, question answering, and knowledge graph construction.

[0003] Previous entity relation extraction schemes usually only focus on the head entity, tail entity and entity relation, and the extraction result is usually a relation triple (head entity, relation, tail entity). In terms of the extraction result itself, it completely ignores the type information of the entity. However, in subsequent application scenarios, the type information of the entity can play a huge role in understanding the entity relation, so the above traditional entity relation extraction scheme needs to be improved in terms of the completeness of the result.

[0004] Therefore, how to propose a new entity relation extraction scheme to achieve detailed processing of the entity type in the entity relation extraction process and improve the accuracy and interpretability of entity relation extraction has become a problem to be solved by those skilled in the art. SUMMARY

[0005] In order to improve the existing entity relation extraction scheme, the present application provides an entity relation extraction method, device, terminal and storage medium. The scheme of the present application fully utilizes the global pointer network, realizes the detailed processing of the entity type in the entity relation extraction process, and improves the accuracy and interpretability of the entity relation extraction.

[0006] In a first aspect, the present application provides an entity relation extraction method adopting the technical scheme as follows.

[0007] An entity relation extraction method includes the following steps:

[0008] serializing the obtained text information to obtain a text sequence, and inputting the text sequence into a pre-trained encoding model to obtain a text encoding result;

[0009] The head entity span and the tail entity span in the text sequence are calculated according to the text encoding result respectively, the head entity prediction is performed according to the head entity span, the first and last positions of the head entity and the corresponding head entity type are obtained, the tail entity prediction is performed according to the tail entity span, the first and last positions of the tail entity and the corresponding tail entity type are obtained;

[0010] The first and last positions of the head entity and the first and last positions of the tail entity are aligned and matched, and the relationship between the head entity and the tail entity is determined according to the alignment and matching result;

[0011] The first and last positions of the head entity, the head entity type, the relationship between the head entity and the tail entity, the first and last positions of the tail entity, and the tail entity type are summarized to form an entity relationship extraction result, which is output as the text information.

[0012] By using the above technical solution, the global pointer network technical architecture is used to effectively capture and utilize the head and tail entity types to enhance the global information in the entity relationship extraction process. Compared with the existing local context entity relationship extraction, the global pointer network can more accurately identify the head entity and the tail entity, and complete entity alignment in the global range, thereby maximizing the accuracy of the entity relationship extraction result.

[0013] In addition, the above technical solution has high adaptability to existing labeling tools, and the output entity relationship extraction result can be directly imported into the labeling tool, which provides convenience for subsequent review and revision by professionals, and further improves the efficiency and usability of entity relationship extraction.

[0014] Preferably, the text information is obtained, and the text information is sequentially processed to obtain a text sequence. The text sequence is input into a pre-trained encoding model to obtain a text encoding result. Specifically, the following steps are included:

[0015] The text information is obtained, and the text information is sequentially processed and corresponding marks are added at the beginning and end of the text to obtain a text sequence.

[0016] The text sequence is input into a pre-trained encoding model, and the output of the encoding model is used as the text encoding result. The marks are adapted to the encoding model, and the encoding model is a BERT-Encoder model.

[0017] By using the above technical solution, the generation process of the text encoding result of the method is further clarified, which provides basic technical support for subsequent processing of the method.

[0018] Preferably, the head entity span and the tail entity span in the text sequence are calculated according to the text encoding result respectively, the head entity prediction is performed according to the head entity span, the start and end positions of the head entity and the corresponding head entity type are obtained, the tail entity prediction is performed according to the tail entity span, the start and end positions of the tail entity and the corresponding tail entity type are obtained, and the specific steps include the following steps:

[0019] The head entity span and the tail entity span in the text sequence are calculated according to the text encoding result respectively, the start index and the end index of the head entity are included in the head entity span, and the start index and the end index of the tail entity are included in the tail entity span.

[0020] The start position of the head entity and the end position of the head entity are obtained according to the start index and the end index of the head entity, the score of the head entity as a specific head entity type is calculated according to the start position of the head entity and the end position of the head entity, and the corresponding head entity type of the head entity is determined according to the score.

[0021] The start position of the tail entity and the end position of the head entity are obtained according to the start index and the end index of the tail entity, the score of the tail entity as a specific tail entity type is calculated according to the start position of the tail entity and the end position of the tail entity, and the corresponding tail entity type of the tail entity is determined according to the score.

[0022] By adopting the above technical scheme, the entity type information is considered in the head entity and tail entity extraction process, the head entity prediction and tail entity prediction process can accurately identify the specific entity type, the overall entity discrimination ability of the method is enhanced, and the risk of false extraction is reduced.

[0023] Preferably, the start and end positions of the head entity and the start and end positions of the tail entity are aligned and matched, and the relationship between the head entity and the tail entity is determined according to the alignment and matching result, and the specific steps include the following steps:

[0024] The matching score of the start index of the head entity and the start index of the tail entity under a specific relationship is calculated according to the start position of the head entity and the start position of the tail entity, and is taken as the first alignment and matching result.

[0025] The matching score of the end index of the head entity and the end index of the tail entity under a specific relationship is calculated according to the end position of the head entity and the end position of the tail entity, and is taken as the second alignment and matching result.

[0026] The relationship alignment between the head entity and the tail entity is completed by combining the first alignment matching result and the second alignment matching result, and the relationship between the head entity and the tail entity corresponding to the head entity and the tail entity is determined.

[0027] By using the above technical solution, the association between the head entity and the tail entity is quickly and accurately obtained, and the relationship between the two is predicted. Considering the semantic association of the head entity and the tail entity, the device or model based on the method can better understand the relationship between entities, thereby improving the integrity of the final entity relationship extraction result.

[0028] Preferably, the entity relationship extraction method further comprises the following steps:

[0029] The loss value of the entity relationship extraction result corresponding to the text information is calculated using a loss function, the loss function is a cross-entropy loss function, the entity loss under the head entity type, the entity loss under the tail entity type, the start index matching loss of the head and tail entity under the relationship alignment, and the end index matching loss of the head and tail entity under the relationship alignment are obtained, and then the total extraction loss is calculated. The parameters in the head entity prediction, the tail entity prediction and the alignment matching process are adjusted and iterated according to the total extraction loss until the total extraction loss after iteration is less than a preset value.

[0030] By using the above technical solution, the verification of the entity relationship extraction process is realized, which provides necessary training and reasoning for the device or model based on the method, and maximizes the effectiveness and accuracy of the whole method.

[0031] In a second aspect, the present application provides an entity relationship extraction device, which adopts the following technical solution.

[0032] An entity relationship extraction device comprises the following modules:

[0033] A text information encoding module is configured to perform serialization processing on the obtained text information to obtain a text sequence, and input the text sequence into a pre-trained encoding model to obtain a text encoding result;

[0034] A head and tail entity extraction module is configured to calculate the head entity span and the tail entity span in the text sequence according to the text encoding result, perform head entity prediction according to the head entity span to obtain the start and end positions of the head entity and the corresponding head entity type, and perform tail entity prediction according to the tail entity span to obtain the start and end positions of the tail entity and the corresponding tail entity type.

[0035] The entity relationship alignment module is configured to align the head and tail positions of the head entity and the head and tail positions of the tail entity, and determine the relationship between the head and tail entities according to the alignment result.

[0036] The extraction result output module is configured to aggregate information of the head and tail positions of the head entity, the head entity type, the relationship between the head and tail entities, the head and tail positions of the tail entity, and the tail entity type, form an entity relationship extraction result, and output the entity relationship extraction result as the output for the text information.

[0037] Preferably, the entity relationship extraction device further comprises the following modules:

[0038] The extraction result verification module is configured to calculate a loss value of the entity relationship extraction result corresponding to the text information by using a loss function, the loss function is a cross-entropy loss function, and entity losses under the head entity type and the tail entity type, a head and tail entity start index matching loss under relationship alignment, and a head and tail entity end index matching loss under relationship alignment are obtained respectively, and then a total extraction loss is calculated, and parameters in the head entity prediction, the tail entity prediction, and the alignment process are adjusted and iterated according to the total extraction loss, until the total extraction loss after iteration is less than a preset value.

[0039] By adopting the above technical solutions, the automation and convenience of the entity relationship extraction process are realized, the entity relationship extraction device or model constructed can greatly reduce the labor workload in the operation process, improve the extraction efficiency, and greatly shorten the extraction time. Meanwhile, the device can also adapt to various labeling tools in the prior art, and has high adaptability and compatibility.

[0040] In a third aspect, the present application provides an intelligent terminal, which adopts the following technical solutions:

[0041] An intelligent terminal, comprising a memory and a processor, the memory stores at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to realize the entity relationship extraction method as described above.

[0042] In a fourth aspect, the present application provides a computer readable storage medium, which adopts the following technical solutions:

[0043] A computer readable storage medium, the readable storage medium stores at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to realize the entity relationship extraction method as described above.

[0044] In summary, the entity relation extraction scheme based on the global pointer network enhancement provided in the application can process entity types in detail and accurately predict the associated relations, and the finally output entity relation extraction result has high accuracy, practicality and expandability. Therefore, the scheme of the application can play a great role in information extraction, question answering, knowledge graph construction and other scenes, and has high application value. BRIEF DESCRIPTION OF DRAWINGS

[0045] In order to more clearly illustrate the specific embodiments of the application or the technical solutions in the prior art, the drawings needed in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the application, and those skilled in the art can also refer to these drawings to obtain other drawings without creative labor.

[0046] Figure 1 is a flowchart of the entity relation extraction method of the embodiment of the application;

[0047] Figure 2 is a flowchart of the S1 step in the entity relation extraction method of the embodiment of the application;

[0048] Figure 3 is a flowchart of the S2 step in the entity relation extraction method of the embodiment of the application;

[0049] Figure 4 is a flowchart of the S3 step in the entity relation extraction method of the embodiment of the application;

[0050] Figure 5 is an architectural diagram of the entity relation extraction device of the embodiment of the application. DETAILED DESCRIPTION

[0051] The application provides an entity relation extraction method, device, terminal and storage medium. The detailed processing of entity types in the entity relation extraction process is realized, and the accuracy and interpretability of entity relation extraction are improved. To make the purpose, technical scheme and advantages of the application clearer, the embodiments of the application will be further described in detail.

[0052] In order to facilitate the understanding of the subsequent steps, before the specific explanation of the scheme, the entity relation extraction of the text is simply explained and defined.

[0053] For a given text T = [x1, x2, ···, x l ], l represents the length of the text, and it is assumed that the text contains n head entities S = {s1, s2, ···, sn} n}, m tail entities O = {o1, o2, ..., o m There are r relations P = {p1, p2, ..., p} between the head and tail entities. r There exist a header entity types S_TYPE={s_t1,s_t2,···,s_t}. a}, b tail entity types O_TYPE={o_t1,o_t2,···,o_t b Therefore, the goal of this scheme can be summarized as follows: to extract all entity relation groups (S, S_TYPE, P, O, O_TYPE) from text T and seamlessly integrate them into an entity relation annotation tool for review and revision by professionals. This achieves efficient and accurate entity relation extraction and lays a solid foundation for subsequent applications such as knowledge graph construction. In the entity relation group, the head entity S and the tail entity O are composed of (sh, st) and (oh, ot) fragments, respectively. Here, sh and oh represent the head and tail indices of the head entity S in text T, and oh and ot represent the head and tail indices of the tail entity O in text T. Therefore, the final extraction target is actually a seven-tuple (sh, st, s_TYPE). type ,p,oh,ot,o type ).

[0054] The following describes in further detail an embodiment of a microservice deployment method of this application with reference to the accompanying drawings.

[0055] An entity relation extraction method, such as Figure 1 As shown, it includes the following steps:

[0056] S1. The acquired text information is serialized to obtain a text sequence. The text sequence is then input into a pre-trained encoding model to obtain the text encoding result. For example... Figure 2 As shown, this step includes the following process.

[0057] S11. Obtain text information, perform serialization processing on the text information, and add corresponding markers at the beginning and end of the text to obtain a text sequence.

[0058] S12. Input the text sequence into a pre-trained encoding model and use the output of the encoding model as the text encoding result. The marker is adapted to the encoding model. The encoding model is a BERT-Encoder model, which includes prediction context information and location information.

[0059] The above process will be illustrated by a specific embodiment below.

[0060] Given a sequence X with l tokens, we map sequence X to the BERT input sequence X.input =[x0,x1,···,x n+1 Here, x0 represents the "[CLS]" marker at the beginning of the text segment, x n+1 This represents the "[SEP]" marker at the end of a text segment. After encoding by the BERT-Encoder model, the corresponding token is represented as H = [v0, v1, ..., v...]. n+1 Here, v0 marked with "[CLS]" is considered a specific marker for the entire sequence task, and H is the word embedding task used downstream. H is calculated in the following form:

[0061] H = BERT-Encoder(X) input ).

[0062] To ensure the smoothness of the subsequent entity relationship extraction process, after completing the aforementioned process, it is also necessary to score and decompose the extraction target as described above.

[0063] As mentioned earlier, the final extraction target is actually a seven-tuple (sh, st, s). type ,p,oh,ot,o type The approach to constructing a joint extraction model from a probabilistic graphical perspective is to first design a seven-tuple scoring function, Score(sh,st,s). type ,p,oh,ot,o type Then, during model training, the labeled seven-tuple Score(sh,st,s) is identified. type ,p,oh,ot,o type If ) > 0, the remaining Score(sh,st,s) type ,p,oh,ot,o type ) < 0; then during model prediction, all possible 7-tuples are enumerated, and only Score(sh,st,s) is output. type ,p,oh,ot,o type The part where ) > 0 is sufficient. However, enumerating all tuples results in too many outputs. Assuming a text segment of length m and n relations, the number N to enumerate 7-tuples is expressed as follows:

[0064]

[0065] Since the above calculation expression is difficult to execute in practice, the following method is used to decompose the seven-tuple scoring function:

[0066] Score(sh,st,s type ,p,oh,ot,o type )

[0067] Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p) type Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p) type Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p)

[0068] Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p) type Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p) type Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p)

[0069] Score(sh, st) + Score(sh, ot) + Score(sh, oh | p) + Score(st, ot | p)

[0070] Score(sh, st) and Score(oh, ot) represent the head entity and tail entity scores, respectively, and the head entity and tail entity are parsed by Score(sh, st) > 0 and Score(oh, ot) > 0.

[0071] Score(sh, st) and Score(oh, ot) represent the head entity and tail entity scores, respectively, and the head entity and tail entity are parsed by Score(sh, st) > 0 and Score(oh, ot) > 0. type Score(sh, st) and Score(oh, ot) represent the head entity and tail entity scores, respectively, and the head entity and tail entity are parsed by Score(sh, st) > 0 and Score(oh, ot) > 0. type Score(sh, st) and Score(oh, ot) represent the head entity and tail entity scores, respectively, and the head entity and tail entity are parsed by Score(sh, st) > 0 and Score(oh, ot) > 0.

[0072] S2, the head entity span and the tail entity span in the text sequence are calculated according to the text encoding result, the head entity prediction is performed according to the head entity span, the start and end positions of the head entity and the corresponding head entity type are obtained, and the tail entity prediction is performed according to the tail entity span, the start and end positions of the tail entity and the corresponding tail entity type are obtained. Figure 3 As shown in the figure, this step includes the following processes.

[0073] S21, the head entity span and the tail entity span in the text sequence are calculated according to the text encoding result, the head entity span includes the start index and the end index of the head entity, and the tail entity span includes the start index and the end index of the tail entity.

[0074] S22, the start position of the head entity and the end position of the head entity are obtained according to the start index and the end index of the head entity, and the score of the head entity as a specific head entity type is calculated according to the start position of the head entity and the end position of the head entity, and the corresponding head entity type of the head entity is determined.

[0075] S23. Based on the start index and end index of the tail entity, the start position of the tail entity and the end position of the head entity are obtained respectively. Based on the start position and end position of the tail entity, the score of the tail entity as a specific tail entity type is calculated and the tail entity type corresponding to the tail entity is determined accordingly.

[0076] The above process will continue to be explained using the specific embodiments described above.

[0077] As mentioned earlier, H has been obtained through encoding by the BERT-Encoder model. Then, the span representations S[i:j] and O[i:j] of the head entity and tail entity are calculated respectively. To this end, this scheme specifically designs a head entity prediction unit and a tail entity prediction unit. Each unit uses two independent feedforward network layers, which depend on the start and end indices of the span.

[0078]

[0079]

[0080] in, They represent s respectively type The vector representation of the type entity's label, where d represents the size of the embedded hidden dimension. Specifically, for s type The type entity span is S[i:j], and the start and end positions are respectively... and This indicates that for the head entity S[i:j] as s type The score for a type of entity is calculated as follows:

[0081]

[0082] in, Let be the mask matrix for the header entity. Since the start index of the header entity is less than or equal to the end index, i.e., i ≤ j, therefore The value in the lower left triangle is obscured.

[0083] Similarly, the tail entity O[i:j] can be obtained as o type Score of type entity The calculation method is as follows:

[0084]

[0085] S3. Align and match the head and tail positions of the head entity and the tail entity, and determine the relationship between the head and tail entities based on the alignment and matching results. For example... Figure 4 As shown, this step includes the following process.

[0086] S31, calculating a matching score of start indexes of the head entity and the tail entity under a specific relation according to the start position of the head entity and the start position of the tail entity, and taking the matching score as a first alignment matching result;

[0087] S32, calculating a matching score of end indexes of the head entity and the tail entity under a specific relation according to the end position of the head entity and the end position of the tail entity, and taking the matching score as a second alignment matching result;

[0088] S33, integrating the first alignment matching result and the second alignment matching result, completing the relation alignment between the head entity and the tail entity, and determining the relation between the head entity and the tail entity corresponding to the head entity and the tail entity.

[0089] The following continues to use the specific embodiments in the foregoing to describe the above process.

[0090] Here, the entity relation alignment is performed by using the global pointer network, so as to align and match the relation between the head entity and the tail entity. It has been mentioned in the foregoing that, after the processing of the head entity prediction unit and the tail entity prediction unit, the relation alignment of the head entity and the tail entity depends on the start indexes sh and oh of the head entity and the tail entity, and for the nested entity, depends on the matching between the start indexes and the end indexes of the head entity and the tail entity.

[0091] q i,h_r = W q,h_r v i + b q,h_r ,

[0092] k j,h_r = W k,h_r v j + b k,h_r .

[0093] wherein, respectively represent the vector representation of the label of the head entity and the tail entity, and d represents the embedding hidden dimension size. Specifically, under the r relation, the start positions of the head entity and the tail entity are represented by q i,h_r and k j,h_r , the start index matching score of the head entity and the tail entity, and the calculation form is as follows:

[0094] s h_r (i,j) = q i,h_r k j,h_r .

[0095] Similarly, the end index matching score s t_r of the head entity and the tail entity can be obtained, and the calculation form is as follows:

[0096] st_r (i,j)=q i,t_r k j,t_r .

[0097] S4, information is summarized on the head-tail position of the head entity, the head entity type, the relationship between the head-tail entity, the head-tail position of the tail entity, the tail entity type, an entity relationship extraction result is formed and output as the output for the text information.

[0098] It should be noted here that the entity relationship extraction result output in the present scheme can be directly imported into a labeling tool for professional personnel to intuitively view the extraction result and make necessary corrections.

[0099] S5, loss value calculation is performed on the entity relationship extraction result corresponding to the text information using a loss function, the loss function is a cross-entropy loss function, entity loss under the head entity type, entity loss under the tail entity type, head-tail entity start index matching loss under relationship alignment, and tail entity end index matching loss under relationship alignment are obtained, and then total extraction loss is calculated, and the parameters in the head entity prediction, the tail entity prediction and the alignment matching process are adjusted and iterated according to the total extraction loss, until the total extraction loss after iteration is less than a preset value.

[0100] The above process will be described below using the specific embodiments in the foregoing.

[0101] The essence of the method is to build an entity relationship extraction model, and a multi-label cross-entropy is introduced as a loss function in the model training process, the purpose of which is to minimize the distance between positive samples and maximize the distance between negative samples.

[0102] The multi-label cross-entropy loss function is defined as follows:

[0103]

[0104] Where P and N represent the positive and negative class sets respectively. Since the entity distribution in the data is relatively sparse, if the above objective function is used for optimization, a large number of negative sample losses will be introduced, and the training cost will also be greatly improved. Here we use a relatively "sparse" multi-label cross-entropy, which only transmits the subscript corresponding to the positive sample each time. Since the number of positive samples is much smaller than the number of negative samples, the matrix size will be greatly reduced. Therefore, the cross-entropy loss function calculation formula after optimization is as follows:

[0105]

[0106] Where A=P∪N represents the total sample.

[0107] According to the loss function defined above, the objective function in this paper is composed of four parts, which are entity loss under head type loss s , entity loss under tail type loss o , head-tail entity start index matching loss under relationship alignment loss h , and head-tail entity end index matching loss under relationship alignment loss t , and the calculation form of total loss total loss is as follows:

[0108] total loss = loss s + loss o + loss h + loss t .

[0109] Based on the same inventive concept as described above, the embodiments of the present application also disclose an entity relationship extraction device, i.e. an entity relationship extraction model, which will be described in further detail below in combination with the drawings of the specification.

[0110] An entity relationship extraction device, as shown in Figure 5 , comprises the following modules:

[0111] A text information encoding module is configured to perform serialization processing on the obtained text information to obtain a text sequence, and input the text sequence into a pre-trained encoding model to obtain a text encoding result;

[0112] A head-tail entity extraction module is configured to calculate a head entity span and a tail entity span in the text sequence according to the text encoding result, perform head entity prediction according to the head entity span to obtain the start and end positions of the head entity and the corresponding head entity type, and perform tail entity prediction according to the tail entity span to obtain the start and end positions of the tail entity and the corresponding tail entity type;

[0113] An entity relationship alignment module is configured to align and match the start and end positions of the head entity and the start and end positions of the tail entity, and determine the relationship between the head-tail entities according to the alignment and matching result;

[0114] An extraction result output module is configured to information aggregate the start and end positions of the head entity, the head entity type, the relationship between the head-tail entities, the start and end positions of the tail entity, and the tail entity type, form an entity relationship extraction result, and output the entity relationship extraction result as the output for the text information.

[0115] It needs to be explained that the device further comprises an extraction result checking module configured to calculate a loss value of the entity relation extraction result corresponding to the text information using a loss function, the loss function is a cross-entropy loss function, and entity losses under head entity types, entity losses under tail entity types, head-tail entity start index matching losses under relation alignment, and head-tail entity end index matching losses under relation alignment are obtained respectively, and then an extraction total loss is calculated. The parameters in the head entity prediction, the tail entity prediction and the alignment matching process are adjusted and iterated according to the extraction total loss, until the extraction total loss after iteration is less than a preset value.

[0116] In a possible implementation, the text information encoding module specifically comprises the following units:

[0117] A text sequence generation unit configured to obtain text information, perform serialization processing on the text information, and add corresponding marks at the beginning and end of the text to obtain a text sequence.

[0118] An encoding result output unit configured to input the text sequence into a pre-trained encoding model and take the output of the encoding model as a text encoding result.

[0119] In a possible implementation, the head-tail entity extraction module specifically comprises the following units:

[0120] An entity span generation unit configured to calculate a head entity span and a tail entity span in the text sequence according to the text encoding result, the head entity span comprising a start index and an end index of the head entity, and the tail entity span comprising a start index and an end index of the tail entity.

[0121] A head entity prediction unit configured to obtain a start position of the head entity and an end position of the head entity according to the start index and the end index of the head entity, and calculate a score of the head entity as a specific head entity type according to the start position of the head entity and the end position of the head entity, and determine a head entity type corresponding to the head entity according to the score.

[0122] A tail entity prediction unit configured to obtain a start position of the tail entity and an end position of the head entity according to the start index and the end index of the tail entity, and calculate a score of the tail entity as a specific tail entity type according to the start position of the tail entity and the end position of the tail entity, and determine a tail entity type corresponding to the tail entity according to the score.

[0123] In a possible implementation, the entity relation alignment module specifically comprises the following units:

[0124] The first alignment matching unit is configured to calculate a matching score of starting indexes of the head entity and the tail entity under a specific relationship according to the starting position of the head entity and the starting position of the tail entity, and take the matching score as a first alignment matching result.

[0125] The second alignment matching unit is configured to calculate a matching score of ending indexes of the head entity and the tail entity under a specific relationship according to the ending position of the head entity and the ending position of the tail entity, and take the matching score as a second alignment matching result.

[0126] The relationship alignment execution unit is configured to complete the relationship alignment between the head entity and the tail entity by comprehensively considering the first alignment matching result and the second alignment matching result, and determine the relationship between the head entity and the tail entity corresponding to the head entity and the tail entity.

[0127] Based on the same inventive concept, the embodiment of the present application further discloses an intelligent terminal, comprising a memory and a processor, the memory stores at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to realize the entity relationship extraction method as described above.

[0128] It should be understood that "multiple" mentioned herein refers to two or more. "And / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents that the associated objects before and after it are in an "or" relationship.

[0129] Based on the same inventive concept, the embodiment of the present application further discloses a computer readable storage medium, the readable storage medium stores at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to realize the entity relationship extraction method as described above.

[0130] Those skilled in the art should understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructing relevant hardware to complete, and the program can be stored in a computer readable storage medium, such as U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and various program code storage media.

[0131] The above merely provides the optional embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for extracting entity relations, characterized in that, Includes the following steps: The acquired text information is serialized to obtain a text sequence, and the text sequence is input into a pre-trained encoding model to obtain the text encoding result. Based on the text encoding results, the head entity span and tail entity span in the text sequence are calculated respectively. Based on the head entity span, head entity prediction is performed to obtain the first and last positions of the head entity and the corresponding head entity type. Based on the tail entity span, tail entity prediction is performed to obtain the first and last positions of the tail entity and the corresponding tail entity type. The head and tail positions of the head entity and the tail entity are aligned and matched, and the relationship between the head and tail entities is determined based on the alignment and matching results. The information about the beginning and end positions of the head entity, the type of the head entity, the relationship between the head and tail entities, the beginning and end positions of the tail entity, and the type of the tail entity is summarized to form an entity relationship extraction result, which is then used as the output for the text information. The process of calculating the head entity span and tail entity span in the text sequence based on the text encoding result, predicting head entities based on the head entity span to obtain the first and last positions of the head entities and their corresponding head entity types, and predicting tail entities based on the tail entity span to obtain the first and last positions of the tail entities and their corresponding tail entity types specifically includes the following steps. Based on the text encoding results, the head entity span and tail entity span in the text sequence are calculated respectively. The head entity span includes the start index and end index of the head entity, and the tail entity span includes the start index and end index of the tail entity. Based on the start and end indices of the header entity, the start and end positions of the header entity are obtained. Based on these positions, a score is calculated for the header entity as a specific header entity type, and the corresponding header entity type is determined accordingly. Based on the start index and end index of the tail entity, the start position of the tail entity and the end position of the head entity are obtained respectively. Based on the start position and end position of the tail entity, the score of the tail entity as a specific tail entity type is calculated and the tail entity type corresponding to the tail entity is determined accordingly. The step of aligning and matching the head and tail positions of the head entity and the tail entity, and determining the relationship between the head and tail entities based on the alignment and matching results, specifically includes the following steps. Based on the start positions of the head entity and the tail entity, the matching score of the start indices of the head entity and the tail entity under a specific relationship is calculated and used as the first alignment matching result. Based on the end positions of the head entity and the tail entity, the matching score of the end indices of the head entity and the tail entity under a specific relationship is calculated and used as the second alignment matching result. By combining the first alignment matching result and the second alignment matching result, the relationship between the head entity and the tail entity is aligned, and the relationship between the head and tail entities corresponding to the head entity and the tail entity is determined.

2. The entity relation extraction method according to claim 1, characterized in that, The process of serializing the acquired text information to obtain a text sequence, and then inputting the text sequence into a pre-trained encoding model to obtain the text encoding result, specifically includes the following steps: Obtain text information, serialize the text information, and add corresponding markers at the beginning and end of the text to obtain a text sequence; The text sequence is input into a pre-trained encoding model, and the output of the encoding model is used as the text encoding result. The tag is adapted to the encoding model, which is the BERT-Encoder model.

3. The entity relation extraction method according to claim 1, characterized in that, It also includes the following steps: The loss function is used to calculate the loss value of the entity relation extraction result corresponding to the text information. The loss function is the cross-entropy loss function. The entity loss under the head entity type, the entity loss under the tail entity type, the head and tail entity start index matching loss under relation alignment, and the head and tail entity end index matching loss under relation alignment are obtained respectively. Then, the total extraction loss is calculated. Based on the total extraction loss, the parameters of the head entity prediction, the tail entity prediction, and the alignment matching process are adjusted and iterated until the total extraction loss after iteration is less than a preset value.

4. An entity relationship extraction device, characterized in that, Includes the following modules: The text information encoding module is configured to serialize the acquired text information to obtain a text sequence, and input the text sequence into a pre-trained encoding model to obtain the text encoding result. The head and tail entity extraction module is configured to calculate the head entity span and tail entity span in the text sequence based on the text encoding result, predict the head entity based on the head entity span to obtain the head and tail positions of the head entity and the corresponding head entity type, and predict the tail entity based on the tail entity span to obtain the tail entity positions of the tail entity and the corresponding tail entity type. The entity relationship alignment module is configured to align and match the beginning and end positions of the head entity and the beginning and end positions of the tail entity, and determine the relationship between the head and tail entities based on the alignment and matching results. The extraction result output module is configured to summarize the information of the head entity's first and last positions, the head entity type, the relationship between the head and tail entities, the tail entity's first and last positions, and the tail entity type, form the entity relationship extraction result, and output it as the text information. The head and tail entity extraction module specifically includes the following units: The entity span generation unit is configured to calculate the head entity span and tail entity span in the text sequence based on the text encoding result. The head entity span includes the start index and end index of the head entity, and the tail entity span includes the start index and end index of the tail entity. The head entity prediction unit is configured to obtain the start position and end position of the head entity based on its start index and end index, respectively; calculate the score of the head entity as a specific head entity type based on the start position and end position of the head entity; and determine the corresponding head entity type based on this score. The tail entity prediction unit is configured to obtain the start position of the tail entity and the end position of the head entity based on the start index and end index of the tail entity, respectively, calculate the score of the tail entity as a specific tail entity type based on the start position and end position of the tail entity, and determine the tail entity type corresponding to the tail entity accordingly. The entity relationship alignment module specifically includes the following units: The first alignment matching unit is configured to calculate the matching score of the start indices of the head entity and the tail entity under a specific relationship based on the start position of the head entity and the start position of the tail entity, and use this score as the first alignment matching result. The second alignment matching unit is configured to calculate the matching score of the end indices of the head entity and the tail entity under a specific relationship based on the end position of the head entity and the end position of the tail entity, and use this score as the second alignment matching result. The relationship alignment execution unit is configured to integrate the first alignment matching result and the second alignment matching result to complete the relationship alignment between the head entity and the tail entity, and determine the relationship between the head and tail entities corresponding to the head entity and the tail entity.

5. The entity relationship extraction device according to claim 4, characterized in that, It also includes the following modules: The extraction result verification module is configured to use a loss function to calculate the loss value of the entity relationship extraction result corresponding to the text information. The loss function is the cross-entropy loss function, which obtains the entity loss under the head entity type, the entity loss under the tail entity type, the head and tail entity start index matching loss under the relationship alignment, and the head and tail entity end index matching loss under the relationship alignment, and then calculates the total extraction loss. Based on the total extraction loss, the parameters of the head entity prediction, the tail entity prediction, and the alignment matching process are adjusted and iterated until the total extraction loss after iteration is less than a preset value.

6. A smart terminal, characterized in that, The system includes a memory and a processor, wherein the memory stores at least one instruction, at least one program, code set, or instruction set, and the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the entity relation extraction method as described in any one of claims 1 to 3.

7. A computer-readable storage medium, characterized in that, The readable storage medium stores at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the entity relation extraction method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Entity relationship joint extraction method based on span and knowledge enhancement

    CN112214610A

  • Entity relation joint extraction method based on global pointer network

    CN114417839A