Text relation extraction method and device, medium and equipment

By performing naming entity recognition and part-of-speech annotation of text, combined with relationship extraction by neural network model, the problem of inaccurate text relationship extraction in the existing technology is solved, and the accuracy of relationship extraction is improved.

CN118939755APending Publication Date: 2024-11-12SHENZHEN QIANHAI HUANRONG LIANYI INFORMATION TECHNOLOGY SERVICES CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410956871.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The existing text relationship extraction method has the problem of inaccurate identification results.

Method used

By naming entity recognition and part-of-speech annotation of the target text, the target neural network model is used for relationship extraction, and relationship extraction is combined with entity word categories and part-of-speech feature vectors, which improves the accuracy of extraction.

Benefits of technology

Comprehensive extraction from both part-of-speech sequence and target string sequence is realized, and the accuracy of relationship extraction is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939755A_ABST
    Figure CN118939755A_ABST
Patent Text Reader

Abstract

The invention discloses a text relation extraction method and device, a medium and equipment. The method comprises the following steps: performing named entity recognition on each character string in an initial character string sequence of a target text to obtain a target character string sequence which corresponds to the initial character string sequence and contains a target entity word category; performing part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence which corresponds to the initial character string sequence and contains the part-of-speech of each character string; and based on the target character string sequence and the part-of-speech sequence, performing relation extraction by using a target neural network model to obtain a target relation triple corresponding to the target text. According to the method and the device, the target relation triple is comprehensively extracted from the two aspects of the part-of-speech sequence and the target character string sequence, and the accuracy of relation extraction / relation extraction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing, and in particular to a text relationship extraction method, device, medium and equipment. Background Art

[0002] Relation extraction refers to extracting key information and the relationship between them from a sentence, which is used to parse news, announcements and other documents in the financial field. The extraction result is usually a triple of "subject-relation-object", such as "company-founder-someone", or "company A-acquisition-company B".

[0003] However, existing text relationship extraction / recognition methods suffer from inaccurate recognition results. Summary of the invention

[0004] In view of this, the present invention provides a text relationship extraction method, device, medium and equipment, the main purpose of which is to solve the problem that the current relationship extraction is not accurate enough.

[0005] To solve the above problems, the present application provides a text relationship extraction method, comprising:

[0006] Performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category;

[0007] Performing part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0008] Based on the target character string sequence and the part-of-speech sequence, a target neural network model is used to perform relationship extraction to obtain a target relationship triple corresponding to the target text.

[0009] Optionally, before performing named entity recognition, the method further includes:

[0010] The target text is segmented to obtain a number of segmented words, so as to obtain the initial character string sequence.

[0011] Optionally, performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing a target entity word category specifically includes:

[0012] Performing named entity recognition on each character string in the initial character string sequence to obtain an entity word category corresponding to each character string to obtain an entity word category sequence;

[0013] Based on the target entity word category in the entity word category sequence, the corresponding character string in the initial character string sequence is replaced to obtain the target character string sequence.

[0014] Optionally, the target neural network model includes a first feature extraction model, a second feature extraction model and a relationship extraction model;

[0015] The step of performing relation extraction based on the target character string sequence and the part-of-speech sequence using a target neural network model to obtain a target relation triple corresponding to the target text specifically includes:

[0016] Based on the target character string sequence, using the first feature extraction model, extracting a first feature vector corresponding to the target character string sequence;

[0017] Based on the part-of-speech sequence, using the second feature extraction model, extract a second feature vector corresponding to the part-of-speech sequence;

[0018] Based on the first feature vector and the second feature vector, the target relation triplet is extracted using the relation extraction model.

[0019] Optionally, the identifying and obtaining the target relation triplet based on the first feature vector and the second feature vector by using the relation extraction model specifically includes:

[0020] Perform feature fusion based on the first feature vector and the second feature vector to obtain a target feature vector;

[0021] The target relation triplet is extracted and obtained by utilizing the relation extraction model based on the target feature vector.

[0022] Optionally, the identifying and obtaining the target relation triplet by using the relation extraction model based on the target feature vector specifically includes:

