A method and device for extracting relationship

By using training samples composed of text to be processed and revised tuples for incremental learning training in the relationship extraction model, the problem of low efficiency and accuracy of relationship extraction under the lack of annotated data is solved, and high accuracy and low cost are achieved. Relationship extraction effect.

CN114386411BActive Publication Date: 2025-01-17BEIJING KINGSOFT DIGITAL ENTERTAINMENT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011112491.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-16
Publication Date
2025-01-17
Estimated Expiration
2040-10-16

AI Technical Summary

Technical Problem

In the case of scarce labeling data, it is difficult for the existing technology to effectively improve the efficiency and accuracy of relationship extraction, and areas with extremely high requirements for the accuracy of relationship extraction, such as government affairs, medicine, etc., manual intervention is inevitable, resulting in higher costs. .

Method used

By obtaining the text to be processed and inputting it into the relation extraction model for processing, the target tuple is obtained. When a revision instruction is received, a revision tuple is generated, and the text to be processed and the revision tuple are composed of a training sample pair, which is added to the initial training sample set to continue training the relationship extraction model.

Benefits of technology

It trains and generates a relationship extraction model with a very small amount of starting data. It improves the accuracy of the model through incremental learning and training, reduces the cost of manual intervention, is suitable for areas where annotation data is scarce, and improves the versatility and accuracy of relationship extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114386411B_ABST
    Figure CN114386411B_ABST
Patent Text Reader

Abstract

The present application provides a relation extraction method and device, wherein the relation extraction method comprises: obtaining a text to be processed; inputting the text to be processed into a relation extraction model for processing, and obtaining a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set; upon receiving a revision instruction, generating a revision tuple based on the revision instruction; generating a training sample pair according to the text to be processed and the revision tuple, and adding the training sample pair to the initial training sample set to continue training the relation extraction model. Through the relation extraction method provided by the present application, a relation extraction model can be trained and generated with a very small amount of startup data, target tuples that do not meet the requirements obtained by the relation extraction model can be corrected, and the revision tuple and the text to be processed pair relation extraction model can be incrementally learned and trained, thereby improving the accuracy of the relation extraction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language technology, and in particular to a relationship extraction method and apparatus, a computing device, and a computer-readable storage medium. Background Art

[0002] Relation extraction is a method of extracting semantic relations from text. It is of great significance in natural language processing applications such as knowledge base, question answering, and abstracts. Relation extraction usually occurs between two specific types of entities.

[0003] Relation extraction is usually regarded as an important part of knowledge graph construction and has received widespread attention. Generally, deep learning-based relationship extraction methods often require large-scale high-quality labeled data, rule-based relationship extraction methods require a lot of labor costs, and remote supervision methods face the problem of pseudo-labeling. Ordinary self-service rules rely on repeatedly occurring relationships and require consistent relationship tuples. The above methods are not suitable for areas with scarce labeled data, sparse relationship tuples, and extremely high requirements for the accuracy of relationship extraction, such as government affairs, medicine, personnel appointment and removal, etc. Since specific fields require extremely high accuracy in relationship extraction, manual intervention is indispensable, and the resulting labor costs cannot be ignored.

[0004] Therefore, how to improve the efficiency and accuracy of relationship extraction and reduce labor costs as much as possible in the case of scarce labeled data has become an urgent problem for technical personnel. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a relationship extraction method and apparatus, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0006] According to a first aspect of an embodiment of the present application, a relationship extraction method is provided, comprising:

[0007] Get the text to be processed;

[0008] Inputting the text to be processed into a relation extraction model for processing, and obtaining a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set;

[0009] In case of receiving the revision instruction, generating a revision tuple based on the revision instruction;

[0010] A training sample pair is generated according to the text to be processed and the revised tuple, and the training sample pair is added to the initial training sample set to continue training the relation extraction model.

[0011] Optionally, after the text to be processed is input into the relation extraction model for processing, the method further includes:

[0012] The relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed.

[0013] Optionally, the relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed, including:

[0014] Performing entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed;

[0015] A target tuple corresponding to the text to be processed is generated according to the entity sequence.

[0016] Optionally, performing entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed includes:

[0017] Performing word segmentation processing on the text to be processed to obtain a word unit set corresponding to the text to be processed;

[0018] Perform entity recognition and part-of-speech tagging processing on the word unit set to obtain a corresponding entity sequence.

[0019] Optionally, generating a target tuple corresponding to the to-be-processed text according to the entity sequence includes:

[0020] Traverse the entity sequence through the stored template pair set to determine a target template pair;

[0021] Relation extraction is performed on the text to be processed based on the target template pair to obtain a target tuple corresponding to the target template pair.

[0022] Optionally, the training samples in the initial training sample set are training texts and bigrams corresponding to the training texts, wherein the bigrams include entity pairs;

[0023] The relationship extraction model is obtained by training the initial training sample set, including:

[0024] Performing entity recognition and part-of-speech tagging on the training text to determine a training entity sequence corresponding to the training text;

