An entity relation extraction model generation method and an entity relation extraction method

CN116011453BActive Publication Date: 2025-10-24XIAMEN MEIYA PICO INFORMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211641148.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2025-10-24
Estimated Expiration
2042-12-20

AI Technical Summary

Technical Problem

[0003]针对上述传统思路无法训练出高效的模型能力,虽然bert具有自注意力机制,能关注到前后词的语义,但在存在大跨度的信息抽取任务时,往往无法关系前后语义,导致抽取效果差的问题,本申请提出了一种实体关系抽取模型生成方法及实体关系抽取方法

Benefits of technology

[0025]1. The present application uses a length longer than the required length in actual deployment as the maximum length for adaptive multi-stage training, because the maximum length is self-adapted and longer when training the model, and the model has higher semantic ability; when deploying, the model's ability can have better performance when using a text smaller than the maximum length of the training as input;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116011453B_ABST
    Figure CN116011453B_ABST
Patent Text Reader

Abstract

The application relates to an entity relationship extraction model generation method and an entity relationship extraction method. The application uses a length longer than the length required in actual deployment as the maximum length to adaptively perform multi-stage training. Since the maximum length during training model selection is self-adaptive and longer, the model has higher semantic ability. When a text smaller than the maximum length of training is used as input during deployment, the ability of the model can be better. It is found in actual tests that the improved training strategy makes the model have an F1 improvement of 3 points in multiple same data sets.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of entity relation extraction, in particular to an entity relation extraction model generation method and an entity relation extraction method. BACKGROUND

[0002] In an NLP actual scene, specific corpus is often very small, and the annotation cost is also very high, so it is important to enable the model to have a higher efficient advanced semantic language model capability. A traditional training strategy is: based on an open source large-scale corpus pre-training model (such as: bert), and then according to the data of a specific scene, the model parameters of the pre-training model are fine-tuned. The maximum text length at the time of final deployment is taken as the maximum length of the training text, and if the text length is less than the maximum value, the space is supplemented. The above traditional idea cannot train a high-efficiency model capability, although bert has a self-attention mechanism and can pay attention to the semantics of the previous and subsequent words, but in the presence of a large-span information extraction task (such as: entity relation extraction task), it is often impossible to relate the semantics of the previous and subsequent words, resulting in poor extraction effect. SUMMARY

[0003] In view of the problem that the above traditional idea cannot train a high-efficiency model capability, although bert has a self-attention mechanism and can pay attention to the semantics of the previous and subsequent words, but in the presence of a large-span information extraction task, it is often impossible to relate the semantics of the previous and subsequent words, resulting in poor extraction effect, the application provides an entity relation extraction model generation method and an entity relation extraction method.

[0004] In a first aspect, the application provides an entity relation extraction model generation method, including the following steps:

[0005] S101: Take 1 / 2 times of the maximum length H at the time of deployment as the maximum length of training to make a training set D1, then train the model on the training set D1, and obtain a model M1 after training convergence;

[0006] S102: Take 1 times of the maximum length H at the time of deployment as the maximum length of training to make a training set D2, and perform fintune training on the D2 training set based on the model M1 in S1 as the model basic parameter to obtain a model M2;

[0007] S103: Take 2 times of the maximum length H at the time of deployment as the maximum length of training to make a training set D3, and perform fintune training on the D3 training set based on the model M2 in S2 as the model basic parameter to obtain a final entity relation extraction model M3.

[0008] Preferably, in the S101, if a single text in the training set is too long, the text is cut.

[0009] Preferably, the operation of cutting the text is:

[0010] Assuming the length of the long sentence is h1, the length of the short sentence to be cut is h2, and the cutting step is:

[0011] Find the h2th character from the first character of the long sentence, and then find the delimiter from the character. The position of the delimiter found is the first position to be cut; if no delimiter is found from the character, it is forced to cut from the character;

[0012] Then repeat the above steps with the cut position as the first sentence until the length of the sentence found backward does not meet h1, then stop.