[0023] Based on the target feature vector, using the relationship extraction model, identifying and obtaining a number of initial relationship triples and probabilities corresponding to each of the initial relationship triples;

[0024] Based on the probabilities corresponding to the initial relationship triples, a target relationship triplet is determined from the initial relationship triples.

[0025] Optionally, the target entity word category includes any one or more of the following: person name, place name, organization name, time, amount;

[0026] The parts of speech include any one or more of the following: verb, noun, adjective, preposition, pronoun, interjection, and numeral.

[0027] In order to solve the above problems, the present application provides a text relationship extraction device, comprising:

[0028] A named entity recognition module is used to perform named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category;

[0029] A tagging module, used to perform part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0030] The relation extraction module is used to perform relation extraction based on the target character string sequence and the part-of-speech sequence using a target neural network model to obtain a target relation triple corresponding to the target text.

[0031] To solve the above problems, the present application provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned text relationship extraction methods are implemented.

[0032] To solve the above problems, the present application provides an electronic device, comprising at least a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above-mentioned text relationship extraction methods when executing the computer program on the memory.

[0033] The text relationship extraction method, apparatus, medium and equipment in the present application perform named entity recognition and part-of-speech tagging on the token sequence / initial string sequence of the target text, and then use the target neural network model to comprehensively and accurately extract and obtain relationship triples based on the target string sequence containing entity word categories and the part-of-speech sequence containing parts of speech, that is, it realizes comprehensive extraction from both the part-of-speech sequence and the target string sequence to obtain the target relationship triples, thereby improving the accuracy of relationship extraction / relationship extraction.

[0034] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0036] Figure 1 This is a flowchart of a text relationship extraction method according to an embodiment of the present application;

[0037] Figure 2 This is a flowchart of a text relationship extraction method according to another embodiment of the present application;

[0038] Figure 3 This is a structural block diagram of a text relationship extraction device according to another embodiment of the present application;

[0039] Figure 4 This is a structural block diagram of an electronic device according to another embodiment of the present application. DETAILED DESCRIPTION

[0040] Various aspects and features of the present application are described herein with reference to the accompanying drawings.

[0041] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.

[0042] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

[0043] These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.

[0044] It should also be understood that although the present application has been described with reference to some specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the present application.

[0045] The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.

[0046] Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied for are merely examples of the present application, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that obscure the present application. Therefore, the specific structural and functional details applied for herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present application in a variety of ways with substantially any suitable detailed structure.

[0047] This specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present application.

[0048] The present application embodiment provides a text relationship extraction method, which can be specifically applied to electronic devices such as terminals and servers, such as Figure 1 As shown, the method in this embodiment includes the following steps:

[0049] Step S101, performing named entity recognition on each character string in an initial character string sequence of a target text to obtain a target character string sequence corresponding to the initial character string sequence and containing a target entity word category;

[0050] In this step, the target text can be a continuous text sequence (such as a sentence, paragraph, etc.). For example, the target text can be "Company A acquired Company B on January 1, 2000". In the specific implementation process, the target text can be segmented in advance to obtain a number of segmentations to obtain the initial string sequence. That is, "Company A acquired Company B on January 1, 2000" can be segmented in advance to obtain a number of segmentations "Company A, on, January 1, 2020, acquired, Company B", that is, each segmentation is used as a string to obtain the initial string sequence, that is, the token sequence of the target text (t1, t2, ..., t n ). Then you can do the token sequence / initial string sequence (t1, t2, ..., t n ) to perform named entity recognition, thereby obtaining the target string sequence (t1, e2, ..., t i ,...,e k ,...,t n ), where e2 represents the target entity word category corresponding to string t2; similarly, e k Represents the string t k The corresponding target entity word category. The target entity word categories include: person name, place name, organization name, time, amount, etc.