[0025] Generate a word template corresponding to the training text according to the entity pair and the training entity sequence;

[0026] A part-of-speech template corresponding to the training text is determined according to the word template.

[0027] The word template and the part-of-speech template are saved correspondingly.

[0028] Optionally, the entity pair includes a head entity and a tail entity;

[0029] Generating a word template corresponding to the training text according to the entity pair and the training entity sequence includes:

[0030] Determine the head entity position and the tail entity position of the head entity identifier corresponding to the head entity and the tail entity identifier corresponding to the tail entity in the training entity sequence;

[0031] A word template is determined in the training entity sequence based on the head entity position and the tail entity position.

[0032] Optionally, determining a part-of-speech template corresponding to the training text according to the word template includes:

[0033] The words in the word template except for the head entity identifier and the tail entity identifier are replaced with corresponding parts of speech to generate a part of speech template corresponding to the training text.

[0034] Optionally, the method further includes:

[0035] In case of receiving a save instruction, the target tuple is saved based on the save instruction.

[0036] According to a second aspect of an embodiment of the present application, a relationship extraction device is provided, comprising:

[0037] An acquisition module, configured to acquire text to be processed;

[0038] An extraction module is configured to input the text to be processed into a relation extraction model for processing, and obtain a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set;

[0039] A receiving module, configured to generate a revision tuple based on the revision instruction when receiving the revision instruction;

[0040] The continuing training module is configured to generate a training sample pair according to the to-be-processed text and the revised tuple, and add the training sample pair to the initial training sample set to continue training the relation extraction model.

[0041] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the relationship extraction method when executing the instructions.

[0042] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the relationship extraction method are implemented.

[0043] According to a fifth aspect of an embodiment of the present application, a chip is provided, which stores computer instructions, and when the instructions are executed by the chip, the steps of the relationship extraction method are implemented.

[0044] The relation extraction method provided in the embodiment of the present application obtains a text to be processed; inputs the text to be processed into a relation extraction model for processing, and obtains a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set; generates a revised tuple based on the revision instruction when a revision instruction is received; generates a training sample pair according to the text to be processed and the revision tuple, and adds the training sample pair to the initial training sample set to continue training the relation extraction model. Through the relation extraction method provided in the present application, a relation extraction model can be trained and generated with a very small amount of startup data. After the target tuple is determined by the relation extraction model, the target tuple is scored, and the target tuple that does not meet the requirements is manually corrected, and the model is continuously incrementally learned and trained to further improve the accuracy of the model. In addition, the model is trained by forming a training sample pair with the text to be processed and the revision tuple, so that it is not necessary to rely on relations that appear repeatedly, and there is no need to consider the problem of tuple relation sparsity. It has universality and is more effective in extracting templates for specific fields. When the accuracy of the relation extraction model is higher, the cost of manual intervention will be reduced accordingly. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;

[0046] Figure 2 is a flow chart of a relationship extraction method provided in an embodiment of the present application;

[0047] Figure 3 is a flow chart of a training method for a relation extraction model in a relation extraction method provided in an embodiment of the present application;

[0048] Figure 4 This is a flow chart of a method for extracting a relationship applied to the field of personnel appointment and dismissal provided by an embodiment of the present application;

[0049] Figure 5 is an architecture diagram of the relationship extraction method provided in the embodiment of the present application;

[0050] Figure 6 It is a structural schematic diagram of the relationship extraction device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0052] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0053] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".

[0054] First, the terms involved in one or more embodiments of the present invention are explained.

[0055] Relational extraction: (RE) is a method of extracting semantics from text. The extracted relationship usually occurs between two specific entities.

[0056] Tuple: It is a basic concept in relational databases. A relation is a table, and each row in the table is a tuple. A tuple can be a binary or a triple.

[0057] Relation extraction model: A model used to analyze the text to be processed, including entity recognition, part-of-speech tagging, storage templates, extraction of relations, and other operations.

[0058] Entity recognition: (Named Entity Recognition, referred to as NER) is an information extraction technology used to identify entities with specific meanings in text, such as names of people, places, and institutions.

[0059] Part-Of-Speech tagging (POS tagging), also known as grammatical tagging or part-of-speech decomposition, is a text data processing technology in corpus linguistics that marks the parts of speech of words in a corpus according to their meaning and context.

[0060] In the present application, a relationship extraction method and apparatus, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0061] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.

[0062] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0063] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0064] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.

[0065] The processor 120 may execute Figure 2 The steps in the relationship extraction method are shown. Figure 2 A flowchart of a relationship extraction method according to an embodiment of the present application is shown, including steps 202 to 208.

[0066] Step 202: Obtain the text to be processed.

[0067] The text to be processed is the text on which the relationship extraction operation needs to be performed. It can be a paragraph, an article, a news report, etc. There are many ways to obtain it. It can be automatically obtained from the website, read from a specified location, or obtain text information entered by the user through an input device, etc. In this application, there is no limitation on how to obtain the text to be processed.

[0068] The field of the text to be processed may be government affairs, personnel appointment and dismissal, medical care, military affairs, etc. In this application, there is no limitation on the field to which the text to be processed belongs.