[0013] Preferably, the delimiters are searched according to priority, and the priority from high to low is: period, exclamation mark, question mark, semicolon and comma.

[0014] Preferably, the corresponding label is also processed while cutting the text, and the corresponding label is also processed.

[0015] If the object of the relationship triple is in the first half of the sentence and the subject is in the second half of the sentence, the relationship will be discarded after cutting.

[0016] Preferably, in the S103, if a single text in the data set is too short, multiple texts are spliced, and the corresponding entity relationship label is also spliced.

[0017] Preferably, the corresponding entity relationship label also includes single entity position adjustment and entity relationship adjustment.

[0018] Preferably, the entity relationship adjustment includes: if the same entity does not appear in the front and back two sentences, it is spliced, otherwise it is not spliced.

[0019] In a second aspect, the present application also provides an entity relationship extraction method, which comprises the following steps:

[0020] The steps are:

[0021] S201: obtaining a text data set that needs to be subjected to entity relationship extraction;

[0022] S202: using the entity relationship extraction model M3 of the first aspect to extract the entity relationship of the text data set, and taking H as the maximum length of the input text;

[0023] S203: outputting the entity relationship extraction result of the model.

[0024] In summary, the present application at least includes the following beneficial technical effects:

[0025] 1. The present application uses a length longer than the required length in actual deployment as the maximum length for adaptive multi-stage training, because the maximum length is self-adapted and longer when training the model, and the model has higher semantic ability; when deploying, the model's ability can have better performance when using a text smaller than the maximum length of the training as input;

[0026] 2. When deploying, use model M3 with H as the maximum length of the input text, the model's ability can have better performance. In actual tests, it is found that the improved training strategy makes the model have an F1 improvement of 3 points in multiple test sets;

[0027] 3. The present application trains the model in the training stage in turn according to 1 / 2 times, 1 times and 2 times of the maximum length H as the maximum length of training, and the length is from short to long, in order to gradually and purposefully guide the model to approach the optimal point when back propagation. Compared with the single-stage single-length training strategy, the semantic capture ability of the final model of the present training strategy is higher. BRIEF DESCRIPTION OF DRAWINGS

[0028] The accompanying drawings are included to provide a further understanding of embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and, together with the description, serve to explain principles of the present application. Other embodiments and many of the intended advantages of the present application will be readily appreciated as the same becomes better understood by reference to the following detailed description when considered in connection with the accompanying drawings. The elements of the drawings are not necessarily to scale relative to each other. Like reference numerals designate corresponding similar parts.

[0029] Figure 1 is a flowchart of a method for generating an entity relationship extraction model according to the present application.

[0030] Figure 2 is a schematic diagram of an entity relationship extraction method according to the present application.

[0031] Figure 3 is a structural schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present application. DETAILED DESCRIPTION

[0032] The present application will be further described below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that, for the sake of description, only the parts related to the application are shown in the drawings.

[0033] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.

[0034] Figure 1 A flowchart of an entity relationship extraction model generation method of the present application is shown, combined with reference Figure 1 The method specifically includes the following steps:

[0035] S101: Make a training set D1 according to 1 / 2 times the maximum length H at deployment as the maximum length for training, then train the model on the training set D1, and obtain the model M1 after training convergence;

[0036] In the S101, if a single text in the training set is too long, the text is cut open;

[0037] The operation of cutting open the text is:

[0038] Suppose the length of a long sentence is h1, and the length of a short sentence to be cut is h2, and the cutting step is:

[0039] Find the h2th character from the first character of the long sentence, and then find the interval symbol from this character to the front of the sentence. The position of the found interval symbol is the first position to be cut open. If no interval symbol is found from this character to the front, it is forced to cut open from this character;

[0040] Then repeat the above steps from the cut position as the beginning of the sentence until the length of the sentence found backward does not meet h1, then stop;

[0041] The interval symbol is searched according to the priority, and the priority from high to low is: period, exclamation mark, question mark, semicolon and comma;