[0051] Step S102, performing part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0052] In the specific implementation process of this step, the text sequence part-of-speech tagging algorithm can be used to process the initial string sequence to obtain a part-of-speech sequence (p1, p2, ..., p n), specifically, a rule-based method can be used, or a language representation module BERT, a long short-term memory network model LSTM, and a CFR model (a model based on game theory), or a long short-term memory network model LSTM and a CFR model (a model based on game theory) can be used for part-of-speech tagging, or other existing part-of-speech tagging methods can be used for part-of-speech tagging. Among them, the part-of-speech sequence includes tokens such as [noun], [verb], and [adjective]. For example, the initial string sequence is (t1, t2, ..., t n ), then token / string t1 can be tagged with part of speech to determine the part of speech p1 corresponding to string t1, and similarly token / string t2 can be tagged with part of speech to determine the part of speech p2 corresponding to string t2, and so on, to determine the part of speech p1 corresponding to string t1. n Corresponding part of speech p n , that is, to obtain the part-of-speech sequence (p1, p2, ..., p n ).

[0053] Step S103, based on the target character string sequence and the part-of-speech sequence, using a target neural network model to perform relationship extraction to obtain a target relationship triple corresponding to the target text.

[0054] In the specific implementation process of this step, the initial neural network model can be pre-trained to obtain the target neural network model. The target neural network model includes a first feature extraction model, a second feature extraction model and a relationship extraction model. When performing relationship extraction, the target string sequence can be input into the first feature extraction model, and the first feature extraction model can be used to extract and obtain the first feature vector corresponding to the target string sequence; the part-of-speech sequence can be input into the second feature extraction model, and the second feature extraction model can be used to extract and obtain the second feature vector corresponding to the target string sequence. Finally, the relationship extraction model can be used to extract and obtain the target relationship triple based on the first feature vector and the second feature vector.

[0055] The text relationship extraction method in this embodiment performs named entity recognition and part-of-speech tagging on the token sequence / initial character string sequence of the target text, and then can use the target neural network model to comprehensively and accurately extract and obtain relationship triples based on the target character string sequence containing entity word categories and the part-of-speech sequence containing parts of speech, thereby improving the accuracy of relationship extraction.

[0056] Another embodiment of the present application provides a text relationship extraction method, such as Figure 2 As shown, the following steps may be specifically included:

[0057] Step S201, performing word segmentation processing on the target text to obtain a number of word segments to obtain the initial character string sequence.

[0058] In this step, the target text refers to a continuous text sequence for which relationship extraction is to be performed, such as a sentence, paragraph, etc. for which relationship extraction is to be performed. In this step, by performing word segmentation on the target text, a number of words can be obtained, and each word can be used as a string / token, thereby obtaining an initial string sequence / token sequence containing a number of strings.

[0059] Step S202: Perform named entity recognition on each string in the initial string sequence to obtain the entity word category corresponding to each string, so as to obtain an entity word category sequence;

[0060] In this step, for the initial string sequence (CLS, t1, t2,..., t n , SEP), named entity recognition can be performed on each string t1, t2... t n in the initial string sequence respectively, so as to obtain the entity word category e1 corresponding to t1, the entity word category e2 corresponding to t2... and the entity word category e n corresponding to t n . Thus, an entity word category sequence (e1, e2,..., e n ) can be obtained. Among them, the first character [CLS] is a special character, and the last character [SEP] indicates the end of the sentence. For example, if the string t1 is "at", then the entity word category e1 corresponding to the string t1 can be obtained as "other" through named entity recognition. Another example, if the string t2 is "January 1, 2000", then the entity word category e2 corresponding to the string t2 can be obtained as "time" through named entity recognition. Another example, if the string t3 is "Zhang San", then the entity word category e3 corresponding to the string t3 can be obtained as "person name". And so on, the entity word category corresponding to each string can be obtained, and further, the category sequence (e1, e2,..., e n ) of entity words can be obtained.

[0061] Step S203: Based on the target entity word category in the entity word category sequence, replace the corresponding string in the initial string sequence to obtain the target string sequence;

