Method and device for extracting entity relationship, electronic equipment and storage medium

文档序号:1963768 发布日期:2021-12-14 浏览:19次 中文

阅读说明:本技术 实体关系的抽取方法及装置、电子设备、存储介质 (Method and device for extracting entity relationship, electronic equipment and storage medium ) 是由 丁锐 于 2021-09-29 设计创作,主要内容包括:本申请公开了一种实体关系的抽取方法及装置、电子设备、存储介质,可应用于金融领域或其他领域,其中,所述方法包括:获取目标文本;将所述目标文本输入预训练语言表征模型Bert中,通过所述预训练语言表征模型Bert对所述目标文本进行处理,得到所述目标文本对应的编码;将所述目标文本对应编码输入预先训练好的目标神经网络模型中,通过所述目标神经网络模型抽取出所述目标文本中的各类关系数据,并基于所述目标文本的关系数据,抽取出所述目标文本中的各个实体数据;其中,所述目标神经网络模型预先利用多个文本样本及其对应的关系标注和实体标注进行训练得到;所述文本样本对应的关系标注和实体标注,均基于确定出的数据结构模式schema进行标注。(The application discloses an entity relationship extraction method and device, electronic equipment and a storage medium, which can be applied to the financial field or other fields, wherein the method comprises the following steps: acquiring a target text; inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text; inputting the corresponding codes of the target text into a pre-trained target neural network model, extracting various types of relation data in the target text through the target neural network model, and extracting each entity data in the target text based on the relation data of the target text; the target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training; and labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.)

1. An extraction method of entity relationships, comprising:

acquiring a target text;

inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text;

inputting the corresponding codes of the target text into a pre-trained target neural network model, extracting various types of relation data in the target text through the target neural network model, and extracting each entity data in the target text based on the relation data of the target text; the target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training; and labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.

2. The method as claimed in claim 1, wherein the target neural network model includes a first neural network model and a second neural network model, and the inputting the target text corresponding codes into a pre-trained target neural network model, extracting various types of relationship data in the target text through the target neural network model, and extracting each entity data in the target text based on the relationship data of the target text comprises:

inputting the codes corresponding to the target texts into the first neural network model, and processing the codes corresponding to the target texts through the first neural network model to obtain various types of relation data in the target texts; the first neural network model is obtained by utilizing the text sample and the corresponding relation label to train in advance;

inputting various types of relation data in the target text into the second neural network model, and processing the relation data in the target text through the second neural network model to obtain various entity data in the target text; and the second neural network model is obtained by utilizing the text sample and the entity label corresponding to the text sample in advance for training.

3. The method of claim 2, wherein the first neural network model consists of a bidirectional long-and-short memory model Bi-LSTM and a logistic regression model Softmax, and wherein the second neural network model consists of a pre-training language characterization model Bert, a bidirectional long-and-short memory model Bi-LSTM, a conditional random field model CRF, and a logistic regression model Softmax.

4. The method of claim 2, wherein the training method of the first neural network model comprises:

determining a data structure mode schema based on prior knowledge;

obtaining a plurality of text samples meeting the data structure mode schema;

labeling corresponding relation labels of the text samples based on the data structure mode schema;

respectively inputting each text sample into a first initial model, and processing the text samples through the first initial model to obtain prediction relation data corresponding to the current text sample;

judging whether the accuracy of the output result of the current first initial model meets a first preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction relation data corresponding to the current text sample;

if the accuracy of the output result of the current first initial model is judged not to meet a first preset requirement, performing parameter adjustment on the current first initial model, and returning to execute the step of inputting each text sample into the first initial model respectively according to the parameter-adjusted first initial model;

and if the accuracy of the output result of the current first initial model meets a first preset requirement, determining the current first initial model as a trained first neural network model.

5. The method of claim 4, wherein the training method of the second neural network model comprises:

obtaining each text sample and the corresponding entity label thereof;

respectively inputting each text sample into the first neural network model to obtain various types of relation data in the text samples;

inputting various types of relation data in each text sample into a second initial model respectively, and processing the various types of relation data in the text samples through the second initial model to obtain prediction entity data corresponding to the current text sample;