[0069] In a specific embodiment provided in the present application, taking the extraction of the relationship in the text to be processed "The group deployed Company A in the M region and established Company B in the N region." as an example, the relationship extraction method provided in the present application is further explained. At this time, the text to be processed is "The group deployed Company A in the M region and established Company B in the N region.".

[0070] Step 204: input the text to be processed into a relation extraction model for processing, and obtain a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set.

[0071] The target tuple is the tuple corresponding to the entity in the text to be processed, which can be a triple or a binary tuple with a relationship identifier. There may be one, two or more tuples corresponding to the text to be processed. The number and form of expression of the target tuple shall be subject to the actual application and are not limited in this application. For example, when the tuple is a binary tuple, it can be expressed as: gender identifier binary tuple (Zhang, male), (Li, female), and when the tuple is a triple, it can be expressed as (Zhang, gender, male), (Li, gender, female).

[0072] The relation extraction model is a model used to extract the relationship between entities in the text to be processed. The training data in the initial training sample set of the relation extraction model consists of training data pairs of training text and training tuples. In practical applications, a very small number of training data pairs can complete the initial training of the relation extraction model, and in subsequent applications, the relation extraction model can be further incrementally trained through incremental learning.

[0073] Optionally, after the text to be processed is input into the relation extraction model for processing, the method further includes:

[0074] The relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed.

[0075] Specifically, the relation extraction model is trained to generate a target tuple corresponding to the to-be-processed text in response to the input to-be-processed text, where the target tuple can be a binary tuple with a relation identifier or a triple tuple. The relation extraction model generates a target tuple corresponding to the to-be-processed text in response to the input to-be-processed text, including S2042 to S2044:

[0076] S2042: Perform entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed.

[0077] In practical applications, after the text to be processed is input into the relation extraction model, the relation extraction model will perform entity recognition and part-of-speech tagging on the text to be processed.

[0078] Named Entity Recognition (NER) is an information extraction technology used to identify entities with specific meanings in text, such as names of people, places, and institutions.

[0079] Part-Of-Speech tagging (POS tagging), also known as grammatical tagging or part-of-speech deconvolution, is a text data processing technology in corpus linguistics that marks the parts of speech of words in a corpus according to their meaning and context.

[0080] The relation extraction model performs entity recognition and part-of-speech tagging on the text to be processed. It needs to identify the entities in the text to be processed and mark the parts of speech of non-entity words.

[0081] Optionally, performing entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed includes:

[0082] Performing word segmentation processing on the text to be processed to obtain a word unit set corresponding to the text to be processed;

[0083] Perform entity recognition and part-of-speech tagging processing on the word unit set to obtain a corresponding entity sequence.

[0084] In practical applications, the text to be processed must first be segmented to obtain a word unit set corresponding to the text to be processed, and then entity recognition and part-of-speech tagging are performed on the word unit set to obtain a corresponding entity sequence.

[0085] In the embodiment provided in the present application, the above example is used to perform word segmentation processing on the text to be processed "The group will deploy Company A in Region M and establish Company B in Region N." to obtain a word unit set corresponding to the text to be processed [Group, will deploy Company A in Region M,, will establish Company B in Region N. ].

[0086] Perform entity recognition and part-of-speech tagging on the word unit set to obtain an entity sequence [Group-n, deploy-v, CO, in -v, LOC,,-w, establish-prep, CO, in -v, LOC,. -w], where "Group-n" means that "Group" is represented by n in the part-of-speech tag, ",-w" means the punctuation mark "," is represented by w in the part-of-speech tag, CO is the entity tag corresponding to the company name, and LOC is the entity tag corresponding to the location.

[0087] S2044. Generate a target tuple corresponding to the text to be processed according to the entity sequence.

[0088] Optionally, generating a target tuple corresponding to the to-be-processed text according to the entity sequence includes:

[0089] Traverse the entity sequence through the stored template pair set to determine a target template pair;

[0090] Relation extraction is performed on the text to be processed based on the target template pair to obtain a target tuple corresponding to the target template pair.

[0091] In the embodiment provided in the present application, following the above example, the relationship extraction model pre-saves a set of template pairs, the template pairs including word templates and part-of-speech templates, and the generated entity sequence is traversed through the template pairs in the template pair set for matching. In the present application, the matching of template pairs adopts a full matching mode, that is, the content in the template pair needs to be completely identical to part of the content in the text to be processed for the match to be successful. For example, if the text to be processed is "The group will deploy Company A in Region M and Company B in Region N.", the template pair that fully matches it is "Deploy CO in LOC." If the template pair is "Deploy CO in LOC.", it is not the same template either, so the target template pair is determined as shown in Table 1 below.

[0092] Table 1

[0093] Serial number Word Templates Part of Speech Template 1 Deploy the,CO,at the,LOC, v, CO, v, LOC, w

[0094] Based on the target template pair shown in Table 1, entity extraction is performed on the text to be processed "The group deployed Company A in Region M and established Company B in Region N." to obtain the relationship extraction results shown in Table 2 below.