[0062] In this step, after obtaining the entity word category sequence (e1, e2,..., e n), the target entity word category e2 time, e3 name..., which is the entity word category of "non-other", can be used to replace the corresponding character strings in the initial string, thereby obtaining the target string sequence. That is, replace the string t2 "January 1, 2000" in the initial string sequence with e2 "time", replace the string t3 "Zhang San" in the initial string sequence with e3 "name", and so on, to obtain the target string sequence (t1, e2, e3..., t i ,...,e k ,...,t n ). In this embodiment, the target entity word categories include any one or more of the following: person name, place name, organization name, time and amount.

[0063] Step S204, performing part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0064] In this step, when performing part-of-speech tagging, the parts of speech include any one or more of the following: verb, noun, adjective, preposition, pronoun, interjection, and numeral.

[0065] Step S205, based on the target character string sequence, using a first feature extraction model in a target neural network model, extracting a first feature vector corresponding to the target character string sequence;

[0066] In this step, the first feature extraction model is specifically an m-layer transformer deep learning model. The m-layer transformer model can be used to extract the target string sequence (t1, e2, ..., t i ,...,e k ,...,t n ) to extract features and obtain the first feature vector embedding.

[0067] Specifically, the input vocabulary (t1, e2, ..., t i ,...,e k ,...,t n) passes through the tokenizer, generates a token and then generates the corresponding token embedding and adds it to the position embedding. The result passes through m layers of transformer, each layer includes multi-head attention (i.e. softmax(Q*KT / √k)*V, where QKV is the result of multiplying the input X of the previous layer by the predetermined weight matrix Q=X*Wq, K=X*Wk, V=X*WV, the number of rows of X is the sequence length, the number of columns is the embedding length, and k is the number of columns of Q) and a fully connected layer (i.e. a linear transformation plus an activation function), and also includes a normalization layer layernorm to perform regularization / normalization based on layer norm.

[0068] Step S206, based on the part-of-speech sequence, using a second feature extraction model in the target neural network model, extracting a second feature vector corresponding to the part-of-speech sequence;

[0069] In this step, the second feature extraction model is also specifically an m-layer transformer deep learning model. The m-layer transformer model can be used to extract the part-of-speech sequence (p1, p2, ..., p n ) to extract features, thereby obtaining a second feature vector embedding. The second feature extraction model and the first feature extraction model in this step are both m-layer transformer models, and the two models have the same structure, but different model coefficients.

[0070] Specifically, the input vocabulary (p1, p2, ..., p n ) passes through the tokenizer, generates a token and then generates the corresponding token embedding and adds it to the position embedding. The result passes through m layers of transformer, each layer includes multi-head attention (i.e. softmax(Q*KT / √k)*V, where QKV is the result of multiplying the input X of the previous layer by the predetermined weight matrix Q=X*Wq, K=X*Wk, V=X*WV, the number of rows of X is the sequence length, the number of columns is the embedding length, and k is the number of columns of Q) and a fully connected layer (i.e. a linear transformation plus an activation function), and also includes a normalization layer layer norm to perform regularization / normalization based on layer norm.

[0071] Step S207: Based on the first feature vector and the second feature vector, a relationship extraction model in a target neural network model is used to extract a target relationship triple.

[0072] In the specific implementation of this step, the relationship extraction model can be a BERT language model (without the embedding layer). Of course, the relationship extraction model can also be other pre-trained speech models.

[0073] In this step, when extracting relation triples, feature fusion can be performed based on the first feature vector and the second feature vector to obtain a target feature vector; based on the target feature vector, the target relation triple can be extracted using the relation extraction model. Specifically, based on the target feature vector, the relation extraction model can be used to identify and obtain a number of initial relation triplets and the probabilities corresponding to each of the initial relation triplets; based on the probabilities corresponding to each of the initial relation triplets, the target relation triplet is determined from each of the initial relation triplets. That is, after obtaining the target feature vector embedding, the target feature vector embedding passes through a linear layer of the BERT language model, and then passes through a softmax normalized exponential function, so that the probability of it belonging to each type of triple can be obtained, and then the triple with the largest probability can be selected as the target relation triplet, or according to a predetermined probability threshold, multiple triplets that meet the probability threshold requirements can be selected as the target relation triplet.