judging whether the accuracy of the output result of the current second initial model meets a second preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction entity data corresponding to the current text sample;

if the accuracy of the output result of the current second initial model is judged not to meet a second preset requirement, performing parameter adjustment on the current second initial model, and returning to execute the step of inputting various types of relation data in each text sample into the second initial model according to the parameter-adjusted second initial model;

and if the accuracy of the output result of the current second initial model meets a second preset requirement, determining the current second initial model as a trained second neural network model.

6. An apparatus for extracting entity relationships, comprising:

a first acquisition unit configured to acquire a target text;

the coding unit is used for inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text;

the extraction unit is used for inputting the corresponding codes of the target texts into a pre-trained target neural network model, extracting various types of relation data in the target texts through the target neural network model, and extracting each entity data in the target texts based on the relation data of the target texts; the target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training; and labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.

7. The apparatus of claim 6, wherein the target neural network model comprises a first neural network model and a second neural network model, and wherein the decimation unit comprises:

the first extraction unit is used for inputting the codes corresponding to the target texts into the first neural network model, and processing the codes corresponding to the target texts through the first neural network model to obtain various types of relation data in the target texts; the first neural network model is obtained by utilizing the text sample and the corresponding relation label to train in advance;

the second extraction unit is used for inputting various types of relation data in the target text into the second neural network model, and processing the relation data in the target text through the second neural network model to obtain various entity data in the target text; and the second neural network model is obtained by utilizing the text sample and the entity label corresponding to the text sample in advance for training.

8. The apparatus of claim 7, wherein the first neural network model consists of a bidirectional long-and-short memory model Bi-LSTM and a logistic regression model Softmax, and wherein the second neural network model consists of a pre-training language characterization model Bert, a bidirectional long-and-short memory model Bi-LSTM, a conditional random field model CRF, and a logistic regression model Softmax.

9. An electronic device, comprising:

a memory and a processor;

wherein the memory is used for storing programs;

the processor is configured to execute the program, and when the program is executed, the program is specifically configured to implement the method for extracting entity relationships according to any one of claims 1 to 5.

10. A computer storage medium storing a computer program which, when executed, implements the method of extracting entity relationships of any one of claims 1 to 5.

Technical Field

The present application relates to the field of data extraction technologies, and in particular, to an entity relationship extraction method and apparatus, an electronic device, and a storage medium.

Background

Now to facilitate the association of data and the intuitive acquisition of the management relationship between data, it is common today to construct a corresponding knowledge graph using data in a database. When the existing data is used for constructing the corresponding knowledge graph, entities and relationships among the entities need to be extracted from the data, and the knowledge graph is constructed based on the entities and the relationships among the entities.

The existing method for extracting the relationships between entities and the entities from the text data mainly extracts the entities in a method of naming the entities and extracts the relationships between the entities from the text data through the specified relationships.

However, in this method, the relationships between the entities are extracted, and the correlation between the entity identification and the relationship extraction is not fully utilized, so the accuracy of the extracted result is low.

Disclosure of Invention

Based on the defects of the prior art, the application provides an entity relationship extraction method and device, an electronic device, and a storage medium, so as to solve the problem that the accuracy of the existing entity relationship extraction method is low.

In order to achieve the above object, the present application provides the following technical solutions:

the first aspect of the present application provides an entity relationship extraction method, including:

acquiring a target text;

inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text;

inputting the corresponding codes of the target text into a pre-trained target neural network model, extracting various types of relation data in the target text through the target neural network model, and extracting each entity data in the target text based on the relation data of the target text; the target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training; and labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.

Optionally, in the above method for extracting entity relationships, the target neural network model includes a first neural network model and a second neural network model, the encoding of the target text is input into a pre-trained target neural network model, various types of relationship data in the target text are extracted through the target neural network model, and each entity data in the target text is extracted based on the relationship data of the target text, including:

inputting the codes corresponding to the target texts into the first neural network model, and processing the codes corresponding to the target texts through the first neural network model to obtain various types of relation data in the target texts; the first neural network model is obtained by utilizing the text sample and the corresponding relation label to train in advance;

