CN111737415A - Entity relationship extraction method, and method and device for acquiring entity relationship learning model - Google Patents

Entity relationship extraction method, and method and device for acquiring entity relationship learning model Download PDF

Info

Publication number
CN111737415A
CN111737415A CN202010537884.XA CN202010537884A CN111737415A CN 111737415 A CN111737415 A CN 111737415A CN 202010537884 A CN202010537884 A CN 202010537884A CN 111737415 A CN111737415 A CN 111737415A
Authority
CN
China
Prior art keywords
text
target
entity relationship
learning model
entity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010537884.XA
Other languages
Chinese (zh)
Inventor
刘知远
韩旭
戴翼
高天宇
林衍凯
李鹏
孙茂松
周杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tsinghua University
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tsinghua University
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tsinghua University, Tencent Technology Shenzhen Co Ltd filed Critical Tsinghua University
Priority to CN202010537884.XA priority Critical patent/CN111737415A/en
Publication of CN111737415A publication Critical patent/CN111737415A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses an entity relationship extraction method, and an entity relationship learning model acquisition method and device. The method comprises the following steps: acquiring a target text and a target entity relationship learning model, wherein the target entity relationship learning model is obtained based on a prototype feature set corresponding to a target entity relationship set; calling a target entity relationship learning model to obtain text features of a target text and target prototype features corresponding to each target entity relationship; determining the matching degree of the target text and any target entity relation based on the text characteristics and the target prototype characteristics corresponding to any target entity relation; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship. In this way, the prototype features in the prototype feature set can represent the entity relationship more comprehensively, the target entity relationship learning model obtained based on the prototype feature set has a better entity relationship learning effect, and the accuracy of extracting the entity relationship by using the target entity relationship learning model is higher.

Description