[0074] That is, the first feature vector and the second feature vector are added, and then the result of the addition is input into a pre-trained language model of BERT (without the embedding layer) or its variant, and BERT is used to output target relationship triplets, such as (company, company, acquisition), (company, date, establishment), (person, organization, one of the members), etc., or triples that do not contain relationships are output.

[0075] In the specific implementation process of this embodiment, the target neural network model can be obtained by pre-training. The specific training process is:

[0076] Step 1: Collect several sample texts and label relationship triples corresponding to each sample text in advance.

[0077] Step 2: Perform named entity recognition on each character string in the initial sample character string sequence of each sample text to obtain a target sample character string sequence corresponding to the initial sample character string sequence and containing the target entity word category.

[0078] In this step, named entity recognition may be performed on each character string in the initial character string sequence to obtain an entity word category corresponding to each character string, so as to obtain a sample entity word category sequence;

[0079] Based on the target entity word category in the sample entity word category sequence, the corresponding character string in the initial sample character string sequence is replaced to obtain the target sample character string sequence. In this step, the specific process of processing the initial sample character string sequence of each sample text to obtain the target sample character string sequence is similar to the process of processing the initial character string sequence of the target text to obtain the target character string sequence, which will not be repeated here.

[0080] Step 3: perform part-of-speech tagging on each character string in the initial sample character string sequence to obtain a sample part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0081] In this step, the process of performing part-of-speech tagging on the initial sample character string of each sample text is similar to the process of performing part-of-speech tagging on the initial character string of each target text, and will not be repeated here.

[0082] Step 4: Based on the target sample character string sequence and the sample part-of-speech sequence of each sample text, the initial neural network model is used to perform relationship extraction to obtain the current relationship triples corresponding to each sample text;

[0083] In this step, the target sample character string sequence can be specifically extracted based on the initial first feature extraction model in the initial neural network model to obtain the first sample feature vector. At the same time, the sample part-of-speech sequence can be extracted based on the initial second feature extraction model in the initial neural network model to obtain the second sample feature vector. The first sample feature vector and the second sample feature vector are feature-fused to obtain the target sample feature vector, and finally the initial relationship extraction model in the initial neural network model is used to extract the relationship of the target sample feature vector to obtain the initial relationship triple.

[0084] Step 5: Based on the initial relationship triples of each sample text and the label relationship triples of each sample text, determine whether the predetermined training stop condition is met; when the predetermined training stop condition is not met, adjust the model parameters of the initial first feature extraction model, the initial second feature extraction model and the initial relationship extraction model to obtain the current first feature extraction model, the current second feature extraction model and the current relationship extraction model, that is, obtain the current neural network model, and then return to step 4 to re-extract the relationship based on the current neural network model to obtain the current relationship triples, until it is determined that the predetermined training stop condition is met based on the current relationship triples of each sample text and the label relationship triples of each sample text, then use the current neural network model as the target neural network model.

[0085] In this embodiment, by setting the target neural network model to a parallel m-layer transformer model plus a BERT model model architecture, feature extraction can be performed on the part-of-speech sequence and the target character string sequence respectively to obtain the first feature vector and the second feature vector, making the extraction of the feature vector more comprehensive, laying the foundation for the subsequent comprehensive and accurate extraction of the first feature vector and the second feature vector to obtain the target relationship triplet.

[0086] Another embodiment of the present application provides a text relationship extraction device, such as Figure 3 As shown, including:

[0087] A named entity recognition module 11 is used to perform named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing a target entity word category;

[0088] A tagging module 12 is used to perform part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0089] The relation extraction module 13 is used to perform relation extraction based on the target character string sequence and the part-of-speech sequence using a target neural network model to obtain a target relation triple corresponding to the target text.

[0090] In the specific implementation process of this embodiment, the text relationship extraction device also includes a processing module, and the processing model is used to perform word segmentation processing on the target text before performing named entity recognition to obtain a plurality of word segments to obtain the initial character string sequence.