inputting various types of relation data in the target text into the second neural network model, and processing the relation data in the target text through the second neural network model to obtain various entity data in the target text; and the second neural network model is obtained by utilizing the text sample and the entity label corresponding to the text sample in advance for training.

Optionally, in the above extraction method of entity relationships, the first neural network model is composed of a bidirectional long-short-term memory model Bi-LSTM and a logistic regression model Softmax, and the second neural network model is composed of a pre-training language characterization model Bert, a bidirectional long-short-term memory model Bi-LSTM, a conditional random field model CRF and a logistic regression model Softmax.

Optionally, in the above method for extracting entity relationships, the method for training the first neural network model includes:

determining a data structure mode schema based on prior knowledge;

obtaining a plurality of text samples meeting the data structure mode schema;

labeling corresponding relation labels of the text samples based on the data structure mode schema;

respectively inputting each text sample into a first initial model, and processing the text samples through the first initial model to obtain prediction relation data corresponding to the current text sample;

judging whether the accuracy of the output result of the current first initial model meets a first preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction relation data corresponding to the current text sample;

if the accuracy of the output result of the current first initial model is judged not to meet a first preset requirement, performing parameter adjustment on the current first initial model, and returning to execute the step of inputting each text sample into the first initial model respectively according to the parameter-adjusted first initial model;

and if the accuracy of the output result of the current first initial model meets a first preset requirement, determining the current first initial model as a trained first neural network model.

Optionally, in the above method for extracting entity relationships, the method for training the second neural network model includes:

obtaining each text sample and the corresponding entity label thereof;

respectively inputting each text sample into the first neural network model to obtain various types of relation data in the text samples;

inputting various types of relation data in each text sample into a second initial model respectively, and processing the various types of relation data in the text samples through the second initial model to obtain prediction entity data corresponding to the current text sample;

judging whether the accuracy of the output result of the current second initial model meets a second preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction entity data corresponding to the current text sample;

if the accuracy of the output result of the current second initial model is judged not to meet a second preset requirement, performing parameter adjustment on the current second initial model, and returning to execute the step of inputting various types of relation data in each text sample into the second initial model according to the parameter-adjusted second initial model;

and if the accuracy of the output result of the current second initial model meets a second preset requirement, determining the current second initial model as a trained second neural network model.

A second aspect of the present application provides an apparatus for extracting entity relationships, including:

a first acquisition unit configured to acquire a target text;

the coding unit is used for inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text;

the extraction unit is used for inputting the corresponding codes of the target texts into a pre-trained target neural network model, extracting various types of relation data in the target texts through the target neural network model, and extracting each entity data in the target texts based on the relation data of the target texts; the target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training; and labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.

Optionally, in the above apparatus for extracting entity relationships, the target neural network model includes a first neural network model and a second neural network model, and the extracting unit includes:

the first extraction unit is used for inputting the codes corresponding to the target texts into the first neural network model, and processing the codes corresponding to the target texts through the first neural network model to obtain various types of relation data in the target texts; the first neural network model is obtained by utilizing the text sample and the corresponding relation label to train in advance;

the second extraction unit is used for inputting various types of relation data in the target text into the second neural network model, and processing the relation data in the target text through the second neural network model to obtain various entity data in the target text; and the second neural network model is obtained by utilizing the text sample and the entity label corresponding to the text sample in advance for training.

Optionally, in the above entity relationship extraction apparatus, the first neural network model is composed of a bidirectional long-short-term memory model Bi-LSTM and a logistic regression model Softmax, and the second neural network model is composed of a pre-training language representation model Bert, a bidirectional long-short-term memory model Bi-LSTM, a conditional random field model CRF and a logistic regression model Softmax.

Optionally, in the above apparatus for extracting entity relationships, the apparatus further includes:

the mode determining unit is used for determining a schema of the data structure based on the prior knowledge;

a second obtaining unit, configured to obtain a plurality of text samples that satisfy the data structure schema;

the marking unit is used for marking the corresponding relation marks of the text samples based on the data structure mode schema;

the first input unit is used for respectively inputting each text sample into a first initial model, and processing the text sample through the first initial model to obtain prediction relation data corresponding to the current text sample;

the first judging unit is used for judging whether the accuracy of the output result of the current first initial model meets a first preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction relation data corresponding to the current text sample;

the first parameter adjusting unit is used for adjusting parameters of the current first initial model if the accuracy of the output result of the current first initial model is judged not to meet a first preset requirement, and returning to execute the step of inputting each text sample into the first initial model according to the adjusted first initial model;

and the first model determining unit is used for determining the current first initial model as the trained first neural network model if the accuracy of the output result of the current first initial model meets a first preset requirement.

Optionally, in the above apparatus for extracting entity relationships, the apparatus further includes:

the third acquisition unit is used for acquiring each text sample and the corresponding entity label thereof;

the second input unit is used for respectively inputting each text sample into the first neural network model to obtain various types of relation data in the text sample;

the third input unit is used for respectively inputting various types of relation data in each text sample into a second initial model, and processing various types of relation data in the text samples through the second initial model to obtain predicted entity data corresponding to the current text sample;

the second judging unit is used for judging whether the accuracy of the output result of the current second initial model meets a second preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction entity data corresponding to the current text sample;

the second parameter adjusting unit is used for adjusting parameters of the current second initial model if the accuracy of the output result of the current second initial model is judged not to meet a second preset requirement, and returning to execute the step of inputting various types of relation data in each text sample into the second initial model according to the adjusted second initial model;

and the second model determining unit is used for determining the current second initial model as a trained second neural network model if the accuracy of the output result of the current second initial model meets a second preset requirement.

A third aspect of the present application provides an electronic device comprising:

a memory and a processor;

wherein the memory is used for storing programs;

the processor is configured to execute the program, and when the program is executed, the program is specifically configured to implement the method for extracting an entity relationship according to any one of the above items.

A fourth aspect of the present application provides a computer storage medium for storing a computer program, which when executed, is configured to implement the method for extracting entity relationships as described in any one of the above.

According to the method for extracting the entity relationship, a data structure mode schema is determined in advance, then the relationship labels and the entity labels of a plurality of text samples are labeled based on the data structure mode schema, and then the relationship labels and the entity labels of the plurality of text samples are utilized to train a target neural network model. When the target text is obtained, the target text is firstly input into a pre-training language representation model Bert, and the target text is processed through the pre-training language representation model Bert to obtain a code corresponding to the target text. And then correspondingly encoding the target text and inputting the target text into a pre-trained target neural network model, extracting various types of relation data in the target text through the target neural network model, then extracting each entity data in the target text based on the relation data of the target text, and not extracting the entity and the relation respectively any more, and fully considering the incidence relation between the entity relation and the entity, thereby effectively ensuring the accuracy of the extraction result.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a flowchart of an entity relationship extraction method according to an embodiment of the present application;

fig. 2 is a flowchart of a method for extracting relationship data and entity data according to an embodiment of the present disclosure;

FIG. 3 is a diagram illustrating an example of an extraction of entity relationships according to an embodiment of the present application;

FIG. 4 is a flowchart of a training method for a first neural network model according to an embodiment of the present disclosure;

FIG. 5 is a flowchart of a training method for a second neural network model according to an embodiment of the present disclosure;

fig. 6 is a schematic structural diagram of an extraction apparatus for entity relationships according to an embodiment of the present disclosure;

fig. 7 is a schematic structural diagram of an extraction unit according to an embodiment of the present disclosure;

fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

In this application, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

The entity relationship extraction method, the entity relationship extraction device, the electronic equipment and the computer storage medium can be used in the financial field or other fields, such as the data processing field. The foregoing is merely an example, and does not limit the application fields of the method, the apparatus, the electronic device, and the computer storage medium for extracting an entity relationship provided in the present invention.

The embodiment of the application provides an extraction method of an entity relationship, as shown in fig. 1, including the following steps:

and S101, acquiring a target text.

Wherein the target text refers to the text to be processed. In the embodiment of the application, the target text is mainly semi-structured or unstructured text.

Optionally, the target text may be obtained from a database, uploaded by a user, or obtained in other manners.

S102, inputting the target text into a pre-training language representation model Bert, and processing the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text.