[0042] The corresponding label is also processed while the text is cut open, and the corresponding label is also processed, including:

[0043] If the object of the relationship triple is in the first half of the sentence and the subject is in the second half of the sentence, the relationship is to be discarded after cutting;

[0044] S102: Make a training set D2 according to 1 times the maximum length H at deployment as the maximum length for training, and perform fintune training on the D2 training set based on the model M1 in S1 as the model base parameter to obtain the model M2;

[0045] S103: Make a training set D3 according to 2 times the maximum length H at deployment as the maximum length for training, and perform fintune training on the D3 training set based on the model M2 in S2 as the model base parameter to obtain the final entity relationship extraction model M3;

[0046] In the S103, if a single text in the data set is too short, multiple texts are spliced, and the corresponding entity relationship label is also spliced;

[0047] The label of the corresponding entity relationship also needs to be spliced, including single entity position adjustment and entity relationship adjustment.

[0048] The entity relationship adjustment includes: if the same entity does not appear in the front and back two sentences, splicing is performed, otherwise splicing is not performed.

[0049] In a second aspect, with reference to Figure 2 The application also discloses an entity relationship extraction method, which comprises the following steps:

[0050] S201: obtaining a text data set requiring entity relationship extraction;

[0051] S202: using the entity relationship extraction model M3 of the first aspect to perform entity relationship extraction on the text data set, and taking H as the maximum length of the input text;

[0052] S203: outputting the entity relationship extraction result of the model.

[0053] The following embodiments will specifically describe the application:

[0054] The application mainly includes two stages:

[0055] 1. Training stage:

[0056] (1) First stage: the maximum length of the training is 1 / 2 times the maximum length H when deployed (if the single text in the data set is too long, the text is cut, and the corresponding label is also processed) to make a training set, and the model M1 is obtained after training on the training set D1 and training convergence.

[0057] The specific operation of cutting the text is as follows:

[0058] Suppose the length of the long sentence is h1, and the length of the short sentence to be cut is h2, then the cutting process of the long sentence is as follows:

[0059] 1) From the first character of the long sentence, find the h2th character, and then find the sentence separator (the optimization priority from high to low is: period, exclamation mark, question mark, semicolon, comma) from the character, and the position of the found sentence separator is the first position to be cut; if no separator is found from the character, the character is forced to be cut.

[0060] 2) Then repeat the logic in 1) with the cutting position as the beginning of the sentence until the length of the sentence found backward does not meet h1, then stop.

[0061] The text segmentation in the above, the corresponding entity relation label also needs to be segmented, the segmentation processing method is P1. Taking the case of dividing the A sentence (length H) into two H / 2 sentences as an example:

[0062] If the object of the relationship triple is located in the first half of the sentence and the subject is located in the second half of the sentence, then this relationship is discarded after segmentation.

[0063] (2) The second stage: according to the strategy of "1 times the maximum length H during deployment as the maximum length of training", the training data set D2 is made, and the model M1 of the first stage is used as the model basis parameter for fintune (finetune means retraining) on the D2 training set. The model M2 is obtained.

[0064] (3) The third stage: according to the strategy of "2 times the maximum length H during deployment as the maximum length of training (if the single text in the data set is too short, then multiple texts are spliced)", the training data set D3 is made, and the model M2 of the second stage is used as the model basis parameter for fintune training on the D3 training set. The final model M3 is obtained.

[0065] When splicing the text in the above, the corresponding entity relation label also needs to be spliced, including single entity position adjustment and entity relation adjustment.

[0066] The splicing processing method is P2, taking the case of splicing B sentence after A sentence as an example:

[0067] 3.1) Single entity position adjustment: the position of the entity in the B sentence needs to be adjusted:

[0068] For example, the first sentence to be spliced is:

[0069] "Xiaowang and Xiaozhang watched basketball together and were very happy."

[0070] At this time, the position of the entity "Xiaowang" is [0, 1] (Note: 0 is the start position and 1 is the end position);

[0071] The second sentence is:

[0072] "Today, Xiaoming is preparing to go fishing."

[0073] At this time, the position of the entity "Xiaoming" is [2, 3];

[0074] After splicing the two sentences, it is:

[0075] "Xiaowang and Xiaozhang watched basketball together and were very happy. Today, Xiaoming is preparing to go fishing."

[0076] After splicing, the position of the entity "Xiaoming" needs to be adjusted to [18, 19];

[0077] 3.2) Adjustment of entity relationship: the same entity cannot appear in the B sentence as in the A sentence, otherwise it will cause semantic confusion and lead to the introduction of noise.

[0078] For example, there is a person name "Xiaoming" in both A and B sentences. The representation of A and B sentences will introduce a new entity relationship for "Xiaoming", which does not exist according to the original annotation. In order to avoid unnecessary noise data, the same entity cannot appear in the B sentence as in the A sentence.

[0079] If the same entity appears in the B sentence as in the A sentence, the two sentences cannot be spliced together.

[0080] 2. Deployment phase:

[0081] When deploying, use model M3, and the maximum length of input text is H. At this time, the model's ability can have better performance. In actual testing, it is found that the improved training strategy makes the model have an F1 improvement of 3 points in multiple test sets, thus showing better entity relationship extraction effect.

[0082] The calculation formula of F1 is: 2PR / (P+R), where P is the accuracy precision, R is the recall rate, and F1 is an index that considers the accuracy precision and recall rate.

[0083] In the training phase, the maximum length of the model is trained in turn according to 1 / 2, 1, and 2 times of the maximum length H. The length is from short to long, which is to gradually and purposefully guide the model to approach the optimal point when backpropagation. Compared with the single-stage single-length training strategy, the final model of this training strategy has higher semantic capture ability.

[0084] The span of the two entities with a relationship at 1 / 2 times the length is not too large. At this time, when training the relationship extraction model based on the pre-trained model bert, it will quickly converge and find an optimal value.

[0085] Then at 1 times, the entity span with a relationship becomes larger, and the semantic ability of the model is required to be higher. However, since this stage is trained on the basis of the model trained in the previous 1 / 2 (which already has certain relationship extraction ability, but the semantic ability to capture long-span is not strong), compared with directly training on the basis of the bert pre-trained model, it is easier to converge and find a better point of the model.

[0086] Finally, at 2 times, the related entity span is the largest, and the semantic ability of the model is the highest. But since this stage is trained on the basis of the model trained in the previous 1 times (already has a certain relationship extraction ability, only the semantic ability of capturing long span is not strong), compared with training directly on the basis of the pre-trained bert model, it is easier to converge and can find a better point of the model.

[0087] The present application uses a longer length than the length required in actual deployment as the maximum length to adaptively train in multiple stages. Since the maximum length during training of the model is adaptively selected and longer, the model has higher semantic ability. When deploying, the model has better performance when using a text smaller than the maximum length of training as input. In actual testing, it is found that the improved training strategy makes the model have an F1 improvement of 3 points in multiple same data sets.

[0088] Reference will now be made to the following description Figure 3 which shows a structural schematic diagram of a computer system 300 of an electronic device suitable for implementing embodiments of the present application. Figure 3 The electronic device shown is merely an example and should not impose any limitation on the functions and use range of embodiments of the present application.

[0089] As shown in Figure 3 , the computer system 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 302 or programs loaded from a storage portion 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the system 300 are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0090] The following components are connected to the I / O interface 305: an input portion 306 including a keyboard, a mouse, and the like; an output portion 307 including a liquid crystal display (LCD), and the like, and a speaker, and the like; a storage portion 308 including a hard disk, and the like; and a communication portion 309 including a network interface card such as a LAN card, a modem, and the like. The communication portion 309 performs communication processing via a network such as the Internet. A drive 230 is also connected to the I / O interface 305 as needed. A removable medium 211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 230 as needed, so that a computer program read therefrom is installed in the storage portion 308 as needed.