[0091] In the specific implementation process of this embodiment, the named entity recognition module includes a recognition unit and a replacement unit; the recognition unit is used to: perform named entity recognition on each character string in the initial character string sequence, obtain the entity word category corresponding to each character string, and obtain an entity word category sequence; the replacement unit is used to: replace the corresponding character string in the initial character string sequence based on the target entity word category in the entity word category sequence, and obtain the target character string sequence.

[0092] In the specific implementation process of this embodiment, the target neural network model includes a first feature extraction model, a second feature extraction model and a relationship extraction model;

[0093] The relationship extraction module includes: a first feature extraction unit, a second feature extraction unit and a relationship extraction unit;

[0094] The first feature extraction unit is used to: based on the target character string sequence, use the first feature extraction model to extract a first feature vector corresponding to the target character string sequence;

[0095] The second feature extraction unit is used to: based on the part-of-speech sequence, use the second feature extraction model to extract a second feature vector corresponding to the part-of-speech sequence;

[0096] The relationship extraction unit is used to extract the target relationship triplet based on the first feature vector and the second feature vector using the relationship extraction model.

[0097] In the specific implementation process of this embodiment, the relationship extraction unit is specifically used to: perform feature fusion based on the first feature vector and the second feature vector to obtain a target feature vector; and extract the target relationship triplet based on the target feature vector using the relationship extraction model.

[0098] In the specific implementation process of this embodiment, the relationship extraction unit is specifically used to: based on the target feature vector, using the relationship extraction model, identify and obtain several initial relationship triplets and the probabilities corresponding to each of the initial relationship triplets; based on the probabilities corresponding to each of the initial relationship triplets, determine the target relationship triplet from each of the initial relationship triplets.

[0099] In the specific implementation of this embodiment, the target entity word categories include any one or more of the following: names of people, places, names of organizations, time, and amounts; the parts of speech include any one or more of the following: verbs, nouns, adjectives, prepositions, pronouns, interjections, and numerals.

[0100] The relationship extraction device in this embodiment performs named entity recognition and part-of-speech tagging on the token sequence / initial character string sequence of the target text, and then can use the target neural network model to comprehensively and accurately extract relationship triples based on the target character string sequence containing entity word categories and the part-of-speech sequence containing parts of speech. That is, it realizes comprehensive extraction from both the part-of-speech sequence and the target character string sequence to obtain the target relationship triples, thereby improving the accuracy of relationship extraction / relationship extraction.

[0101] Another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the following method steps are implemented:

[0102] Step 1: performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category;

[0103] Step 2: perform part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0104] Step three: Based on the target character string sequence and the part-of-speech sequence, use the target neural network model to perform relationship extraction to obtain a target relationship triple corresponding to the target text.

[0105] The specific implementation process of the above method steps can be found in the above-mentioned embodiments of any text relationship extraction method, and this embodiment will not be repeated here.

[0106] The storage medium in the present application performs named entity recognition and part-of-speech tagging on the token sequence / initial string sequence of the target text, and then can use the target neural network model to comprehensively and accurately extract and obtain relationship triples based on the target string sequence containing entity word categories and the part-of-speech sequence containing parts of speech, that is, it realizes comprehensive extraction from both the part-of-speech sequence and the target string sequence to obtain the target relationship triples, thereby improving the accuracy of relationship extraction / relationship extraction.

[0107] Another embodiment of the present application provides an electronic device, such as Figure 4 As shown, at least a memory 1 and a processor 2 are included, the memory 1 stores a computer program, and the processor 2 implements the following method steps when executing the computer program on the memory 1:

[0108] Step 1: performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category;

[0109] Step 2: perform part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string;

[0110] Step three: Based on the target character string sequence and the part-of-speech sequence, use the target neural network model to perform relationship extraction to obtain a target relationship triple corresponding to the target text.

[0111] The specific implementation process of the above method steps can be found in the above-mentioned embodiments of any text relationship extraction method, and this embodiment will not be repeated here.

[0112] The storage medium in the present application performs named entity recognition and part-of-speech tagging on the token sequence / initial string sequence of the target text, and then can use the target neural network model to comprehensively and accurately extract and obtain relationship triples based on the target string sequence containing entity word categories and the part-of-speech sequence containing parts of speech, that is, it realizes comprehensive extraction from both the part-of-speech sequence and the target string sequence to obtain the target relationship triples, thereby improving the accuracy of relationship extraction / relationship extraction.

[0113] The above embodiments are only exemplary embodiments of the present application and are not intended to limit the present application. The protection scope of the present application is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present application within the essence and protection scope of the present application, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present application.

Claims

1. A text relationship extraction method, characterized in that: include: Performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category; Performing part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string; Based on the target character string sequence and the part-of-speech sequence, a target neural network model is used to perform relationship extraction to obtain a target relationship triple corresponding to the target text.

2. The method according to claim 1, characterized in that Before performing named entity recognition, the method further includes: The target text is segmented to obtain a number of segmented words, so as to obtain the initial character string sequence.

3. The method according to claim 1, characterized in that The step of performing named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category specifically includes: Performing named entity recognition on each character string in the initial character string sequence to obtain an entity word category corresponding to each character string to obtain an entity word category sequence; Based on the target entity word category in the entity word category sequence, the corresponding character string in the initial character string sequence is replaced to obtain the target character string sequence.

4. The method according to claim 1, characterized in that The target neural network model includes a first feature extraction model, a second feature extraction model and a relationship extraction model; The step of performing relation extraction based on the target character string sequence and the part-of-speech sequence using a target neural network model to obtain a target relation triple corresponding to the target text specifically includes: Based on the target character string sequence, using the first feature extraction model, extracting a first feature vector corresponding to the target character string sequence; Based on the part-of-speech sequence, using the second feature extraction model, extract a second feature vector corresponding to the part-of-speech sequence; Based on the first feature vector and the second feature vector, the target relation triplet is extracted using the relation extraction model.

5. The method according to claim 4, characterized in that The step of identifying and obtaining the target relation triplet based on the first feature vector and the second feature vector by using the relation extraction model specifically includes: Perform feature fusion based on the first feature vector and the second feature vector to obtain a target feature vector; The target relation triplet is extracted and obtained by utilizing the relation extraction model based on the target feature vector.

6. The method according to claim 5, characterized in that The step of identifying and obtaining the target relation triplet based on the target feature vector and utilizing the relation extraction model specifically includes: Based on the target feature vector, using the relationship extraction model, identifying and obtaining a number of initial relationship triples and the probability corresponding to each of the initial relationship triples; Based on the probabilities corresponding to the initial relationship triples, a target relationship triplet is determined from the initial relationship triples.

7. The method according to any one of claims 1 to 6, characterized in that: The target entity word categories include any one or more of the following: person name, place name, organization name, time, amount; The parts of speech include any one or more of the following: verb, noun, adjective, preposition, pronoun, interjection, and numeral.

8. A text relationship extraction device, characterized in that: include: A named entity recognition module is used to perform named entity recognition on each character string in the initial character string sequence of the target text to obtain a target character string sequence corresponding to the initial character string sequence and containing the target entity word category; A tagging module, used to perform part-of-speech tagging on each character string in the initial character string sequence to obtain a part-of-speech sequence corresponding to the initial character string sequence and containing the part-of-speech of each character string; The relation extraction module is used to perform relation extraction based on the target character string sequence and the part-of-speech sequence using a target neural network model to obtain a target relation triple corresponding to the target text.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the text relationship extraction method according to any one of claims 1 to 7 are implemented.

10. An electronic device, characterized in that: The method comprises at least a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the text relationship extraction method according to any one of claims 1 to 7 when executing the computer program on the memory.

Citation Information

Patent Citations

  • Entity association relationship analysis method and related device

    CN110276066A

  • Entity relationship extraction method and device

    CN111753029A

  • Entity relationship joint extraction method, terminal and storage medium

    CN112364650A

  • Entity extraction model training method, entity relation extraction method and device

    CN115545030A

  • Entity relation joint extraction method based on relation attention enhancement and part-of-speech mask

    CN116911252A