Specifically, the target text is input into a pre-training language Representation model (Bert), and the target text is encoded by the pre-training language Representation model Bert to obtain a code corresponding to the target text, so as to obtain a feature vector corresponding to the target text.

S103, inputting the corresponding codes of the target text into a pre-trained target neural network model, extracting various kinds of relation data in the target text through the target neural network model, and extracting each entity data in the target text based on the relation data of the target text.

In the embodiment of the application, the target neural network model is a model with a multi-level structure, so that the target text corresponding codes are input into the pre-trained target neural network model, the target neural network model extracts various kinds of relation data in the target text first, and then extracts various entity data from the target text based on the relation between the obtained relation data and the entity data.

It should be noted that, since the attribute also belongs to one entity, the entity data in the embodiment of the present application includes two types, namely, a non-attribute entity and an attribute entity, so that a triple is formed together with the relationship data, and further, a knowledge graph corresponding to the target text can be constructed by using the obtained triple.

The target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training. And labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema. The relation, the entity range and the like included in the text in the application scene are specified in the data structure mode schema, so that the relation label and the entity label corresponding to the text sample can be labeled according to the data structure mode schema.

Optionally, in another embodiment of the present application, the target neural network model may specifically include a first neural network model and a second neural network model, that is, the target neural network model is composed of the first neural network model and the second neural network model. Relationships between the entities are extracted by the first neural network model, and the entities are extracted based on the extracted relationships by the second neural network model.

Alternatively, both the first neural network model and the second neural network model may employ a combined multi-level model. The first neural network model consists of a bidirectional long-time and short-time memory model Bi-LSTM and a logistic regression model Softmax. Moreover, since the input of the first neural network model is obtained by the pre-training language representation model Bert, the first neural network model may also be considered to be composed of the pre-training language representation model Bert, the bidirectional long-and-short time memory model Bi-LSTM, and the logistic regression model Softmax, that is, the first neural network model is "Bert + Bi-LSTM + Softmax". Note that, at this time, the input of the first neural network model is the target text.

The second neural network model can be composed of a pre-training language representation model Bert, a bidirectional long-and-short time memory model Bi-LSTM, a conditional random field model CRF and a logistic regression model Softmax, namely the second neural network model is 'Bert + Bi-LSTM + CRF + Softmax'.

Optionally, in this embodiment of the present application, a specific implementation manner of step S103, as shown in fig. 2, includes the following steps:

s201, inputting the codes corresponding to the target text into the first neural network model, and processing the codes corresponding to the target text through the first neural network model to obtain various types of relation data in the target text.

And the first neural network model is obtained by utilizing the text sample and the corresponding relation label to train in advance.

S202, inputting various kinds of relation data in the target text into a second neural network model, and processing the relation data in the target text through the second neural network model to obtain various entity data in the target text.

And the second neural network model is obtained by training in advance by using the text sample and the entity label corresponding to the text sample.

Therefore, in the embodiment of the application, various types of relationship data in the target text are extracted through the first neural network model, and then the entity is extracted through the second upgraded network model based on the extracted relationship data. For example, as shown in FIG. 3, the target is text: the medium silver iron card has two types, namely a gold card and a silver card, and is mainly applied to railway windows, websites, self-service equipment and the like which gather to pay for cards for shopping and automatic keyboard equipment in a specified section of a railway to pay for cards and get into the station for riding. Relational data are extracted through a pre-training language representation model Bert and a first neural network model, namely an entity is extracted through the Bert + Bi-LSTM + Softmax and then through a second neural network model Bert + Bi-LSTM + CRF + Softmax based on the relational data.

Optionally, in an embodiment of the present application, a method for training a first neural network model is provided, as shown in fig. 4, including:

s401, determining a data structure mode schema based on prior knowledge.

S402, obtaining a plurality of text samples meeting the schema of the data structure.

And S403, labeling the corresponding relation labels of the text samples based on the data structure mode schema.

Specifically, the data structure mode schema sets the range of the relationship contained in the data, so that the relationship label corresponding to each text sample can be labeled based on the data structure mode schema.

Optionally, since entity labels corresponding to the text samples are required to be used in subsequent training of the second neural network model, the entity labels corresponding to the text samples may also be labeled based on the data structure schema while step S403 is executed.

S404, inputting each text sample into the first initial model respectively, and processing the text samples through the first initial model to obtain the prediction relation data corresponding to the current text sample.

S405, calculating the accuracy of the output result of the current first initial model based on the relation label corresponding to the text sample and the comparison result of the prediction relation data corresponding to the current text sample.

S406, judging whether the accuracy of the output result of the current first initial model meets a first preset requirement.

Specifically, the first preset requirement may be a preset threshold.

If the output result accuracy of the current first initial model is determined not to meet the first preset requirement, it is determined that the model still needs to be trained, so step S407 is executed at this time. If the accuracy of the output result of the current first initial model is determined to meet the first predetermined requirement, it indicates that the model meets the requirement, and then step S408 is executed.

And S407, performing parameter adjustment on the current first initial model.

Optionally, the parameters in the first initial model may be adjusted based on a loss function corresponding to the first initial model.

After step S407 is executed, it is necessary to return to step S404 with respect to the first initial model after parameter adjustment.

And S408, determining the current first initial model as the trained first neural network model.

Accordingly, in an embodiment of the present application, a training method of a second neural network model is provided, as shown in fig. 5, including:

s501, obtaining each text sample and corresponding entity labels thereof.

Optionally, the entity label corresponding to the text sample may be labeled at the same time as labeling the relationship. Of course, the labeling may be performed when the second neural network model needs to be trained.

And S502, respectively inputting each text sample into the first neural network model to obtain various types of relation data in the text samples.

S503, inputting the various types of relation data in the text samples into a second initial model respectively, and processing the various types of relation data in the text samples through the second initial model to obtain the prediction entity data corresponding to the current text sample.

S504, calculating the accuracy of the output result of the current second initial model based on the relation label corresponding to the text sample and the comparison result of the prediction entity data corresponding to the current text sample.

And S505, judging whether the accuracy of the output result of the current second initial model meets a second preset requirement.

Specifically, the second preset requirement may be a preset threshold.

If the output result accuracy of the current second initial model is determined not to meet the second preset requirement, it is determined that the model does not meet the requirement yet, and training is required, so step S506 is executed at this time. If the output result accuracy of the current second initial model meets the second preset requirement, step S507 is executed.

And S506, performing parameter adjustment on the current second initial model.

Optionally, the second initial model may be adjusted based on a corresponding loss function of the second initial model to make the second initial model converge faster.

After step S506 is executed, it is necessary to return to step S503 for the second initial model after parameter adjustment.

And S507, determining the current second initial model as a trained second neural network model.

According to the method for extracting the entity relationship, a data structure mode schema is determined in advance, then the relationship labels and the entity labels of a plurality of text samples are labeled based on the data structure mode schema, and then the relationship labels and the entity labels of the plurality of text samples are used for training a target neural network model. When the target text is obtained, the target text is firstly input into a pre-training language representation model Bert, and the target text is processed through the pre-training language representation model Bert to obtain a code corresponding to the target text. And then correspondingly encoding the target text and inputting the target text into a pre-trained target neural network model, extracting various types of relation data in the target text through the target neural network model, then extracting each entity data in the target text based on the relation data of the target text, and not extracting the entity and the relation respectively any more, and fully considering the incidence relation between the entity relation and the entity, thereby effectively ensuring the accuracy of the extraction result.

Another embodiment of the present application provides an apparatus for extracting entity relationships, as shown in fig. 6, including:

a first obtaining unit 601, configured to obtain a target text.

The encoding unit 602 is configured to input the target text into the pre-training language representation model Bert, and process the target text through the pre-training language representation model Bert to obtain a code corresponding to the target text.

The extracting unit 603 is configured to input the corresponding codes of the target text into a pre-trained target neural network model, extract various types of relationship data in the target text through the target neural network model, and extract each entity data in the target text based on the relationship data of the target text.

The target neural network model is obtained by utilizing a plurality of text samples and corresponding relation labels and entity labels thereof in advance for training. And labeling the relation label and the entity label corresponding to the text sample based on the determined data structure mode schema.

Optionally, in another embodiment of the present application, the target neural network model includes a first neural network model and a second neural network model. The extraction unit in the embodiment of the present application, as shown in fig. 7, includes:

