Entity relation extraction method, entity relation learning model acquisition method and device
By acquiring and optimizing the prototype feature set of the entity relationship learning model, the problem of insufficient representativeness of memorized text is solved, and a higher entity relationship extraction accuracy is achieved.
Patent Information
- Application Number
- CN202010537884.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-12
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2040-10-12
AI Technical Summary
In existing technologies, the representativeness of memory texts corresponding to entity relationships is poor, resulting in poor learning performance of entity relationship learning models and consequently affecting the accuracy of entity relationship extraction.
By acquiring the target entity relationship learning model, utilizing the prototype feature set corresponding to the target entity relationship set, and combining it with the target memory text set, the entity relationship learning model is optimized to improve its learning effect.
This improves the accuracy of entity relation extraction, ensuring that the entity relation learning model can more comprehensively represent entity relations and enhance the accuracy of entity relation extraction.
Smart Images

Figure CN111737415B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of artificial intelligence, in particular to an entity relation extraction method, an entity relation learning model obtaining method and equipment. BACKGROUND
[0002] Information extraction aims to extract structured information from large-scale unstructured or semi-structured natural language texts. Entity relation extraction is one of the important sub-tasks of information extraction, and the purpose of entity relation extraction is to extract entity relations between entities from texts. For example, the entity relation "serves as chairman" is extracted from the given text "Newton serves as chairman of the Royal Society", and the extracted entity relation can be used as an external resource for various downstream applications (such as search engines, question and answer systems, etc.). With the development of artificial intelligence technology, in the process of entity relation extraction, an entity relation learning model that has learned the continuously emerging entity relations is first obtained, and then the entity relation extraction task is implemented based on the obtained entity relation learning model.
[0003] In related technologies, an entity relation learning model is obtained directly based on a memory text corresponding to an entity relation, and then entity relation extraction is performed based on the obtained entity relation learning model. The representative of the memory text corresponding to the entity relation is poor, and it is difficult to comprehensively represent the entity relation. The entity relation learning model obtained based on the memory text corresponding to the entity relation has poor entity relation learning effect, and the accuracy of entity relation extraction based on the obtained entity relation learning model is low. SUMMARY
[0004] Embodiments of the present application provide an entity relation extraction method, an entity relation learning model obtaining method and equipment, which can be used to improve the accuracy of entity relation extraction. The technical solution is as follows:
[0005] In one aspect, the embodiments of the present application provide an entity relation extraction method, which comprises:
[0006] obtaining a target text and a target entity relation learning model to be extracted, the target entity relation learning model being obtained based on a prototype feature set corresponding to a target entity relation set, the prototype feature set corresponding to the target entity relation set being obtained based on a target memory text set, and the target entity relation set including each target entity relation that the target entity relation learning model has learned;
[0007] calling the target entity relation learning model to obtain text features of the target text and target prototype features corresponding to each target entity relation in the target entity relation set respectively;
[0008] For any target entity relationship in the target entity relationship set, a matching degree of the target text and the any target entity relationship is determined based on a text feature of the target text and a target prototype feature corresponding to the any target entity relationship; and an entity relationship corresponding to the target text is determined based on the matching degrees of the target text and each target entity relationship.
[0009] The application further provides an obtaining method of an entity relationship learning model, which comprises the following steps:
[0010] obtaining a training text set corresponding to a set of entity relationships to be learned, wherein the set of entity relationships to be learned comprises at least one entity relationship to be learned, and the training text set comprises training texts corresponding to each entity relationship to be learned respectively;
[0011] taking the set of the entity relationships to be learned and the set of learned entity relationships as a target entity relationship set, and updating an existing memory text set based on the training text set to obtain a target memory text set;
[0012] training a first entity relationship learning model based on the training text set to obtain a second entity relationship learning model;
[0013] obtaining a prototype feature set corresponding to the target entity relationship set based on the second entity relationship learning model and the target memory text set, and optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set;
[0014] in response to satisfying an optimization termination condition, taking an entity relationship learning model obtained when the optimization termination condition is satisfied as a target entity relationship learning model.
[0015] In a possible implementation manner, the third adjusted second entity relationship learning model comprises a third adjusted second feature extraction model and a second relationship feature management model, the second relationship feature management model is configured to manage a target relationship feature set corresponding to the target entity relationship set, and the fourth adjustment of the third adjusted second entity relationship learning model based on the activated text set comprises:
[0016] calling the third adjusted second feature extraction model to perform feature extraction on each activated text in the activated text set to obtain a text feature of the each activated text;
[0017] for any activated text, obtaining a matching result corresponding to the any activated text based on a target relationship feature set managed by the second relationship feature management model and a text feature of the any activated text;
[0018] Determine a sixth loss function based on the matching result corresponding to each activated text; update the parameters of the third adjusted second feature extraction model based on the sixth loss function.
[0019] In another aspect, an entity relationship extraction device is provided, the device comprising:
[0020] A first obtaining unit is configured to obtain a target text and a target entity relationship learning model to be used for extracting an entity relationship, the target entity relationship learning model being obtained based on a prototype feature set corresponding to a target entity relationship set, the prototype feature set corresponding to the target entity relationship set being obtained based on a target memory text set, and the target entity relationship set including each target entity relationship that has been learned by the target entity relationship learning model.
[0021] A second obtaining unit is configured to call the target entity relationship learning model to obtain a text feature of the target text and a target prototype feature corresponding to each target entity relationship in the target entity relationship set.
[0022] A determining unit is configured to determine, for any target entity relationship in the target entity relationship set, a matching degree between the target text and the target entity relationship based on the text feature of the target text and the target prototype feature corresponding to the target entity relationship, and determine an entity relationship corresponding to the target text based on the matching degrees between the target text and each target entity relationship.
[0023] In a possible implementation, the second obtaining unit is further configured to, for any target entity relationship in the target entity relationship set, obtain a target candidate text set corresponding to the target entity relationship based on the target memory text set, call the target entity relationship learning model to obtain a text feature of each target candidate text in the target candidate text set corresponding to the target entity relationship, and obtain the target prototype feature corresponding to the target entity relationship based on the text features of the target candidate texts.
[0024] An entity relationship learning model obtaining device is also provided, the device comprising:
[0025] A first obtaining unit is configured to obtain a training text set corresponding to a set of entity relationships to be learned, the set of entity relationships to be learned including at least one entity relationship to be learned, and the training text set including a training text corresponding to each entity relationship to be learned.
[0026] A second obtaining unit is configured to take a union of the set of entity relationships to be learned and a set of learned entity relationships as a target entity relationship set, and update an existing memory text set based on the training text set to obtain a target memory text set.
[0027] a training unit configured to train a first entity relation learning model based on the training text set to obtain a second entity relation learning model;
[0028] a third obtaining unit configured to obtain a prototype feature set corresponding to the target entity relation set based on the second entity relation learning model and the target memory text set;
[0029] an optimization unit configured to optimize the second entity relation learning model based on the target memory text set and the prototype feature set;
[0030] a determination unit configured to, in response to the optimization termination condition being met, determine an entity relation learning model obtained when the optimization termination condition is met as the target entity relation learning model.
[0031] In a possible implementation, the first entity relation learning model comprises a first feature extraction model and a first relation feature management model, and the first relation feature management model is configured to manage an initial relation feature set corresponding to the target entity relation set; the training unit is configured to invoke the first feature extraction model to perform feature extraction on each training text in the training text set to obtain a text feature of the training text; for any training text, the initial relation feature set managed by the first relation feature management model and the text feature of the any training text are used to obtain a matching result corresponding to the any training text; a first loss function is determined based on the matching result corresponding to each training text; and parameters of the first feature extraction model and the first relation feature management model are updated based on the first loss function.
[0032] In a possible implementation, the second obtaining unit is further configured to perform clustering processing on the training texts in the training text set, determine a memory text quantity corresponding to each to-be-learned entity relation in the to-be-learned entity relation set according to a clustering result obtained, perform clustering processing on the training texts in the training text set corresponding to any to-be-learned entity relation according to the memory text quantity corresponding to the any to-be-learned entity relation, determine a memory text corresponding to the any to-be-learned entity relation according to a clustering result obtained, and add the memory texts corresponding to the to-be-learned entity relations to the existing memory text set to obtain the target memory text set.
[0033] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model; the third obtaining unit is configured to, for any target entity relationship in the target entity relationship set, construct a prototype text set corresponding to the any target entity relationship based on the target memory text set; invoke the second feature extraction model to perform feature extraction on each prototype text in the prototype text set to obtain text features of the each prototype text; obtain prototype features corresponding to the any target entity relationship based on the text features of the each prototype text; and take a set of prototype features corresponding to each target entity relationship in the target entity relationship set as a prototype feature set corresponding to the target entity relationship set.
[0034] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model; the optimization unit is configured to, for any target entity relationship in the target entity relationship set, construct a first instance text set corresponding to the any target entity relationship based on the target memory text set; invoke the second feature extraction model to perform feature extraction on each first instance text in the first instance text set to obtain text features of the each first instance text; for any first instance text, obtain a matching result corresponding to the any first instance text based on the prototype feature set and the text features of the any first instance text; obtain a first sub-loss function corresponding to the any target entity relationship based on the matching result corresponding to each first instance text; determine a second loss function based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set; and update parameters of the second feature extraction model based on the second loss function.
[0035] In a possible implementation, the optimization unit is further configured to take the set of the target memory text set and the training text set as an active text set; and optimize the second entity relationship learning model based on the active text set, the target memory text set, and the prototype feature set.
[0036] In a possible implementation, the optimization unit is further configured to perform first adjustment on the second entity relationship learning model based on the active text set, and perform second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
[0037] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model and a second relationship feature management model, the second relationship feature management model being configured to manage a target relationship feature set corresponding to the target entity relationship set; and the optimization unit is further configured to: invoke the second feature extraction model to perform feature extraction on each active text in the active text set, to obtain a text feature of the active text; for any active text, obtain a matching result corresponding to the active text based on the target relationship feature set managed by the second relationship feature management model and the text feature of the active text; determine a third loss function based on the matching result corresponding to each active text; and update a parameter of the second feature extraction model based on the third loss function.
[0038] In a possible implementation, the first adjusted second entity relationship learning model comprises a first adjusted second feature extraction model; and the optimization unit is further configured to: for any target entity relationship in the target entity relationship set, construct a second instance text set corresponding to the target entity relationship based on the target memory text set; invoke the first adjusted second feature extraction model to perform feature extraction on each second instance text in the second instance text set, to obtain a text feature of the second instance text; for any second instance text, obtain a matching result corresponding to the second instance text based on the prototype feature set and the text feature of the second instance text; obtain a second sub-loss function corresponding to the target entity relationship based on the matching result corresponding to each second instance text; determine a fourth loss function based on the second sub-loss function corresponding to each target entity relationship in the target entity relationship set; and update a parameter of the first adjusted second feature extraction model based on the fourth loss function.
[0039] In a possible implementation, the optimization unit is further configured to: perform third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set; and perform fourth adjustment on the second entity relationship learning model after the third adjustment based on the active text set.
[0040] In a possible implementation, the second entity relation learning model comprises a second feature extraction model; the optimization unit is further configured to, for any target entity relation in the set of target entity relations, construct a third instance text set corresponding to the any target entity relation based on the set of target memory texts; invoke the second feature extraction model to perform feature extraction on each third instance text in the third instance text set to obtain a text feature of the each third instance text; for any third instance text, obtain a matching result corresponding to the any third instance text based on the set of prototype features and the text feature of the any third instance text; obtain a third sub-loss function corresponding to the any target entity relation based on the matching result corresponding to each third instance text; determine a fifth loss function based on the third sub-loss function corresponding to each target entity relation in the set of target entity relations; and update parameters of the second feature extraction model based on the fifth loss function.
[0041] In a possible implementation, the third adjusted second entity relation learning model comprises a third adjusted second feature extraction model and a second relation feature management model, and the second relation feature management model is configured to manage a set of target relation features corresponding to the set of target entity relations; the optimization unit is further configured to invoke the third adjusted second feature extraction model to perform feature extraction on each active text in the set of active texts to obtain a text feature of the each active text; for any active text, obtain a matching result corresponding to the any active text based on the set of target relation features managed by the second relation feature management model and the text feature of the any active text; determine a sixth loss function based on the matching result corresponding to each active text; and update parameters of the third adjusted second feature extraction model based on the sixth loss function.
[0042] In another aspect, a computer device is provided, which comprises a processor and a memory, and the memory stores at least one program code, which is loaded and executed by the processor to implement any of the above-described entity relation extraction methods or any of the above-described entity relation learning model obtaining methods.
[0043] In another aspect, a computer readable storage medium is also provided, which stores at least one program code, which is loaded and executed by a processor to implement any of the above-described entity relation extraction methods or any of the above-described entity relation learning model obtaining methods.
[0044] In another aspect, a computer program product is provided, in which at least one computer program is stored, the at least one computer program is loaded and executed by a processor to implement the entity relation extraction method described above, or to implement the obtaining method of the entity relation learning model described above.
[0045] The technical solutions provided by the embodiments of the present application at least bring the following beneficial effects:
[0046] The target entity relation learning model is obtained based on the prototype feature set corresponding to the target entity relation set, the prototype feature set is obtained based on the target memory text set, the prototype features in the prototype feature set are more representative than the memory text, and can more comprehensively represent the entity relations, the target entity relation learning model obtained based on the prototype feature set has good entity relation learning effect, and the accuracy of entity relation extraction using the target entity relation learning model is higher. BRIEF DESCRIPTION OF DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0048] Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
[0049] Figure 2 is a flowchart of an entity relation extraction method provided by an embodiment of the present application;
[0050] Figure 3 is a flowchart of an obtaining method of a target entity relation learning model provided by an embodiment of the present application;
[0051] Figure 4 is a process schematic diagram of discovering and learning new entity relations appearing continuously provided by an embodiment of the present application;
[0052] Figure 5 is a process schematic diagram of obtaining a target entity relation learning model provided by an embodiment of the present application;
[0053] Figure 6 is a schematic diagram of the average accuracy of entity relation extraction changing with the number of tasks provided by an embodiment of the present application;
[0054] Figure 7 is a schematic diagram of an entity relation extraction device provided by an embodiment of the present application;
[0055] Figure 8 is a schematic diagram of an entity relationship learning model acquisition device provided by an embodiment of the present application;
[0056] Figure 9 is a structural schematic diagram of a server provided by an embodiment of the present application;
[0057] Figure 10 is a structural schematic diagram of a terminal provided by an embodiment of the present application. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.
[0059] Artificial intelligence (AI) is the use of digital computers or digital computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0060] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software technologies. Artificial intelligence basic technologies generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc.
[0061] The scheme provided by the embodiments of the present application relates to artificial intelligence natural language processing technology. Natural language processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language used in daily life, so it has a close relationship with the study of linguistics. Natural language processing technology usually includes text processing, entity relationship extraction, semantic understanding, machine translation, robot question answering, knowledge graph, etc.
[0062] With the research and progress of artificial intelligence technology, artificial intelligence technology is researched and applied in many fields, such as common smart home, smart wearable device, virtual assistant, smart speaker, smart marketing, unmanned driving, autonomous driving, unmanned aerial vehicle, robot, smart medical treatment, smart customer service and the like. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important value.
[0063] The embodiment of the present application provides an entity relationship extraction method and an entity relationship learning model acquisition method, please refer to Figure 1 which shows the schematic diagram of the implementation environment of the entity relationship extraction method and the entity relationship learning model acquisition method provided by the embodiment of the present application. The implementation environment can include a terminal 11 and a server 12.
[0064] The entity relationship extraction method can be implemented based on the terminal 11, or can be implemented based on the server 12, and the embodiment of the present application does not limit this. In addition, the entity relationship learning model acquisition method can be implemented based on the terminal 11, or can be implemented based on the server 12.
[0065] In a possible implementation manner, the terminal 11 can be any kind of electronic product that can interact with a user through one or more ways such as a keyboard, a touchpad, a touch screen, a remote controller, voice interaction or a handwriting device, for example, a PC (Personal Computer), a mobile phone, a smart phone, a PDA (Personal Digital Assistant), a wearable device, a PPC (Pocket PC), a tablet computer, a smart car machine, a smart television, a smart speaker and the like. The server 12 can be a server, or a server cluster composed of multiple servers, or a cloud computing service center. The terminal 11 and the server 12 establish a communication connection through a wired or wireless network.
[0066] Those skilled in the art should understand that the terminal 11 and the server 12 described above are only examples, and other existing or future terminal or server, such as applicable to the present application, should also be included in the protection scope of the present application, and are included herein by reference.
[0067] Based on the implementation environment shown in Figure 1 The embodiment of the present application provides an entity relationship extraction method, which is taken as an example that the method is applied to the terminal 11. As shown in Figure 2 The entity relationship extraction method provided by the embodiment of the present application can include the following steps:
[0068] In step 201, the target text for extracting entity relationships and the target entity relationship learning model are obtained. The target entity relationship learning model is obtained based on the prototype feature set corresponding to the target entity relationship set, and the prototype feature set corresponding to the target entity relationship set is obtained based on the target memory text set.
[0069] The target entity relationship set includes all target entity relationships that the target entity relationship learning model has learned.
[0070] The target text is any text containing entity relations to be extracted. In one possible implementation, the process of obtaining the target text is as follows: obtaining the target statement, preprocessing the obtained target statement, and obtaining the target text corresponding to the target statement. The target statement refers to any statement containing two entities. This application embodiment does not limit the source of the target statement. For example, the target statement can come from a corpus or from a webpage, etc.
[0071] In one possible implementation, the process of preprocessing the acquired target statement to obtain the target text corresponding to the target statement is as follows: by extracting various information such as semantic information and the positions of the beginning and end entities of the target statement, the target statement is parsed into a tag sequence, and the tag sequence is used as the target text.
[0072] A target entity relation learning model refers to an entity relation learning model that has learned continuously occurring entity relations before entity relation extraction from the target text. In this embodiment, the target entity relation learning model is obtained based on the prototype feature set corresponding to the target entity relation set. The target entity relation set includes all target entity relations learned by the target entity relation learning model before entity relation extraction from the target text, and the prototype feature set includes the prototype features corresponding to each target entity relation. The prototype feature set corresponding to the target entity relation set is obtained based on the target memory text set, which includes the memory text corresponding to each target entity relation.
[0073] The process of obtaining the target entity relationship learning model can be executed by either the terminal or the server, and this application embodiment does not limit this. When the process of obtaining the target entity relationship learning model is executed by the terminal, the terminal obtains the target entity relationship learning model locally; when the process of obtaining the target entity relationship learning model is executed by the server, the terminal obtains the target entity relationship learning model from the server.
[0074] For details on the process of obtaining the target entity relationship learning model, please refer to Figure 3 The illustrated embodiments will not be described in detail here. Furthermore, the target entity relation set and target memory text set are described in detail during the process of obtaining the target entity relation learning model, and will also not be repeated here.
[0075] In step 202, a target entity relationship learning model is invoked to obtain the text features of the target text and the target prototype features corresponding to each target entity relationship in the target entity relationship set respectively.
[0076] The target entity relationship learning model has good text feature extraction capability. After obtaining the target text, the target entity relationship learning model is invoked to obtain the text features of the target text. The text features of the target text are used to determine the entity relationship corresponding to the target text.
[0077] In a possible implementation manner, the target entity relationship learning model comprises a target feature extraction model. The manner of invoking the target entity relationship learning model to obtain the text features of the target text is: invoking the target feature extraction model to perform feature extraction on the target text to obtain the text features of the target text.
[0078] The target prototype features corresponding to any target entity relationship refer to the final prototype features of the target entity relationship obtained by using the target entity relationship learning model. The target prototype features are used for comparison with the text features of the target text to further determine the entity relationship corresponding to the target text.
[0079] In a possible implementation manner, the method for obtaining the target prototype features corresponding to any target entity relationship in the target entity relationship set comprises the following steps 2021 to 2023:
[0080] Step 2021: For any target entity relationship in the target entity relationship set, based on the target memory text set, a target candidate text set corresponding to the target entity relationship is obtained.
[0081] In a possible implementation manner, based on the target memory text set, the target candidate text set corresponding to the target entity relationship is obtained in the following manner: the set of target memory texts corresponding to the target entity relationship in the target memory text set is taken as the candidate text set; and a reference number of candidate texts in the candidate text set are selected to constitute the target candidate text set corresponding to the target entity relationship. The reference number can be set according to experience or adjusted according to the number of candidate texts in the candidate text set, which is not limited in the embodiments of the present application. In a possible implementation manner, the reference number can be the same as the number of candidate texts in the candidate text set, in which case, all the target memory texts corresponding to the target entity relationship in the target memory file set are taken as the target candidate texts constituting the target candidate text set. The target prototype features obtained based on such a target candidate text set are more representative.
[0082] Step 2022: The target entity relationship learning model is invoked to obtain the text features of each target candidate text in the target candidate text set corresponding to the target entity relationship.
[0083] In a possible implementation, the target entity relation learning model comprises a target feature extraction model, and the manner in which the text features of each target candidate text in the target candidate text set corresponding to any target entity relation are obtained by calling the target entity relation learning model is: the target feature extraction model is called to perform feature extraction on each target candidate text in the target candidate text set corresponding to any target entity relation, to obtain the text features of each target candidate text.
[0084] Step 2023: Based on the text features of each target candidate text, obtain the target prototype feature corresponding to any target entity relation.
[0085] After obtaining the text features of each target candidate text, based on the text features of each target candidate text, the target prototype feature corresponding to any target entity relation is obtained. In a possible implementation, the process of obtaining the target prototype feature corresponding to any target entity relation based on the text features of each target candidate text can be implemented based on formula 1:
[0086]
[0087] wherein, denotes the target entity relation r i corresponding target prototype feature; f(x j ) denotes the text feature of the target candidate text x j ; and S denotes the number of target candidate texts in the target candidate text set.
[0088] In a possible implementation, the process of obtaining the target prototype feature corresponding to any target entity relation based on the text features of each target candidate text can also be: based on the text features of the target candidate text and the target relation feature corresponding to any target entity relation, the target prototype feature corresponding to any target entity relation is obtained. The target relation feature corresponding to any target entity relation is obtained in the process of obtaining the target entity relation learning model, and can represent the general feature of any target entity relation. The target prototype feature obtained in this manner can better represent the any target entity relation. For example, the process of obtaining the target prototype feature corresponding to any target entity relation based on the text features of the target candidate text and the target relation feature corresponding to any target entity relation can be implemented based on formula 2:
[0089]
[0090] wherein, denotes the target entity relation r i corresponding target prototype feature; f(x j ) denotes the text feature of the target candidate text x jthe text features of the target text; S represents the number of target candidate texts in the target candidate text set; r i represents the target entity relationship r i corresponding to the target relationship feature.
[0091] Steps 2021 to 2023 introduce the process of obtaining the target prototype feature corresponding to any target entity relationship from the perspective of any target entity relationship. According to the manner of steps 2021 to 2023, the target prototype feature corresponding to each target entity relationship can be obtained respectively.
[0092] In step 203, for any target entity relationship in the target entity relationship set, the matching degree between the target text and the target entity relationship is determined based on the text features of the target text and the target prototype feature corresponding to the target entity relationship; and the entity relationship corresponding to the target text is determined based on the matching degrees between the target text and the target entity relationships.
[0093] After obtaining the text features of the target text and the target prototype features corresponding to each target entity relationship, the matching degrees between the target text and each target entity relationship are determined based on the text features of the target text and the target prototype features corresponding to each target entity relationship, and then the entity relationship corresponding to the target text is determined based on the matching degrees between the target text and each target entity relationship.
[0094] Taking the process of determining the matching degree between the target text and any target entity relationship in the target entity relationship set as an example, in a possible implementation manner, for any target entity relationship in the target entity relationship set, the process of determining the matching degree between the target text and the target entity relationship based on the text features of the target text and the target prototype feature corresponding to the target entity relationship is as follows: obtaining the similarity between the text features of the target text and the target prototype feature corresponding to the target entity relationship; and determining the matching degree between the target text and the target entity relationship based on the similarity between the text features of the target text and the target prototype feature corresponding to the target entity relationship.
[0095] In a possible implementation manner, the process of determining the matching degree between the target text and the target entity relationship based on the similarity between the text features of the target text and the target prototype feature corresponding to the target entity relationship can be implemented based on formula 3:
[0096]
[0097] wherein s(x, r i ) represents the matching degree between the target text x and the target entity relationship r i ; f(x) represents the text features of the target text x; represents the target entity relationship r icorresponding target prototype feature; text features and target entity relations r i similarity between corresponding target prototype features.
[0098] After determining the matching degrees of the target text and each target entity relation, the target entity relation corresponding to the target text is determined based on the matching degrees of the target text and each target entity relation. In a possible implementation, the target entity relation corresponding to the target text is determined based on the matching degrees of the target text and each target entity relation in the following manner: the target entity relation corresponding to the highest matching degree is taken as the target entity relation corresponding to the target text. The process of taking the target entity relation corresponding to the highest matching degree as the target entity relation corresponding to the target text can be implemented based on formula 4.
[0099]
[0100] wherein s(x, r i ) represents the matching degree of the target text x and the target entity relation r i , represents the target entity relation set; represents the target entity relation corresponding to the highest matching degree, that is, represents the target entity relation corresponding to the target text.
[0101] In the embodiments of the present application, the target entity relation learning model is obtained based on the prototype feature set corresponding to the target entity relation set, and the prototype feature set is obtained based on the target memory text set. The prototype features in the prototype feature set are more representative than the memory texts and can more comprehensively represent entity relations. The target entity relation learning model obtained based on the prototype feature set has a good entity relation learning effect, and the accuracy of entity relation extraction using the target entity relation learning model is relatively high.
[0102] Based on the implementation environment shown in Figure 1 , the embodiments of the present application provide an acquisition method of an entity relation learning model. It should be noted that the acquisition method of the entity relation learning model provided by the embodiments of the present application can be executed before step 201 in the embodiment shown in Figure 2 , or can be executed in the process of executing step 201 in the embodiment shown in Figure 2 . The embodiments of the present application do not limit this. As shown in Figure 3 , the acquisition method of the target entity relation learning model provided by the embodiments of the present application can include the following steps:
[0103] In step 301, a training text set corresponding to a set of entity relationships to be learned is acquired, the set of entity relationships to be learned including at least one entity relationship to be learned, and the training text set including training texts respectively corresponding to each entity relationship to be learned.
[0104] An entity relationship is used to indicate a relationship between two entities in a text. For example, for the text "Newton served as the president of the Royal Society", the two entities in the text are "Newton" and "the Royal Society", and the entity relationship between the two entities is "served as the president". By learning entity relationships in texts with known entity relationships, appropriate entity relationships can be extracted in texts with unknown entity relationships, thereby providing external resources for the implementation of various downstream applications (such as search engines, question and answer systems, etc.).
[0105] In practical applications, new entity relationships are constantly emerging. At present, in exploring how to discover and learn new entity relationships constantly emerging, a solution composed of two levels of pipelines has appeared: (1) Open relation extraction. Learning to extract phrases, subjects and objects in sentences to construct specific relationship patterns, then discovering new entity relationships through clustering, and finally using the new entity relationships to expand the text set containing these new entity relationships in large-scale text corpus; (2) Continuous relationship learning. Continuously using the text set expanded with new entity relationships before to acquire an efficient entity relationship learning model. The entity relationship learning model accepts a series of tasks for training to process the learning of existing and newly emerging entity relationships, where each task has a set of entity relationships to be learned.
[0106] Exemplarily, the process of discovering and learning new entity relationships constantly emerging is as shown in Figure 4 Figure 4 In the open relation extraction stage, new entity relations are constantly discovered, for example, a new entity relation "date of birth" is discovered from the sentence "Xiaoming was born on January 1, 2000" and the sentence "Xiaohong's birthday is February 1, 2005", and a new entity relation "band member" is discovered from the sentence "Xiaohua is the guitarist of A band" and the sentence "Xiaohai is the lead singer of B band". In the continuous relation learning stage, new entity relations are constantly learned, and the process of discovering new entity relations and learning new entity relations is cross performed. For example, first, learn the entity relation "date of birth" according to the text set corresponding to the entity relation "date of birth". After learning the entity relation "date of birth", select the memory text from the text set corresponding to the entity relation "date of birth" and add it to the existing memory text set. Next, learn the entity relation "band member" using the text set corresponding to the entity relation "band member" and the existing memory text set; after learning the entity relation "band member", select the memory text from the text set corresponding to the entity relation "band member" and add it to the existing memory text set; and then continue to learn new entity relations based on the text set corresponding to the new entity relations and the existing memory text set.
[0107] It should be noted that, since new entity relations are constantly emerging, the learning process of entity relations is a continuous learning process. The process of continuously learning entity relations can be regarded as a process of learning in a series of tasks. After learning in each new task, an entity relation learning model with good learning effect on the entity relations that have already appeared is expected to be obtained, so that the obtained entity relation learning model can be used to accurately extract the entity relations of a certain text based on the entity relations that have been learned. The entity relation learning model can continuously learn the relationship between the entity relations and the text, and then extract text features close to the real entity relations. Further, the extraction of text features is used to implement the extraction task of entity relations.
[0108] The set of entity relations to be learned in the embodiments of the present application refers to the set of entity relations that need to be learned in a new task. The set of entity relations to be learned includes at least one to-be-learned relation. It should be noted that the set of to-be-learned relations can include entity relations that have been learned in old tasks, or can all be entity relations that have not been learned in old tasks, and the embodiments of the present application do not limit this. In addition, the number of to-be-learned entity relations in the set of to-be-learned entity relations can be set according to experience, or can be flexibly adjusted according to application scenarios, and the embodiments of the present application do not limit this. Exemplarily, the set of to-be-learned entity relations that need to be learned in a new task can be represented as R k .
[0109] After determining the set of entity relationships to be learned in the new task, a set of training texts corresponding to the set of entity relationships to be learned is obtained. The set of training texts includes training texts corresponding to each entity relationship to be learned. That is, the set of training texts is composed of training texts corresponding to each entity relationship to be learned. It should be noted that the training text corresponding to each entity relationship to be learned can be one or more, and the number of training texts corresponding to different entity relationships to be learned can be the same or different, which is not limited in the embodiments of the present application.
[0110] The process of obtaining the set of training texts corresponding to the set of entity relationships to be learned is the process of obtaining training texts corresponding to each entity relationship to be learned. In a possible implementation, for any entity relationship to be learned, the process of obtaining the training text corresponding to the entity relationship to be learned is: extracting a sentence containing the entity relationship to be learned from the text corpus, and preprocessing the sentence containing the entity relationship to be learned to obtain the training text corresponding to the entity relationship to be learned.
[0111] In a possible implementation, the process of preprocessing the sentence containing the entity relationship to be learned to obtain the training text corresponding to the entity relationship to be learned is: parsing the sentence into a token sequence by extracting semantic information, head entity position, and other information of the sentence, and taking the token sequence as the training text.
[0112] In a possible implementation, in addition to each training text, the set of training texts also includes an entity relationship label of each training text, and the entity relationship label is used to indicate the entity relationship that the training text actually corresponds to. Exemplarily, the set of training texts is represented as wherein, represents each training text; represents the entity relationship label corresponding to each training text; and N (N is an integer greater than 1) represents the number of training texts in the set of training texts. Based on any training text the corresponding relationship label It can be known that, the corresponding relationship label indicates the entity relationship. It should be noted that, the entity relationship indicated by the entity relationship label is a certain entity relationship to be learned in the set of entity relationships to be learned R k .
[0113] After obtaining the set of training texts, the existing entity relationship learning model is trained based on the set of training texts to obtain a target entity relationship learning model that can have good performance on the current new task and the previous old task. That is, in the k th (k is an integer not less than 1) task, the target entity relationship learning model is trained based on the training set T ktraining, to learn a set of entity relations R to be learned k Because new entity relations are constantly emerging, it is desirable to obtain a target entity relation learning model that can perform well on the kth task and the previous k-1 tasks. In order to obtain the target entity relation learning model, the target entity relation learning model is trained on the training set T k After obtaining the target entity relation learning model, the target entity relation learning model is tested on the test set T (Q i represents the test set in the ith (i is an integer not less than 1) task, represents the union set of the test sets in each task) and it is desirable to achieve an effect of accurately classifying all the test texts on all the currently known entity relations in the target entity relation set R. (R i represents the set of entity relations to be learned in the ith task, represents the union set of the sets of entity relations to be learned in each task) and it is desirable to achieve an effect of accurately classifying all the test texts on all the currently known entity relations in the target entity relation set R.
[0114] In step 302, the set of the set of entity relations to be learned and the set of entity relations learned is taken as the target entity relation set; the existing memory text set is updated based on the training text set to obtain the target memory text set.
[0115] The set of entity relations to be learned is the set of entity relations to be learned in the current task, and the set of entity relations learned is the set of entity relations to be learned in the old task before the current task. The entity relations to be learned in the old task have been learned in the old task, and the entity relations to be learned in the old task are referred to as the learned relations. It should be noted that for any entity relation that has been learned in the old task, the entity relation can still be used as an entity relation to be learned in a new task. That is, there can be the same entity relations in the set of entity relations to be learned and the set of entity relations learned. In the process of obtaining the set of the set of entity relations to be learned and the set of entity relations learned, only one of the same entity relations is retained, that is, the number of each entity relation in the target entity relation set is only one.
[0116] After taking the set of the set of entity relations to be learned and the set of entity relations learned as the target entity relation set, the target entity relation set includes all the entity relations involved in the current new task and the old task before the current task. Exemplarily, the target entity relation set can be represented as (R i represents the set of entity relations to be learned in the ith task). It should be noted that after obtaining the target entity relation learning model, each target entity relation in the target entity relation set is an entity relation learned by the target entity relation learning model.
[0117] In addition to obtaining the target entity relation set, a target memory text set is obtained. The target memory text set is a set of a small number of memory texts extracted from the training text set corresponding to each task including the current new task to represent each task. The target memory text set is used to memorize all the relations that have occurred based on a small amount of text. Before obtaining the training text set corresponding to the current new task, an existing memory text set has been obtained based on previous old tasks (if there is no old task, the existing memory text set is an empty set). In this case, the process of obtaining the target memory text set is a process of updating the existing memory text set based on the training text set to obtain the target memory text set. In a possible implementation, the process of updating the existing memory text set based on the training text set to obtain the target memory text set includes the following three steps:
[0118] Step 1: Clustering processing is performed on the training texts in the training text set, and the number of memory texts corresponding to each entity relation to be learned in the entity relation set to be learned is determined according to the obtained clustering result.
[0119] The clustering processing on the training texts in the training text set can cluster similar training texts into the same category. The clustering method used by the embodiments of the present application for clustering processing is not limited. For example, the clustering method of K-Means (K-means) is used to cluster the training texts in the training text set. In a possible implementation, the number of clusters is set in advance, and then the training texts in the training text set are clustered into the number of cluster clusters. The number of clusters can be set according to the capacity of the texts to be memorized in the current new task. It should be noted that the capacity of the texts to be memorized in different tasks can be the same or different, and the embodiments of the present application are not limited in this regard.
[0120] For example, assuming that the capacity of the texts to be memorized in the current new task is B (B is an integer not less than 1), after clustering processing is performed on the training texts in the target training text set, B cluster clusters can be obtained.
[0121] After clustering the training texts in the target training text set, a clustering result is obtained, and then the number of memory texts corresponding to each entity relationship to be learned in the entity relationship set to be learned is determined according to the clustering result. The clustering result can indicate the number of clustering clusters and which training texts are contained in each clustering cluster. In a possible implementation, the manner of determining the number of memory texts corresponding to each entity relationship to be learned in the entity relationship set to be learned according to the clustering result is as follows: taking the training text closest to the clustering center in each clustering cluster as a candidate training text, counting the number of candidate training texts corresponding to each entity relationship to be learned in the entity relationship set to be learned based on the entity relationship to be learned corresponding to each candidate training text, and determining the number of memory texts corresponding to each entity relationship to be learned according to the number of candidate training texts corresponding to each entity relationship to be learned.
[0122] The number of candidate training texts corresponding to each entity relationship to be learned can represent the importance of each entity relationship to be learned in the current new task. The more the number of candidate training texts corresponding to a certain entity relationship to be learned, the more important the entity relationship to be learned in the current new task. For an important entity relationship to be learned, more texts should be memorized. That is, the more the number of candidate training texts corresponding to an entity relationship to be learned, the greater the number of memory texts corresponding to the entity relationship to be learned should be. For example, assuming that the capacity of texts to be memorized in the current new task is B, the number of clustering clusters is B, and the number of candidate texts is also B because one candidate training text is extracted in each clustering cluster. Assuming that the number of entity relationships to be learned in the entity relationship set to be learned is |R K |, the number of memory texts corresponding to an important entity relationship to be learned can be no less than The number of memory texts corresponding to an unimportant entity relationship to be learned can be no greater than
[0123] In a possible implementation, a corresponding relationship between the number of candidate texts and the number of memory texts is set in advance, and then the number of memory texts corresponding to each entity relationship to be learned is determined based on the corresponding relationship and the number of candidate texts corresponding to each entity relationship to be learned. It should be noted that when the corresponding relationship between the number of candidate texts and the number of memory texts is set, the number of candidate texts and the number of memory texts should have a positive correlation.
[0124] In a possible implementation, after the number of memory texts corresponding to each entity relationship to be learned is determined, the number of memory texts corresponding to each entity relationship to be learned is verified respectively. When the number of memory texts corresponding to each entity relationship to be learned is verified successfully, step 2 is performed; when the number of memory texts corresponding to any entity relationship to be learned fails to be verified, the number of memory texts corresponding to each entity relationship to be learned is adjusted, and then step 2 is performed again.
[0125] In a possible implementation, the manner of checking the number of memory texts corresponding to each entity relationship to be learned is as follows: for any entity relationship to be learned, it is detected whether the number of memory texts corresponding to the entity relationship to be learned is not greater than the number of training texts corresponding to the entity relationship to be learned; when the number of memory texts corresponding to the entity relationship to be learned is not greater than the number of training texts corresponding to the entity relationship to be learned, it is indicated that the checking of the number of memory texts corresponding to the entity relationship to be learned is successful; when the number of memory texts corresponding to the entity relationship to be learned is greater than the number of training texts corresponding to the entity relationship to be learned, it is indicated that the checking of the number of memory texts corresponding to the entity relationship to be learned is failed.
[0126] In a possible implementation, when the checking of the number of memory texts corresponding to any entity relationship to be learned is failed, the manner of adjusting the number of memory texts corresponding to each entity relationship to be learned is as follows: the number of memory texts corresponding to the entity relationship to be learned that fails in the checking is reduced to be equal to the number of training texts corresponding to the entity relationship to be learned; the reduced number is added to the number of memory texts corresponding to other entity relationships to be learned that succeed in the checking. After the adjustment, the number of memory texts corresponding to each entity relationship to be learned is not greater than the number of training texts corresponding to the entity relationship to be learned.
[0127] Step 2: for any entity relationship to be learned, memory texts corresponding to the entity relationship to be learned are determined according to the number of memory texts corresponding to the entity relationship to be learned.
[0128] According to step 1, the number of memory texts corresponding to each entity relationship to be learned can be determined, and then the number of memory texts corresponding to each entity relationship to be learned is needed to select the number of memory texts from the training texts corresponding to each entity relationship to be learned as memory texts. For any entity relationship to be learned, the process of determining the memory texts corresponding to the entity relationship to be learned is as follows: the training texts corresponding to the entity relationship to be learned are clustered according to the number of memory texts corresponding to the entity relationship to be learned, and the memory texts corresponding to the entity relationship to be learned are determined according to the clustering result.
[0129] According to the number of memory texts corresponding to any to-be-learned entity relationship, the training texts corresponding to any to-be-learned entity relationship in the training text set are clustered to cluster the training texts corresponding to any to-be-learned entity relationship in the training text set into a cluster of memory text quantity, and the clustering result obtained indicates which training texts are included in each cluster. In a possible implementation manner, the manner of determining the memory text corresponding to any to-be-learned entity relationship according to the obtained clustering result is that the training text closest to the cluster center in each cluster is taken as the memory text corresponding to the to-be-learned entity relationship. The memory text corresponding to any to-be-learned entity relationship obtained in this manner can preferably represent the to-be-learned entity relationship.
[0130] According to the manner of step 2, the memory text corresponding to each to-be-learned entity relationship can be obtained, and then step 3 is performed. The memory text corresponding to each to-be-learned entity relationship is more useful and diverse text in the training text set, and can cover the mode of the to-be-learned entity relationship in the to-be-learned entity relationship set as much as possible, and the memory sample can effectively approach the feature distribution of the to-be-learned entity relationship.
[0131] Step 3: Add the memory text corresponding to each to-be-learned entity relationship to the existing memory text set to obtain a target memory text set.
[0132] After obtaining the memory text corresponding to each to-be-learned entity relationship, the memory text corresponding to each to-be-learned entity relationship is added to the existing memory text set to obtain a target memory text set. The existing memory text set is obtained based on a previous old task, and it needs to be noted that if there is no old task, the existing memory text set is an empty set. At this time, the target memory text set includes memory text subsets corresponding to each task that has appeared, for example, the target memory text set can be represented as wherein M i represents the memory text subset corresponding to the i th task. In a possible implementation manner, in addition to saving the memory text, the memory text subset can also save the entity relationship label of each memory text. For example, the memory text subset of the k th task can be represented as wherein, represents each memory text, represents the entity relationship label of each memory text, and B represents the capacity of the text to be memorized by the k th task.
[0133] In step 303, the first entity relationship learning model is trained based on the training text set to obtain a second entity relationship learning model.
[0134] The first entity relation learning model refers to an obtained entity relation learning model before training using the training text set. The first entity relation learning model has learned the entity relation in the old task, but has not been exposed to the training text in the training text set. At this time, the first entity relation learning model cannot well extract text features from the training text in the training text set. Therefore, the first feature extraction model needs to be trained using the training text set The first entity relation learning model is trained so that the entity relation learning model masters the pattern of the entity relation to be learned in the entity relation set R k .
[0135] In a possible implementation, the first entity relation learning model includes a first feature extraction model and a first relation feature management model. The first relation feature management model is configured to manage an initial relation feature set corresponding to the target entity relation set. The process of training the first entity relation learning model based on the training text set includes the following steps 3031 to 3033.
[0136] Step 3031: calling the first feature extraction model to perform feature extraction on each training text in the training text set to obtain text features of each training text.
[0137] The first feature extraction model is a feature extraction model before training using the training text set. The first feature extraction model cannot well extract text features from the training text in the training text set, and needs to be trained to improve the extraction effect of the text features.
[0138] The structure of the first feature extraction model is not limited in the embodiments of the present application, as long as the text features can be extracted. For example, the first feature extraction model is a BILSTM (Bi-directional Long Short-Term Memory, bidirectional long short-term memory model), a convolutional neural network model, or a pre-trained language model.
[0139] In the process of calling the first feature extraction model to perform feature extraction on each training text in the training text set, the first feature extraction model can perform feature extraction on one training text at a time, or perform feature extraction on multiple training texts at a time. The embodiments of the present application are not limited in this regard. Regardless of which way is used, the text features of each training text can be obtained.
[0140] For any training text, the process of calling the first feature extraction model to perform feature extraction on the training text to obtain the text features of the training text can be based on formula 5:
[0141] x = (x) (formula 5)
[0142] wherein x represents any training text, and x represents the text feature of the training text x. In a possible implementation, the text feature of the training text can be represented by a vector, and the dimension of the vector can be defined based on the structure and parameters of the first feature extraction model, which is not limited in the embodiments of the present application. For example, assuming that the dimension of the vector is d (an integer not less than 1), then x belongs to a d-dimensional Euclidean space (i.e.
[0143] Step 3032: For any training text, based on the initial relationship feature set managed by the first relationship feature management model and the text feature of any training text, obtaining the matching result corresponding to any training text.
[0144] The first relationship feature management model is used to manage the initial relationship feature set corresponding to the target entity relationship set. The initial relationship feature set includes the initial relationship feature corresponding to each target entity relationship in the target entity relationship set. It should be noted that for the target entity relationship that has been learned, the initial relationship feature corresponding to the target entity relationship can be learned in the previous old task, which can accurately represent the target entity relationship; for the entity relationship that has not been learned, the initial relationship feature corresponding to the target can be a randomly initialized relationship feature, which needs to be further optimized.
[0145] The matching result corresponding to any training text is used to indicate the similarity between the text feature of the training text and the initial relationship feature corresponding to each target entity relationship. In a possible implementation, for any training text, based on the initial relationship feature set managed by the first relationship feature management model and the text feature of any training text, the matching result corresponding to any training text is obtained in the following manner: the similarity between the text feature of any training text and each initial relationship feature in the initial relationship feature set is obtained respectively, and the similarity between the text feature of any training text and each initial relationship feature in the initial relationship feature set is taken as the matching result corresponding to any training text.
[0146] It should be noted that the embodiments of the present application do not limit the manner of calculating the similarity between two features. For example, when two features are represented by vectors, the cosine similarity between two vectors is calculated.
[0147] Based on the manner of step 3032, the matching result corresponding to each training text can be obtained respectively.
[0148] Step 3033: Based on the matching result corresponding to each training text respectively, determining the first loss function; and updating the parameters of the first feature extraction model and the first relationship feature management model based on the first loss function.
[0149] In one possible implementation, the matching result for any training text is the similarity between the text features of that training text and each initial relation feature in the initial relation feature set. Based on the matching results corresponding to each training text, the calculation formula for the first loss function is determined as Formula 6:
[0150]
[0151] Where L(θ) represents the first loss function; Represents training text Text features Relationship r with the target entity j The corresponding initial relation feature r j The similarity between them; Represents training text Entity Relationship Tags The target entity relationship indicated is r j ; Represents training text Entity Relationship Tags The target entity relation indicated is not r j σ represents the sigmoid function; N represents the number of training texts in the training text set; This indicates the number of target entity relations in the target entity relation set.
[0152] After obtaining the first loss function, the parameters of the first feature extraction model and the first relation feature management model are updated based on the first loss function. It should be noted that since the first relation feature management model is used to manage the initial relation feature set corresponding to the target entity relation set, the process of updating the parameters of the first relation feature management model is the process of updating the initial relation feature set.
[0153] Each execution of steps 3031 to 3033 updates the parameters of the first feature extraction model and the first relation feature management model, completing one training iteration of the first entity relation learning model. The training process of the first entity relation learning model based on the training text set is iterative. After each training iteration, it is determined whether the training termination condition is met. If the training termination condition is not met, the parameters of the first feature extraction model and the first relation feature management model are updated according to steps 3031 to 3033 until the training termination condition is met. The entity relation learning model obtained when the training termination condition is met is used as the second entity relation learning model. Thus, the second entity relation learning model is obtained. This second entity relation learning model has the ability to extract good text features from the training text in the training text set.
[0154] In a possible implementation, the training termination condition is satisfied in the following three cases:
[0155] Case 1: the number of iterations reaches a threshold number of iterations.
[0156] The threshold number of iterations can be set empirically or adjusted flexibly according to application scenarios, which is not limited in the embodiments of the present application.
[0157] Case 2: the first loss function is less than a loss threshold.
[0158] The loss threshold can be set empirically or adjusted flexibly according to application scenarios, which is not limited in the embodiments of the present application.
[0159] Case 3: the first loss function converges.
[0160] The first loss function converges means that, as the number of iterations increases, the first loss function fluctuates within a reference range in the training results of a reference number of iterations. For example, assuming that the reference range is -10 -3 ~ 10 -3 , and the reference number of iterations is 10. If the first loss function fluctuates within -10 -3 ~ 10 -3 in the training results of 10 iterations, it is considered that the first loss function converges.
[0161] When any of the above cases is satisfied, it is considered that the training termination condition is satisfied, and the entity relationship learning model when the training termination condition is satisfied is taken as a second entity relationship learning model. For the case that the first entity relationship learning model includes a first feature extraction model and a first relationship feature management model, the second entity relationship learning model obtained when the training termination condition is satisfied includes a second feature extraction model and a second relationship feature management model. The second feature extraction model is a feature extraction model obtained by training the first feature extraction model using the training text set, and the second relationship feature management model is a relationship feature management model obtained by training the first relationship feature management model using the training text set. It should be noted that, since the process of updating the parameters of the first relationship feature management model refers to the process of updating the initial relationship feature set, the second relationship feature management model obtained by training manages the updated initial relationship feature set, which is taken as a target relationship feature set in the embodiments of the present application. The target relationship feature set includes target relationship features corresponding to each target entity relationship. The target relationship feature corresponding to any target entity relationship is used to represent the general feature of the any target entity relationship.
[0162] It should be noted that the second target entity relation learning model obtained in this step 303 learns the set of entity relations to be learned in the new task, but in order to reduce the forgetting of the entity relations learned in the old task by the second entity relation learning model and to strengthen the recognition ability of the entity relations in the new task, the second entity relation learning model needs to be further optimized based on step 304.
[0163] In step 304, based on the second entity relation learning model and the set of target memory texts, a set of prototype features corresponding to the set of target entity relations is obtained; and based on the set of target memory texts and the set of prototype features, the second entity relation learning model is optimized.
[0164] The set of prototype features corresponding to the set of target entity relations includes prototype features corresponding to each target entity relation in the set of target entity relations respectively. Compared with the memory texts, the prototype features corresponding to any target entity relation can more comprehensively represent the feature distribution of the any target entity relation. Learning the prototype features is conducive to better learning the target entity relations.
[0165] In a possible implementation manner, the second entity relation learning model includes a second feature extraction model; and the process of obtaining the set of prototype features corresponding to the set of target entity relations based on the second entity relation learning model and the set of target memory texts includes the following steps A to C:
[0166] Step A: for any target entity relation in the set of target entity relations, based on the set of target memory texts, a set of prototype texts corresponding to the any target entity relation is constructed.
[0167] The set of prototype features includes prototype features corresponding to each target entity relation respectively, and steps A and B introduce the process of obtaining the prototype features corresponding to any target entity relation from the perspective of the any target entity relation.
[0168] The set of prototype texts corresponding to any target entity relation is used to obtain the prototype features corresponding to the any target entity relation. In a possible implementation manner, the process of constructing the set of prototype texts corresponding to any target entity relation based on the set of target memory texts is as follows: the set of target memory texts corresponding to the any target entity relation in the set of target memory texts is taken as a set of candidate texts; and a first specified number of candidate texts in the set of candidate texts are randomly selected to form the set of prototype texts corresponding to the any target entity relation. The first specified number is used to limit the number of prototype texts in the set of prototype texts, and the first specified number can be set according to experience or adjusted according to the number of candidate texts in the set of candidate texts, which is not limited in the embodiments of the present application. For example, when the number of candidate texts in the set of candidate texts is 100, the first specified number can be set to 10.
[0169] Exemplarily, for any target entity relation The prototype text set corresponding to any target entity relation is denoted as Any prototype text in the prototype text set is denoted as selected from the target memory text set The any prototype text corresponds to the any target entity relation r i That is, the entity relation label of the any prototype text indicates that the any target entity relation r i is indicated by the entity relation label of the any prototype text . i |P| represents the number of prototype texts included in the prototype text set corresponding to the any target entity relation, which is the same as the first specified number.
[0170] Step B: calling the second feature extraction model to perform feature extraction on each prototype text in the prototype text set to obtain the text feature of each prototype text; and obtaining the prototype feature corresponding to any target entity relation based on the text feature of each prototype text.
[0171] After obtaining the prototype feature set corresponding to any target entity relation, the second feature extraction model is called to perform feature extraction on each prototype text in the prototype text set to obtain the text feature of each prototype text. The implementation process of this step can be referred to step 3031, which will not be described here.
[0172] After obtaining the text feature of each prototype text, the prototype feature corresponding to any target entity relation is obtained based on the text feature of each prototype text. In one possible implementation manner, the prototype feature corresponding to any target entity relation is obtained based on the text feature of each prototype text in the following manner: calculating the average feature of the text features of each prototype text, and taking the average feature as the prototype feature corresponding to the any target entity relation. This process can be implemented based on formula 7:
[0173]
[0174] wherein p i represents the prototype feature corresponding to the target entity relation r ; |P i | represents the number of prototype texts included in the prototype text set corresponding to the target entity relation r i . represents the text feature of the jth prototype text in the prototype text set corresponding to the target entity relation r i .
[0175] According to the manners of step A and step B, the prototype features corresponding to each target entity relationship in the target entity relationship set can be obtained. It should be noted that the first specified number can be the same or different in the process of obtaining the prototype features corresponding to different target entity relationships, and the embodiments of the present application do not limit this.
[0176] Step C: Taking the set of prototype features corresponding to each target entity relationship in the target entity relationship set as the prototype feature set corresponding to the target entity relationship set.
[0177] After obtaining the prototype features corresponding to each target entity relationship in the target entity relationship set, the set of prototype features corresponding to each target entity relationship in the target entity relationship set is taken as the prototype feature set corresponding to the target entity relationship set.
[0178] After obtaining the prototype feature set, the second entity relationship learning model is optimized based on the target memory text set and the prototype feature set, so that the second entity relationship learning model retains the old entity relationship recognition ability while strengthening the recognition ability of new entity relationships.
[0179] In a possible implementation manner, the implementation manner of optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set includes but is not limited to the following two manners:
[0180] Implementation manner one: directly optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set.
[0181] In this implementation manner one, the second entity relationship learning model is directly optimized based on the target memory text set and the prototype feature set, and the optimization process is relatively simple. In a possible implementation manner, the second entity relationship learning model includes a second feature extraction model; the process of directly optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set includes the following steps a to e:
[0182] Step a: for any target entity relationship in the target entity relationship set, based on the target memory text set, a first instance text set corresponding to any target entity relationship is constructed.
[0183] The first instance text set is used to obtain the matching result corresponding to the any target entity relation. In a possible implementation manner, based on the target memory text set, the process of constructing the first instance text set corresponding to the any target entity relation is as follows: taking the set of target memory texts corresponding to the any target entity relation in the target memory text set as a candidate text set; and randomly selecting a second specified number of candidate texts in the candidate text set to form the first instance text set corresponding to the any target entity relation. The second specified number is used to limit the number of first instance texts in the first instance text set. For the same target entity relation, the second specified number can be the same as or different from the first specified number, and the embodiments of the present application do not limit this. It should be noted that even if the second specified number can be the same as the first specified number, since the first instance text set and the prototype text set are both formed by randomly selecting candidate texts in the candidate text set, the first instance text set and the second prototype text set can be different.
[0184] Exemplarily, for the any target entity relation The first instance text set corresponding to the any target entity relation can be expressed as Wherein, the any first instance text is selected from the target memory text set The any prototype text corresponds to the any target entity relation r i That is, the any prototype text has an entity relation label indicating the any target entity relation r i . i The number of first instance texts included in the first instance text set corresponding to the any target entity relation r is represented by |, which is the same as the second specified number.
[0185] Step b: calling the second feature extraction model to perform feature extraction on each first instance text in the first instance text set to obtain the text features of each first instance text.
[0186] After obtaining the first instance text set corresponding to the any target entity relation, the second feature extraction model is called to perform feature extraction on each first instance text in the first instance text set to obtain the text features of each first instance text. The implementation process of this step can be referred to step 3031, which will not be described here.
[0187] Step c: for the any first instance text, based on the prototype feature set and the text features of the any first instance text, obtaining the matching result corresponding to the any first instance text.
[0188] After obtaining the text features of each first instance text, further obtain the first matching result corresponding to each first instance text. The matching result corresponding to any first instance text is used to indicate the similarity between the text feature of the any first instance text and each prototype feature in the prototype feature set.
[0189] In a possible implementation, for any first instance text, based on the prototype feature set and the text feature of the any instance text, the process of obtaining the matching result corresponding to the any first instance text includes: obtaining the similarity between the text feature of the any first instance text and each prototype feature in the prototype feature set respectively, and taking the similarity between the text feature of the any first instance text and each prototype feature in the prototype feature set as the matching result corresponding to the any first instance text.
[0190] It should be noted that the manner of calculating the similarity between two features is not limited by the embodiments of the present application. For example, when two features are represented by vectors, the cosine similarity between two vectors is calculated.
[0191] According to the manner of step c, the sub-matching result corresponding to each first instance text in the first instance text set can be obtained, and then step d is performed.
[0192] Step d: based on the matching result corresponding to each first instance text respectively, obtain the first sub-loss function corresponding to any target entity relationship.
[0193] In a possible implementation, for the case that the sub-matching result corresponding to any first instance text is the similarity between the text feature of the any first instance text and each prototype feature in the prototype feature set, based on the matching result corresponding to each first instance text respectively, the process of obtaining the first sub-loss function corresponding to any target entity relationship can be implemented based on formula 8:
[0194]
[0195] wherein, denotes the target entity relationship r i corresponding first sub-loss function; denotes the text feature of the first instance text in the first instance text set p ; p i denotes the prototype feature corresponding to the target entity relationship r i ; p denotes the similarity between the text feature of the first instance text p and the prototype feature p i corresponding to the target entity relationship r i ; p l denotes the target entity relationship r lcorresponding prototype feature; denotes the number of target entity relationships in the target entity relationship set.
[0196] Steps a to d introduce the process of obtaining the first sub-loss function corresponding to any target entity relationship from the perspective of the target entity relationship. For each target entity relationship in the target entity relationship set, the first sub-loss function corresponding to each target entity relationship can be obtained according to the manner of steps a to d.
[0197] Step e: determining the second loss function based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set respectively; updating the parameters of the second feature extraction model based on the second loss function.
[0198] After obtaining the first sub-loss function corresponding to each target entity relationship in the target entity relationship set respectively, the second loss function is determined based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set respectively. In one possible implementation manner, the process of determining the second loss function based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set respectively can be based on the following formula 9:
[0199] Formula 9 is implemented as follows:
[0200]
[0201] wherein, L R (θ) denotes the second loss function; denotes the first sub-loss function corresponding to the target entity relationship r i The meanings of other parameters are the same as those in formula 8, which will not be described here.
[0202] After obtaining the second loss function, the parameters of the second feature extraction model are updated based on the second loss function.
[0203] The process of optimizing the second entity relationship learning model is an iterative process, and the parameters of the second feature extraction model are updated once for each optimization of the second entity relationship learning model. After each optimization of the second entity relationship learning model, it is determined whether the optimization termination condition is met. If the optimization termination condition is not met, the optimization of the second entity relationship learning model is continued; until the optimization termination condition is met, step 305 is executed.
[0204] It should be noted that the prototype feature set used to optimize the second entity relationship learning model is obtained based on the second entity relationship learning model. In the process of continuing to optimize the second entity relationship learning model, since the second entity relationship learning model has been optimized in the previous iteration process, the prototype feature set corresponding to the target entity relationship set needs to be reacquired based on the already optimized second entity relationship learning model, and then the second entity relationship learning model is directly optimized based on the target memory text set and the newly acquired prototype feature set.
[0205] In this implementation, the optimization termination condition can be any one of the following: the optimization number reaches the optimization number threshold, the second loss function is less than the loss threshold, and the second loss function converges.
[0206] Implementation two: the set of the target memory text set and the training text set is used as the activation text set; the second entity relationship learning model is optimized based on the activation text set, the target memory text set, and the prototype feature set.
[0207] In this way two, the process of optimizing the second entity relationship learning model increases the influence of the activation text set. The activation text set is the set of the target memory text set and the training text set, that is, the activation text set includes all the memory texts and all the training texts in the current new task, and the activation text set is used to continuously activate the entity relationship learning model to further improve the ability of the entity relationship learning model to learn new entity relationships and remember old entity relationships. Illustratively, the target memory text set and the training text set T k are combined to obtain the activation text set. Wherein, M represents the number of activation texts in the activation text set.
[0208] In this implementation two, increasing the influence of the activation text set on the optimization process of the second entity relationship learning model is beneficial to improve the optimization effect of the second entity relationship learning model.
[0209] In a possible implementation, the process of optimizing the second entity relationship learning model based on the activation text set, the target memory text set, and the prototype feature set can be completed based on two adjustment processes. According to the data used by the two adjustment processes, the way of optimizing the second entity relationship learning model based on the activation text set, the target memory text set, and the prototype feature set includes the following two ways:
[0210] Way one: the second entity relationship learning model is adjusted based on the activation text set, and the first adjusted second entity relationship learning model is adjusted based on the target memory text set and the prototype feature set.
[0211] The implementation process of this mode one is divided into two steps:
[0212] Step one: performing first adjustment on the second entity relationship learning model based on the activated text set.
[0213] The process of performing first adjustment on the second entity relationship learning model based on the activated text set can be regarded as a process of memory reenactment and activation.
[0214] In a possible implementation manner, the second entity relationship learning model comprises a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is configured to manage a target relationship feature set corresponding to the target entity relationship set. The process of performing first adjustment on the second entity relationship learning model based on the activated text set comprises the following three steps:
[0215] 1. calling the second feature extraction model to perform feature extraction on each activated text in the activated text set to obtain text features of each activated text.
[0216] The implementation manner of this step can be referred to step 3031, and details are not described herein.
[0217] 2. for any activated text, obtaining a matching result corresponding to the activated text based on the target relationship feature set managed by the second relationship feature management model and the text features of the activated text.
[0218] The target relationship feature set managed by the second relationship feature management model is obtained based on training of the first relationship feature management model. The target relationship feature set comprises target relationship features corresponding to each target entity relationship. The target relationship feature corresponding to any target entity relationship is configured to represent a general feature of the target entity relationship.
[0219] The matching result corresponding to any activated text is configured to indicate a similarity between the text features of the activated text and the target relationship features corresponding to each target entity relationship. In a possible implementation manner, for any activated text, the matching result corresponding to the activated text is obtained in the following manner: similarities between the text features of the activated text and each target relationship feature in the target relationship feature set are obtained respectively, and the similarities between the text features of the activated text and each target relationship feature in the target relationship feature set are taken as the matching result corresponding to the activated text.
[0220] It should be noted that the manner of calculating the similarity between two features is not limited in the embodiments of the present application. Exemplarily, when two features are represented by vectors, a cosine similarity between two vectors is calculated.
[0221] Based on the method in step 2, the matching results corresponding to each activated text can be obtained.
[0222] 3. Determine the third loss function based on the matching results corresponding to each activated text; update the parameters of the second feature extraction model based on the third loss function.
[0223] In one possible implementation, the matching result for any activated text is the similarity between the text features of that activated text and each target relation feature in the target relation feature set. Based on the matching results corresponding to each activated text, the calculation formula for the third loss function is determined as Formula 10:
[0224]
[0225] Where L A (θ) represents the third loss function; Indicates activation text Text features Relationship r with the target entity j The corresponding target relation feature r j The similarity between them; Indicates activation text Entity Relationship Tags The target entity relationship indicated is r j ; Indicates activation text Entity Relationship Tags The target entity relation indicated is not r j σ represents the sigmoid function; M represents the number of active texts in the active text set. This indicates the number of target entity relations in the target entity relation set.
[0226] After obtaining the third loss function, the parameters of the second feature extraction model are updated based on the third loss function. It should be noted that since the target relation feature set corresponding to the target entity relation set managed by the second relation feature management model is the pre-trained target relation feature set, there is no need to update the parameters of the second relation feature management model.
[0227] Each time steps 1 to 3 are executed, the parameters of the second feature extraction model are updated. After each parameter update, it is determined whether the first adjustment termination condition is met. If the first adjustment termination condition is not met, the parameters of the second feature extraction model are updated according to steps 1 to 3 until the first adjustment termination condition is met. The entity relationship learning model obtained when the first adjustment termination condition is met is used as the second entity relationship learning model after the first adjustment, and then step two is executed.
[0228] In a possible implementation, the first adjustment termination condition is met when the number of times of updating the parameters of the second feature extraction model reaches a first adjustment number threshold. The first adjustment number threshold can be set according to experience or adjusted flexibly according to application scenarios, and the embodiments of the present application do not limit this.
[0229] Step two: performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
[0230] The process of performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set can be regarded as a memory reconsolidation process. Only memory rehearsal and activation can cause overfitting, so that the model can only remember a number of texts saved in the memory text set in the end. Meanwhile, the core of learning entity relationship is to master the prototype features of entity relationship rather than memorize samples by rote, therefore, memory reconsolidation is performed based on step two while memory rehearsal and activation are performed based on step one, so that the entity relationship learning model can form long-term memory for the entity relationship that has appeared, maintain the memory of old entity relationship knowledge, reduce the loss and confusion of past memory, and learn new processed entity relationship at the same time.
[0231] After obtaining the first adjusted second entity relationship learning model, second adjustment is performed on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set. In a possible implementation, the first adjusted second entity relationship learning model includes a first adjusted second feature extraction model; and the process of performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set includes the following five steps:
[0232] 1. For any target entity relationship in the target entity relationship set, a second instance text set corresponding to the target entity relationship is constructed based on the target memory text set.
[0233] 2. The first adjusted second feature extraction model is called to perform feature extraction on each second instance text in the second instance text set, to obtain text features of each second instance text.
[0234] 3. For any second instance text, a matching result corresponding to the second instance text is obtained based on the prototype feature set and the text features of the second instance text.
[0235] 4. A second sub-loss function corresponding to any target entity relationship is obtained based on the matching result corresponding to each second instance text.
[0236] 5. Determine a fourth loss function based on the second sub-loss function corresponding to each target entity relation in the target entity relation set; and update the parameters of the first adjusted second feature extraction model based on the fourth loss function.
[0237] The implementation process of the above five steps can be referred to steps a to e in the first implementation manner, which will not be described here again. It should be noted that, unlike steps a to e in the first implementation manner, steps a to e are a process of directly updating the parameters of the second feature extraction model, while the five steps here are a process of updating the parameters of the first adjusted second feature extraction model.
[0238] Each time steps 1 to 5 are executed, the parameters of the first adjusted second feature extraction model are updated once. Each time the parameters of the first adjusted second feature extraction model are updated, it is determined whether the second adjustment termination condition is met. If the second adjustment termination condition is not met, the parameters of the first adjusted second feature extraction model are continuously updated according to steps 1 to 5 above until the second adjustment termination condition is met. The entity relation learning model obtained when the second adjustment termination condition is met is taken as the second entity relation learning model after one optimization.
[0239] In a possible implementation manner, the second adjustment termination condition is met when the number of times of updating the parameters of the first adjusted second feature extraction model reaches a second adjustment number threshold. The second adjustment number threshold can be the same as or different from the first adjustment number threshold, which is not limited in the embodiments of the present application.
[0240] Each time steps 1 and 2 are executed, the second entity relation learning model is optimized once. Each time the optimization of the second entity relation learning model is completed, it is determined whether the optimization termination condition is met once. If the optimization termination condition is not met, the optimization of the second entity relation learning model is continuously performed; and until the optimization termination condition is met, step 305 is executed.
[0241] It should be noted that the prototype feature set used to optimize the second entity relation learning model is obtained based on the second entity relation learning model. In the process of continuously optimizing the second entity relation learning model, since the second entity relation learning model has been optimized in the previous iteration process, the prototype feature set corresponding to the target entity relation set needs to be reacquired based on the second entity relation learning model that has been optimized, and then the second entity relation learning model is continuously optimized based on the activated text set, the target memory text set and the newly acquired prototype feature set.
[0242] In this way, the optimization termination condition can be satisfied in any one of the following: the number of optimizations reaches a number threshold, the third loss function and the fourth loss function are both less than a loss threshold, and the third loss function and the third loss function are both convergent.
[0243] In the second way, the second entity relationship learning model is adjusted based on the target memory text set and the prototype feature set, and the third adjusted second entity relationship learning model is adjusted based on the activated text set.
[0244] In the second way, the second entity relationship learning model is adjusted based on the target memory text set and the prototype feature set, and the third adjusted second entity relationship learning model is adjusted based on the activated text set.
[0245] The implementation process of the second way also includes two steps:
[0246] Step I: The second entity relationship learning model is adjusted based on the target memory text set and the prototype feature set.
[0247] In one possible implementation, the second entity relationship learning model includes a second feature extraction model, and the implementation process of step I includes the following five steps:
[0248] 1. For any target entity relationship in the target entity relationship set, a third instance text set corresponding to any target entity relationship is constructed based on the target memory text set.
[0249] 2. The second feature extraction model is called to extract features of each third instance text in the third instance text set, to obtain text features of each third instance text.
[0250] 3. For any third instance text, a matching result corresponding to any third instance text is obtained based on the prototype feature set and the text features of any third instance text.
[0251] 4. A third sub-loss function corresponding to any target entity relationship is obtained based on the matching result corresponding to each third instance text.
[0252] 5. A fifth loss function is determined based on the third sub-loss function corresponding to each target entity relationship in the target entity relationship set, and the parameters of the second feature extraction model are updated based on the fifth loss function.
[0253] The implementation process of the above five steps can refer to steps a to e in the implementation mode one, which will not be repeated here.
[0254] After each execution of steps 1-5, the parameters of the second feature extraction model are updated once, and for each update of the parameters of the second feature extraction model, it is determined whether the third adjustment termination condition is met. If the third adjustment termination condition is not met, the parameters of the second feature extraction model are updated according to steps 1-5 above until the third adjustment termination condition is met. The entity relationship learning model obtained when the third adjustment termination condition is met is taken as the third adjusted second entity relationship learning model, and step II is then executed.
[0255] In a possible implementation, the third adjustment termination condition is met when the number of times of updating the parameters of the second feature extraction model reaches a third adjustment number threshold. The third adjustment number threshold can be the same as the first adjustment number threshold or the second adjustment number threshold, or can be different from the first adjustment number threshold and the second adjustment number threshold, and the embodiments of the present application do not limit this.
[0256] Step II: Fourth adjustment of the third adjusted second entity relationship learning model based on the activated text set.
[0257] In a possible implementation, the third adjusted second entity relationship learning model includes a second relationship feature management model and a third adjusted second feature extraction model, and the second relationship feature management model is configured to manage a target relationship feature set corresponding to a target entity relationship set. The process of fourth adjustment of the third adjusted second entity relationship learning model based on the activated text set includes the following three steps:
[0258] 1. The third adjusted second feature extraction model is called to perform feature extraction on each activated text in the activated text set, and text features of each activated text are obtained.
[0259] 2. For any activated text, a matching result corresponding to the activated text is obtained based on the target relationship feature set managed by the second relationship feature management model and the text features of the activated text.
[0260] 3. A sixth loss function is determined based on the matching result corresponding to each activated text, and the parameters of the third adjusted second feature extraction model are updated based on the sixth loss function.
[0261] The implementation process of the above three steps can be referred to the three steps of first adjustment of the second entity relationship learning model based on the activated text set, and details are not described herein. It should be noted that, different from the three steps of first adjustment of the second entity relationship learning model based on the activated text set, the three steps of first adjustment of the second entity relationship learning model based on the activated text set are the process of updating the parameters of the second feature extraction model, while the three steps herein are the process of updating the parameters of the third adjusted second feature extraction model.
[0262] After each execution of steps 1-3, the parameters of the third adjusted second feature extraction model are updated once, and each time the parameters of the third adjusted second feature extraction model are updated, it is determined whether the fourth adjustment termination condition is met. If the fourth adjustment termination condition is not met, the parameters of the third adjusted second feature extraction model are continuously updated according to steps 1-3 until the fourth adjustment termination condition is met. The entity relationship learning model obtained when the fourth adjustment termination condition is met is taken as the second entity relationship learning model after one optimization.
[0263] In a possible implementation manner, the fourth adjustment termination condition is met when the number of times of updating the parameters of the third adjusted second feature extraction model reaches a fourth adjustment number threshold. The fourth adjustment number threshold can be the same as any one of the first adjustment number threshold, the second adjustment number threshold, and the third adjustment number threshold, or can be different from the first adjustment number threshold, the second adjustment number threshold, and the third adjustment number threshold, which is not limited in the embodiments of the present application.
[0264] After each execution of steps I and II, the second entity relationship learning model is optimized once. After each optimization of the second entity relationship learning model is completed, it is determined whether the optimization termination condition is met once. If the optimization termination condition is not met, the second entity relationship learning model is continuously optimized. Until the optimization termination condition is met, step 305 is executed.
[0265] It should be noted that the prototype feature set used to optimize the second entity relationship learning model is obtained based on the second entity relationship learning model. In the process of continuously optimizing the second entity relationship learning model, since the second entity relationship learning model has been optimized in the previous iteration process, the prototype feature set corresponding to the target entity relationship set needs to be reacquired based on the second entity relationship learning model that has been optimized, and then the second entity relationship learning model is continuously optimized based on the activated text set, the target memory text set, and the newly acquired prototype feature set.
[0266] In this way two, the optimization termination condition can be met when the optimization number reaches a number threshold, the fifth loss function and the sixth loss function are both less than a loss threshold, or the fifth loss function and the sixth loss function are both converged.
[0267] In step 305, in response to the optimization termination condition being met, the entity relationship learning model obtained when the optimization termination condition is met is taken as the target entity relationship learning model.
[0268] When the optimization termination condition is met, the entity relation learning model obtained when the optimization termination condition is met is taken as the target entity relation learning model. In this way, the target entity relation learning model is obtained. The target entity relation learning model obtained at this time learns the new entity relation on the basis of maintaining the memory of the old entity relation. The target entity relation learning model has good knowledge maintaining ability and continuous learning ability, and has good practicability.
[0269] Exemplarily, the process of obtaining the target entity relation learning model is as shown in Figure 5 It is assumed that the entity relation C needs to be learned in the current new task, and the entity relations A and B have been learned in the previous old task. The process of obtaining the target entity relation learning model involves the following four stages:
[0270] 1. Training stage: obtain the training text set corresponding to the entity relation C, obtain the loss function by using the training text set, and train the first entity relation learning model to obtain the second entity relation learning model. 2. Obtaining prototype feature stage: add the memory text corresponding to the entity relation C to the existing memory text set to obtain a target memory text set; based on the target memory text set, sample to obtain the prototype text set corresponding to each entity relation (the entity relations A, B and C), and then obtain the prototype feature corresponding to each entity relation according to the prototype text set of each entity relation. 3. Reenactment and activation stage: merge the target memory text set and the training text set to obtain an activated text set, obtain the loss function based on the activated text set, and perform the first adjustment on the second entity relation learning model. 4. Reinforcement stage: based on the target memory text set, sample to obtain the instance text set corresponding to each entity relation (the entity relations A, B and C), and then obtain the loss function according to the instance text set corresponding to each entity relation and perform the second adjustment on the first adjusted second entity relation learning model.
[0271] In the above four stages, the three stages of obtaining the prototype feature set, reenactment and activation, and reinforcement are performed in a loop. When the above obtaining process meets the optimization termination condition, the entity relation learning model obtained when the optimization termination condition is met is taken as the target entity relation learning model.
[0272] After obtaining the target entity relation learning model, the target entity relation learning model obtained by the embodiments of the present application and the entity relation learning model obtained in related technologies are tested by using a test set to verify the effectiveness of the target entity relation learning model obtained by the embodiments of the present application.
[0273] Exemplarily, three test sets are selected in the embodiments of the present application, which are: 1, FewRel (The Few-Shot Relation Classification Dataset) test set; 2, SimpleQ (Simple Question) test set; 3, TACRED (Text Analysis Conference Relation Extraction Dataset) test set. The target entity relation learning model obtained by the embodiments of the present application and the entity relation learning models obtained in the related technologies are all tested on each test set, and the performances of the entity relation learning models are evaluated by using two performance indicators in the test results, which are: 1, overall performance (W): used to represent the accuracy of relation extraction on all tasks of the entire test set; 2, average performance (A): used to represent the average accuracy of relation extraction on multiple batches of sub-tasks by dividing all tasks of the entire test set into multiple batches of sub-tasks. After testing on all tasks, the overall performance and the average performance are used to evaluate the overall performance of the entity relation learning model. The test results are shown in Table 1:
[0274] Table 1
[0275]
[0276] In Table 1, EWC, GEM, AGEM, EMR and EA-EMR are all entity relation learning models obtained in the related technologies. According to Table 1, the performance of the target entity relation learning model obtained by the embodiments of the present application is significantly better than that of the entity relation learning models obtained in the related technologies, and almost has the best performance in all test sets. On the SimpleQ test set, the performance of the target entity relation learning model obtained by the embodiments of the present application is close to that of EA-EMR and EMR obtained in the related technologies, which may be because the SimpleQ test set is too simple. On the FewRel and TACRED test sets, the performance of the target entity relation learning model obtained by the embodiments of the present application is better than that of all entity relation learning models obtained in the related technologies, which shows the superiority of the memory activation and reconsolidation mechanism proposed in the embodiments of the present application.
[0277] In addition, in order to further study the change of model performance in the process of learning new tasks, as shown in Figure 6 According to three different test sets (FewRel, SimpleQ and TACRED), the average accuracy of entity relation extraction with the number of tasks in the process of continuous learning of entity relation of the target entity relation learning model obtained by the embodiments of the present application and the entity relation learning models obtained in the related technologies is tested. According toFigure 6 It can be seen that, with the increase of the number of tasks, the performance of all models has a certain degree of decline, which shows that forgetting old entity relationship is inevitable, and is one of the main difficulties of continuous relationship learning. In addition, compared with the entity relationship learning model obtained in the related art, the target entity relationship learning model obtained in the embodiment of the present application achieves better results, which shows the effectiveness of memory reconsolidation, and further shows that it is more important and more reasonable to understand the relationship prototype than to memorize the text by rote.
[0278] Exemplarily, the memory capacity refers to the number of memory texts saved in the memory text set in each task. The influence of memory capacity on the target entity relationship learning model obtained in the embodiment of the present application and the entity relationship learning model obtained in the related art is further studied. The overall performance (W) and average performance (A) of the target entity relationship learning model obtained in the embodiment of the present application and the entity relationship learning model obtained in the related art are tested based on three memory capacities (10, 25 and 50) by using three test sets (FewRel, SimpleQ and TACRED), and the test results are shown in Table 2:
[0279] Table 2
[0280]
[0281] According to Table 2, (1) with the increase of memory capacity, the performance of each model has different degrees of improvement, which shows that memory capacity is one of the key factors determining the performance of the entity relationship learning model. (2) On the FewRel and TACRED test sets, the target entity relationship learning model obtained in the embodiment of the present application maintains the best performance under different memory capacities, and even reaches the performance comparable to other models under larger memory capacities. That is, compared with the method of obtaining the entity relationship learning model based on memory text, obtaining the entity relationship learning model by using prototype features in the embodiment of the present application is a more effective method of using memory.
[0282] In the embodiment of the present application, the target entity relationship learning model is obtained based on the way of memory rehearsal, activation and reconsolidation. By introducing the scene memory activation and reconsolidation mechanism in the human long-term memory formation mechanism, the target entity relationship learning model can still maintain the memory of old entity relationship when learning new entity relationship knowledge, and the obtained target entity relationship learning model has good knowledge retention ability and continuous learning ability, and has good practicability. Compared with the related art, the embodiment of the present application requires the model to understand the prototype features of the old entity relationship, rather than fitting some specific memory text too much, so that the entity relationship can be better distinguished in the long-term learning process.
[0283] In the embodiments of the present application, in the process of obtaining the target entity relation learning model, first, training is performed based on the training text set, and then optimization is performed based on the target memory text set and the prototype feature set. The prototype feature set corresponding to the target entity relation set is obtained based on the target memory text set, and the prototype feature is more representative than the memory text and can more comprehensively represent the real feature distribution of the entity relation. The target entity relation learning model obtained in this way has better learning effect on the entity relation, and the target entity relation learning model obtained in this way has higher accuracy in entity relation extraction.
[0284] Referring to Figure 7 The embodiments of the present application provide an entity relation extraction device, which comprises:
[0285] The first obtaining unit 701 is configured to obtain a target text to be extracted for entity relation and a target entity relation learning model, the target entity relation learning model being obtained based on a prototype feature set corresponding to a target entity relation set, the prototype feature set corresponding to the target entity relation set being obtained based on a target memory text set, the target entity relation set comprising each target entity relation learned by the target entity relation learning model.
[0286] The second obtaining unit 702 is configured to call the target entity relation learning model to obtain text features of the target text and target prototype features corresponding to each target entity relation in the target entity relation set.
[0287] The determining unit 703 is configured to determine, for any target entity relation in the target entity relation set, a matching degree between the target text and the target entity relation based on the text features of the target text and the target prototype features corresponding to the target entity relation, and determine an entity relation corresponding to the target text based on the matching degrees between the target text and each target entity relation.
[0288] In a possible implementation manner, the second obtaining unit 702 is further configured to, for any target entity relation in the target entity relation set, obtain a target candidate text set corresponding to the target entity relation based on the target memory text set, call the target entity relation learning model to obtain text features of each target candidate text in the target candidate text set corresponding to the target entity relation, and obtain the target prototype features corresponding to the target entity relation based on the text features of each target candidate text.
[0289] In the embodiments of the present application, the target entity relationship learning model is obtained based on a prototype feature set corresponding to a target entity relationship set, the prototype feature set is obtained based on a target memory text set, the prototype features in the prototype feature set are more representative than the memory texts and can more comprehensively represent the entity relationships, the target entity relationship learning model obtained based on the prototype feature set has good entity relationship learning effect, and the accuracy of entity relationship extraction using the target entity relationship learning model is higher.
[0290] Referring to Figure 8 The embodiments of the present application provide an obtaining device of an entity relationship learning model, which comprises:
[0291] The first obtaining unit 801 is configured to obtain a training text set corresponding to a to-be-learned entity relationship set, the to-be-learned entity relationship set comprising at least one to-be-learned entity relationship, and the training text set comprising training texts respectively corresponding to each to-be-learned entity relationship.
[0292] The second obtaining unit 802 is configured to take the to-be-learned entity relationship set and a learned entity relationship set as a target entity relationship set, update an existing memory text set based on the training text set, and obtain a target memory text set.
[0293] The training unit 803 is configured to train a first entity relationship learning model based on the training text set and obtain a second entity relationship learning model.
[0294] The third obtaining unit 804 is configured to obtain a prototype feature set corresponding to the target entity relationship set based on the second entity relationship learning model and the target memory text set.
[0295] The optimization unit 805 is configured to optimize the second entity relationship learning model based on the target memory text set and the prototype feature set.
[0296] The determination unit 806 is configured to take an entity relationship learning model obtained when an optimization termination condition is met as the target entity relationship learning model in response to the optimization termination condition being met.
[0297] In a possible implementation, the first entity relationship learning model comprises a first feature extraction model and a first relationship feature management model, and the first relationship feature management model is configured to manage an initial relationship feature set corresponding to the target entity relationship set; the training unit 803 is configured to call the first feature extraction model to perform feature extraction on each training text in the training text set to obtain text features of each training text; for any training text, based on the initial relationship feature set managed by the first relationship feature management model and the text features of any training text, a matching result corresponding to any training text is obtained; based on the matching result corresponding to each training text, a first loss function is determined; and parameters of the first feature extraction model and the first relationship feature management model are updated based on the first loss function.
[0298] In a possible implementation, the second obtaining unit 802 is further configured to perform clustering processing on the training texts in the training text set, determine the number of memory texts corresponding to each entity relationship to be learned in the entity relationship set to be learned according to the obtained clustering result; for any entity relationship to be learned, perform clustering processing on the training texts corresponding to any entity relationship to be learned in the training text set according to the number of memory texts corresponding to any entity relationship to be learned, and determine the memory text corresponding to any entity relationship to be learned according to the obtained clustering result; and add the memory texts corresponding to each entity relationship to be learned to the existing memory text set to obtain a target memory text set.
[0299] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model; and the third obtaining unit 804 is configured to, for any target entity relationship in the target entity relationship set, construct a prototype text set corresponding to any target entity relationship based on the target memory text set; call the second feature extraction model to perform feature extraction on each prototype text in the prototype text set to obtain text features of each prototype text; obtain a prototype feature corresponding to any target entity relationship based on the text features of each prototype text; and take a set of prototype features corresponding to each target entity relationship in the target entity relationship set as a prototype feature set corresponding to the target entity relationship set.
[0300] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model; the optimization unit 805 is configured to, for any target entity relationship in the target entity relationship set, construct a first instance text set corresponding to the any target entity relationship based on the target memory text set; call the second feature extraction model to perform feature extraction on each first instance text in the first instance text set to obtain a text feature of each first instance text; for any first instance text, obtain a matching result corresponding to the any first instance text based on the prototype feature set and the text feature of the any first instance text; obtain a first sub-loss function corresponding to the any target entity relationship based on the matching result corresponding to each first instance text; determine a second loss function based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set; and update the parameters of the second feature extraction model based on the second loss function.
[0301] In a possible implementation, the optimization unit 805 is further configured to take the set of the target memory text set and the training text set as an active text set; and optimize the second entity relationship learning model based on the active text set, the target memory text set, and the prototype feature set.
[0302] In a possible implementation, the optimization unit 805 is further configured to perform a first adjustment on the second entity relationship learning model based on the active text set, and perform a second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
[0303] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is configured to manage a target relationship feature set corresponding to the target entity relationship set; the optimization unit 805 is further configured to call the second feature extraction model to perform feature extraction on each active text in the active text set to obtain a text feature of each active text; for any active text, obtain a matching result corresponding to the any active text based on the target relationship feature set managed by the second relationship feature management model and the text feature of the any active text; determine a third loss function based on the matching result corresponding to each active text; and update the parameters of the second feature extraction model based on the third loss function.
[0304] In a possible implementation, the first adjusted second entity relationship learning model comprises a first adjusted second feature extraction model; the optimization unit 805 is further configured to, for any target entity relationship in the target entity relationship set, construct a second instance text set corresponding to the any target entity relationship based on the target memory text set; call the first adjusted second feature extraction model to perform feature extraction on each second instance text in the second instance text set to obtain a text feature of each second instance text; for any second instance text, obtain a matching result corresponding to the any second instance text based on the prototype feature set and the text feature of the any second instance text; obtain a second sub-loss function corresponding to the any target entity relationship based on the matching result corresponding to each second instance text; determine a fourth loss function based on the second sub-loss function corresponding to each target entity relationship in the target entity relationship set; and update the parameters of the first adjusted second feature extraction model based on the fourth loss function.
[0305] In a possible implementation, the optimization unit 805 is further configured to perform third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set, and perform fourth adjustment on the third adjusted second entity relationship learning model based on the active text set.
[0306] In a possible implementation, the second entity relationship learning model comprises a second feature extraction model; the optimization unit 805 is further configured to, for any target entity relationship in the target entity relationship set, construct a third instance text set corresponding to the any target entity relationship based on the target memory text set; call the second feature extraction model to perform feature extraction on each third instance text in the third instance text set to obtain a text feature of each third instance text; for any third instance text, obtain a matching result corresponding to the any third instance text based on the prototype feature set and the text feature of the any third instance text; obtain a third sub-loss function corresponding to the any target entity relationship based on the matching result corresponding to each third instance text; determine a fifth loss function based on the third sub-loss function corresponding to each target entity relationship in the target entity relationship set; and update the parameters of the second feature extraction model based on the fifth loss function.
[0307] In a possible implementation, the third adjusted second entity relationship learning model includes a third adjusted second feature extraction model and a second relationship feature management model, and the second relationship feature management model is configured to manage a target relationship feature set corresponding to the target entity relationship set; the optimization unit 805 is further configured to call the third adjusted second feature extraction model to perform feature extraction on each active text in the active text set, to obtain a text feature of each active text; for any active text, based on the target relationship feature set managed by the second relationship feature management model and the text feature of any active text, a matching result corresponding to any active text is obtained; based on the matching result corresponding to each active text respectively, a sixth loss function is determined; and based on the sixth loss function, the parameters of the third adjusted second feature extraction model are updated.
[0308] In the embodiments of the present application, in the process of obtaining the target entity relationship learning model, the training is first performed based on the training text set, and then the optimization is performed based on the target memory text set and the prototype feature set. The prototype feature set corresponding to the target entity relationship set is obtained based on the target memory text set, and the prototype feature set is more representative than the memory text and can more comprehensively represent the real feature distribution of the entity relationship. The target entity relationship learning model obtained in this way has better learning effect on the entity relationship, and the accuracy of the entity relationship extraction performed by the target entity relationship learning model obtained in this way is higher.
[0309] It should be noted that the apparatus provided in the above embodiments is only used as an example to illustrate the division of the above functional modules, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.
[0310] Figure 9 is a structural schematic diagram of a server provided by the embodiments of the present application. The server can have great differences due to different configurations or performances, and can include one or more processors (Central Processing Units, CPU) 901 and one or more memories 902, wherein the one or more memories 902 store at least one program code, which is loaded and executed by the one or more processors 901 to implement the entity relationship extraction method or the method for obtaining the entity relationship learning model provided by each method embodiment. Of course, the server can also have a wired or wireless network interface, a keyboard, and an input and output interface, and other components for realizing the functions of the device, which will not be described here.
[0311] Figure 10 FIG. 1 is a structural schematic diagram of a terminal according to an embodiment of the present application. The terminal can be a smartphone, a tablet computer, a notebook computer, or a desktop computer. The terminal can also be referred to as a user equipment, a portable terminal, a laptop terminal, a desktop terminal, or other names.
[0312] Generally, the terminal includes a processor 1001 and a memory 1002.
[0313] The processor 1001 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1001 can be implemented in at least one of a hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 1001 can also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also referred to as a CPU (Central Processing Unit). The coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1001 can be integrated with a GPU (Graphics Processing Unit) for rendering and drawing content required to be displayed on a display screen. In some embodiments, the processor 1001 can further include an AI (Artificial Intelligence) processor for processing machine learning-related computing operations.
[0314] The memory 1002 can include one or more computer-readable storage media, which can be non-transitory. The memory 1002 can also include a high-speed random access memory, and a non-volatile memory such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction for being executed by the processor 1001 to implement an entity relationship extraction method or an acquisition method of an entity relationship learning model provided by the method embodiments of the present application.
[0315] In some embodiments, the terminal can further optionally include a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 can be connected through a bus or a signal line. Each peripheral device can be connected to the peripheral device interface 1003 through a bus, a signal line or a circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 1004, a touch display screen 1005, a camera component 1006, an audio circuit 1007, a positioning component 1008 and a power supply 1009.
[0316] The peripheral device interface 1003 can be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002 and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002 and the peripheral device interface 1003 can be implemented on a separate chip or circuit board, and the present embodiment does not limit this.
[0317] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 1004 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G and 5G), wireless local area networks and / or WiFi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 1004 can also include NFC (Near Field Communication) related circuitry, which is not limited by the present application.
[0318] The display screen 1005 is configured to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 is further configured to capture touch signals on or above the surface of the display screen 1005. The touch signals can be input to the processor 1001 as control signals for processing. In this case, the display screen 1005 can also be configured to provide virtual buttons and / or virtual keyboard, also known as soft buttons and / or soft keyboard. In some embodiments, the display screen 1005 can be one, disposed on the front panel of the terminal; in other embodiments, the display screen 1005 can be at least two, respectively disposed on different surfaces of the terminal or in a folding design; in still other embodiments, the display screen 1005 can be a flexible display screen, disposed on a curved surface or a folding surface of the terminal. Even, the display screen 1005 can also be disposed in an irregular shape, i.e., a special-shaped screen. The display screen 1005 can be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc.
[0319] The camera assembly 1006 is configured to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, the rear camera is at least two, respectively any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, to realize the background blur function by fusing the main camera and the depth-of-field camera, the panoramic shooting and VR (Virtual Reality) shooting function by fusing the main camera and the wide-angle camera, or other fusion shooting functions. In some embodiments, the camera assembly 1006 can further include a flash. The flash can be a single-color-temperature flash or a dual-color-temperature flash. The dual-color-temperature flash refers to the combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
[0320] The audio circuit 1007 can include a microphone and a speaker. The microphone is used to collect sound waves of a user and an environment, and convert the sound waves into an electrical signal input to the processor 1001 for processing, or input to the radio frequency circuit 1004 to realize voice communication. For the purpose of stereo sound collection or noise reduction, the microphone can be multiple, respectively arranged at different parts of the terminal. The microphone can also be an array microphone or an omnidirectional collection type microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker can be a traditional diaphragm speaker, or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, not only can the electrical signal be converted into a sound wave audible to humans, but also can be converted into a sound wave inaudible to humans for ranging purposes. In some embodiments, the audio circuit 1007 can also include a headphone jack.
[0321] The positioning component 1008 is used to position the current geographic position of the terminal to realize navigation or LBS (Location Based Service). The positioning component 1008 can be a positioning component based on the GPS (Global Positioning System) of the United States, the Beidou system of China, the Glonass system of Russia or the Galileo system of the European Union.
[0322] The power supply 1009 is used to supply power to each component in the terminal. The power supply 1009 can be alternating current, direct current, disposable battery or rechargeable battery. When the power supply 1009 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0323] In some embodiments, the terminal also includes one or more sensors 1010. The one or more sensors 1010 include but are not limited to: an acceleration sensor 1011, a gyroscope sensor 1012, a pressure sensor 1013, a fingerprint sensor 1014, an optical sensor 1015 and a proximity sensor 1016.
[0324] The acceleration sensor 1011 can detect the acceleration in three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor 1011 can be used to detect the components of gravitational acceleration in three coordinate axes. The processor 1001 can control the touch display screen 1005 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 1011. The acceleration sensor 1011 can also be used for game or user motion data collection.
[0325] The gyroscope sensor 1012 can detect the body direction and rotation angle of the terminal, and the gyroscope sensor 1012 can cooperate with the acceleration sensor 1011 to collect the 3D action of the user on the terminal. According to the data collected by the gyroscope sensor 1012, the processor 1001 can realize the following functions: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization when shooting, game control, and inertial navigation.
[0326] The pressure sensor 1013 can be arranged on the side frame of the terminal and / or the lower layer of the touch display screen 1005. When the pressure sensor 1013 is arranged on the side frame of the terminal, the user's holding signal on the terminal can be detected, and the left and right hand recognition or shortcut operation can be performed by the processor 1001 according to the holding signal collected by the pressure sensor 1013. When the pressure sensor 1013 is arranged on the lower layer of the touch display screen 1005, the operable control on the UI interface can be controlled by the processor 1001 according to the pressure operation of the user on the touch display screen 1005. The operable control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0327] The fingerprint sensor 1014 is used to collect the fingerprint of the user, and the identity of the user can be recognized by the processor 1001 according to the fingerprint collected by the fingerprint sensor 1014, or by the fingerprint sensor 1014 according to the collected fingerprint. When the identity of the user is recognized as a trusted identity, the processor 1001 authorizes the user to perform related sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, payment, and changing settings. The fingerprint sensor 1014 can be arranged on the front, back or side of the terminal. When the terminal is provided with a physical button or a manufacturer's logo, the fingerprint sensor 1014 can be integrated with the physical button or the manufacturer's logo.
[0328] The optical sensor 1015 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the touch display screen 1005 according to the ambient light intensity collected by the optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 1005 is decreased. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 according to the ambient light intensity collected by the optical sensor 1015.
[0329] The proximity sensor 1016, also referred to as a distance sensor, is usually arranged on the front panel of the terminal. The proximity sensor 1016 is used to collect the distance between the user and the front of the terminal. In one embodiment, when the proximity sensor 1016 detects that the distance between the user and the front of the terminal gradually decreases, the touch display screen 1005 is switched from the bright screen state to the screen-off state under the control of the processor 1001; when the proximity sensor 1016 detects that the distance between the user and the front of the terminal gradually increases, the touch display screen 1005 is switched from the screen-off state to the bright screen state under the control of the processor 1001.
[0330] Those skilled in the art can understand that the structure shown in the foregoing embodiments does not constitute a limitation on the terminal, and the terminal can include more or fewer components than those shown in the drawings, or combine certain components, or adopt a different component arrangement. Figure 10
[0331] In an example embodiment, a computer device is also provided, which includes a processor and a memory having at least one piece of program code stored therein. The at least one piece of program code is loaded and executed by one or more processors to implement any of the above entity relationship extraction methods or the acquisition method of any of the entity relationship learning models.
[0332] In an example embodiment, a computer readable storage medium is also provided, which has at least one piece of program code stored therein. The at least one piece of program code is loaded and executed by a processor of a computer device to implement any of the above entity relationship extraction methods or the acquisition method of any of the entity relationship learning models.
[0333] In a possible implementation manner, the above computer readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0334] In an example embodiment, a computer program product is also provided, which has at least one piece of computer program stored therein. The at least one piece of computer program is loaded and executed by a processor of a computer device to implement any of the above entity relationship extraction methods or the acquisition method of any of the entity relationship learning models.
[0335] It should be understood that the "multiple" mentioned herein refers to two or more than two. The "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents that the associated objects before and after are in an "or" relationship.
[0336] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0337] The above is only an exemplary embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for extracting entity relations, characterized in that, The method includes: Obtain the target text for extracting entity relations and the target entity relation learning model. The target entity relation learning model is obtained based on the prototype feature set corresponding to the target entity relation set. The prototype feature set corresponding to the target entity relation set is obtained based on the target memory text set. The target entity relation set includes each target entity relation already learned by the target entity relation learning model. The target entity relationship learning model is invoked to obtain the text features of the target text and the target prototype features corresponding to each target entity relationship in the target entity relationship set. For any target entity relationship in the target entity relationship set, the matching degree between the target text and the target entity relationship is determined based on the text features of the target text and the target prototype features corresponding to the target entity relationship; based on the matching degree between the target text and each target entity relationship, the entity relationship corresponding to the target text is determined.
2. The method according to claim 1, characterized in that, Before determining the matching degree between the target text and the target entity relationship based on the text features of the target text and the target prototype features corresponding to any target entity relationship, the method further includes: For any target entity relationship in the target entity relationship set, obtain the target candidate text set corresponding to any target entity relationship based on the target memory text set; The target entity relationship learning model is invoked to obtain the text features of each target candidate text in the target candidate text set corresponding to any target entity relationship; Based on the textual features of each target candidate text, the target prototype features corresponding to any target entity relationship are obtained.
3. A method for obtaining an entity relationship learning model, characterized in that, The method includes: Obtain the training text set corresponding to the set of entity relations to be learned, wherein the set of entity relations to be learned includes at least one entity relation to be learned, and the training text set includes training texts corresponding to each entity relation to be learned. The set of entity relations to be learned and the set of entity relations already learned are used as the target entity relation set; the existing memory text set is updated based on the training text set to obtain the target memory text set; The first entity relationship learning model is trained based on the training text set to obtain the second entity relationship learning model; Based on the second entity relationship learning model and the target memory text set, obtain the prototype feature set corresponding to the target entity relationship set; based on the target memory text set and the prototype feature set, optimize the second entity relationship learning model; In response to the satisfaction of the optimization termination condition, the entity relationship learning model obtained when the optimization termination condition is satisfied is taken as the target entity relationship learning model.
4. The method according to claim 3, characterized in that, The first entity relationship learning model includes a first feature extraction model and a first relationship feature management model. The first relationship feature management model is used to manage the initial relationship feature set corresponding to the target entity relationship set. The training of the first entity relation learning model based on the training text set includes: The first feature extraction model is invoked to extract features from each training text in the training text set, thereby obtaining the text features of each training text. For any training text, based on the initial relation feature set managed by the first relation feature management model and the text features of any training text, the matching result corresponding to any training text is obtained; Based on the matching results corresponding to each training text, a first loss function is determined; the parameters of the first feature extraction model and the first relationship feature management model are updated based on the first loss function.
5. The method according to claim 3, characterized in that, The step of updating the existing memory text set based on the training text set to obtain the target memory text set includes: Cluster the training texts in the training text set, and determine the number of memorized texts corresponding to each entity relation in the entity relation set to be learned based on the clustering results. For any entity relation to be learned, cluster the training texts in the training text set that correspond to the entity relation to be learned according to the number of memory texts corresponding to the entity relation to be learned, and determine the memory texts corresponding to the entity relation to be learned based on the clustering results. Add the memory text corresponding to each entity relationship to be learned to the existing memory text set to obtain the target memory text set.
6. The method according to claim 3, characterized in that, The second entity relationship learning model includes a second feature extraction model; the step of obtaining the prototype feature set corresponding to the target entity relationship set based on the second entity relationship learning model and the target memory text set includes: For any target entity relationship in the target entity relationship set, construct a prototype text set corresponding to any target entity relationship based on the target memory text set; The second feature extraction model is invoked to extract features from each prototype text in the prototype text set to obtain the text features of each prototype text; based on the text features of each prototype text, the prototype features corresponding to any target entity relationship are obtained. The set of prototype features corresponding to each target entity relationship in the target entity relationship set is taken as the prototype feature set corresponding to the target entity relationship set.
7. The method according to any one of claims 3-6, characterized in that, The second entity relationship learning model includes a second feature extraction model; the optimization of the second entity relationship learning model based on the target memory text set and the prototype feature set includes: For any target entity relation in the target entity relation set, construct a first instance text set corresponding to any target entity relation based on the target memory text set; The second feature extraction model is invoked to extract features from each first instance text in the first instance text set, thereby obtaining the text features of each first instance text; For any first instance text, based on the prototype feature set and the text features of any first instance text, obtain the matching result corresponding to any first instance text; Based on the matching results corresponding to each first instance text, obtain the first sub-loss function corresponding to any target entity relationship; Based on the first sub-loss function corresponding to each target entity relationship in the target entity relationship set, a second loss function is determined; and the parameters of the second feature extraction model are updated based on the second loss function.
8. The method according to any one of claims 3-6, characterized in that, The optimization of the second entity relation learning model based on the target memory text set and the prototype feature set includes: The set of the target memory text set and the set of the training text set are used as the activation text set; The second entity relationship learning model is optimized based on the activated text set, the target memory text set, and the prototype feature set.
9. The method according to claim 8, characterized in that, The optimization of the second entity relation learning model based on the activated text set, the target memory text set, and the prototype feature set includes: The second entity relationship learning model is first adjusted based on the activated text set, and then the second entity relationship learning model after the first adjustment is adjusted based on the target memory text set and the prototype feature set.
10. The method according to claim 9, characterized in that, The second entity relationship learning model includes a second feature extraction model and a second relationship feature management model. The second relationship feature management model is used to manage the target relationship feature set corresponding to the target entity relationship set. The first adjustment to the second entity relation learning model based on the activated text set includes: The second feature extraction model is invoked to extract features from each active text in the active text set, thereby obtaining the text features of each active text. For any activated text, based on the target relation feature set managed by the second relation feature management model and the text features of the activated text, the matching result corresponding to the activated text is obtained; Based on the matching results corresponding to each activated text, a third loss function is determined; and the parameters of the second feature extraction model are updated based on the third loss function.
11. The method according to claim 9 or 10, characterized in that, The first adjusted second entity relationship learning model includes the first adjusted second feature extraction model; the second adjustment of the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set includes: For any target entity relation in the target entity relation set, a second instance text set corresponding to any target entity relation is constructed based on the target memory text set; The first adjusted second feature extraction model is invoked to extract features from each second instance text in the second instance text set, thereby obtaining the text features of each second instance text; For any second instance text, based on the prototype feature set and the text features of any second instance text, obtain the matching result corresponding to any second instance text; Based on the matching results corresponding to each second instance text, obtain the second sub-loss function corresponding to any target entity relationship; Based on the second sub-loss function corresponding to each target entity relationship in the target entity relationship set, a fourth loss function is determined; and the parameters of the first adjusted second feature extraction model are updated based on the fourth loss function.
12. The method according to claim 8, characterized in that, The optimization of the second entity relation learning model based on the activated text set, the target memory text set, and the prototype feature set includes: The second entity relationship learning model is adjusted a third time based on the target memory text set and the prototype feature set, and the adjusted second entity relationship learning model is adjusted a fourth time based on the activated text set.
13. The method according to claim 12, characterized in that, The second entity relationship learning model includes a second feature extraction model; the third adjustment to the second entity relationship learning model based on the target memory text set and the prototype feature set includes: For any target entity relation in the target entity relation set, a third instance text set corresponding to any target entity relation is constructed based on the target memory text set; The second feature extraction model is invoked to extract features from each third instance text in the third instance text set, thereby obtaining the text features of each third instance text; For any third instance text, based on the prototype feature set and the text features of any third instance text, obtain the matching result corresponding to any third instance text; Based on the matching results corresponding to each third instance text, obtain the third sub-loss function corresponding to any target entity relationship; Based on the third sub-loss function corresponding to each target entity relationship in the target entity relationship set, a fifth loss function is determined; and the parameters of the second feature extraction model are updated based on the fifth loss function.
14. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one piece of program code, the at least one piece of program code being loaded and executed by the processor to implement the entity relation extraction method as described in any one of claims 1 to 2, or to implement the entity relation learning model acquisition method as described in any one of claims 3 to 13.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the entity relation extraction method as described in any one of claims 1 to 2, or to implement the entity relation learning model acquisition method as described in any one of claims 3 to 13.
Citation Information
Patent Citations
Training method of entity relationship extraction model and method for extracting entity relationship
CN110619053A
Identifying relationships between entities using machine learning
US20190197176A1