Entity relationship extraction method, and method and device for acquiring entity relationship learning model
Technical Field
The embodiment of the application relates to the technical field of artificial intelligence, in particular to an entity relationship extraction method, and an entity relationship learning model acquisition method and device.
Background
Information extraction, which aims to extract structured information from large-scale unstructured or semi-structured natural language text. The entity relationship extraction is one of important subtasks in information extraction, and the purpose of the entity relationship extraction is to extract entity relationships between entities from text. For example, an entity relationship "acting as a chairman" is extracted from a given text "newtonian royal society of students", and the extracted entity relationship may be used as an external resource for various types of downstream applications (e.g., search engines, question and answer systems, etc.). With the development of artificial intelligence technology, in the process of extracting the entity relationship, an entity relationship learning model for learning the entity relationship which continuously appears is obtained firstly, and then the task of extracting the entity relationship is realized based on the obtained entity relationship learning model.
In the related art, an entity relationship learning model is directly obtained based on a memory text corresponding to an entity relationship, and then the entity relationship is extracted based on the obtained entity relationship learning model. The representativeness of the memory text corresponding to the entity relationship is poor, the entity relationship is difficult to represent comprehensively, the entity relationship learning model obtained based on the memory text corresponding to the entity relationship has poor entity relationship learning effect, and the accuracy of extracting the entity relationship based on the obtained entity relationship learning model is low.
Disclosure of Invention
The embodiment of the application provides an entity relationship extraction method, an entity relationship learning model acquisition method and an entity relationship learning model acquisition device, which can be used for improving the accuracy of entity relationship extraction. The technical scheme is as follows:
in one aspect, an embodiment of the present application provides an entity relationship extraction method, where the method includes:
acquiring a target text of an entity relationship to be extracted and a target entity relationship learning model, wherein 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 corresponding to the target entity relationship set is obtained based on a target memory text set, and the target entity relationship set comprises all target entity relationships learned by the target entity relationship learning model;
calling the target entity relationship learning model to obtain text features of the target text and 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, determining the matching degree of the target text and the any target entity relationship based on the text features of the target text and the target prototype features corresponding to the any target entity relationship; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship.
Also provided is an acquisition method of the entity relationship learning model, which comprises the following steps:
acquiring a training text set corresponding to an entity relationship set to be learned, wherein the entity relationship set to be learned comprises at least one entity relationship to be learned, and the training text set comprises training texts respectively corresponding to the entity relationships to be learned;
combining the set of the entity relationship set to be learned and the learned entity relationship set into a target entity relationship set; updating the existing memory text set based on the training text set to obtain a target memory text set;
training the first entity relation learning model based on the training text set to obtain a second entity relation learning model;
based on the second entity relationship learning model and the target memory text set, acquiring a prototype feature set corresponding to the target entity relationship set; optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set;
and in response to the optimization termination condition being met, taking the entity relationship learning model obtained when the optimization termination condition is met as a target entity relationship learning model.
In a possible implementation manner, 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 used for managing a target relationship feature set corresponding to the target entity relationship set; performing a fourth adjustment on the third adjusted second entity relationship learning model based on the activated text set, including:
calling the third adjusted 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;
for any activated text, acquiring a matching result corresponding to the any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of the any activated text;
determining a sixth loss function based on the matching result respectively corresponding to each activated text; updating parameters of the third adjusted second feature extraction model based on the sixth loss function.
In another aspect, an entity relationship extraction apparatus is provided, the apparatus includes:
the system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring a target text of an entity relationship to be extracted and a target entity relationship learning model, 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 corresponding to the target entity relationship set is obtained based on a target memory text set, and the target entity relationship set comprises all target entity relationships learned by the target entity relationship learning model;
a second obtaining unit, configured to invoke the target entity relationship learning model to obtain text features of the target text and target prototype features corresponding to each target entity relationship in the target entity relationship set;
a determining unit, configured to determine, for any target entity relationship in the target entity relationship set, a matching degree between the target text and the any target entity relationship based on a text feature of the target text and a target prototype feature corresponding to the any target entity relationship; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship.
In a possible implementation manner, the second obtaining unit is further configured to, for any target entity relationship in the target entity relationship set, obtain, based on the target memory text set, a target candidate text set corresponding to the any target entity relationship; calling the target entity relationship learning model to obtain the text features of each target candidate text in the target candidate text set corresponding to any target entity relationship; and acquiring a target prototype feature corresponding to any target entity relation based on the text feature of each target candidate text.
There is also provided an apparatus for acquiring an entity relationship learning model, the apparatus including:
the system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring a training text set corresponding to an entity relationship set to be learned, the entity relationship set to be learned comprises at least one entity relationship to be learned, and the training text set comprises training texts respectively corresponding to the entity relationships to be learned;
the second acquisition unit is used for cooperating the set of the entity relationship set to be learned and the learned entity relationship set as a target entity relationship set; updating the existing memory text set based on the training text set to obtain a target memory text set;
the training unit is used for training the first entity relationship learning model based on the training text set to obtain a second entity relationship learning model;
a third obtaining unit, configured to obtain, based on the second entity relationship learning model and the target memory text set, an archetype feature set corresponding to the target entity relationship set;
the optimization unit is used for optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set;
and the determining unit is used for responding to the condition that the optimization termination is met and taking the entity relationship learning model obtained when the optimization termination is met as the target entity relationship learning model.
In one possible implementation manner, the first entity relationship learning model includes a first feature extraction model and a first relationship feature management model, and the first relationship feature management model is used for managing an initial relationship feature set corresponding to the target entity relationship set; the training unit is used for calling the first feature extraction model to extract features of each training text in the training text set to obtain text features of each training text; for any training text, acquiring a matching result corresponding to the any training text based on the initial relation feature set managed by the first relation feature management model and the text feature of the any training text; determining a first loss function based on the matching result corresponding to each training text; updating parameters of the first feature extraction model and the first relational feature management model based on the first loss function.
In a possible implementation manner, the second obtaining unit is further configured to perform clustering processing on the training texts in the training text set, and determine, according to an obtained clustering result, the number of memory texts corresponding to each entity relationship to be learned in the entity relationship set to be learned; for any entity relation to be learned, clustering training texts corresponding to the entity relation to be learned in the training text set according to the number of memory texts corresponding to the entity relation to be learned, and determining the memory texts corresponding to the entity relation to be learned according to the obtained clustering result; and adding the memory text corresponding to each entity relation to be learned into the existing memory text set to obtain a target memory text set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the third obtaining unit is configured to construct, for any target entity relationship in the target entity relationship set, a prototype text set corresponding to the any target entity relationship based on the target memory text set; calling 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; based on the text features of the prototype texts, acquiring prototype features corresponding to any target entity relationship; and taking the set of prototype features respectively corresponding to each target entity relationship in the target entity relationship set as the prototype feature set corresponding to the target entity relationship set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the optimization unit is used for constructing a first instance text set corresponding to any target entity relation in the target entity relation set based on the target memory text set; calling 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 each first instance text; for any first instance text, acquiring 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; acquiring a first sub-loss function corresponding to any target entity relation based on the matching result corresponding to each first instance text; determining a second loss function based on the first sub-loss functions corresponding to the target entity relations in the target entity relation set; updating parameters of the second feature extraction model based on the second loss function.
In a possible implementation manner, the optimization unit is further configured to cooperate the target memory text set and the set of training text sets as an activation text set; and optimizing the second entity relationship learning model based on the activation text set, the target memory text set and the prototype feature set.
In a possible implementation manner, the optimization unit is further configured to perform a first adjustment on the second entity relationship learning model based on the activated 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.
In a possible implementation manner, the second entity relationship learning model includes a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is used for managing a target relationship feature set corresponding to the target entity relationship set; the optimization unit is further configured to invoke the second feature extraction model to perform feature extraction on each activated text in the activated text set, so as to obtain text features of each activated text; for any activated text, acquiring a matching result corresponding to the any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of the any activated text; determining a third loss function based on the matching result respectively corresponding to each activated text; updating parameters of the second feature extraction model based on the third loss function.
In one possible implementation, the first adjusted second entity relationship learning model includes a first adjusted second feature extraction model; the optimization unit is further configured to construct, for any target entity relationship in the target entity relationship set, a second instance text set corresponding to the target entity relationship based on the target memory text set; calling the first adjusted second feature extraction model to perform feature extraction on each second instance text in the second instance text set to obtain text features of each second instance text; for any second instance text, acquiring a matching result corresponding to the any second instance text based on the prototype feature set and the text features of the any second instance text; acquiring a second sub-loss function corresponding to any target entity relation based on the matching result corresponding to each second instance text; determining a fourth loss function based on the second sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; updating parameters of the first adjusted second feature extraction model based on the fourth loss function.
In a possible implementation manner, the optimization unit is further configured to perform a third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set, and perform a fourth adjustment on the third adjusted second entity relationship learning model based on the activated text set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the optimization unit is further configured to construct, for any target entity relationship in the target entity relationship set, a third instance text set corresponding to the target entity relationship based on the target memory text set; calling the second feature extraction model to perform feature extraction on each third instance text in the third instance text set to obtain text features of each third instance text; for any third instance text, acquiring a matching result corresponding to the any third instance text based on the prototype feature set and the text features of the any third instance text; acquiring a third sub-loss function corresponding to any target entity relation based on the matching result corresponding to each third instance text; determining a fifth loss function based on the third sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; updating parameters of the second feature extraction model based on the fifth loss function.
In a possible implementation manner, 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 used for managing a target relationship feature set corresponding to the target entity relationship set; the optimization unit is further configured to invoke the third adjusted second feature extraction model to perform feature extraction on each activated text in the activated text set, so as to obtain text features of each activated text; for any activated text, acquiring a matching result corresponding to the any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of the any activated text; determining a sixth loss function based on the matching result respectively corresponding to each activated text; updating parameters of the third adjusted second feature extraction model based on the sixth loss function.
In another aspect, a computer device is provided, where the computer device includes a processor and a memory, where the memory stores at least one program code, and the at least one program code is loaded and executed by the processor to implement any one of the entity relationship extraction methods described above or implement any one of the entity relationship learning model acquisition methods described above.
On the other hand, a computer-readable storage medium is further provided, where at least one program code is stored in the computer-readable storage medium, and the at least one program code is loaded and executed by a processor to implement any one of the entity relationship extraction methods described above or implement any one of the entity relationship learning model acquisition methods described above.
On the other hand, a computer program product is further provided, where at least one segment of computer program is stored in the computer program product, and the at least one segment of computer program is loaded and executed by a processor to implement any one of the entity relationship extraction methods described above or implement any one of the entity relationship learning model acquisition methods described above.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects:
the target entity relationship learning model is obtained based on a prototype feature set corresponding to the target entity relationship set, the prototype feature set is obtained based on the target memory text set, prototype features in the prototype feature set are more representative than memory texts and can represent entity relationships more comprehensively, the target entity relationship learning model obtained based on the prototype feature set has a good entity relationship learning effect, and the accuracy of extracting the entity relationships by using the target entity relationship learning model is high.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic illustration of an implementation environment provided by an embodiment of the present application;
fig. 2 is a flowchart of an entity relationship extraction method according to an embodiment of the present application;
fig. 3 is a flowchart of a method for acquiring a target entity relationship learning model according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a process for discovering and learning new relationships that continuously appear according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a process for obtaining a target entity relationship learning model according to an embodiment of the present disclosure;
FIG. 6 is a graph illustrating a variation curve of an average accuracy rate of entity relationship extraction with task number according to an embodiment of the present disclosure;
fig. 7 is a schematic diagram of an entity relationship extraction apparatus according to an embodiment of the present application;
fig. 8 is a schematic diagram of an apparatus for acquiring an entity relationship learning model according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a server provided in an embodiment of the present application;
fig. 10 is a schematic structural diagram of a terminal according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Artificial Intelligence (AI) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence is the research of the design principle and the realization method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making.
The artificial intelligence technology is a comprehensive subject and relates to the field of extensive technology, namely the technology of a hardware level and the technology of a software level. The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The scheme provided by the embodiment of the application relates to an artificial intelligence natural language processing technology. Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, entity relationship extraction, semantic understanding, machine translation, robotic question and answer, knowledge-graph, and the like.
With the research and progress of artificial intelligence technology, the artificial intelligence technology is developed and applied in a plurality of fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, unmanned aerial vehicles, robots, smart medical care, smart customer service, and the like.
Referring to fig. 1, a schematic diagram of an implementation environment of the entity relationship extraction method and the entity relationship learning model acquisition method provided in the embodiment of the present application is shown. The implementation environment may include: a terminal 11 and a server 12.
The entity relationship extraction method may be implemented based on the terminal 11, or may be implemented based on the server 12, which is not limited in this embodiment of the present application. In addition, the method for acquiring the entity relationship learning model may be implemented based on the terminal 11, or may be implemented based on the server 12.
In one possible implementation, the terminal 11 may be any electronic product capable of performing human-Computer interaction with a user through one or more modes of a keyboard, a touch pad, 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 Pocket PC (Pocket PC), a tablet Computer, a smart car machine, a smart television, a smart sound box, and the like. The server 12 may be a server, a server cluster composed of a plurality of servers, or a cloud computing service center. The terminal 11 establishes a communication connection with the server 12 through a wired or wireless network.
It should be understood by those skilled in the art that the above-mentioned terminal 11 and server 12 are only examples, and other existing or future terminals or servers may be suitable for the present application and are included within the scope of the present application and are herein incorporated by reference.
Based on the implementation environment shown in fig. 1, an embodiment of the present application provides an entity relationship extraction method, which is applied to the terminal 11 as an example. As shown in fig. 2, the entity relationship extracting method provided in the embodiment of the present application may include the following steps:
in step 201, a target text of an entity relationship to be extracted and a target entity relationship learning model are obtained, the target entity relationship learning model is obtained based on a prototype feature set corresponding to a target entity relationship set, and the prototype feature set corresponding to the target entity relationship set is obtained based on a target memory text set.
The target entity relationship set comprises all target entity relationships which are learned by the target entity relationship learning model.
The target text is the text of any entity relation to be extracted. In one possible implementation, the process of obtaining the target text is: and acquiring a target sentence, and preprocessing the acquired target sentence to obtain a target text corresponding to the target sentence. The target sentence is a sentence including two entities, and the source of the target sentence is not limited in the embodiments of the present application, and the target sentence may be derived from a corpus, a web page, or the like.
In a possible implementation manner, the process of preprocessing the obtained target sentence to obtain the target text corresponding to the target sentence is as follows: the target sentence is analyzed into a mark sequence by extracting various information such as semantic information, head and tail entity positions and the like of the target sentence, and the mark sequence is used as a target text.
The target entity relationship learning model refers to an entity relationship learning model which is obtained in advance before entity relationship extraction is carried out on a target text and learns continuously-occurring entity relationships. In the embodiment of the application, the target entity relationship learning model is obtained based on the prototype feature set corresponding to the target entity relationship set. The target entity relationship set comprises all target entity relationships learned by a target entity relationship learning model before entity relationship extraction is carried out on a target text, and the prototype feature set comprises prototype features corresponding to all the target entity relationships respectively. The prototype feature set corresponding to the target entity relationship set is obtained based on the target memory text set, and the target memory text set comprises memory texts corresponding to all the target entity relationships respectively.
The process of obtaining the target entity relationship learning model may be executed by a terminal or a server, which is not limited in the embodiment of the present application. For the condition that the process of obtaining the target entity relationship learning model is executed by the terminal, the terminal locally obtains the target entity relationship learning model; and for the condition that 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.
The process of obtaining the target entity relationship learning model is detailed in the embodiment shown in fig. 3, and is not repeated here. In addition, the target entity relationship set and the target memory text set are introduced in detail in the process of obtaining the target entity relationship learning model, and details are not repeated here.
In step 202, a target entity relationship learning model is invoked to obtain text features of a target text and target prototype features corresponding to each target entity relationship in a target entity relationship set.
The target entity relation learning model has good text feature extraction capability. And after the target text is obtained, calling a target entity relationship learning model to obtain the text characteristics of the target text. The text characteristics of the target text are used for determining the entity relationship corresponding to the target text.
In one possible implementation, the target entity relationship learning model includes a target feature extraction model. The method for acquiring the text features of the target text by calling the target entity relationship learning model comprises the following steps: and calling a target feature extraction model to extract features of the target text to obtain text features of the target text.
The target prototype feature corresponding to any target entity relationship is the final prototype feature of any target entity relationship obtained by using a target entity relationship learning model, and the target prototype feature is used for comparing with the text feature of the target text so as to further determine the entity relationship corresponding to the target text.
In a possible implementation manner, the method for obtaining a target prototype feature corresponding to any target entity relationship in the target entity relationship set includes the following steps 2021 to 2023:
step 2021: and for any target entity relation in the target entity relation set, acquiring a target candidate text set corresponding to the any target entity relation based on the target memory text set.
In a possible implementation manner, based on the target memory text set, the manner of obtaining the target candidate text set corresponding to any target entity relationship is as follows: taking a set of target memory texts corresponding to any target entity relationship in the target memory text set as a candidate text set; and selecting a reference number of candidate texts from the candidate text set to form a target candidate text set corresponding to any target entity relationship. The reference number may be set empirically, or may be adjusted according to the number of candidate texts in the candidate text set, which is not limited in the embodiment of the present application. In a possible implementation manner, the reference number may be the same as the number of candidate texts in the candidate text set, in this case, all target memory texts corresponding to any target entity relationship in the target memory file set are used as 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.
Step 2022: and calling a target entity relationship learning model to obtain the text characteristics of each target candidate text in a target candidate text set corresponding to any target entity relationship.
In one possible implementation manner, the target entity relationship learning model includes a target feature extraction model, the target entity relationship learning model is called, and the manner of obtaining the text features of each target candidate text in the target candidate text set corresponding to any target entity relationship is as follows: and calling a target feature extraction model to perform feature extraction on each target candidate text in the target candidate text set corresponding to any target entity relationship to obtain the text feature of each target candidate text.
Step 2023: and acquiring target prototype features corresponding to any target entity relationship based on the text features of the target candidate texts.
And after the text features of each target candidate text are obtained, acquiring target prototype features corresponding to any target entity relationship based on the text features of each target candidate text. In a possible implementation manner, based on the text features of each target candidate text, the process of obtaining the target prototype feature corresponding to any target entity relationship may be implemented based on formula 1:
Figure BDA0002537678310000111
wherein the content of the first and second substances,
Figure BDA0002537678310000112
representing target entity relationships riCorresponding target prototype features; f (x)j) Representing target candidate text xjThe text feature of (2); s represents the number of target candidate texts in the target candidate text set.
In a possible implementation manner, based on the text features of each target candidate text, the process of obtaining the target prototype feature corresponding to any target entity relationship may further be: and acquiring a target prototype feature corresponding to any target entity relationship based on the text feature of the target candidate text and the target relationship feature corresponding to any target entity relationship. The target relationship characteristics corresponding to any target entity relationship are obtained in the process of obtaining the target entity relationship learning model, and can represent the general characteristics of any target entity relationship. The target prototype features obtained in this way can better represent any target entity relationship. Illustratively, based on the text features of the target candidate text and the target relationship features corresponding to any target entity relationship, the process of obtaining the target prototype features corresponding to any target entity relationship may be implemented based on formula 2:
Figure BDA0002537678310000121
wherein the content of the first and second substances,
Figure BDA0002537678310000122
representing target entity relationships riCorresponding target prototype features; f (x)j) Representing target candidate text xjThe text feature of (2); s represents the number of target candidate texts in a target candidate text set; r isiRepresenting target entity relationships riCorresponding target relationship characteristics.
Step 2021 to step 2023 describe a process of obtaining a target prototype feature corresponding to any target entity relationship from the perspective of any target entity relationship. Target prototype features corresponding to the target entity relationships can be obtained according to the manner from step 2021 to step 2023.
In step 203, for any target entity relationship in the target entity relationship set, determining a matching degree between the target text and any target entity relationship based on the text features of the target text and the target prototype features corresponding to any target entity relationship; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship.
After the text features of the target text and the target prototype features respectively corresponding to each target entity relationship are obtained, the matching degree of the target text and each target entity relationship is determined based on the text features of the target text and the target prototype features respectively corresponding to each target entity relationship, and then the entity relationship corresponding to the target text is determined based on the matching degree of the target text and each target entity relationship.
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 one possible implementation manner, for any target entity relationship in the target entity relationship set, based on the text feature of the target text and the target prototype feature corresponding to any target entity relationship, the process of determining the matching degree between the target text and any target entity relationship is as follows: acquiring the similarity between the text features of the target text and the target prototype features corresponding to any target entity relationship; and determining the matching degree of the target text and any target entity relation based on the similarity between the text features of the target text and the target prototype features corresponding to any target entity relation.
In a possible implementation manner, based on the similarity between the text feature of the target text and the target prototype feature corresponding to any target entity relationship, the process of determining the matching degree between the target text and any target entity relationship may be implemented based on formula 3:
Figure BDA0002537678310000123
wherein, s (x, r)i) Representing the relation r between the target text x and the target entityiThe degree of matching; f (x) represents a text feature of the target text x;
Figure BDA0002537678310000124
representing target entity relationships riCorresponding target prototype features;
Figure BDA0002537678310000125
text feature representing target text x and target entity relationship riSimilarity between corresponding target prototype features.
And after the matching degree of the target text and each target entity relation is determined, determining the entity relation corresponding to the target text based on the matching degree of the target text and each target entity relation. In one possible implementation manner, based on the matching degree between the target text and each target entity relationship, the manner of determining the entity relationship corresponding to the target text is as follows: and taking the target entity relationship corresponding to the highest matching degree as the entity relationship corresponding to the target text. The process of taking the target entity relationship corresponding to the highest matching degree as the entity relationship corresponding to the target text can be realized based on formula 4:
Figure BDA0002537678310000131
wherein, s (x, r)i) Representing the relation r between the target text x and the target entityiThe degree of matching of (a) to (b),
Figure BDA0002537678310000132
representing a set of target entity relationships;
Figure BDA0002537678310000133
the target entity relationship corresponding to the highest degree of matching, that is,
Figure BDA0002537678310000134
and representing the entity relation corresponding to the target text.
In the embodiment of the application, the target entity relationship learning model is obtained based on a prototype feature set corresponding to the target entity relationship set, the prototype feature set is obtained based on the target memory text set, prototype features in the prototype feature set are more representative than memory texts and can represent entity relationships more comprehensively, the target entity relationship learning model obtained based on the prototype feature set has a better entity relationship learning effect, and the accuracy of extracting entity relationships by using the target entity relationship learning model is higher.
Based on the implementation environment shown in fig. 1, an embodiment of the present application provides a method for acquiring an entity relationship learning model, and the method is applied to the terminal 11 as an example. It should be noted that the method for acquiring the entity relationship learning model provided in the embodiment of the present application may be executed before executing step 201 in the embodiment shown in fig. 2, or may be executed during executing step 201 in the embodiment shown in fig. 2, which is not limited in the embodiment of the present application. As shown in fig. 3, the method for obtaining a target entity relationship learning model provided in the embodiment of the present application may include the following steps:
in step 301, a training text set corresponding to an entity relationship set to be learned is obtained, where the entity relationship set to be learned includes at least one entity relationship to be learned, and the training text set includes training texts corresponding to the entity relationships to be learned, respectively.
An entity relationship is used to indicate a relationship between two entities in the text, for example, for the text "newton acts as a princess of the royal society," newton "and" royal society, "the entity relationship between the two entities is" acts as a principal. By learning the entity relationship in the text with the known entity relationship, the appropriate entity relationship can be extracted from the text with the unknown entity relationship, and external resources are further provided for the implementation of various downstream applications (such as a search engine, a question-answering system and the like).
In the actual application process, new entity relationships continuously appear. At present, when how to discover and learn new entity relationships which continuously appear is explored, a solution composed of two stages of pipelines appears: (1) and extracting the open relations. Learning and extracting phrases and subject objects in sentences to construct a specific relation mode, finding new entity relations through clustering, and finally expanding a text set containing the new entity relations in a large-scale text corpus by using the new entity relations; (2) and (5) continuously learning the relationship. And continuously using the text set which is expanded by the new entity relation to obtain an efficient entity relation learning model. The entity relationship learning model is trained by a series of tasks to process the learning of existing and emerging entity relationships, wherein each task has a set of entity relationships to be learned.
Illustratively, the process of discovering, learning new entity relationships that continually appear is shown in FIG. 4. In fig. 4, in the open relationship extraction stage, new entity relationships are continuously discovered, for example, a new entity relationship "band member" is discovered from a sentence "Xiaoming born on 1/2000" and a sentence "Xiaohong born on 2/1/2005", a new entity relationship "birth date" is discovered from a sentence "Xiaohua is guitarian of a band" and a sentence "Xiaoheidan is a leading singer of B band". In the continuous relation learning stage, new entity relations are continuously learned, and the processes of discovering new entity relations and learning new entity relations are alternately carried out. For example, the entity relationship "date of birth" is first learned from a text set corresponding to the entity relationship "date of birth". After the entity relationship of birth date is learned, a memory text is selected from a text set corresponding to the entity relationship of birth date and is added to an existing memory text set. Next, learning the entity relation 'band member' by using a text set corresponding to the entity relation 'band member' and an existing memory text set; after learning the entity relationship 'band member', selecting a memory text from a text set corresponding to the entity relationship 'band member' and adding the memory text to an existing memory text set; and then, continuously learning the new entity relationship according to the text set corresponding to the new entity relationship and the existing memory text set.
It should be noted that, since new entity relationships are continuously appeared, the learning process of the entity relationships is a continuous learning process. The process of continuously learning entity relationships can be viewed as a process of learning in a series of tasks. After learning in each new task, it is desirable to obtain an entity relationship learning model having a good learning effect on an existing entity relationship, so that the obtained entity relationship learning model can be used to achieve an effect of accurately extracting an entity relationship of a certain text based on the learned entity relationship. The entity relationship learning model can continuously learn the relationship between the entity relationship and the text, and then can extract the text features close to the real entity relationship. And further realizing the task of extracting the entity relation based on the extracted text characteristics.
The entity relationship set to be learned in the embodiment of the application refers to a set of entity relationships needing to be learned in a new task. The entity relationship set to be learned includes at least one relationship to be learned. It should be noted that the set of relationships to be learned may include entity relationships that have already been learned in the old task, or may be all entity relationships that have not been learned in the old task, which is not limited in the embodiment of the present application. In addition, the number of the entity relationships to be learned in the entity relationship set to be learned may be set according to experience, or may be flexibly adjusted according to an application scenario, which is not limited in the embodiment of the present application. Illustratively, the set of relationships of the entity to be learned that needs to be learned in the new task can be represented as Rk
And after determining the relation set of the entity to be learned which needs to be learned in the new task, acquiring a training text set corresponding to the relation set of the entity to be learned. The training text set comprises training texts respectively corresponding to the relations of the entities to be learned. That is to say, the training text set is composed of training texts corresponding to the entity relations to be learned respectively. It should be noted that each entity relationship to be learned may be one or more training texts, and the number of the training texts corresponding to different entity relationships to be learned may be the same or different, which is not limited in this embodiment of the present application.
The process of obtaining the training text set corresponding to the relationship set of the entity to be learned is the process of obtaining the training text corresponding to each relationship of the entity to be learned. In a possible implementation manner, for any entity relationship to be learned, the process of obtaining the training text corresponding to the entity relationship to be learned includes: and extracting sentences containing any entity relation to be learned from the text corpus, and preprocessing the sentences containing any entity relation to be learned to obtain a training text corresponding to any entity relation to be learned.
In a possible implementation manner, the process of preprocessing the sentence including any one entity relationship to be learned to obtain the training text corresponding to any one entity relationship to be learned includes: the sentences are analyzed into a mark sequence by extracting semantic information, head and tail entity positions and other information of the sentences, and the mark sequence is used as a training text.
In a possible implementation manner, the training text set further includes, in addition to each training text, an entity relationship label of each training text, where the entity relationship label is used to indicate an entity relationship really corresponding to the training text. Illustratively, the training text set is represented as
Figure BDA0002537678310000151
Wherein the content of the first and second substances,
Figure BDA0002537678310000152
representing respective training texts;
Figure BDA0002537678310000153
represent each training sentenceThe corresponding entity relationship label; n (N is an integer greater than 1) represents the number of training texts in the training text set. Based on any training text
Figure BDA0002537678310000154
Corresponding relation label
Figure BDA0002537678310000155
In a clear view of the above, it is known that,
Figure BDA0002537678310000156
correspondence label
Figure BDA0002537678310000157
The indicated entity relationships. It should be noted that, in the following description,
Figure BDA0002537678310000158
the indicated entity relationship is the entity relationship set R to be learnedkTo be learned entity relationship.
After the training text set is obtained, training an existing entity relationship learning model based on the training text set so as to obtain a target entity relationship learning model which can well perform on a current new task and a previous old task. That is, in the kth task (k is an integer not less than 1), in the training set TkTraining to learn the relation set R of the entity to be learnedkBecause new entity relationships are continuously appearing, the target entity relationship learning model which is expected to be obtained can have good performance on the kth task and the first k-1 tasks. In the utilization of TkAfter obtaining the target entity relation learning model, the target entity relation learning model is
Figure BDA0002537678310000161
(QiRepresents a test set in the ith (i is an integer not less than 1) task,
Figure BDA0002537678310000162
a union representing test sets in respective tasks) on which a test is to be performed, it is desirable to be able toAll the test texts are collected in all the currently known entity relations
Figure BDA0002537678310000163
(RiRepresenting the set of entity relationships that need to be learned in the ith task,
Figure BDA0002537678310000164
representing a union of sets of entity relationships that need to be learned in each task). It should be noted that, accurately classifying on the currently known entity relationship set means accurately determining which entity relationship in the currently known entity relationship set corresponds to the test text.
In step 302, cooperating a set of the entity relationship set to be learned and the learned entity relationship set as a target entity relationship set; and updating the existing memory text set based on the training text set to obtain a target memory text set.
The set of the entity relations to be learned is a set of the entity relations needing to be learned in the current task, and the set of the learned entity relations is a set of the entity relations needing to be learned in an old task before the current task. The entity relationship to be learned in the old task is already learned in the old task, and the entity relationship to be learned in the old task is called a learned relationship. It should be noted that, for any entity relationship that has already been learned in the old task, the entity relationship can still be used as the entity relationship that needs to be learned in the new task. That is, the same entity relationship may exist in the set of relationships to be learned and the set of learned relationships. In the process of acquiring the set of the entity relationship set to be learned and the learned entity relationship set, only one entity relationship is reserved, that is, the number of each entity relationship in the target entity relationship set is only one.
And after the entity relationship set to be learned and the learned entity relationship set are combined into a target entity relationship set, the target entity relationship set comprises all entity relationships related in the current new task and the previous old task. Illustratively, the target entity relationship set may be represented as
Figure BDA0002537678310000165
(RiRepresenting the set of entity relationships that need to be learned in the ith task). It should be noted that, after the target entity relationship learning model is obtained, all target entity relationships in the target entity relationship set are entity relationships that have been learned by the target entity relationship learning model.
Besides 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 which are extracted from the training text set corresponding to each task including the current new task and used for representing each task. The target memory text set is used for memorizing all the appeared relations based on a small amount of texts. Before the training text set corresponding to the current new task is obtained, an existing memory text set is obtained based on the previous old task (if the old task does not exist, the existing memory text set is an empty set). Under the condition, 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 manner, 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:
step 1: and clustering the training texts in the training text set, and 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 obtained clustering result.
Clustering the training texts in the training text set can cluster the similar training texts into the same category. The embodiment of the present application does not limit the clustering method used for clustering. Illustratively, the training texts in the training text set are clustered by using a K-Means clustering method. In one possible implementation, the number of clusters is preset, and then the training texts in the training text set are clustered into the cluster clusters with the number of clusters. The number of clusters can be set according to the capacity of the texts needing to be memorized in the current new task. It should be noted that the volumes of the texts to be memorized in different tasks may be the same or different, and this is not limited in the embodiments of the present application.
For example, assuming that the capacity of the text to be memorized in the current new task is B (B is an integer not less than 1), B cluster clusters can be obtained after clustering the training texts in the target training text set.
After the training texts in the target training text set are clustered, a clustering result is obtained, 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 clustering result. The result of clustering may indicate the number of clusters and which training texts are contained in each cluster. In a possible implementation manner, the manner of determining the number of the 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, and counting the number of the candidate training texts corresponding to each entity relation to be learned in the entity relation set to be learned based on the entity relation to be learned corresponding to each candidate training text; and determining the number of the memory texts corresponding to the entity relations to be learned according to the number of the candidate training texts corresponding to the entity relations to be learned.
The number of the candidate training texts corresponding to each entity relationship to be learned can represent the importance degree 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 is, the more important the entity relationship to be learned is in the current new task. For important entity relationships to be learned, more text should be remembered. That is to say, the larger the number of candidate training texts corresponding to the entity relationship to be learned is, the larger the number of memory texts corresponding to the entity relationship to be learned should be. Exemplarily, assuming that the capacity of the text to be memorized in the current new task is B, the number of the cluster clusters is B, and since one candidate training text is extracted from each cluster, the number of the candidate texts is also B. Suppose the number of entity relationships to be learned in the set of entity relationships to be learned is | RKIf the number of the memory texts corresponding to the important entity relationship to be learned is not less than
Figure BDA0002537678310000171
The number of the memory texts corresponding to the unimportant entity relationship to be learned can be not more than
Figure BDA0002537678310000181
In a possible implementation manner, a corresponding relation between the number of candidate texts and the number of memory texts is preset, and then the number of memory texts corresponding to each entity relationship to be learned is determined based on the corresponding relation 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.
In a possible implementation manner, after the number of the memory texts corresponding to each entity relationship to be learned is determined, the number of the memory texts corresponding to each entity relationship to be learned is respectively checked. When the number of the memory texts corresponding to the entity relations to be learned is successfully verified, executing the step 2; and when the quantity of the memory texts corresponding to any entity relationship to be learned fails to be checked, adjusting the quantity of the memory texts corresponding to each entity relationship to be learned, and then executing the step 2.
In one possible implementation manner, the manner of checking the number of the memory texts corresponding to each entity relationship to be learned is as follows: for any entity relation to be learned, detecting whether the number of memory texts corresponding to the entity relation to be learned is not more than the number of training texts corresponding to the entity relation to be learned; when the number of the memory texts corresponding to the entity relationship to be learned is not more than the number of the training texts corresponding to the entity relationship to be learned, the number of the memory texts corresponding to the entity relationship to be learned is verified successfully; and when the number of the memory texts corresponding to the entity relationship to be learned is larger than the number of the training texts corresponding to the entity relationship to be learned, indicating that the number of the memory texts corresponding to the entity relationship to be learned fails to be checked.
In a possible implementation manner, when the number of memory texts corresponding to any entity relationship to be learned fails to be checked, the manner of adjusting the number of memory texts corresponding to each entity relationship to be learned is as follows: reducing the number of memory texts corresponding to the entity relationship to be learned which fails in verification to be equal to the number of training texts corresponding to the entity relationship to be learned which fails in verification; and adding the subtracted number to the number of the memory texts corresponding to the entity relationship to be learned which is successfully verified. After adjustment, the number of the memory texts corresponding to each entity relationship to be learned is not more than the number of the corresponding training texts.
Step 2: and for any entity relation to be learned, clustering training texts corresponding to any entity relation to be learned in the training text set according to the number of the memory texts corresponding to any entity relation to be learned, and determining the memory texts corresponding to any entity relation to be learned according to the obtained clustering result.
According to the step 1, the number of the memory texts corresponding to each entity relationship to be learned can be determined, and then the training texts with the number of the memory texts are selected from the training texts corresponding to each entity relationship to be learned as the memory texts according to the number of the memory texts corresponding to each entity relationship to be learned. For any entity relation to be learned, the process of determining the memory text corresponding to the entity relation to be learned is as follows: and clustering the training texts corresponding to any entity relation to be learned in the training text set according to the number of the memory texts corresponding to any entity relation to be learned, and determining the memory texts corresponding to any entity relation to be learned according to the obtained clustering result.
According to the number of the memory texts corresponding to any entity relation to be learned, clustering processing is carried out on the training texts corresponding to any entity relation to be learned in the training text set, so that the training texts corresponding to any entity relation to be learned in the training text set can be clustered into clusters of the number of the memory texts, and the obtained clustering result indicates which training texts are included in each cluster. In a possible implementation manner, the manner of determining the memory text corresponding to any entity relationship to be learned according to the obtained clustering result is as follows: and taking the training text closest to the clustering center in each clustering cluster as the memory text corresponding to the relation of any entity to be learned. The memory text corresponding to any entity relationship to be learned obtained in the way can well represent any entity relationship to be learned.
And (3) obtaining memory texts corresponding to the entity relations to be learned according to the mode of the step (2), and then executing the step (3). The memory texts corresponding to the entity relations to be learned are more useful and diversified texts in the training text set, the modes of the entity relations to be learned in the entity relation set to be learned can be covered as far as possible, and the memory samples can be effectively close to the feature distribution of the entity relations to be learned.
And step 3: and adding the memory text corresponding to each entity relation to be learned into the existing memory text set to obtain a target memory text set.
And after the memory text corresponding to each entity relation to be learned is obtained, adding the memory text corresponding to each entity relation to be learned into the existing memory text set to obtain a target memory text set. The existing memory text set is obtained based on the previous old task, and it should be noted that if there is no old task, the existing memory text set is an empty set. The obtained target memory text set comprises memory text subsets corresponding to the appeared tasks respectively. For example, the target memory text set may be represented as
Figure BDA0002537678310000191
Wherein M isiAnd representing the memory text subset corresponding to the ith task. In one possible implementation, in addition to storing memory texts, entity relationship tags of the respective memory texts may be stored in the memory text subset. For example, the subset of memory text for the kth task may be represented as
Figure BDA0002537678310000192
Wherein the content of the first and second substances,
Figure BDA0002537678310000193
the respective memory text is represented by a plurality of memory texts,
Figure BDA0002537678310000194
and B represents the capacity of the text required to be memorized by the kth task.
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.
The first entity relationship learning model refers to an obtained entity relationship learning model before training by using a training text set, the first entity relationship learning model learns entity relationships in old tasks but does not contact training texts in the training text set, and text features cannot be well extracted from the training texts in the training text set at the moment. Therefore, it is necessary to first utilize the training text set
Figure BDA0002537678310000201
Training the first entity relation learning model to enable the entity relation learning model to master the relation set R of the entity to be learnedkThe pattern of the entity relationship to be learned in (1).
In one possible implementation manner, the first entity relationship learning model includes a first feature extraction model and a first relationship feature management model, and the first relationship feature management model is used for managing an initial relationship feature set corresponding to the target entity relationship set. The process of training the first entity relationship learning model based on the training text set comprises the following steps 3031 to 3033:
step 3031: and calling a first feature extraction model to extract features of each training text in the training text set to obtain text features of each training text.
The first feature extraction model is a feature extraction model before training by using a training text set, cannot well extract text features from training texts of the training text set, and needs parameters to improve the extraction effect of the text features.
The structure of the first feature extraction model is not limited in the embodiments of the present application as long as text features can be extracted. Illustratively, the first feature extraction model is a bilst (Bi-directional Long Short-Term Memory) model, a convolutional neural network model, or a pre-training language model, etc.
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 may perform feature extraction on only one training text at a time, or may perform feature extraction on a plurality of training texts at the same time at a time, which is not limited in the embodiment of the present application. In either way, the text features of each training text can be obtained.
For any training text, calling a first feature extraction model to perform feature extraction on the training text, and obtaining the text features of the training text may be performed based on formula 5:
x ═ x (x) (equation 5)
Where x represents any training text and x represents a text feature of the training text x. In a possible implementation manner, the text features of the training text may be represented by vectors, and the dimensions of the vectors may be defined based on the structure and parameters of the first feature extraction model, which is not limited in this embodiment of the present application. For example, assuming that the dimension of the vector is d (an integer not less than 1), x belongs to the d-dimensional Euclidean space (i.e., x is an integer of 1 or more)
Figure BDA0002537678310000202
)。
Step 3032: and for any training text, acquiring a matching result corresponding to any training text based on the initial relation feature set managed by the first relation feature management model and the text feature of any training text.
The first relation characteristic management model is used for managing an initial relation characteristic set corresponding to the target entity relation set. The initial relationship feature set comprises initial relationship features corresponding to all target entity relationships in the target entity relationship set. It should be noted that, for the learned target entity relationship, the initial relationship characteristic corresponding to the target entity relationship can be learned in the previous old task, and can represent the target entity relationship more accurately; for the entity relationship that has not been learned, the initial relationship features respectively corresponding to the targets may refer to relationship features initialized at random, and further optimization is required.
And the matching result corresponding to any training text is used for indicating the similarity between the text feature of any training text and the initial relationship feature corresponding to each target entity relationship. In a possible implementation manner, 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 manner of obtaining the matching result corresponding to any training text is as follows: and respectively obtaining the similarity between the text feature of any training text and each initial relationship feature in the initial relationship feature set, and taking the similarity between the text feature of any training text and each initial relationship feature in the initial relationship feature set as a corresponding matching result of any training text.
It should be noted that the embodiment of the present application does not limit the way of calculating the similarity between two features. Illustratively, when both features are represented by vectors, the cosine similarity between the two vectors is calculated.
Based on the manner of step 3032, matching results corresponding to the training texts can be obtained.
Step 3033: determining a first loss function based on the matching result corresponding to each training text; parameters of the first feature extraction model and the first relational feature management model are updated based on the first loss function.
In one possible implementation manner, the matching result corresponding to any training text is a similarity between the text feature of the training text and each initial relationship feature in the initial relationship feature set. Determining a calculation formula of the first loss function as a formula 6 based on the matching result corresponding to each training text:
Figure BDA0002537678310000211
whereinL (θ) represents a first loss function;
Figure BDA0002537678310000212
representing training text
Figure BDA0002537678310000213
Text feature of
Figure BDA0002537678310000214
And target entity relationship rjCorresponding initial relationship characteristic rjThe similarity between them;
Figure BDA0002537678310000215
representing training text
Figure BDA0002537678310000216
Entity relationship tags of
Figure BDA0002537678310000217
The indicated target entity relationship is rj
Figure BDA0002537678310000218
Representing training text
Figure BDA0002537678310000219
Entity relationship tags of
Figure BDA00025376783100002110
Indicated target entity relationship is not rj(ii) a σ represents a sigmoid (sigmoid) function; n represents the number of training texts in the training text set;
Figure BDA00025376783100002111
representing the number of target entity relationships in the set of target entity relationships.
After the first loss function is obtained, parameters of the first feature extraction model and the first relational feature management model are updated based on the first loss function. It should be noted that, since the first relational feature management model is used to manage the initial relational feature set corresponding to the target entity relational set, the process of updating the parameters of the first relational feature management model is the process of updating the initial relational feature set.
And (4) updating the parameters of the first feature extraction model and the first relation feature management model once and updating the parameters of each pair of the first feature extraction model and the first relation feature management model once every time step 3031 to step 3033 are executed, and finishing one training of the first entity relation learning model. The process of training the first entity relationship learning model based on the training text set is an iterative process, and whether a training termination condition is met or not is judged once each training. And if the training termination condition is not met, continuing updating the parameters of the first feature extraction model and the first relation feature management model according to the steps 3031 to 3033 until the training termination condition is met. And taking the entity relationship learning model obtained when the training termination condition is met as a second entity relationship learning model. Thereby, a second entity relationship learning model is obtained. The second entity relation learning model obtained at the moment has the capability of extracting good text features from the training texts in the training text set.
In one possible implementation, satisfying the training termination condition includes, but is not limited to, the following three cases:
in case 1, the iterative training times reach a threshold number.
The number threshold may be set empirically, or may be flexibly adjusted according to an application scenario, which is not limited in the embodiment of the present application.
Case 2, the first loss function is less than the loss threshold.
The loss threshold may be set empirically, or may be flexibly adjusted according to an application scenario, which is not limited in the embodiment of the present application.
Case 3, the first loss function converges.
The convergence of the first loss function means that the fluctuation range of the first loss function is within the reference range in the training result of the reference number as the number of iterative training increases. For example, assume a reference range of-10-3~10-3Assume that the reference number is 10. If the first lossThe fluctuation ranges of the functions in 10 times of iterative training results are all-10-3~10-3And, the first loss function is considered to converge.
When any one of the above conditions 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 the second entity relationship learning model. And for the condition that the first entity relationship learning model comprises 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 met comprises a second feature extraction model and a second relationship feature management model. The second feature extraction model is a feature extraction model obtained after the first feature extraction model is trained by the training text set, and the second relation feature management model is a relation feature management model obtained after the first relation feature management model is trained by the training text set. It should be noted that, since the process of updating the parameters of the first relational feature management model refers to a process of updating the initial relational feature set, the second relational feature management model obtained through training manages the updated initial relational feature set, and the updated initial relational feature set is used as the target relational feature set in the embodiment of the present application. The target relationship feature set comprises target relationship features corresponding to all target entity relationships. The target relation characteristic corresponding to any target entity relation is used for representing the general characteristic of any target entity relation.
It should be noted that the second target entity relationship learning model obtained in this step 303 learns the entity relationship set to be learned in the new task, but in order to reduce forgetting of the entity relationship learned in the old task by the second entity relationship learning model and enhance the recognition capability of the entity relationship in the new task, the second entity relationship learning model needs to be further optimized based on step 304.
In step 304, based on the second entity relationship learning model and the target memory text set, obtaining an archetype feature set corresponding to the target entity relationship set; and optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set.
The prototype feature set corresponding to the target entity relationship set comprises prototype features corresponding to all target entity relationships in the target entity relationship set. Compared with a memory text, the prototype feature corresponding to any target entity relationship can more comprehensively represent the feature distribution of any target entity relationship. The target entity relationship can be better learned through learning the prototype feature.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; based on the second entity relationship learning model and the target memory text set, the process of obtaining the prototype feature set corresponding to the target entity relationship set comprises the following steps A to C:
step A: and for any target entity relation in the target entity relation set, constructing a prototype text set corresponding to the target entity relation based on the target memory text set.
The prototype feature set comprises prototype features corresponding to the target entity relations, and the step A and the step B introduce the process of obtaining the prototype features corresponding to the target entity relations from the perspective of any target entity relation.
The prototype text set corresponding to any target entity relationship is used for obtaining the prototype feature corresponding to any target entity relationship. In a possible implementation manner, based on the target memory text set, the process of constructing the prototype text set corresponding to any target entity relationship is as follows: taking a set of target memory texts corresponding to any target entity relationship in the target memory text set as a candidate text set; and randomly selecting a first specified number of candidate texts from the candidate text set to form a prototype text set corresponding to any target entity relationship. The first designated number is used to limit the number of prototype texts in the prototype text set, and the first designated number may be set empirically or may be adjusted according to the number of candidate texts in the candidate text set, which is not limited in the embodiment of the present application. For example, when the number of candidate texts in the candidate text set is 100, the first specified number may be set to 10.
Illustratively, for any target entity relationship
Figure BDA0002537678310000241
The prototype text set corresponding to any target entity relationship is expressed as
Figure BDA0002537678310000242
Any prototype text therein
Figure BDA0002537678310000243
Selecting from a target memory text set
Figure BDA0002537678310000244
Any prototype text
Figure BDA0002537678310000245
The corresponding entity relationship is the any target entity relationship riThat is, any of the prototype texts
Figure BDA0002537678310000246
Entity relationship tags of
Figure BDA0002537678310000247
The indicated entity relationship is the any target entity relationship ri。|PiAnd | represents the number of prototype texts included in the prototype text set corresponding to any target entity relationship, which is the same as the first specified number.
And B: calling a 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; and acquiring prototype features corresponding to any target entity relationship based on the text features of the prototype texts.
And after a prototype feature set corresponding to any target entity relationship is obtained, calling a second feature extraction model to perform feature extraction on each prototype text in the prototype text set to obtain the text features of each prototype text. The implementation process of this step can refer to step 3031, and is not described herein again.
After the text features of the prototype texts are obtained, the prototype features corresponding to any target entity relationship are obtained based on the text features of the prototype texts. In a possible implementation manner, based on the text features of each prototype text, the manner of obtaining the prototype feature corresponding to any target entity relationship is as follows: and calculating the average characteristic of the text characteristic of each prototype text, and taking the average characteristic as the prototype characteristic corresponding to any target entity relationship. This process can be implemented based on equation 7:
Figure BDA0002537678310000248
wherein p isiRepresenting target entity relationships
Figure BDA0002537678310000249
Corresponding prototype features; i PiI represents the target entity relationship riThe number of prototype texts included in the corresponding prototype text set;
Figure BDA00025376783100002410
representing target entity relationships riText features of the jth prototype text in the corresponding set of prototype texts.
And obtaining prototype features corresponding to each target entity relationship in the target entity relationship set according to the mode of the step A and the step B. It should be noted that, in the process of obtaining prototype features corresponding to different target entity relationships, the first designated numbers may be the same or different, and this is not limited in the embodiment of the present application.
And C: and 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.
After the prototype features corresponding to each target entity relationship in the target entity relationship set are obtained, the set of prototype features corresponding to each target entity relationship in the target entity relationship set is used as the prototype feature set corresponding to the target entity relationship set.
After the prototype feature set is obtained, 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 can enhance the recognition capability of the new entity relationship while keeping the recognition capability of the old entity relationship.
In one possible implementation, the second entity relationship learning model is optimized based on the target memory text set and the prototype feature set, which includes but is not limited to the following two types:
the implementation mode is as follows: and optimizing the second entity relationship learning model directly based on the target memory text set and the prototype feature set.
In the first implementation mode, the second entity relationship learning model is optimized directly on the basis of the target memory text set and the prototype feature set, and the optimization process is simple. In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the process of optimizing the second entity relationship learning model directly based on the target memory text set and the prototype feature set comprises the following steps a to e:
step a: and for any target entity relation in the target entity relation set, constructing a first instance text set corresponding to the target entity relation based on the target memory text set.
The first instance text set is used for obtaining a matching result corresponding to 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 any target entity relationship is as follows: taking a set of target memory texts corresponding to any target entity relationship in the target memory text set as a candidate text set; and randomly selecting a second specified number of candidate texts from the candidate text set to form a first example text set corresponding to any target entity relationship. The second specified number is for limiting a number of the first instance text in the first instance text set. For the same target entity relationship, the second specified number may be the same as the first specified number, or may be different from the first specified number, which is not limited in the embodiment of the present application. It should be noted that even though the second designated number may be the same as the first designated number, the first example text set and the second prototype text set may be different because the first example text set and the prototype text set are both formed by randomly selecting candidate texts from the candidate text set.
Illustratively, for any target entity relationship
Figure BDA0002537678310000251
The first instance text set corresponding to any target entity relationship can be expressed as
Figure BDA0002537678310000252
Any one of the example texts
Figure BDA0002537678310000253
Selecting from a target memory text set
Figure BDA0002537678310000254
Any prototype text
Figure BDA0002537678310000255
The corresponding entity relationship is the any target entity relationship riThat is, any of the prototype texts
Figure BDA0002537678310000256
Entity relationship tags of
Figure BDA0002537678310000257
The indicated entity relationship is the any target entity relationship ri。|IiAnd | represents the number of the first instance texts included in the first instance text set corresponding to any target entity relationship, which is the same as the second specified number.
Step b: and calling a second feature extraction model to perform feature extraction on each first instance text in the first instance text set to obtain text features of each first instance text.
And after a first instance text set corresponding to any target entity relationship is obtained, calling a second feature extraction model to perform feature extraction on each first instance text in the first instance text set to obtain text features of each first instance text. The implementation process of this step can refer to step 3031, and is not described herein again.
Step c: and for any first instance text, acquiring a matching result corresponding to any first instance text based on the prototype feature set and the text features of any first instance text.
After the text features of the first instance texts are obtained, first matching results corresponding to the first instance texts are further obtained. The matching result corresponding to any first example text is used for indicating the similarity between the text feature of the any first example text and each prototype feature in the prototype feature set.
In a possible implementation manner, for any first instance text, the process of obtaining 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 includes: and respectively obtaining the similarity between the text feature of any first instance text and each prototype feature in the prototype feature set, and taking the similarity between the text feature of any first instance text and each prototype feature in the prototype feature set as a corresponding matching result of any first instance text.
It should be noted that the embodiment of the present application does not limit the way of calculating the similarity between two features. Illustratively, when both features are represented by vectors, the cosine similarity between the two vectors is calculated.
According to the mode of the step c, the sub-matching result corresponding to each first instance text in the first instance text set can be obtained, and then the step d is executed.
Step d: and acquiring a first sub-loss function corresponding to any target entity relation based on the matching result corresponding to each first instance text.
In a possible implementation manner, for a case that the sub-matching result corresponding to any first instance text is a similarity between the text feature of the first instance text and each prototype feature in the prototype feature set, the process of obtaining the first sub-loss function corresponding to any target entity relationship based on the matching result corresponding to each first instance text may be implemented based on formula 8:
Figure BDA0002537678310000261
wherein the content of the first and second substances,
Figure BDA0002537678310000262
representing target entity relationships riA corresponding first sub-loss function;
Figure BDA0002537678310000263
representing a first instance text in a first instance text set
Figure BDA0002537678310000264
The text feature of (2); p is a radical ofiRepresenting target entity relationships riCorresponding prototype features;
Figure BDA0002537678310000265
representing a first instance text
Figure BDA0002537678310000266
Text feature and target entity relationship r ofiCorresponding prototype feature piThe similarity between them; p is a radical oflRepresenting target entity relationships rlCorresponding prototype features;
Figure BDA0002537678310000267
representing the number of target entity relationships in the set of target entity relationships.
And step a to step d introduce the process of obtaining the first sub-loss function corresponding to any target entity relationship from the perspective of any target entity relationship. And for each target entity relationship in the target entity relationship set, acquiring a first sub-loss function corresponding to each target entity relationship according to the modes from the step a to the step d.
Step e: determining a second loss function based on the first sub-loss functions corresponding to the target entity relations in the target entity relation set; parameters of the second feature extraction model are updated based on the second loss function.
After the first sub-loss functions corresponding to the target entity relations in the target entity relation set are obtained, the second loss functions are determined based on the first sub-loss functions corresponding to the target entity relations in the target entity relation set. In a possible implementation manner, based on the first sub-loss functions respectively corresponding to each target entity relationship in the target entity relationship set, the process of determining the second loss function may be based on a common loss function
Equation 9 achieves:
Figure BDA0002537678310000271
wherein L isR(θ) represents a second loss function;
Figure BDA0002537678310000272
representing target entity relationships riA corresponding first sub-loss function; the meaning of other parameters is the same as that of equation 8, and is not described herein.
After the second loss function is obtained, the parameters of the second feature extraction model are updated based on the second loss function.
The optimization process of the second entity relationship learning model is an iterative process, and the parameters of each pair of second feature extraction models are updated once to complete the optimization of the second entity relationship learning model once. Judging whether the optimization termination condition is met once every time the optimization of the second entity relationship learning model is completed, and if the optimization termination condition is not met, continuing to optimize the second entity relationship learning model; until the optimization termination condition is satisfied, step 305 is executed.
It should be noted that the prototype feature set used for optimizing the second entity relationship learning model is obtained based on the second entity relationship learning model, and in the process of continuously optimizing the second entity relationship learning model, since the second entity relationship learning model is already optimized in the previous iteration process, the prototype feature set corresponding to the target entity relationship set needs to be obtained again based on the optimized second entity relationship learning model, and then the second entity relationship learning model is continuously optimized based on the target memory text set and the newly obtained prototype feature set.
In this implementation, the condition that the optimization termination is satisfied may be any one of the number of times of optimization reaching the threshold of the number of times of optimization, the second loss function being smaller than the loss threshold, and the second loss function converging.
The implementation mode two is as follows: combining a target memory text set and a training text set into an activation text set; and optimizing the second entity relationship learning model based on the activation text set, the target memory text set and the prototype feature set.
In this way, the process of optimizing the second entity relationship learning model increases the impact of activating the text set. The activated text set is a set of a target memory text set and a training text set, that is, the activated text set includes all memory texts and all training texts in the current new task, and the activated text set is used for continuously activating the entity relationship learning model, so as to further improve the ability of the entity relationship learning model to learn new entity relationships and remember old entity relationships. Illustratively, the target is remembered in the text set
Figure BDA0002537678310000281
And a training text set T of the kth taskkIn combination, the resulting set of activation text can be represented as
Figure BDA0002537678310000282
Where M represents the number of active texts in the active text set.
Under the second implementation mode, the influence of the activated text set on the optimization process of the second entity relationship learning model is increased, and the optimization effect of the second entity relationship learning model is improved.
In one possible implementation manner, based on the activated text set, the target memory text set, and the prototype feature set, the process of optimizing the second entity relationship learning model may be completed based on two adjustment processes, and according to different data utilized by the two adjustment processes, based on the activated text set, the target memory text set, and the prototype feature set, the modes of optimizing the second entity relationship learning model include the following two modes:
the first method is as follows: and performing first adjustment on the second entity relationship learning model based on the activated text set, and performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
The implementation process of the first mode is divided into two steps:
the method comprises the following steps: a first adjustment is made to the second entity relationship learning model based on the set of active text.
The process of first adjusting the second entity relationship learning model based on the activation text set may be viewed as a process of memory replay and activation.
In one possible implementation manner, the second entity relationship learning model includes a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is used for managing a target relationship feature set corresponding to the target entity relationship set. The process of first adjusting the second entity relationship learning model based on the active text set includes the following three steps:
1. and calling a second feature extraction model to perform feature extraction on each activated text in the activated text set to obtain the text features of each activated text.
The implementation of this step can be referred to as step 3031, and is not described herein again.
2. And for any activated text, acquiring a matching result corresponding to any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of any activated text.
The second relational feature management model manages the target relational feature set based on training of the first relational feature management model. The target relationship feature set comprises target relationship features corresponding to all target entity relationships. The target relation characteristic corresponding to any target entity relation is used for representing the general characteristic of any target entity relation.
The matching result corresponding to any activated text is used for indicating the similarity between the text feature of any activated text and the target relationship feature corresponding to each target entity relationship. In a possible implementation manner, for any activated text, based on the target relationship feature set managed by the second relationship feature management model and the text feature of any activated text, the manner of obtaining the matching result corresponding to any activated text is as follows: and respectively acquiring the similarity between the text feature of any activated text and each target relation feature in the target relation feature set, and taking the similarity between the text feature of any activated text and each target relation feature in the target relation feature set as a corresponding matching result of any activated text.
It should be noted that the embodiment of the present application does not limit the way of calculating the similarity between two features. Illustratively, when both features are represented by vectors, the cosine similarity between the two vectors is calculated.
Based on the mode of step 2, the matching result corresponding to each activated text can be obtained.
3. Determining a third loss function based on the matching result respectively corresponding to each activated text; the parameters of the second feature extraction model are updated based on the third loss function.
In one possible implementation manner, the matching result corresponding to any activated text is a similarity between the text feature of the any activated text and each target relationship feature in the target relationship feature set. Determining a calculation formula of a third loss function as formula 10 based on the matching result corresponding to each activated text:
Figure BDA0002537678310000291
wherein L isA(θ), representing a third loss function;
Figure BDA0002537678310000292
presentation activation text
Figure BDA0002537678310000293
Text feature of
Figure BDA0002537678310000294
And target entity relationship rjCorresponding target relation characteristic rjThe similarity between them;
Figure BDA0002537678310000295
presentation activation text
Figure BDA0002537678310000296
Entity relationship tags of
Figure BDA0002537678310000297
The indicated target entity relationship is rj
Figure BDA0002537678310000298
Presentation activation text
Figure BDA0002537678310000299
Entity relationship tags of
Figure BDA00025376783100002910
Indicated target entity relationship is not rj(ii) a σ represents a sigmoid (sigmoid) function; m represents the number of active texts in the active text set;
Figure BDA00025376783100002911
representing the number of target entity relationships in the set of target entity relationships.
After the third loss function is obtained, the parameters of the second feature extraction model are updated based on the third loss function. It should be noted that, since the target relationship feature set corresponding to the target entity relationship set managed by the second relationship feature management model is the trained target relationship feature set, it is not necessary to update the parameters of the second relationship feature management model.
And (3) updating the parameters of the second feature extraction model once every time the steps 1 to 3 are executed, updating the parameters of each pair of second feature extraction models once, and judging whether the first adjustment termination condition is met. And if the first adjustment termination condition is not met, continuing to update the parameters of the second feature extraction model according to the steps 1 to 3 until the first adjustment termination condition is met. And taking the entity relationship learning model obtained when the first adjustment termination condition is met as a first adjusted second entity relationship learning model, and further executing the second step.
In one possible implementation manner, the satisfaction of the first adjustment termination condition means that the number of times of updating the parameter of the second feature extraction model reaches a first adjustment number threshold. The first adjustment time threshold may be set empirically, or may be flexibly adjusted according to an application scenario, which is not limited in the embodiment of the present application.
Step two: and performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
The process of performing the 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 process of memory consolidation. Only performing memory replay and activation may cause overfitting, so that the model can only finally memorize a plurality of texts stored in a memory text set, and meanwhile, the core of learning the entity relationship lies in mastering the prototype characteristics of the entity relationship rather than remembering a hard back memory sample.
And after the first adjusted second entity relationship learning model is obtained, performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set. In one possible implementation, the first adjusted second entity relationship learning model includes a first adjusted second feature extraction model; the second adjustment process of the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set comprises the following five steps:
1. and for any target entity relation in the target entity relation set, constructing a second instance text set corresponding to the target entity relation based on the target memory text set.
2. And calling the first adjusted second feature extraction model to extract features of each second instance text in the second instance text set to obtain text features of each second instance text.
3. And for any second example text, acquiring a matching result corresponding to any second example text based on the prototype feature set and the text features of any second example text.
4. And acquiring a second sub-loss function corresponding to any target entity relation based on the matching result corresponding to each second instance text.
5. Determining a fourth loss function based on the second sub-loss functions corresponding to the target entity relations in the target entity relation set; the parameters of the first adjusted second feature extraction model are updated based on a fourth loss function.
The implementation process of the above five steps can refer to steps a to e in implementation mode one, and details are not described here. It should be noted that, unlike the steps a to e in the first implementation, the steps a to e are processes of directly updating the parameters of the second feature extraction model, and the five steps here are processes of updating the parameters of the first adjusted second feature extraction model.
And (5) updating the parameters of the first adjusted second feature extraction model once every time the steps 1 to 5 are executed, updating the parameters of each pair of first adjusted second feature extraction models once, and judging whether a second adjustment termination condition is met. And if the second adjustment termination condition is not met, continuing to update the parameters of the first adjusted second feature extraction model according to the steps 1 to 5 until the second adjustment termination condition is met. And taking the entity relationship learning model obtained when the second adjustment termination condition is met as the second entity relationship learning model after the first optimization.
In one possible implementation manner, the meeting of the second adjustment termination condition means that the number of times of updating the parameter of the first adjusted second feature extraction model reaches a second adjustment number threshold. The second adjustment time threshold may be the same as the first adjustment time threshold, or may be different from the first adjustment time threshold, which is not limited in this embodiment of the application.
And optimizing the second entity relationship learning model once every time the first step and the second step are executed. Judging whether the optimization termination condition is met once every time the optimization of the second entity relationship learning model is completed, and if the optimization termination condition is not met, continuing to optimize the second entity relationship learning model; until the optimization termination condition is satisfied, step 305 is executed.
It should be noted that the prototype feature set used for optimizing the second entity relationship learning model is obtained based on the second entity relationship learning model, and in the process of continuously optimizing the second entity relationship learning model, since the second entity relationship learning model is already optimized in the previous iteration process, the prototype feature set corresponding to the target entity relationship set needs to be obtained again based on the optimized second entity relationship learning model, and then the second entity relationship learning model needs to be continuously optimized based on the activated text set, the target memory text set and the newly obtained prototype feature set.
In this manner, the satisfaction of the optimization termination condition may mean that the number of times of optimization reaches the number threshold, the third loss function and the fourth loss function are both smaller than the loss threshold, and the third loss function are both converged.
The second method comprises the following steps: and performing third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set, and performing fourth adjustment on the second entity relationship learning model after the third adjustment based on the activated text set.
In the second mode, the second entity relationship learning model is adjusted based on the target memory text set and the prototype feature set, and then the second entity relationship learning model adjusted based on the target memory text set and the prototype feature set is adjusted based on the activated text set.
The implementation process of the second mode is also divided into two steps:
step I: and performing third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set.
In a possible implementation manner, the second entity relationship learning model includes a second feature extraction model, and the implementation process of step i includes the following five steps:
1. and for any target entity relation in the target entity relation set, constructing a third instance text set corresponding to the target entity relation based on the target memory text set.
2. And calling a second feature extraction model to extract features of each third instance text in the third instance text set to obtain text features of each third instance text.
3. And for any third example text, acquiring a matching result corresponding to any third example text based on the prototype feature set and the text features of any third example text.
4. And acquiring a third sub-loss function corresponding to any target entity relation based on the matching result corresponding to each third instance text.
5. Determining a fifth loss function based on the third sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; the parameters of the second feature extraction model are updated based on the fifth loss function.
The implementation process of the above five steps can refer to steps a to e in implementation mode one, and details are not described here.
And (5) updating the parameters of the second feature extraction model once every time the steps 1 to 5 are executed, updating the parameters of each pair of second feature extraction models once, and judging whether a third adjustment termination condition is met. And if the third adjustment termination condition is not met, continuing to update the parameters of the second feature extraction model according to the steps 1 to 5 until the third adjustment termination condition is met. And taking the entity relationship learning model obtained when the third adjustment termination condition is met as a second entity relationship learning model after the third adjustment, and further executing the step II.
In one possible implementation manner, the satisfaction of the third adjustment termination condition means that the number of times of updating the parameter of the second feature extraction model reaches a third adjustment number threshold. The third adjustment time threshold may be the same as the first adjustment time threshold or the second adjustment time threshold, or may be different from both the first adjustment time threshold and the second adjustment time threshold, which is not limited in this embodiment of the application.
Step II: and performing fourth adjustment on the third adjusted second entity relationship learning model based on the activated text set.
In a possible implementation manner, 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 used for managing a target relationship feature set corresponding to the target entity relationship set. The process of performing a fourth adjustment on the third adjusted second entity relationship learning model based on the activated text set includes the following three steps:
1. and calling the third adjusted second feature extraction model to extract features of each activated text in the activated text set to obtain text features of each activated text.
2. And for any activated text, acquiring a matching result corresponding to any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of any activated text.
3. Determining a sixth loss function based on the matching result respectively corresponding to each activated text; the parameters of the third adjusted second feature extraction model are updated based on a sixth loss function.
The implementation process of the above three steps can refer to the three steps of performing the first adjustment on the second entity relationship learning model based on the activated text set, and details are not repeated here. It should be noted that, unlike the three steps of performing the first adjustment on the second entity relationship learning model based on the activation text set, the three steps of performing the first adjustment on the second entity relationship learning model based on the activation text set are processes of updating parameters of the second feature extraction model, and the three steps are processes of updating parameters of the second feature extraction model after the third adjustment.
And (3) updating the parameters of the third adjusted second feature extraction model once every time the steps 1 to 3 are executed, updating the parameters of each pair of third adjusted second feature extraction models once, and judging whether a fourth adjustment termination condition is met. And if the fourth adjustment termination condition is not met, continuing to update the parameters of the second feature extraction model after the third adjustment according to the steps 1 to 3 until the fourth adjustment termination condition is met. And taking the entity relationship learning model obtained when the fourth adjustment termination condition is met as the second entity relationship learning model after the first optimization.
In one possible implementation manner, the satisfaction of the fourth adjustment termination condition means that the number of times of updating the parameter of the third adjusted second feature extraction model reaches a fourth adjustment number threshold. The fourth adjustment time threshold may be the same as any one of the first adjustment time threshold, the second adjustment time threshold, and the third adjustment time threshold, or may be different from the first adjustment time threshold, the second adjustment time threshold, and the third adjustment time threshold, which is not limited in this embodiment of the application.
And optimizing the second entity relationship learning model once every time the step I and the step II are executed. Judging whether the optimization termination condition is met once every time the optimization of the second entity relationship learning model is completed, and if the optimization termination condition is not met, continuing to optimize the second entity relationship learning model; until the optimization termination condition is satisfied, step 305 is executed.
It should be noted that the prototype feature set used for optimizing the second entity relationship learning model is obtained based on the second entity relationship learning model, and in the process of continuously optimizing the second entity relationship learning model, since the second entity relationship learning model is already optimized in the previous iteration process, the prototype feature set corresponding to the target entity relationship set needs to be obtained again based on the optimized second entity relationship learning model, and then the second entity relationship learning model needs to be continuously optimized based on the activated text set, the target memory text set and the newly obtained prototype feature set.
In this second embodiment, the satisfaction of the optimization termination condition may be any one of the optimization number reaching number threshold, the fifth loss function and the sixth loss function being smaller than the loss threshold, and the fifth loss function and the sixth loss function converging.
In step 305, in response to the optimization termination condition being satisfied, the entity relationship learning model obtained when the optimization termination condition is satisfied is taken as the target entity relationship learning model.
And when the optimization termination condition is met, taking the entity relationship learning model obtained when the optimization termination condition is met as a target entity relationship learning model. Thus, the target entity relation learning model is acquired. The target entity relationship learning model acquired at this time learns new entity relationships on the basis of keeping the memory of old entity relationships. The target entity relation learning model has good knowledge holding capacity and continuous learning capacity and good practicability.
Illustratively, the process of obtaining the target entity relationship learning model is as shown in fig. 5, and it is assumed that the entity relationship to be learned in the current new task is entity relationship C, and the entity relationship that has been learned in the previous old task includes entity relationship a and entity relationship B. The process of obtaining the target entity relationship learning model involves the following 4 stages:
1. a training stage: and acquiring a training text set corresponding to the entity relationship C, acquiring a loss function by using the training text set, and training the first entity relationship learning model to obtain a second entity relationship learning model. 2. And (3) obtaining prototype features: selecting a memory text corresponding to the entity relation C from the training text set, and adding the memory text into the existing memory text set to obtain a target memory text set; based on the target memory text set, a prototype text set corresponding to each entity relationship (entity relationship A, entity relationship B and entity relationship C) is obtained through sampling, and then prototype features corresponding to each entity relationship are obtained according to the prototype text set of each entity relationship. 3. Replay and activation phases: and combining the target memory text set and the training text set to obtain an activated text set, acquiring a loss function based on the activated text set, and performing first adjustment on the second entity relationship learning model. 4. And a re-consolidation stage: based on the target memory text set, sampling and obtaining an example text set corresponding to each entity relationship (entity relationship A, entity relationship B and entity relationship C), further obtaining a loss function according to the example text set corresponding to each entity relationship, and performing second adjustment on the first adjusted second entity relationship learning model.
In the four phases, the three phases of acquisition of the prototype feature set, replay and activation, and reconsolidation are performed cyclically. And when the acquisition process meets the optimization termination condition, taking the entity relationship learning model obtained when the optimization termination condition is met as a target entity relationship learning model.
After the target entity relationship learning model is obtained, the target entity relationship learning model obtained in the embodiment of the present application and the entity relationship learning model obtained in the related technology are tested by using a test set, so as to verify the effectiveness of the target entity relationship learning model obtained in the embodiment of the present application.
Illustratively, in the embodiment of the present application, three test sets are selected, which are respectively: 1. a FewRel (The Few-shotRelation Classification Dataset, a rare case relation Classification Dataset) test set; 2. simpleQ (simple question) test set; 3. TACRED (Text Analysis Conference relationship extraction Dataset) test set. The target entity relationship learning model obtained in the embodiment of the application and the entity relationship learning model obtained in the related technology are tested on each test set, and the performance of the entity relationship learning model is evaluated by using two performance indexes in the test result, wherein the two performance indexes are respectively as follows: 1. bulk property (W): for representing the accuracy of the relationship extraction across all tasks of the entire test set; 2. average property (a): the method is used for representing the average accuracy of the relationship extraction of the whole test set by dividing all tasks into multiple sub-tasks. After testing for all tasks, the overall performance of the entity relationship learning model is evaluated with the final overall performance and the average performance. The test results are shown in table 1:
TABLE 1
Figure BDA0002537678310000351
In Table 1, EWC, GEM, AGEM, EMR, and EA-EMR are all entity relationship learning models obtained in the related art. As can be seen from table 1, the performance of the target entity relationship learning model obtained in the embodiment of the present application is significantly better than that of the entity relationship learning model obtained in the related art, and has the optimal performance in almost all test sets. On the SimpleQ test set, the performance of the target entity relationship learning model obtained by the embodiment of the application is close to that of EA-EMR and EMR obtained in the related art, probably because the SimpleQ test set is too simple. On the test sets of FweRel and TACRED, the performance of the target entity relationship learning model obtained in the embodiment of the application is superior to the entity relationship learning models obtained in all related technologies, and the superiority of the memory activation and re-consolidation mechanism provided by the embodiment of the application is shown.
In addition, in order to further study the change of the model performance in the process of learning a new task, as shown in fig. 6, the change curves of the average accuracy of entity relationship extraction with the number of tasks in the process of continuously learning entity relationships 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 according to 3 different test sets (FweRel, SimpleQ, and TACRED). As can be seen from fig. 6: with the increase of the number of tasks, the performance of all models is reduced to a certain degree, which indicates that forgetting old entity relations is inevitable and is one of the main difficulties of continuous relation 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 application obtains a better result, which explains the effectiveness of memory re-consolidation, and further explains that the understanding of the relationship prototype is more important and more reasonable than the learning of the memorandum-based text.
Illustratively, memory capacity refers to the number of memory texts saved in a memory text set per task. The influence of the memory capacity on the target entity relationship learning model obtained in the embodiment of the application and the entity relationship learning model obtained in the related technology is further researched. The overall performance (W) and the 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 on the basis of three memory capacities (10, 25, and 50) are tested by using three test sets (FweRel, SimpleQ, and TACRED), respectively, and the test results are shown in table 2:
TABLE 2
Figure BDA0002537678310000361
From table 2, it can be seen that: (1) the performance of each model is improved to different degrees along with the increase of the memory capacity, which shows that the memory capacity is one of the key factors for 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 application keeps the best performance under different memory capacities, and even achieves the performance equivalent to other models under larger memory capacities. That is to say, compared with a method for obtaining an entity relationship learning model based on a memory text, the method for obtaining the entity relationship learning model by using prototype features in the embodiment of the application is a more effective method for using memory.
In the embodiment of the application, the target entity relationship learning model is obtained based on the memory replay, activation and re-consolidation modes, the scene memory activation and re-consolidation mechanism in the human long-term memory forming mechanism is introduced, so that the target entity relationship learning model can still better keep the memory of the old entity relationship when learning new entity relationship knowledge, and the obtained target entity relationship learning model has better knowledge holding capacity and continuous learning capacity and has good practicability. Compared with the related art, the embodiment of the application requires the model to understand the prototype characteristics of the old entity relationship instead of fitting some specific memory texts too much, so that the entity relationship can be better distinguished in the long-term learning process.
In the embodiment of the application, in the process of obtaining the target entity relationship learning model, training is performed based on a training text set, and then optimization is performed based on a target memory text set and a 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 is more representative than the memory text and can represent the real feature distribution of the entity relationship more comprehensively. The target entity relationship learning model obtained in the mode has a good entity relationship learning effect, and the accuracy of extracting the entity relationship by using the target entity relationship learning model obtained in the mode is high.
Referring to fig. 7, an embodiment of the present application provides an entity relationship extraction apparatus, including:
a first obtaining unit 701, configured to obtain a target text of an entity relationship to be extracted and a target entity relationship learning model, where 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 corresponding to the target entity relationship set is obtained based on a target memory text set, and the target entity relationship set includes each target entity relationship learned by the target entity relationship learning model;
a second obtaining unit 702, configured to invoke a target entity relationship learning model to obtain text features of a target text and target prototype features corresponding to each target entity relationship in a target entity relationship set;
a determining unit 703, configured to determine, for any target entity relationship in the target entity relationship set, a matching degree between the target text and any target entity relationship based on a text feature of the target text and a target prototype feature corresponding to any target entity relationship; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship.
In a possible implementation manner, the second obtaining unit 702 is further configured to, for any target entity relationship in the target entity relationship set, obtain, based on the target memory text set, a target candidate text set corresponding to the target entity relationship; calling a target entity relationship learning model to obtain the text characteristics of each target candidate text in a target candidate text set corresponding to any target entity relationship; and acquiring target prototype features corresponding to any target entity relationship based on the text features of the target candidate texts.
In the embodiment of the application, the target entity relationship learning model is obtained based on a prototype feature set corresponding to the target entity relationship set, the prototype feature set is obtained based on the target memory text set, prototype features in the prototype feature set are more representative than memory texts and can represent entity relationships more comprehensively, the target entity relationship learning model obtained based on the prototype feature set has a better entity relationship learning effect, and the accuracy of extracting entity relationships by using the target entity relationship learning model is higher.
Referring to fig. 8, an embodiment of the present application provides an apparatus for acquiring an entity relationship learning model, where the apparatus includes:
a first obtaining unit 801, configured to obtain a training text set corresponding to an entity relationship set to be learned, where the entity relationship set to be learned includes at least one entity relationship to be learned, and the training text set includes training texts respectively corresponding to the entity relationships to be learned;
a second obtaining unit 802, configured to cooperate a set of the entity relationship set to be learned and a set of learned entity relationship sets as a target entity relationship set; updating the existing memory text set based on the training text set to obtain a target memory text set;
a training unit 803, configured to train the first entity relationship learning model based on a training text set to obtain a second entity relationship learning model;
a third obtaining unit 804, configured to obtain an prototype feature set corresponding to the target entity relationship set based on the second entity relationship learning model and the target memory text set;
the optimizing unit 805 is configured to optimize the second entity relationship learning model based on the target memory text set and the prototype feature set;
and the determining unit 806 is configured to, in response to the optimization termination condition being satisfied, take the entity relationship learning model obtained when the optimization termination condition is satisfied as the target entity relationship learning model.
In one possible implementation manner, the first entity relationship learning model includes a first feature extraction model and a first relationship feature management model, and the first relationship feature management model is used for managing an initial relationship feature set corresponding to a target entity relationship set; a training unit 803, configured to invoke a first feature extraction model to perform feature extraction on each training text in the training text set, so as to obtain a text feature of each training text; for any training text, acquiring a matching result corresponding to any training text based on the initial relation feature set managed by the first relation feature management model and the text feature of any training text; determining a first loss function based on the matching result corresponding to each training text; parameters of the first feature extraction model and the first relational feature management model are updated based on the first loss function.
In a possible implementation manner, the second obtaining unit 802 is further configured to perform clustering processing on the training texts in the training text set, and determine, according to an obtained clustering result, the number of memory texts corresponding to each entity relationship to be learned in the entity relationship set to be learned; for any entity relation to be learned, clustering training texts corresponding to any entity relation to be learned in the training text set according to the number of the memory texts corresponding to the entity relation to be learned, and determining the memory texts corresponding to the entity relation to be learned according to the obtained clustering result; and adding the memory text corresponding to each entity relation to be learned into the existing memory text set to obtain a target memory text set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; a third obtaining unit 804, configured to construct, for any target entity relationship in the target entity relationship set, a prototype text set corresponding to any target entity relationship based on the target memory text set; calling a 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; acquiring prototype features corresponding to any target entity relation based on the text features of the prototype texts; and taking the set of prototype features respectively corresponding to each target entity relationship in the target entity relationship set as the prototype feature set corresponding to the target entity relationship set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the optimizing unit 805 is configured to construct, for any target entity relationship in the target entity relationship set, a first instance text set corresponding to the target entity relationship based on the target memory text set; calling a second feature extraction model to extract features of each first instance text in the first instance text set to obtain text features of each first instance text; for any first instance text, acquiring a matching result corresponding to any first instance text based on the prototype feature set and the text features of any first instance text; acquiring a first sub-loss function corresponding to any target entity relation based on the matching result corresponding to each first instance text; determining a second loss function based on the first sub-loss functions corresponding to the target entity relations in the target entity relation set; parameters of the second feature extraction model are updated based on the second loss function.
In one possible implementation, the optimizing unit 805 is further configured to cooperate a set of the target memory text set and the training text set as an activation text set; and optimizing the second entity relationship learning model based on the activation text set, the target memory text set and the prototype feature set.
In a possible implementation manner, the optimization unit 805 is further configured to perform a first adjustment on the second entity relationship learning model based on the activation 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.
In one possible implementation manner, the second entity relationship learning model includes a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is used for managing a target relationship feature set corresponding to the target entity relationship set; the optimizing unit 805 is further configured to invoke a second feature extraction model to perform feature extraction on each activated text in the activated text set, so as to obtain text features of each activated text; for any activated text, acquiring a matching result corresponding to any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of any activated text; determining a third loss function based on the matching result respectively corresponding to each activated text; the parameters of the second feature extraction model are updated based on the third loss function.
In one possible implementation, the first adjusted second entity relationship learning model includes a first adjusted second feature extraction model; the optimizing unit 805 is further configured to construct, for any target entity relationship in the target entity relationship set, a second instance text set corresponding to the target entity relationship based on the target memory text set; calling the first adjusted second feature extraction model to extract features of each second instance text in the second instance text set to obtain text features of each second instance text; for any second instance text, acquiring a matching result corresponding to any second instance text based on the prototype feature set and the text features of any second instance text; acquiring a second sub-loss function corresponding to any target entity relation based on the matching result corresponding to each second instance text; determining a fourth loss function based on the second sub-loss functions corresponding to the target entity relations in the target entity relation set; the parameters of the first adjusted second feature extraction model are updated based on a fourth loss function.
In a possible implementation manner, the optimization unit 805 is further configured to perform a third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set, and perform a fourth adjustment on the third adjusted second entity relationship learning model based on the activation text set.
In one possible implementation, the second entity relationship learning model includes a second feature extraction model; the optimizing unit 805 is further configured to construct, for any target entity relationship in the target entity relationship set, a third instance text set corresponding to the target entity relationship based on the target memory text set; calling a second feature extraction model to extract features of each third instance text in the third instance text set to obtain text features of each third instance text; for any third example text, acquiring a matching result corresponding to any third example text based on the prototype feature set and the text features of any third example text; acquiring a third sub-loss function corresponding to any target entity relation based on the matching result corresponding to each third instance text; determining a fifth loss function based on the third sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; the parameters of the second feature extraction model are updated based on the fifth loss function.
In a possible implementation manner, 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 used for managing a target relationship feature set corresponding to the target entity relationship set; the optimizing unit 805 is further configured to invoke the third adjusted second feature extraction model to perform feature extraction on each activated text in the activated text set, so as to obtain text features of each activated text; for any activated text, acquiring a matching result corresponding to any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of any activated text; determining a sixth loss function based on the matching result respectively corresponding to each activated text; the parameters of the third adjusted second feature extraction model are updated based on a sixth loss function.
In the embodiment of the application, in the process of obtaining the target entity relationship learning model, training is performed based on a training text set, and then optimization is performed based on a target memory text set and a 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 is more representative than the memory text and can represent the real feature distribution of the entity relationship more comprehensively. The target entity relationship learning model obtained in the mode has a good entity relationship learning effect, and the accuracy of extracting the entity relationship by using the target entity relationship learning model obtained in the mode is high.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Fig. 9 is a schematic structural diagram of a server according to an embodiment of the present application, where the server may generate relatively large differences due to different configurations or performances, and may include one or more processors (CPUs) 901 and one or more memories 902, where the one or more memories 902 store at least one program code, and the at least one program code is loaded and executed by the one or more processors 901 to implement the entity relationship extraction method or the entity relationship learning model obtaining method provided in the foregoing method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input/output, and the server may also include other components for implementing the functions of the device, which are not described herein again.
Fig. 10 is a schematic structural diagram of a terminal according to an embodiment of the present application. The terminal may be: a smartphone, a tablet, a laptop, or a desktop computer. A terminal may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, etc.
Generally, a terminal includes: a processor 1001 and a memory 1002.
Processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so forth. The processor 1001 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also referred to as a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content that the display screen needs to display. In some embodiments, the processor 1001 may further include an AI (Artificial Intelligence) processor for processing a computing operation related to machine learning.
Memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in the memory 1002 is configured to store at least one instruction for execution by the processor 1001 to implement the entity relationship extraction method or the entity relationship learning model acquisition method provided by the method embodiments in the present application.
In some embodiments, the terminal may further include: a peripheral interface 1003 and at least one peripheral. The processor 1001, memory 1002 and peripheral interface 1003 may be connected by a bus or signal line. Various peripheral devices may be connected to peripheral interface 1003 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of radio frequency circuitry 1004, touch screen display 1005, camera assembly 1006, audio circuitry 1007, positioning assembly 1008, and power supply 1009.
The peripheral interface 1003 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 1001 and the memory 1002. In some embodiments, processor 1001, memory 1002, and peripheral 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 interface 1003 may be implemented on separate chips or circuit boards, which are not limited by this embodiment.
The Radio Frequency circuit 1004 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 1004 communicates with communication networks and other communication devices via electromagnetic signals. The radio frequency circuit 1004 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1004 comprises: 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 so forth. The radio frequency circuit 1004 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: metropolitan area networks, various generation mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the rf circuit 1004 may further include NFC (Near Field Communication) related circuits, which are not limited in this application.
The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to capture touch signals on or over the surface of the display screen 1005. The touch signal may be input to the processor 1001 as a control signal for processing. At this point, the display screen 1005 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display screen 1005 may be one, disposed on a front panel of the terminal; in other embodiments, the display screens 1005 may be at least two, respectively disposed on different surfaces of the terminal or in a folded design; in still other embodiments, the display 1005 may be a flexible display, disposed on a curved surface or a folded surface of the terminal. Even more, the display screen 1005 may be arranged in a non-rectangular irregular figure, i.e., a shaped screen. The Display screen 1005 may be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), and the like.
The camera assembly 1006 is used to capture images or video. Optionally, the camera assembly 1006 includes a front camera and a rear camera. Generally, a front camera is disposed at a front panel of the terminal, and a rear camera is disposed at a rear surface of the terminal. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, camera assembly 1006 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
The audio circuit 1007 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 1001 for processing or inputting the electric signals to the radio frequency circuit 1004 for realizing voice communication. For the purpose of stereo sound collection or noise reduction, a plurality of microphones can be arranged at different parts of the terminal respectively. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 1001 or the radio frequency circuit 1004 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, the audio circuit 1007 may also include a headphone jack.
The positioning component 1008 is used to locate the current geographic Location of the terminal to implement navigation or LBS (Location based service). The positioning component 1008 may be a positioning component based on a Global Positioning System (GPS) in the united states, a beidou system in china, a graves system in russia, or a galileo system in the european union.
The power supply 1009 is used to supply power to each component in the terminal. The power source 1009 may be alternating current, direct current, disposable batteries, or rechargeable batteries. When the power source 1009 includes a rechargeable battery, the rechargeable battery may support wired charging or wireless charging. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, the terminal also includes one or more sensors 1010. The one or more sensors 1010 include, but are not limited to: acceleration sensor 1011, gyro sensor 1012, pressure sensor 1013, fingerprint sensor 1014, optical sensor 1015, and proximity sensor 1016.
The acceleration sensor 1011 can detect the magnitude of acceleration on three coordinate axes of a coordinate system established with the terminal. For example, the acceleration sensor 1011 may be used to detect components of the gravitational acceleration in three coordinate axes. The processor 1001 may control the touch display screen 1005 to display a 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 may also be used for acquisition of motion data of a game or a user.
The gyro sensor 1012 may detect a body direction and a rotation angle of the terminal, and the gyro sensor 1012 and the acceleration sensor 1011 may cooperate to collect a 3D motion of the user with respect to the terminal. From the data collected by the gyro sensor 1012, the processor 1001 may implement the following functions: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
The pressure sensor 1013 may be disposed at a side frame of the terminal and/or at a lower layer of the touch display screen 1005. When the pressure sensor 1013 is disposed on a side frame of the terminal, a user's holding signal of the terminal can be detected, and the processor 1001 performs left-right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 1013. When the pressure sensor 1013 is disposed at a lower layer of the touch display screen 1005, the processor 1001 controls the operability control on the UI interface according to the pressure operation of the user on the touch display screen 1005. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.
The fingerprint sensor 1014 is used to collect a fingerprint of the user, and the processor 1001 identifies the user according to the fingerprint collected by the fingerprint sensor 1014, or the fingerprint sensor 1014 identifies the user according to the collected fingerprint. Upon identifying that the user's identity is a trusted identity, the processor 1001 authorizes the user to perform relevant sensitive operations including unlocking a screen, viewing encrypted information, downloading software, paying, and changing settings, etc. The fingerprint sensor 1014 may be disposed on the front, back, or side of the terminal. When a physical key or vendor Logo is provided on the terminal, the fingerprint sensor 1014 may be integrated with the physical key or vendor Logo.
The optical sensor 1015 is used to collect the ambient light intensity. In one embodiment, the processor 1001 may control the display brightness of the touch display screen 1005 according to the intensity of the ambient light 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 turned down. In another embodiment, the processor 1001 may also dynamically adjust the shooting parameters of the camera assembly 1006 according to the intensity of the ambient light collected by the optical sensor 1015.
A proximity sensor 1016, also known as a distance sensor, is typically provided 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 surface of the terminal gradually decreases, the processor 1001 controls the touch display screen 1005 to switch from a bright screen state to a dark screen state; when the proximity sensor 1016 detects that the distance between the user and the front surface of the terminal gradually becomes larger, the touch display screen 1005 is controlled by the processor 1001 to switch from the breath screen state to the bright screen state.
Those skilled in the art will appreciate that the configuration shown in fig. 10 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
In an exemplary embodiment, a computer device is also provided that includes a processor and a memory having at least one program code stored therein. The at least one program code is loaded and executed by one or more processors to implement any one of the above entity relationship extraction methods or any one of the acquisition methods of the entity relationship learning model.
In an exemplary embodiment, a computer-readable storage medium is further provided, in which at least one program code is stored, and the at least one program code is loaded and executed by a processor of a computer device to implement any one of the entity relationship extraction methods or any one of the entity relationship learning model acquisition methods described above.
In one possible implementation, the computer-readable storage medium may 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, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is further provided, in which at least one piece of computer program is stored, and the at least one piece of computer program is loaded and executed by a processor of a computer device to implement any one of the entity relationship extraction methods or any one of the entity relationship learning model obtaining methods described above.
It should be understood that reference to "a plurality" herein means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
It is noted that the terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences 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 apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The above description is only exemplary of the present application and should not be taken as limiting the present application, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. An entity relationship extraction method, the method comprising:
acquiring a target text of an entity relationship to be extracted and a target entity relationship learning model, wherein 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 corresponding to the target entity relationship set is obtained based on a target memory text set, and the target entity relationship set comprises all target entity relationships learned by the target entity relationship learning model;
calling the target entity relationship learning model to obtain text features of the target text and 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, determining the matching degree of the target text and the any target entity relationship based on the text features of the target text and the target prototype features corresponding to the any target entity relationship; and determining the entity relationship corresponding to the target text based on the matching degree of the target text and each target entity relationship.
2. The method according to claim 1, wherein before determining the matching degree between the target text and any 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 comprises:
for any target entity relation in the target entity relation set, acquiring a target candidate text set corresponding to the any target entity relation based on the target memory text set;
calling the target entity relationship learning model to obtain the text features of each target candidate text in the target candidate text set corresponding to any target entity relationship;
and acquiring a target prototype feature corresponding to any target entity relation based on the text feature of each target candidate text.
3. A method for acquiring an entity relationship learning model is characterized by comprising the following steps:
acquiring a training text set corresponding to an entity relationship set to be learned, wherein the entity relationship set to be learned comprises at least one entity relationship to be learned, and the training text set comprises training texts respectively corresponding to the entity relationships to be learned;
combining the set of the entity relationship set to be learned and the learned entity relationship set into a target entity relationship set; updating the existing memory text set based on the training text set to obtain a target memory text set;
training the first entity relation learning model based on the training text set to obtain a second entity relation learning model;
based on the second entity relationship learning model and the target memory text set, acquiring a prototype feature set corresponding to the target entity relationship set; optimizing the second entity relationship learning model based on the target memory text set and the prototype feature set;
and in response to the optimization termination condition being met, taking the entity relationship learning model obtained when the optimization termination condition is met as a target entity relationship learning model.
4. The method according to claim 3, wherein the first entity relationship learning model includes a first feature extraction model and a first relationship feature management model, and the first relationship feature management model is used for managing an initial relationship feature set corresponding to the target entity relationship set; training a first entity relationship learning model based on the training text set comprises:
calling the first feature extraction model to extract features of each training text in the training text set to obtain text features of each training text;
for any training text, acquiring a matching result corresponding to the any training text based on the initial relation feature set managed by the first relation feature management model and the text feature of the any training text;
determining a first loss function based on the matching result corresponding to each training text; updating parameters of the first feature extraction model and the first relational feature management model based on the first loss function.
5. The method of claim 3, wherein the updating the existing memory text set based on the training text set to obtain a target memory text set comprises:
clustering the training texts in the training text set, and 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 obtained clustering result;
for any entity relation to be learned, clustering training texts corresponding to the entity relation to be learned in the training text set according to the number of memory texts corresponding to the entity relation to be learned, and determining the memory texts corresponding to the entity relation to be learned according to the obtained clustering result;
and adding the memory text corresponding to each entity relation to be learned into the existing memory text set to obtain a target memory text set.
6. The method of claim 3, wherein the second entity relationship learning model comprises a second feature extraction model; the obtaining of 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 relation in the target entity relation set, constructing a prototype text set corresponding to the target entity relation based on the target memory text set;
calling 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; based on the text features of the prototype texts, acquiring prototype features corresponding to any target entity relationship;
and taking the set of prototype features respectively corresponding to each target entity relationship in the target entity relationship set as the prototype feature set corresponding to the target entity relationship set.
7. The method of any of claims 3-6, wherein the second entity relationship learning model comprises a second feature extraction model; the optimizing 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, constructing a first instance text set corresponding to the target entity relation based on the target memory text set;
calling 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 each first instance text;
for any first instance text, acquiring 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;
acquiring a first sub-loss function corresponding to any target entity relation based on the matching result corresponding to each first instance text;
determining a second loss function based on the first sub-loss functions corresponding to the target entity relations in the target entity relation set; updating parameters of the second feature extraction model based on the second loss function.
8. The method according to any one of claims 3-6, wherein said optimizing said second entity relationship learning model based on said set of target memory texts and said set of prototype features comprises:
combining the target memory text set and the training text set into an activation text set;
and optimizing the second entity relationship learning model based on the activation text set, the target memory text set and the prototype feature set.
9. The method of claim 8, wherein optimizing the second entity relationship learning model based on the set of activation text, the set of target memory text, and the set of archetype features comprises:
and performing first adjustment on the second entity relationship learning model based on the activated text set, and performing second adjustment on the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set.
10. The method according to claim 9, wherein the second entity relationship learning model includes a second feature extraction model and a second relationship feature management model, and the second relationship feature management model is used for managing a target relationship feature set corresponding to the target entity relationship set; the first adjusting the second entity relationship learning model based on the active text set comprises:
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;
for any activated text, acquiring a matching result corresponding to the any activated text based on the target relation feature set managed by the second relation feature management model and the text feature of the any activated text;
determining a third loss function based on the matching result respectively corresponding to each activated text; updating parameters of the second feature extraction model based on the third loss function.
11. The method according to claim 9 or 10, wherein the first adjusted second entity relationship learning model comprises a first adjusted second feature extraction model; the second adjusting of the first adjusted second entity relationship learning model based on the target memory text set and the prototype feature set comprises:
for any target entity relation in the target entity relation set, constructing a second instance text set corresponding to the target entity relation based on the target memory text set;
calling the first adjusted second feature extraction model to perform feature extraction on each second instance text in the second instance text set to obtain text features of each second instance text;
for any second instance text, acquiring a matching result corresponding to the any second instance text based on the prototype feature set and the text features of the any second instance text;
acquiring a second sub-loss function corresponding to any target entity relation based on the matching result corresponding to each second instance text;
determining a fourth loss function based on the second sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; updating parameters of the first adjusted second feature extraction model based on the fourth loss function.
12. The method of claim 8, wherein optimizing the second entity relationship learning model based on the set of activation text, the set of target memory text, and the set of archetype features comprises:
and performing third adjustment on the second entity relationship learning model based on the target memory text set and the prototype feature set, and performing fourth adjustment on the second entity relationship learning model after the third adjustment based on the activated text set.
13. The method of claim 12, wherein the second entity relationship learning model comprises a second feature extraction model; the third adjusting the second entity relationship learning model based on the target memory text set and the prototype feature set comprises:
for any target entity relation in the target entity relation set, constructing a third instance text set corresponding to the target entity relation based on the target memory text set;
calling the second feature extraction model to perform feature extraction on each third instance text in the third instance text set to obtain text features of each third instance text;
for any third instance text, acquiring a matching result corresponding to the any third instance text based on the prototype feature set and the text features of the any third instance text;
acquiring a third sub-loss function corresponding to any target entity relation based on the matching result corresponding to each third instance text;
determining a fifth loss function based on the third sub-loss functions respectively corresponding to the target entity relations in the target entity relation set; updating parameters of the second feature extraction model based on the fifth loss function.
14. A computer device comprising a processor and a memory, wherein at least one program code is stored in the memory, and the at least one program code is loaded and executed by the processor to implement the entity relationship extraction method according to any one of claims 1 to 2, or to implement the entity relationship learning model acquisition method according to any one of claims 3 to 13.
15. A computer-readable storage medium, wherein at least one program code is stored in the computer-readable storage medium, and the at least one program code is loaded and executed by a processor to implement the entity relationship extraction method according to any one of claims 1 to 2, or to implement the entity relationship learning model acquisition method according to any one of claims 3 to 13.
CN202010537884.XA 2020-06-12 2020-06-12 Entity relationship extraction method, and method and device for acquiring entity relationship learning model Pending CN111737415A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010537884.XA CN111737415A (en) 2020-06-12 2020-06-12 Entity relationship extraction method, and method and device for acquiring entity relationship learning model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010537884.XA CN111737415A (en) 2020-06-12 2020-06-12 Entity relationship extraction method, and method and device for acquiring entity relationship learning model