the first extracting unit 701 is configured to input the codes corresponding to the target text into the first neural network model, and process the codes corresponding to the target text through the first neural network model to obtain various types of relationship data in the target text.

The first neural network model is obtained by training in advance by using text samples and corresponding relation labels thereof.

The second extraction unit 702 is configured to input various types of relationship data in the target text into the second neural network model, and process the relationship data in the target text through the second neural network model to obtain entity data in the target text.

And the second neural network model is obtained by training in advance by using the text sample and the entity label corresponding to the text sample.

Optionally, in the extraction apparatus of entity relationships provided in another embodiment of the present application, the first neural network model is composed of a bidirectional long-and-short memory model Bi-LSTM and a logistic regression model Softmax, and the second neural network model is composed of a pre-training language characterization model Bert, a bidirectional long-and-short memory model Bi-LSTM, a conditional random field model CRF, and a logistic regression model Softmax.

Optionally, in an extraction apparatus of entity relationships provided in another embodiment of the present application, further includes:

and the mode determining unit is used for determining the data structure mode schema based on the prior knowledge.

And the second acquisition unit is used for acquiring a plurality of text samples meeting the data structure mode schema.

And the marking unit is used for marking the corresponding relation marks of the text samples based on the data structure mode schema.

And the first input unit is used for respectively inputting each text sample into the first initial model, and processing the text sample through the first initial model to obtain the prediction relation data corresponding to the current text sample.

And the first judging unit is used for judging whether the accuracy of the output result of the current first initial model meets a first preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction relation data corresponding to the current text sample.

And the first parameter adjusting unit is used for adjusting parameters of the current first initial model if the accuracy of the output result of the current first initial model is judged not to meet the first preset requirement, and returning and executing the first initial model after parameter adjustment to input each text sample into the first initial model respectively.

And the first model determining unit is used for determining the current first initial model as the trained first neural network model if the accuracy of the output result of the current first initial model meets the first preset requirement.

Optionally, in an extraction apparatus of entity relationships provided in another embodiment of the present application, further includes:

and the third acquisition unit is used for acquiring each text sample and the entity label corresponding to the text sample.

And the second input unit is used for respectively inputting each text sample into the first neural network model to obtain various types of relation data in the text samples.

And the third input unit is used for respectively inputting various types of relation data in each text sample into the second initial model, and processing various types of relation data in the text samples through the second initial model to obtain the prediction entity data corresponding to the current text sample.

And the second judging unit is used for judging whether the accuracy of the output result of the current second initial model meets a second preset requirement or not based on the relation label corresponding to the text sample and the comparison result of the prediction entity data corresponding to the current text sample.

And the second parameter adjusting unit is used for adjusting the parameters of the current second initial model if the accuracy of the output result of the current second initial model is judged not to meet the second preset requirement, and returning and executing the second initial model after parameter adjustment to input various types of relation data in each text sample into the second initial model.

And the second model determining unit is used for determining the current second initial model as the trained second neural network model if the output result accuracy of the current second initial model meets the second preset requirement.

It should be noted that, for the specific working processes of each unit provided in the foregoing embodiments of the present application, reference may be made to the implementation of the corresponding step in the foregoing method embodiments, and details are not described here again.

Another embodiment of the present application provides an electronic device, as shown in fig. 8, including:

a memory 801 and a processor 802.

The memory 801 is used to store programs.

The processor 802 is configured to execute the program stored in the memory 801, and when the program is executed, the method for extracting the entity relationship provided in any of the above embodiments is specifically implemented.

Another embodiment of the present application provides a computer storage medium for storing a computer program, and when the computer program is executed, the computer storage medium is used for implementing the method for extracting entity relationships provided in any one of the above embodiments.

Computer storage media, including permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.

The method and the device for extracting entity relationships, the electronic device, and the storage medium provided by the present application may be used in the financial field or other fields. The other fields are arbitrary fields other than the financial field, for example, the big data field. The foregoing is merely an example, and does not limit application fields of the method and apparatus for extracting entity relationships, the electronic device, and the storage medium provided by the present invention.

Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.

The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于大数据的法规识别方法、装置、电子设备及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!