[0091] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 309, and / or installed from the detachable medium 211. When the computer program is executed by the central processing unit (CPU) 301, the above-described functions defined in the methods of the present application are performed.

[0092] As another aspect, the present application also provides a computer readable storage medium, which can be included in the electronic device described in the above embodiments, or can exist separately without being assembled into the electronic device. The above computer readable storage medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods as shown in the above embodiments. Figure 1

[0093] It should be noted that the computer readable storage medium described in the present application can be a computer readable signal medium or a computer readable storage medium, or any combination of the above two. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable storage medium other than the computer readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.​

[0094] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0095] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0096] The specific embodiments described above are examples for implementing the application and the application is not limited to only the embodiments described above. Any modifications of structure, equivalent structures, changes or replacements within the technical scope of the application will fall into the scope of the application. Therefore, the scope of the application should be determined by the scope of the claims.

[0097] In the description of the application, it needs to be understood that the terms "upper", "lower", "inner", "outer" and the like indicate the orientation or positional relationship shown in the drawings based on the orientation or positional relationship shown in the drawings, and are only for the purpose of facilitating the description of the application and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the application. The word 'comprising' does not exclude the existence of elements or steps not listed in the claims. The word 'a' or 'an' in front of an element does not exclude the existence of multiple such elements. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that the combination of these measures cannot be used to improve. Any reference signs in the claims should not be interpreted as limiting the scope.

Claims

1. A method for generating an entity relation extraction model, the method comprising: The method comprises the following steps: S101: make a training set D1 according to 1 / 2 of the maximum length H of the input text at deployment as the maximum length of training, then train the model on the training set D1, and obtain the model M1 after training convergence; if a single text in the training set is too long, cut the text; The operation of cutting the text is: assuming that the length of a long sentence is h1, and the length of a short sentence to be cut is h2, the cutting steps are: find the h2th character from the first character of the long sentence, and then find the interval symbol of the sentence from the character, and the position of the found interval symbol is the first position to be cut; if no interval symbol is found from the character, the character is forced to be cut; then repeat the above steps from the cut position as the beginning of the sentence until the length of the sentence found backward does not meet h1, then stop; S102: make a training set D2 according to 1 times the maximum length H at deployment as the maximum length of training, and perform fintune training on the D2 training set based on the model M1 in S1 as the model base parameter to obtain the model M2; S103: make a training set D3 according to 2 times the maximum length H at deployment as the maximum length of training, and perform fintune training on the D3 training set based on the model M2 in S2 as the model base parameter to obtain the final entity relation extraction model M3.

2. The method of claim 1, wherein: The interval symbol is searched according to the priority, and the priority from high to low is: period, exclamation mark, question mark, semicolon and comma.

3. The method of claim 2, wherein: The corresponding label is also processed when the text is cut, and the corresponding label is also processed, comprising: If the object of the relationship triple is in the first half of the sentence and the subject is in the second half of the sentence, the relationship is discarded after cutting.

4. The method of claim 1, wherein: In the S103, if a single text in the data set is too short, multiple texts are spliced, and the corresponding entity relation label is also spliced.

5. The method of claim 4, wherein: The corresponding entity relation label also needs to be spliced, including single entity position adjustment and entity relation adjustment.

6. The method of claim 5, wherein: The entity relation adjustment comprises: if the same entity does not appear in the front and back two sentences, splicing is performed, otherwise, splicing is not performed.

7. An entity relationship extraction method, characterized by: The method comprises the following steps: S201: obtain a text data set requiring entity relation extraction; S202: use the entity relation extraction model M3 in any one of claims 1-6 to perform entity relation extraction on the text data set, and take H as the maximum length of the input text; S203: output the entity relation extraction result of the model.

Citation Information

Patent Citations

  • road extraction method based on remote sensing images and deep learning

    CN109800736A

  • Adaptive small sample learning intelligent error correction method based on ALBERT model

    CN114757169A