Publications (1)

Publication Number Publication Date
CN111737415A true CN111737415A (en) 2020-10-02

Family

ID=72649144

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010537884.XA Pending CN111737415A (en) 2020-06-12 2020-06-12 Entity relationship extraction method, and method and device for acquiring entity relationship learning model

Country Status (1)

Country Link
CN (1) CN111737415A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112466462A (en) * 2020-11-26 2021-03-09 华侨大学 EMR information association and evolution method based on deep learning of image

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112466462A (en) * 2020-11-26 2021-03-09 华侨大学 EMR information association and evolution method based on deep learning of image
CN112466462B (en) * 2020-11-26 2023-03-07 华侨大学 EMR information association and evolution method based on deep learning of image

Similar Documents

Publication Publication Date Title
CN110471858B (en) Application program testing method, device and storage medium
CN111243668B (en) Method and device for detecting molecule binding site, electronic device and storage medium
CN110807325B (en) Predicate identification method, predicate identification device and storage medium
CN111598160B (en) Training method and device of image classification model, computer equipment and storage medium
CN111104980B (en) Method, device, equipment and storage medium for determining classification result
CN112749728A (en) Student model training method and device, computer equipment and storage medium
CN111930964B (en) Content processing method, device, equipment and storage medium
CN112733970B (en) Image classification model processing method, image classification method and device
JP2023508062A (en) Dialogue model training method, apparatus, computer equipment and program
CN111581958A (en) Conversation state determining method and device, computer equipment and storage medium
CN113392180A (en) Text processing method, device, equipment and storage medium
CN111753498A (en) Text processing method, device, equipment and storage medium
CN113569042A (en) Text information classification method and device, computer equipment and storage medium
CN113724189A (en) Image processing method, device, equipment and storage medium
CN113821658A (en) Method, device and equipment for training encoder and storage medium
CN112287070A (en) Method and device for determining upper and lower position relation of words, computer equipment and medium
CN112163095A (en) Data processing method, device, equipment and storage medium
CN115168643B (en) Audio processing method, device, equipment and computer readable storage medium
CN111737415A (en) Entity relationship extraction method, and method and device for acquiring entity relationship learning model
CN110990549A (en) Method and device for obtaining answers, electronic equipment and storage medium
CN114281937A (en) Training method of nested entity recognition model, and nested entity recognition method and device
CN114328815A (en) Text mapping model processing method and device, computer equipment and storage medium
CN113761195A (en) Text classification method and device, computer equipment and computer readable storage medium
CN115221888A (en) Entity mention identification method, device, equipment and storage medium
CN112035649A (en) Question-answer model processing method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination