Entity relation extraction method, device, equipment, medium and program product

By using the entity fragment identification, relation matrix generation, and prediction modules in the entity relation extraction model, the model prediction results are directly output, which solves the problem of instability in single-stage entity relation extraction and improves the stability and interpretability of the model.

CN114357183BActive Publication Date: 2026-01-02BEIJING UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111562485.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2026-01-02
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

The results of the single-stage entity and relation joint extraction method are unstable, and there are problems of error accumulation and entity redundancy.

Method used

The entity fragment identification module, relation matrix generation module, and relation prediction module in the entity relation extraction model directly output the model prediction results, avoiding mutual constraints and filtering between modules. The combination module and relation matrix generation module are used to generate a fragment permutation matrix for relation prediction.

Benefits of technology

It improves the stability and interpretability of the model, enhances the accuracy and reliability of entity relation extraction, and solves the problem of unstable results in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114357183B_ABST
    Figure CN114357183B_ABST
Patent Text Reader

Abstract

The present application provides an entity relationship extraction method, device, equipment, medium and program product, the method comprises: obtaining a to-be-recognized sentence; inputting the to-be-recognized sentence into an entity fragment identification module in an entity relationship extraction model to obtain an entity fragment arrangement of the to-be-recognized sentence; inputting a fragment arrangement vector corresponding to the entity fragment arrangement into a relationship matrix generation module in the entity relationship extraction model to obtain a fragment arrangement matrix representing the relationship between all entity fragments; inputting the fragment arrangement matrix into a relationship prediction module in the entity relationship extraction model to obtain a relationship prediction result corresponding to each entity fragment. The present application is used to solve the defect of unstable entity relationship extraction result in the prior art, and realizes higher stability of the entity relationship extraction model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer processing, and in particular to an entity relation extraction method, device, equipment, medium and program product. BACKGROUND

[0002] As an important research topic in the field of information extraction, the main purpose of entity and relation extraction is to extract the semantic relationship between the marked entity pairs in the sentence, that is, to determine the relationship category between the entity pairs in the unstructured text on the basis of entity recognition, and to form structured data for storage and retrieval, so as to provide data support for downstream tasks such as knowledge graph.

[0003] At present, entity recognition and relation extraction are mainly divided into single-stage method (joint) and two-stage method (pipeline) in terms of model structure. The single-stage method (joint) is a model that obtains entities and the relationship between entity pairs in a sentence at the same time, that is, entity and relationship triplets. This method is convenient for global optimization and joint decoding. The two-stage method (pipeline) first obtains the entity information in the sentence, and then determines whether the existing entities have a certain relationship based on the entity information. The two-stage method has clear division of labor and is easy to understand, but it has the problems of error accumulation and entity redundancy. Because of its simple structure and compliance with the development direction of model simplification, the single-stage method is the preferred method for entity and relation extraction models.

[0004] However, the current single-stage entity and relation joint extraction method has a problem: the output of the single-stage entity and relation joint extraction method is obtained by indirectly filtering the prediction results of the entity prediction module and the relationship prediction module divided inside the model through logical operation. Therefore, even if there is an error in the prediction of a certain module, it may be indirectly eliminated or magnified. Therefore, the entity relation extraction result of the single-stage entity and relation joint extraction method is unstable. SUMMARY

[0005] The present application provides an entity relation extraction method, device, equipment, medium and program product to solve the defect of unstable entity relation extraction result of the single-stage entity and relation joint extraction method in the prior art, and to realize higher stability of the entity relation extraction model.

[0006] The present application provides an entity relation extraction method, comprising:

[0007] obtaining a to-be-recognized sentence;

[0008] inputting the to-be-recognized sentence into an entity fragment recognition module in an entity relation extraction model to obtain an entity fragment arrangement of the to-be-recognized sentence;

[0009] input the entity segment arrangement corresponding segment arrangement vector into a relation matrix generation module in the entity relation extraction model to obtain a segment arrangement matrix representing the relations between all entity segments;

[0010] input the segment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain a relation prediction result corresponding to each entity segment.

[0011] According to the entity relation extraction method provided by the application, the step of inputting the entity segment arrangement corresponding segment arrangement vector into the relation matrix generation module in the entity relation extraction model to obtain the segment arrangement matrix representing the relations between all entity segments comprises:

[0012] input the entity segment arrangement corresponding segment arrangement vector into a combination module in the entity relation extraction model to obtain a combination vector output by the combination module;

[0013] input the combination vector into the relation matrix generation module in the entity relation extraction model to obtain the segment arrangement matrix representing the relations between all entity segments;

[0014] The combination module is used for combining the entity segment arrangement corresponding entity segment arrangement combination vector.

[0015] According to the entity relation extraction method provided by the application, the implementation formula of the relation matrix generation module is:

[0016]

[0017] wherein S is the input quantity of the relation matrix generation module, Span_matrix(S) is the output quantity of the relation matrix generation module, d k is the distance between any two vectors in the input quantity, and liner(S) is linear transformation.

[0018] According to the entity relation extraction method provided by the application, before the step of inputting the entity segment arrangement corresponding segment arrangement vector into the relation matrix generation module in the entity relation extraction model to obtain the segment arrangement matrix representing the relations between all entity segments, the method further comprises:

[0019] input a to-be-recognized sentence into a language model in the entity relation extraction model to obtain a word embedding vector corresponding to the to-be-recognized sentence;

[0020] input the corresponding word embedding vector as the entity segment arrangement corresponding segment arrangement vector.

[0021] According to the entity relation extraction method provided by the application, the arrangement of the entity segments output by the entity segment identification module is recorded through position information of the entity segments, and the position information includes the start position and the end position of each entity segment in the sentence.

[0022] According to the entity relation extraction method provided by the application, the relation prediction module includes convolution, and a loss function corresponding to the relation prediction module is calculated by using binary cross entropy loss.

[0023] The application further provides an entity relation extraction device, comprising:

[0024] The acquisition module is configured to acquire a to-be-identified sentence.

[0025] The first execution module is configured to input the to-be-identified sentence into an entity segment identification module in an entity relation extraction model to obtain an entity segment arrangement of the to-be-identified sentence.

[0026] The second execution module is configured to input a segment arrangement vector corresponding to the entity segment arrangement into a relation matrix generation module in the entity relation extraction model to obtain a segment arrangement matrix representing relations between all entity segments.

[0027] The third execution module is configured to input the segment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain a relation prediction result corresponding to each entity segment.

[0028] The application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the entity relation extraction method according to any one of the above when executing the program.

[0029] The application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the steps of the entity relation extraction method according to any one of the above.

[0030] The application further provides a computer program product comprising a computer program, wherein the computer program is executable on a processor to implement the steps of the entity relation extraction method according to any one of the above.

[0031] The entity relationship extraction method, device, equipment, medium and program product provided by the present application can identify entity word fragments in a to-be-identified sentence, obtain an entity fragment arrangement, generate a relationship matrix corresponding to the entity fragment arrangement, obtain a fragment arrangement matrix, and finally predict the relationship prediction result of all entity fragments in the to-be-identified sentence based on the fragment arrangement matrix. That is, the relationship prediction is performed based on the generated fragment arrangement matrix, so that the model prediction result can be directly output without using mutual restriction between modules to filter the result, thereby improving the stability and interpretability of the model, improving the stability and interpretability of the model, and solving the defect of unstable entity relationship extraction result in the prior art. BRIEF DESCRIPTION OF DRAWINGS

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

[0033] Figure 1 is one of the flowcharts of the entity relationship extraction method provided by the present application;

[0034] Figure 2 is a structural diagram of an entity relationship extraction model in the entity relationship extraction method provided by the present application;

[0035] Figure 3 is an exemplary relationship prediction result of the entity relationship extraction method provided by the present application;

[0036] Figure 4 is the second flowchart of the entity relationship extraction method provided by the present application;

[0037] Figure 5 is the third flowchart of the entity relationship extraction method provided by the present application;

[0038] Figure 6 is a structural diagram of the entity relationship extraction device provided by the present application;

[0039] Figure 7 is a structural diagram of the electronic device provided by the present application. DETAILED DESCRIPTION

[0040] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.

[0041] The technical solutions of the present application will be described below with reference to the drawings in the present application. Figures 1-7 The entity relation extraction method of the present application is described.

[0042] Please refer to Figure 1 The present application provides an entity relation extraction method, which comprises the following steps.

[0043] Step 10: obtaining a to-be-recognized sentence;

[0044] Step 20: inputting the to-be-recognized sentence into an entity segment identification module in an entity relation extraction model to obtain an entity segment arrangement of the to-be-recognized sentence;

[0045] Step 30: inputting a segment arrangement vector corresponding to the entity segment arrangement into a relation matrix generation module in the entity relation extraction model to obtain a segment arrangement matrix representing the relations between all the entity segments;

[0046] Step 40: inputting the segment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain a relation prediction result corresponding to each entity segment.

[0047] In the present embodiment, please refer to the structure schematic diagram of the entity relation extraction model shown in Figure 2 The entity relation extraction model comprises an entity segment identification module, a relation matrix generation module and a relation prediction module. The entity relation extraction model is a model for the attributes of the words contained in a sentence, which is used to predict the relations of the entities contained in any to-be-recognized sentence, i.e., to identify the attributes of the words contained in any to-be-recognized sentence. For example, please refer to Figure 3The entity relationship extraction model is used for identifying the entity relationship of the to-be-identified sentence "nerve center is damaged". The entity relationship identification result of each entity of the to-be-identified sentence "nerve center is damaged" includes that "nerve" is a noun, "nerve center" is a noun, "damage" is a verb, and "nerve center is damaged" is a symptom. The entity segment identification module is used for identifying all possible entity segments of the sentence, for example, "nerve", "nerve center", "nerve center is damaged" and the like. The relationship matrix generation module is used for converting the sentence feature vector into a matrix representing the relationship between entities. The relationship prediction module is used for predicting the attributes of all possible entities and the relationship between entities in the to-be-identified sentence according to the relationship matrix of the entity.

[0048] Specifically, the specific application process of the entity relationship extraction method is as follows: obtaining a to-be-identified sentence and inputting the to-be-identified sentence into the entity relationship extraction model to predict the relationship of each entity in the to-be-identified sentence by the entity relationship extraction model. The to-be-identified sentence can be any sentence. Specifically, the to-be-identified sentence is input into the entity segment identification module of the entity relationship extraction model to identify all possible entity segments in the to-be-identified sentence by the entity segment identification module, and obtain the arrangement of all possible entity segments in the to-be-identified sentence. Then, the entity segment arrangement is input into the relationship matrix generation module of the entity relationship extraction model to convert the entity segment arrangement into a segment arrangement matrix representing the relationship between all entity segments. Then, the segment arrangement matrix is input into the relationship prediction module of the entity relationship extraction model, and the relationship prediction result of each entity segment can be obtained by the relationship prediction module, so as to finally identify the relationship attributes of all possible entities in the to-be-identified sentence.

[0049] In the embodiment, the extracted entity attribute type can be used as an auxiliary task to improve the relationship prediction of the entity relationship extraction model. When the model training is completed and deployed in the production environment, the predicted part of the entity can be filtered out, and the relationship prediction is directly performed.

[0050] Further, all possible entity segments contained in the to-be-identified sentence are identified, that is, the entity segment arrangement is obtained. In a feasible embodiment, the start position and end position of the segment arrangement in the to-be-identified sentence are recorded by the start position and end position of the segment arrangement in the to-be-identified sentence, that is, in the embodiment, the result output by the entity segment identification module is the position information of the entity segment arrangement, so that the position of the entity segment arrangement in the to-be-identified sentence is known by the position information of the entity segment arrangement, and the position information of the entity segment arrangement includes the start position and end position of the entity segment arrangement.