[0095] Table 2

[0096] Company Name Company Location Company A M Area

[0097] At this point, the relationship extraction of the text to be processed "The group deployed Company A in Region M and established Company B in Region N." is completed, and (Company A, Region M) is the target tuple.

[0098] Step 206: When a revision instruction is received, generate a revision tuple based on the revision instruction.

[0099] In practical applications, after obtaining the target tuple, it is necessary to determine whether all the relationship groups in the text to be processed are extracted or whether the extracted target tuple is correct through manual annotation. If the relationship groups in the text to be processed are not fully extracted or are extracted incorrectly, the target tuple needs to be revised.

[0100] For example, in a section of text to be processed, three target tuples A, B, and C should be extracted, but only two target tuples A and C are extracted, and tuple B is not extracted. In this case, a revision instruction is accepted, and the revision instruction includes revision information. A revised tuple B is generated based on the revision information. For another example, in a section of text to be processed, the tuple that should be extracted is (X, Y), and the target tuple actually extracted is (X, Z). If a relation extraction error occurs, a revision instruction is received, and the revision instruction includes revision information. Based on the revision information, the target tuple (X, Z) is revised to a revised tuple (X, Y).

[0101] When the target tuple is not fully extracted or an extraction error occurs, a revision instruction is received, the revision instruction carries revision information, and a corresponding revision tuple is generated based on the revision information carried in the revision instruction. In actual applications, the revision tuple is specifically the tuple that was not extracted.

[0102] In the embodiment provided in the present application, following the above example, the text to be processed is "The group deployed Company A in Region M and established Company B in Region N." The text to be processed should be able to extract two target tuples, one is (Company A, Region M) and the other is (Company B, Region N), but actually only the target tuple (Company A, Region M) is extracted. Therefore, a revision instruction is received, and the revision instruction carries the revision information "Company B, Region N". Based on the revision instruction, a revision tuple (Company B, Region N) is generated.

[0103] Step 208: Generate a training sample pair according to the text to be processed and the revised tuple, and add the training sample pair to the initial training sample set to continue training the relationship extraction model.

[0104] After obtaining the revised tuple, the text to be processed and the revised tuple are combined into a training sample pair. The training sample pair is equivalent to data annotation of the text to be processed and the revised tuple, which is used for further incremental learning and training of the relationship extraction model.

[0105] Further incremental learning and training of the relationship extraction model is similar to the process of training the relationship extraction model with the training samples in the initial training sample set. Template pairs are extracted from the training texts in the training sample pairs and added to the template pair set, so as to facilitate the subsequent extraction of related relations from the to-be-processed texts in the same format. For the specific relationship extraction model training method, see Figure 3 , Figure 3 A flow chart of a training method for a relationship extraction model provided in an embodiment of the present application is shown. The training samples in the initial training sample set are training texts and bigrams corresponding to the training texts. The training method specifically includes steps 302 to 308.

[0106] Step 302: Perform entity recognition and part-of-speech tagging on the training text to determine a training entity sequence corresponding to the training text.

[0107] In practical applications, after the relationship extraction model is trained with a small amount of training data, it is trained through continuous incremental learning and training in the subsequent use process. When encountering new relationship forms, new template pairs can be generated through incremental learning methods and saved in the template pair set, so that when the same expression is encountered later, the relationship can be extracted more accurately.

[0108] When training the relationship extraction model based on the training samples, the training text must first be subjected to entity recognition and part-of-speech tagging to determine the training entity sequence of the training text in the training samples. For details on entity recognition and part-of-speech tagging of the training text, please refer to the relevant description in S2042 above, which will not be repeated here.

[0109] In the embodiment provided in the present application, the above example is used. The text to be processed "The group deployed Company A in the M region and established Company B in the N region." is the training text, and the revised tuple (Company B, N region) is the bigram corresponding to the training text. To perform entity recognition and part-of-speech tagging on the training text "The group deployed Company A in the M region and established Company B in the N region.", the training text must first be segmented to obtain a corresponding word unit set, and then the words in the word unit set must be entity recognized and tagged to obtain a training entity sequence [Group-n, deploy-v, CO, in-v, LOC,,-w, establish-prep, CO, in-v, LOC,. -w].

[0110] Step 304: Generate a word template corresponding to the training text according to the entity pair and the training entity sequence.

[0111] Optionally, the entity pair includes a head entity and a tail entity;

[0112] Generating a word template corresponding to the training text according to the entity pair and the training entity sequence includes:

[0113] Determine the head entity position and the tail entity position of the head entity identifier corresponding to the head entity and the tail entity identifier corresponding to the tail entity in the training entity sequence;

[0114] A word template is determined in the training entity sequence based on the head entity position and the tail entity position.

[0115] In practical applications, an entity pair includes a head entity and a tail entity. The head entity and the tail entity in the entity pair are matched in a training entity sequence. Specifically, the head entity position and the tail entity position are determined in the training entity sequence according to the head entity identifier corresponding to the head entity and the tail entity identifier corresponding to the tail entity. Then, the element before the head entity identifier, the head entity identifier, the element between the head entity identifier and the tail entity identifier, the tail entity identifier, and the element after the tail entity identifier are formed into an element group, and then a word template is generated. The elements referred to here are elements in the training entity sequence, which can be words, numbers, punctuation marks, etc.

[0116] In the embodiment provided in the present application, the entity pair is (Company B, Region N), wherein the head entity identifier corresponding to the head entity "Company B" is "CO", and the tail entity identifier corresponding to the tail entity "Region N" is "LOC". In the training entity sequence [Group-n, will-v, CO, deployed in -v, LOC,,-w, will-prep, CO, established in -v, LOC,. -w], the head entity position of the head entity identifier "CO" corresponding to the head entity "Company B" in the training entity sequence is determined, and the tail entity identifier "LOC" corresponding to the tail entity "Region N" in the training entity sequence is determined. Then, it is determined that the element before the head entity identifier is "will-prep", the head entity identifier is "CO", the element between the head entity identifier and the tail entity identifier is "established in -v", the tail entity identifier is "LOC", and the element after the tail entity identifier is ".", so the generated word template is (will, CO, established in, LOC,.).

[0117] Step 306: Determine the part-of-speech template corresponding to the training text according to the word template.

[0118] Optionally, determining a part-of-speech template corresponding to the training text according to the word template includes:

[0119] Replace the words in the word template except for the head entity identifier and the tail entity identifier with their corresponding parts of speech to generate a part-of-speech template corresponding to the training text.

[0120] After obtaining the word template, replace the words in the word template except for the head entity identifier and the tail entity identifier with their corresponding parts of speech, that is, replace the element before the head entity identifier, the elements between the head entity identifier and the tail entity identifier, and the element after the tail entity identifier with their corresponding parts of speech to generate a part-of-speech template.

[0121] In the embodiment provided in the present application, following the above example, replace "将" in the word template (将, CO, 建立在, LOC, 。) with "prep", replace "建立在" with "v", and replace "。" with "w", thereby generating a part-of-speech template (prep, CO, v, LOC, w).

[0122] Step 308: Save the word template and the part-of-speech template in correspondence.

[0123] In the embodiment provided in the present application, following the above example, after obtaining the word template and the part-of-speech template, save the two in correspondence to the template pair set. When there is again a text to be processed with formats (将, CO, 建立在, LOC, 。) and (prep, CO, v, LOC, w) for relation extraction, the corresponding target tuple can be extracted.

[0124] Optionally, the method further includes: when receiving a save instruction, save the target tuple based on the save instruction.

[0125] In practical applications, when receiving a save instruction, save the obtained target tuple to complete the relation extraction work. It should be noted that if a revision instruction is received first and a revised tuple is generated, then when receiving a save instruction, the revised tuple will also be saved together.

[0126] In the embodiment provided in the present application, following the above example, if a save instruction is received before receiving a revision instruction, save the target tuple (Company A, Region M). If a save instruction is received after receiving a revision instruction, then save the target tuple (Company A, Region M) and the revised tuple (Company B, Region N).

[0127] The relation extraction method provided in the embodiment of the present application obtains a text to be processed; inputs the text to be processed into a relation extraction model for processing, and obtains a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set; upon receiving a revision instruction, generates a revision tuple based on the revision instruction; generates a training sample pair according to the text to be processed and the revision tuple, and adds the training sample pair to the initial training sample set to continue training the relation extraction model. Through the relation extraction method provided in the present application, a relation extraction model can be trained and generated with a very small amount of startup data. After the target tuple is determined by the relation extraction model, the target tuple is scored, and the target tuple that does not meet the requirements is manually corrected, and the model is continuously subjected to incremental learning training to further improve the accuracy of the model. In addition, the model is trained by forming a training sample pair of the text to be processed and the revision tuple, so that it is not necessary to rely on relations that appear repeatedly, and there is no need to consider the problem of tuple relation sparsity. It has universality and is more effective in extracting templates for specific fields.

[0128] Combine the following Figure 4 and Figure 5 Further explanation of the relationship extraction method provided in this application is given. Figure 5 FIG. 1 shows an architecture diagram of a relationship extraction method provided by an embodiment of the present application. Figure 5 As shown, the relation extraction model is first preliminarily trained through training sample pairs (training documents + training tuples). The relation extraction model obtains template pairs by processing entity recognition and part-of-speech tagging of training documents, and then evaluates and scores the obtained template pairs through training sample pairs. Specifically, the training documents in the training sample pairs are processed by template pairs to extract tuples, and the obtained tuples are compared with the training tuples, and the scores are scored based on the comparison results. Template pairs with scores exceeding a preset threshold are added to the template pair set. When there is a new text task to be processed that requires relation extraction, the text to be processed is input into the relation extraction model, matched with the template pairs in the template pair set, a target tuple is generated, and a tuple evaluation is performed on the target tuple. When the target tuple is not fully extracted or an extraction error occurs, a revision instruction is received, a revision tuple is generated, and a new training sample pair is generated from the revision tuple and the text to be processed, and the relation extraction model is continuously incrementally trained to generate a new template pair.

[0129] See also Figure 4 , Figure 4 A relationship extraction method according to an embodiment of the present application is shown. The relationship extraction method is described by taking the processing of a text to be processed in the field of personnel appointments and dismissals as an example, and includes steps 402 to 418.

[0130] Step 402: Obtain the text to be processed.

[0131] In the specific embodiment provided in the present application, the text to be processed is obtained: "Approved by the organization: Zhang is appointed to positions A and B; Li no longer holds positions B and C."

[0132] Step 404: Input the text to be processed into the relation extraction model.

[0133] In the specific embodiment provided in the present application, the text to be processed "Approved by the organization: Zhang is appointed to positions A and B; Li no longer holds positions B and C." is input into the relationship extraction model for processing.

[0134] Step 406: The relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed, and obtains the target tuple output by the relation extraction model.

[0135] In the specific embodiment provided in the present application, the relationship extraction model first performs word segmentation processing on the processed text "Approved by the organization: Zhang is appointed as position A and position B; Li no longer holds positions B and C." to obtain a word unit set [Approved by the organization: Zhang is appointed as position A, position B; Li no longer holds position B and position C. ].

[0136] Entity recognition and part-of-speech tagging are performed on the word unit set to obtain an entity sequence [after-prep, organization-n, approval-v,:-w,PER, appointed-v,POST,,-w,POST,;-w,PER, no longer appointed-v,POST, and-prep,POST,.], where PER is the entity identifier corresponding to the name, POST is the entity identifier corresponding to the position, prep represents a preposition, n represents a noun, v represents a verb, and w represents a punctuation mark.

[0137] Use the entity sequence to traverse the stored template pair set to match the target template pair shown in Table 3 below:

[0138] Table 3

[0139] Serial number Word Templates Part of Speech Template 1 :,PER,ANY,POST, w,PER,v,POST,w 2 ;,PER,no longer serves as,POST,and w, PER, v, PER, prep 3 ;,PER,no longer serves as,POST,and,POST,. w,PER,v,POST,prep,POST,w

[0140] Based on the target template pairs in Table 3 above, relationship extraction is performed on the text to be processed "Approved by the organization: Zhang is appointed to positions A and B; Li no longer holds positions B and C." to obtain the relationship extraction results shown in Table 4 below.

[0141] Table 4

[0142]

[0143]

[0144] Among them, the target tuple corresponding to template pair number 1 is (Zhang, position A), the target tuple corresponding to template pair number 2 is (Li, position B), and the target tuple corresponding to template pair number 3 is (Li, position C).

[0145] Step 408: Receive a revision instruction, and generate a revision tuple based on the revision instruction.

[0146] In the specific embodiment provided in the present application, if the relationship "Zhang is appointed to position B" in the to-be-processed text "Approved by the organization: Zhang is appointed to position A and position B; Li no longer holds positions B and C." is not correctly extracted, a revision instruction sent by the user is received, and the revision instruction is used to revise the unextracted relationship tuple. The revision instruction includes revision information "Zhang is appointed to position B", and a revision tuple (Zhang, position B) is generated based on the revision information in the revision instruction.

[0147] Step 410: Generate a training sample pair according to the text to be processed and the revised tuple, and add the training sample pair to the initial training sample set to continue training the relation extraction model.

[0148] In the specific embodiment provided in the present application, the text to be processed "Approved by the organization: Zhang holds positions A and B; Li no longer holds positions B and C." and the revised tuple (Zhang, position B) are combined to form a training sample pair, and the training sample pair is added to the initial training sample set to continue training the relationship extraction model.

[0149] The relation extraction model performs entity recognition and part-of-speech tagging on the text to be processed "Approved by the organization: Zhang holds positions A and B; Li no longer holds positions B and C.", determines the training entity sequence corresponding to the text to be processed [by-prep, organization-n, approve-v, :-w, PER, hold-v, POST, ,-w, POST, ;-w, PER, no longer hold-v, POST, and-prep, POST, 。], in the revised tuple (Zhang, position B), the head entity is "Zhang" and the tail entity is "position B", determines the head entity position and the tail entity position of the head entity identifier PER corresponding to the head entity "Zhang" and the tail entity identifier POST corresponding to the tail entity "position B" in the training entity sequence, and forms a word template (:, PER, hold, POST, ,, POST, ;) from the element ":" before the head entity identifier PER corresponding to the head entity "Zhang" in the training entity sequence, the head entity identifier "PER", the elements "hold POST、" between the head entity identifier and the tail entity identifier corresponding to the tail entity "position B", the tail entity identifier "POST", and the element ";" after the tail entity identifier. Replace the words except the head entity and the tail entity in the word template with the corresponding parts of speech to generate the part-of-speech template (w, PER, v, POST, w, POST, w) corresponding to the training text. Thus, the word template (:, PER, hold, POST, ,, POST, ;) and the part-of-speech template (w, PER, v, POST, w, POST, w) are stored in the template pair set correspondingly.