[0051] The entity relation extraction method provided by the application can recognize entity word fragments in a sentence to be recognized, obtain an entity fragment arrangement, generate a relation matrix corresponding to the entity fragment arrangement, obtain a fragment arrangement matrix, and finally predict the relation prediction result of all entity fragments in the sentence to be recognized based on the fragment arrangement matrix. In other words, the relation is predicted based on the fragment arrangement matrix of the generated sentence, so that the model prediction result can be directly output without using mutual restriction between modules to filter the result, thereby improving the stability and interpretability of the model, improving the stability and interpretability of the model, and solving the defect of unstable entity relation extraction result in the prior art.

[0052] In some other embodiments, please refer to Figure 4 , the step of inputting the fragment arrangement vector corresponding to the entity fragment arrangement into the relation matrix generation module in the entity relation extraction model to obtain the fragment arrangement matrix representing the relation between all entity fragments includes:

[0053] Step 301, input the fragment arrangement vector corresponding to the entity fragment arrangement into the combination module in the entity relation extraction model to obtain the combination vector output by the combination module;

[0054] Step 302, input the combination vector into the relation matrix generation module in the entity relation extraction model to obtain the fragment arrangement matrix representing the relation between all entity fragments;

[0055] The combination module is used to combine the entity fragment arrangement vectors corresponding to all entity fragment arrangements.

[0056] In this embodiment, the entity relation extraction model further includes a combination module for combining the fragment arrangement vectors corresponding to all entity fragment arrangements. The specific process of generating the fragment arrangement matrix based on the fragment arrangement vectors corresponding to the entity fragment arrangements includes: first, input the fragment arrangement vectors corresponding to the entity fragment arrangements into the combination module in the entity relation extraction model to combine the fragment arrangement matrices corresponding to the entity fragments by the combination module to obtain the combination vector output by the combination module; then, input the combination vector output by the combination module into the relation matrix generation module in the entity relation extraction model to obtain the fragment arrangement matrix representing the relation between all entity fragments.

[0057] This embodiment improves the model prediction efficiency of the entity relation extraction model by first combining the fragment arrangement vectors corresponding to the entity fragment arrangements to obtain a combination vector, and then generating a fragment arrangement matrix based on the combination vector.

[0058] Further, the implementation formula of the relationship matrix generation module is:

[0059]

[0060] Wherein, S is the input quantity of the relationship matrix generation module, Span_matrix(S) is the output quantity of the relationship matrix generation module, d k is the distance between any two vectors in the input quantity, and liner(S) is a linear transformation.

[0061] In some other embodiments, referring to Figure 5 , before the step of inputting the entity segment arrangement corresponding segment arrangement vector into the relationship matrix generation module in the entity relationship extraction model to obtain the segment arrangement matrix representing the relationship between all entity segments, the method further comprises:

[0062] Step 50: inputting the to-be-recognized sentence into the language model in the entity relationship extraction model to obtain the word embedding vector corresponding to the to-be-recognized sentence;

[0063] Step 60: taking the corresponding word embedding vector as the entity segment arrangement corresponding segment arrangement vector.

[0064] In this embodiment, the word embedding vector X expressing the features of the sentence is generated based on the language model.

[0065] X n =M(x n )

[0066] Wherein, n represents the length of the sentence, M represents the used language model, and x represents the input sentence content.

[0067] First, input the sentence x to be recognized into the trained language model M, so as to convert the words in the to-be-recognized sentence into word embedding vectors through the language model. Here, the commonly effective Bert model is used. After the sentence passes through the language model, the vector representation X corresponding to each word is obtained, and the vector representation of the whole sentence is Xn. The BERT model is a self-encoding language model, which is a model capable of mathematicalizing symbols.

[0068] After generating the word embedding vector of the to-be-recognized sentence, the corresponding word embedding vector is found according to the position information of the segment arrangement, so as to find the entity segment arrangement corresponding segment arrangement vector.

[0069] Further, the entity segment arrangement output by the entity segment recognition module is recorded through the position information of the entity segment, and the position information includes the start position and end position of each entity segment in the sentence.

[0070] In this embodiment, the identified entity segment arrangement is denoted as span, and the starting position pos_s and the ending position pos_e of each entity segment arrangement in the sentence are recorded.

[0071] The entity segment arrangement span is generated according to the specified length, and the entity segment arrangement is expressed as follows:

[0072] (S pos_s ,S pos_e )

[0073] Here, pos_s and pos_e belong to n, and represent the starting position of the entity segment arrangement in the sentence and the ending position of the entity segment arrangement in the sentence, respectively.

[0074] In some other embodiments, the relationship prediction module includes a convolution, and a loss function corresponding to the relationship prediction module uses a binary cross-entropy loss calculation.

[0075] In this embodiment, the points in the segment arrangement matrix are predicted using a convolution.

[0076] The segment arrangement matrix is received, and the segment arrangement matrix is predicted using a convolution with a kernel size of 1 and a kernel number equal to the number of relationship categories plus one. Here, plus one is to add a 'none' category. After convolution, the prediction result corresponding to each point is obtained. Considering that there are more than two relationships between two entities, a binary cross-entropy loss calculation is used in the loss function, so that multi-label prediction can be performed. After prediction, the prediction result corresponding to each point in the matrix can be obtained directly according to the threshold 0.5. The row of the result represents the subject of the relationship, the list of the result represents the object of the relationship, and the point information represents the type of the relationship.

[0077] Based on the entity relationship extraction method proposed in the present application, an exemplary example of the present application is proposed as follows.

[0078] S1: generating a word embedding vector X representing sentence features based on a language model.

[0079] X n =M(x n )

[0080] Wherein, n represents the length of the sentence, M represents the language model, and x represents the input sentence content.

[0081] First, input the sentence x to be recognized into the trained language model M, the Bert model. After the sentence passes through the language model, the vector representation corresponding to each word X is obtained, and the vector representation of the whole sentence is Xn.

[0082] S2: At the same time, construct the corresponding fragment arrangement span for each word, and record the starting position pos_s and ending position pos_e of each fragment arrangement in the sentence.

[0083] According to the specified length, generate the corresponding fragment arrangement span for each word, and the entity fragment arrangement expression is as follows:

[0084] (S pos_s ,S pos_e )

[0085] Here, pos_s and pos_e belong to n, indicating the starting position of the entity fragment in the sentence and the ending position of the entity fragment in the sentence.

[0086] S3: Use the generated entity fragment expression to find the corresponding n from Xn in turn, and find the corresponding word embedding vector according to the position information of the fragment arrangement to combine

[0087] According to the generated entity fragment arrangement, the starting position vector representation Xpos_s and the ending position vector representation Xpos_e of each entity can be found, and then they are spliced together to be combined into a vector:

[0088] S i =(X i ,pos-s,X i ,pos-e)

[0089] I represents the serial number of the entity fragment arrangement, and S represents the combined vector.

[0090] S4: Vector multiplication to construct fragment arrangement matrix

[0091] After obtaining the vector representation Si of all fragment arrangements span, it is transformed by two linear layers (FC) to obtain two new vector representations, and then the two vectors are multiplied to obtain the span_matrix matrix representing the relationship between the fragments. The specific implementation formula is as follows:

[0092]

[0093] After obtaining the relationship matrix between all words representing the fragment arrangement, it is input into the relationship prediction module.

[0094] S5: Use convolution to predict the relationship of the points of the fragment arrangement matrix.

[0095] The Span_matrix matrix is received, and the matrix is predicted by using a convolution kernel with a size of 1 and a number of convolution kernels equal to the number of relationship categories plus one, where the plus one is to increase a 'none' category. The prediction result corresponding to each point is obtained after convolution, and considering that there are more than two relationships between two entities, a binary cross-entropy loss is used to calculate the loss function, so that multi-label prediction can be performed. After prediction, the prediction result corresponding to each point in the matrix can be directly obtained according to a threshold of 0.5, where the row of the result represents the subject of the relationship, the list of the result represents the object of the relationship, and the point information represents the type of the relationship.

[0096] The entity relationship extraction device provided by the present application is described below. The entity relationship extraction device described below can be correspondingly referred to the entity relationship extraction method described above.

[0097] Please refer to Figure 6 The present application also provides an entity relationship extraction device, comprising:

[0098] The acquisition module 610 is configured to acquire a to-be-identified sentence.

[0099] The first execution module 620 is configured to input the to-be-identified sentence into an entity segment identification module in an entity relationship extraction model to obtain an entity segment arrangement of the to-be-identified sentence.

[0100] The second execution module 630 is configured to input a segment arrangement vector corresponding to the entity segment arrangement into a relationship matrix generation module in the entity relationship extraction model to obtain a segment arrangement matrix representing relationships between all entity segments.

[0101] The third execution module 640 is configured to input the segment arrangement matrix into a relationship prediction module in the entity relationship extraction model to obtain a relationship prediction result corresponding to each entity segment.

[0102] Further, the second execution module is further configured to:

[0103] input the segment arrangement vector corresponding to the entity segment arrangement into a combination module in the entity relationship extraction model to obtain a combination vector output by the combination module;

[0104] input the combination vector into the relationship matrix generation module in the entity relationship extraction model to obtain the segment arrangement matrix representing the relationships between all entity segments.

[0105] The combination module is configured to combine the segment arrangement vectors corresponding to the entity segment arrangements.

[0106] Further, the relationship matrix generation module is implemented by the following formula:

[0107]

[0108] Where S is the input of the relation matrix generation module, Span_matrix(S) is the output of the relation matrix generation module, and d k Let S be the distance between any two vectors in the input quantities, and liner(S) be the linear transformation.

[0109] Furthermore, the entity relationship extraction device also includes:

[0110] The fourth execution module is used to input the sentence to be identified into the language model in the entity relation extraction model to obtain the word embedding vector corresponding to the sentence to be identified;

[0111] The fifth execution module is used to use the corresponding word embedding vector as the segment arrangement vector corresponding to the entity segment arrangement.

[0112] Furthermore, the entity fragment arrangement output by the entity fragment recognition module is recorded through the position information of the entity fragments, and the position information includes determining the start and end positions of each entity fragment in the sentence.

[0113] Furthermore, the relationship prediction module includes convolution, and the loss function corresponding to the relationship prediction module is calculated using binary cross-entropy loss.

[0114] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute an entity relation extraction method. This method includes: acquiring a sentence to be identified; inputting the sentence to be identified into an entity fragment identification module in the entity relation extraction model to obtain an arrangement of entity fragments of the sentence to be identified; inputting the fragment arrangement vector corresponding to the entity fragment arrangement into a relation matrix generation module in the entity relation extraction model to obtain a fragment arrangement matrix representing the relationships between all entity fragments; and inputting the fragment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain relation prediction results corresponding to each entity fragment.

[0115] Further, the logic instructions in the memory 730 described above can be implemented in the form of software functional units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or parts of the present application that essentially contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0116] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the entity relationship extraction method provided by the above-mentioned methods. The method comprises: obtaining a to-be-recognized sentence; inputting the to-be-recognized sentence into an entity segment identification module in an entity relationship extraction model to obtain an entity segment arrangement of the to-be-recognized sentence; inputting a segment arrangement vector corresponding to the entity segment arrangement into a relationship matrix generation module in the entity relationship extraction model to obtain a segment arrangement matrix representing relationships between all entity segments; and inputting the segment arrangement matrix into a relationship prediction module in the entity relationship extraction model to obtain a relationship prediction result corresponding to each entity segment.

[0117] In yet another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement an entity relationship extraction method provided by the above-mentioned methods. The method comprises: obtaining a to-be-recognized sentence; inputting the to-be-recognized sentence into an entity segment identification module in an entity relationship extraction model to obtain an entity segment arrangement of the to-be-recognized sentence; inputting a segment arrangement vector corresponding to the entity segment arrangement into a relationship matrix generation module in the entity relationship extraction model to obtain a segment arrangement matrix representing relationships between all entity segments; and inputting the segment arrangement matrix into a relationship prediction module in the entity relationship extraction model to obtain a relationship prediction result corresponding to each entity segment.

[0118] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0119] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and necessary universal hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of software products, and the computer software products can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and include a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0120] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An entity relation extraction method, characterized by, The method comprises the following steps: obtaining a sentence to be recognized; inputting the sentence to be recognized into an entity fragment recognition module in an entity relation extraction model to obtain an entity fragment arrangement of the sentence to be recognized; inputting a fragment arrangement vector corresponding to the entity fragment arrangement into a combination module in the entity relation extraction model to obtain a combination vector output by the combination module; wherein the combination module is configured to combine fragment arrangement vectors corresponding to each entity fragment arrangement, and specifically configured to find a corresponding word embedding vector according to position information of the entity fragment arrangement, and splice the word embedding vector to obtain a corresponding combination vector; inputting the combination vector into a relation matrix generation module in the entity relation extraction model to obtain a fragment arrangement matrix representing relations between all entity fragments; wherein a relation prediction result corresponding to a diagonal line of the fragment arrangement matrix is an entity attribute type, and a relation prediction result corresponding to other positions of the fragment arrangement matrix except the diagonal line is a relation type between entities; inputting the fragment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain a relation prediction result corresponding to each entity fragment; an implementation formula of the relation matrix generation module is as follows: where S is the input of the relationship matrix generating module, Span_matrix(S) is the output of the relationship matrix generating module, d k is the distance between any two vectors in the input, and liner(S) is a linear transformation.

2. The method of claim 1, wherein, Before the step of inputting the fragment arrangement vector corresponding to the entity fragment arrangement into the relation matrix generation module in the entity relation extraction model to obtain the fragment arrangement matrix representing relations between all entity fragments, the method further comprises the following steps: inputting the sentence to be recognized into a language model in the entity relation extraction model to obtain a word embedding vector corresponding to the sentence to be recognized; taking the corresponding word embedding vector as the fragment arrangement vector corresponding to the entity fragment arrangement.

3. The method of claim 1, wherein, The entity fragment arrangement output by the entity fragment recognition module is recorded through position information of the entity fragment, and the position information comprises a start position and an end position of each entity fragment in a sentence.

4. The method of claim 1, wherein, The relation prediction module comprises a convolution, and a loss function corresponding to the relation prediction module is calculated using a binary cross entropy loss.

5. An entity relation extraction apparatus characterized by comprising: The method comprises the following steps: an obtaining module is configured to obtain a sentence to be recognized; a first executing module is configured to input the sentence to be recognized into an entity fragment recognition module in an entity relation extraction model to obtain an entity fragment arrangement of the sentence to be recognized; a second executing module is configured to input a fragment arrangement vector corresponding to the entity fragment arrangement into a combination module in the entity relation extraction model to obtain a combination vector output by the combination module; wherein the combination module is configured to combine fragment arrangement vectors corresponding to each entity fragment arrangement, and specifically configured to find a corresponding word embedding vector according to position information of the entity fragment arrangement, and splice the word embedding vector to obtain a corresponding combination vector; inputting the combination vector into a relation matrix generation module in the entity relation extraction model to obtain a fragment arrangement matrix representing relations between all entity fragments; wherein a relation prediction result corresponding to a diagonal line of the fragment arrangement matrix is an entity attribute type, and a relation prediction result corresponding to other positions of the fragment arrangement matrix except the diagonal line is a relation type between entities; The third executing module is configured to input the segment arrangement matrix into a relation prediction module in the entity relation extraction model to obtain a relation prediction result corresponding to each entity segment. An implementation formula of the relation matrix generating module is as follows: where S is the input of the relationship matrix generating module, Span_matrix(S) is the output of the relationship matrix generating module, d k is the distance between any two vectors in the input, and liner(S) is a linear transformation.

6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the entity relation extraction method according to any one of claims 1 to 4 when executing the program.

7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the entity relation extraction method according to any one of claims 1 to 4.

8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the entity relation extraction method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Relationship extraction system with relation mode recognition capability

    CN113657095A