[0150] Step 412: Receive a save instruction and save the target tuple based on the save instruction.

[0151] In the specific embodiment provided by the present application, the tuples of the new position relationship (Zhang, position A), the tuples of the removed position relationship (Li, position B), and the tuples of the removed position relationship (Li, position C) are the extracted relationship tuples. Before receiving the save instruction, a revision instruction is also received, and a revised tuple (Zhang, position B) is generated based on the revision instruction. After receiving the save instruction, the above four tuples are saved.

[0152] The relation extraction method provided in the embodiment of the present application obtains a text to be processed; inputs the text to be processed into a relation extraction model for processing, and obtains a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set; upon receiving a revision instruction, generates a revision tuple based on the revision instruction; generates a training sample pair according to the text to be processed and the revision tuple, and adds the training sample pair to the initial training sample set to continue training the relation extraction model. Through the relation extraction method provided in the present application, a relation extraction model can be trained and generated with a very small amount of startup data. After the target tuple is determined by the relation extraction model, the target tuple is scored, and the target tuple that does not meet the requirements is manually corrected, and the model is continuously subjected to incremental learning training to further improve the accuracy of the model. In addition, the model is trained by forming a training sample pair of the text to be processed and the revision tuple, so that it is not necessary to rely on relations that appear repeatedly, and there is no need to consider the problem of tuple relation sparsity. It has universality and is more effective in extracting templates for specific fields.

[0153] Corresponding to the above method embodiment, the present application also provides a relationship extraction device embodiment, Figure 6 FIG. 1 is a schematic diagram showing the structure of a relationship extraction device according to an embodiment of the present application. Figure 6 As shown, the device comprises:

[0154] An acquisition module 602 is configured to acquire a text to be processed;

[0155] The extraction module 604 is configured to input the text to be processed into a relation extraction model for processing, and obtain a target tuple output by the relation extraction model, wherein the relation extraction model is obtained by training an initial training sample set;

[0156] The receiving module 606 is configured to generate a revision tuple based on the revision instruction when receiving the revision instruction;

[0157] The continuing training module 608 is configured to generate a training sample pair according to the to-be-processed text and the revised tuple, and add the training sample pair to the initial training sample set to continue training the relation extraction model.

[0158] Optionally, the extraction module 604 is further configured so that the relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed.

[0159] Optionally, the extraction module 604 is further configured to:

[0160] Performing entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed;

[0161] A target tuple corresponding to the text to be processed is generated according to the entity sequence.

[0162] Optionally, the extraction module 604 is further configured to:

[0163] Performing word segmentation processing on the text to be processed to obtain a word unit set corresponding to the text to be processed;

[0164] Perform entity recognition and part-of-speech tagging processing on the word unit set to obtain a corresponding entity sequence.

[0165] Optionally, the extraction module 604 is further configured to:

[0166] Traverse the entity sequence through the stored template pair set to determine a target template pair;

[0167] Relation extraction is performed on the text to be processed based on the target template pair to obtain a target tuple corresponding to the target template pair.

[0168] Optionally, the training samples in the initial training sample set are training texts and bigrams corresponding to the training texts, wherein the bigrams include entity pairs;

[0169] The device also includes a model training module, which is configured to:

[0170] Performing entity recognition and part-of-speech tagging on the training text to determine a training entity sequence corresponding to the training text;

[0171] Generate a word template corresponding to the training text according to the entity pair and the training entity sequence;

[0172] A part-of-speech template corresponding to the training text is determined according to the word template.

[0173] The word template and the part-of-speech template are saved correspondingly.

[0174] Optionally, the model training module is further configured as follows:

[0175] Generating a word template corresponding to the training text according to the entity pair and the training entity sequence includes:

[0176] Determine the head entity position and the tail entity position of the head entity identifier corresponding to the head entity and the tail entity identifier corresponding to the tail entity in the training entity sequence;

[0177] A word template is determined in the training entity sequence based on the head entity position and the tail entity position.

[0178] Optionally, the model training module is further configured as follows:

[0179] The words in the word template except for the head entity identifier and the tail entity identifier are replaced with corresponding parts of speech to generate a part of speech template corresponding to the training text.

[0180] Optionally, the device further comprises:

[0181] The saving module is configured to save the target tuple based on the saving instruction when receiving the saving instruction.

[0182] The relationship extraction device provided in the present application can train and generate a relationship extraction model with a very small amount of starting data. After determining the target tuple through the relationship extraction model, the target tuple is scored, and the target tuple that does not meet the requirements is manually corrected. The model continues to be incrementally learned and trained to further improve the accuracy of the model. In addition, the model is trained in a way that the text to be processed and the revised tuple are composed of training sample pairs. This does not need to rely on relations that appear multiple times, and there is no need to consider the problem of tuple relationship sparsity. It has universality and is more effective in extracting templates for specific fields.

[0183] The above is a schematic scheme of a relation extraction device of this embodiment. It should be noted that the technical scheme of the relation extraction device and the technical scheme of the relation extraction method described above belong to the same concept, and the details of the technical scheme of the relation extraction device that are not described in detail can be found in the description of the technical scheme of the relation extraction method described above.

[0184] It should be noted that the components in the device claim should be understood as the functional modules that must be established to implement the steps of the program flow or the steps of the method, and the functional modules are not actually divided or separated. The device claim defined by such a group of functional modules should be understood as the functional module architecture of the solution mainly implemented by the computer program recorded in the specification, and should not be understood as the physical device that mainly implements the solution by hardware.

[0185] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the relationship extraction method when executing the instructions.

[0186] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned relationship extraction method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned relationship extraction method.

[0187] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the relationship extraction method as described above.

[0188] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned relationship extraction method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned relationship extraction method.

[0189] An embodiment of the present application discloses a chip storing computer instructions, which implement the steps of the relationship extraction method as described above when executed by a processor.

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

[0191] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0192] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0193] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0194] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. A relationship extraction method, characterized in that: include: Get the text to be processed; The text to be processed is input into a relational extraction model for processing, and a target tuple output by the relational extraction model is obtained, wherein the relational extraction model is obtained by training an initial training sample set, and the training samples in the initial training sample set are training texts and bigrams corresponding to the training texts, wherein the bigrams include entity pairs, and the training method of the relational extraction model includes: performing entity recognition and part-of-speech tagging on the training texts to determine a training entity sequence corresponding to the training texts; generating a word template corresponding to the training texts according to the entity pairs and the training entity sequence; determining a part-of-speech template corresponding to the training text according to the word templates; and saving the word templates and the part-of-speech templates in correspondence; In case of receiving the revision instruction, generating a revision tuple based on the revision instruction; A training sample pair is generated according to the text to be processed and the revised tuple, and the training sample pair is added to the initial training sample set to continue training the relation extraction model.

2. The relationship extraction method according to claim 1, characterized in that: After the text to be processed is input into the relation extraction model for processing, the method further includes: The relation extraction model generates a target tuple corresponding to the text to be processed in response to the input text to be processed.

3. The relationship extraction method according to claim 2, characterized in that: The relation extraction model generates a target tuple corresponding to the input text to be processed in response to the input text to be processed, including: Performing entity recognition and part-of-speech tagging on the text to be processed to determine an entity sequence corresponding to the text to be processed; A target tuple corresponding to the text to be processed is generated according to the entity sequence.

4. The relationship extraction method according to claim 3, characterized in that: Performing entity recognition and part-of-speech tagging on the text to be processed to determine the entity sequence corresponding to the text to be processed includes: Performing word segmentation processing on the text to be processed to obtain a word unit set corresponding to the text to be processed; Perform entity recognition and part-of-speech tagging processing on the word unit set to obtain a corresponding entity sequence.

5. The relationship extraction method according to claim 3, characterized in that: Generating a target tuple corresponding to the to-be-processed text according to the entity sequence includes: Traverse the entity sequence through the stored template pair set to determine a target template pair; Relation extraction is performed on the text to be processed based on the target template pair to obtain a target tuple corresponding to the target template pair.

6. The relationship extraction method according to claim 1, characterized in that: The entity pair includes a head entity and a tail entity; Generating a word template corresponding to the training text according to the entity pair and the training entity sequence includes: Determine the head entity position and the tail entity position of the head entity identifier corresponding to the head entity and the tail entity identifier corresponding to the tail entity in the training entity sequence; A word template is determined in the training entity sequence based on the head entity position and the tail entity position.

7. The relationship extraction method according to claim 1, characterized in that: Determining a part-of-speech template corresponding to the training text according to the word template includes: The words in the word template except for the head entity identifier and the tail entity identifier are replaced with corresponding parts of speech to generate a part of speech template corresponding to the training text.

8. The relationship extraction method according to claim 1, characterized in that: The method further comprises: In case of receiving a save instruction, the target tuple is saved based on the save instruction.

9. A relationship extraction device, characterized in that: include: An acquisition module, configured to acquire text to be processed; The extraction module is configured to input the text to be processed into a relational extraction model for processing, and obtain a target tuple output by the relational extraction model, wherein the relational extraction model is obtained by training an initial training sample set, and the training samples in the initial training sample set are training texts and bigrams corresponding to the training texts, wherein the bigrams include entity pairs, and the training method of the relational extraction model includes: performing entity recognition and part-of-speech tagging on the training texts, and determining a training entity sequence corresponding to the training texts; generating a word template corresponding to the training texts according to the entity pairs and the training entity sequence; determining a part-of-speech template corresponding to the training text according to the word templates; and saving the word templates and the part-of-speech templates in correspondence; A receiving module, configured to generate a revision tuple based on the revision instruction when receiving the revision instruction; The continuing training module is configured to generate a training sample pair according to the to-be-processed text and the revised tuple, and add the training sample pair to the initial training sample set to continue training the relation extraction model.

10. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method according to any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Text relationship extraction method and device, computer equipment and storage medium

    CN111324743A