Method, device, electronic device and storage medium for processing entity relations in text

By introducing coding layer, parameter optimization layer and classification layer into the text entity relationship processing model, combined with the BERT algorithm and attention mechanism, the instability problem of entity relationship extraction and classification in the existing technology is solved, and more accurate and efficient classification of entity relationships.

CN112528019BActive Publication Date: 2025-01-10TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the extraction and classification of text entity relationships, the model training accuracy and processing results are unstable due to sample feature instability and insufficient data.

Method used

The entity relationship processing model including coding layer, parameter optimization layer and classification layer is adopted, feature information is extracted through the BERT algorithm, and the classification parameters are optimized using meta-information, and parameters are updated in combination with the attention mechanism algorithm to improve the accuracy of entity relationship classification.

Benefits of technology

It realizes more accurate and efficient text entity relationship classification, reduces the negative impact of sample noise and insufficient data, and improves the model's adaptability and classification accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112528019B_ABST
    Figure CN112528019B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, electronic device and storage medium for processing entity relationships in text. The method comprises: obtaining a target text; inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text; the entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of the entity relationship as input, and is used to determine the category of the entity relationship in the text; the entity relationship processing model comprises a coding layer, a parameter optimization layer and a classification layer, the coding layer is used to determine the feature information according to the target text, the classification layer is used to determine the category of the entity relationship in the target text according to the feature information of the target text and classification parameters, and the parameter optimization layer is used to optimize the classification parameters; the classification parameters are determined by the meta information of the category of the text, so that the meta information of the category is used as the judgment guide of the characteristic information of the text, so that the classification of the entity relationship in the text is more accurate and efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a method, device, electronic device and storage medium for processing entity relationships in text. Background Art

[0002] In the information age, massive amounts of data are generated every day. Names of people, places, time, dates and other proper nouns and things in the data are represented as entities. The relationships between entities are extracted from the data to build a knowledge graph. The knowledge graph includes the categories of entity relationships and the relationships between entities. Therefore, after extracting entity relationships from new texts, the categories of the entity relationships are also determined and stored in the knowledge graph.

[0003] The extraction and classification of entity relationships in texts requires a model trained based on examples (i.e., sample instances), but model training and optimization are mostly completed based on the feature information of the text. However, if the sample features are unstable (for example, the sample is noisy data), or if there is too little sample data to support training and learning, the accuracy of the trained model cannot be guaranteed, and the subsequent model processing results on the text will be unstable. Summary of the invention

[0004] In view of the problems existing in the prior art, the present invention provides a method, device, electronic device and storage medium for processing entity relationships in text.

[0005] The present invention provides a method for processing entity relationships in text, comprising:

[0006] Obtain the target text to be processed with respect to entity relations;

[0007] Inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text;

[0008] The entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of entity relationships in the training text as input, and is used to determine the category of entity relationships in a text;

[0009] The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on a target text. The classification layer is used to determine the category of entity relationships in a target text based on the feature information and classification parameters of the target text. The parameter optimization layer is used to optimize the classification parameters. The classification parameters are determined by the meta-information of the text category.

[0010] According to a method for processing entity relationships in text provided by the present invention, the step of inputting the target text into a preset entity relationship processing model to obtain the category of entity relationships in the target text comprises:

[0011] Input the target text into the encoding layer, and the encoding layer outputs the feature information of the target text;

[0012] Input the feature information of the target text into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer;

[0013] The feature information of a preset number of target texts and the meta-information of the categories of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts.

[0014] According to a method for processing entity relationships in text provided by the present invention, the feature information of the target text outputted by the encoding layer includes:

[0015] The encoding layer uses the BERT algorithm to vectorize all characters in the target text to obtain a feature vector matrix, which is output as the feature information of the target text.

[0016] According to a method for processing entity relationships in text provided by the present invention, the classification layer determines the category of entity relationships in the target text according to feature information of the target text and classification parameters called from the parameter optimization layer, including:

[0017] The classification layer obtains the normalized values ​​corresponding to the preset categories of the entity relationships in the target text according to the feature vector matrix and classification parameters;

[0018] The category corresponding to the normalized value with the largest value is selected as the category of the entity relationship in the target text.

[0019] According to a method for processing entity relationships in text provided by the present invention, the feature information of a preset number of target texts and the meta information of the categories of the target texts are input into a parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta information of the categories of the target texts, including:

[0020] The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm;

[0021] The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm;

[0022] The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm;

[0023] The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

[0024] The present invention also provides a device for processing entity relationships in a text, comprising:

[0025] An acquisition module is used to acquire a target text to be processed with respect to an entity relationship;

[0026] A processing module, used for inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text;

[0027] The entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of entity relationships in the training text as input, and is used to determine the category of entity relationships in a text;

[0028] The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on a target text. The classification layer is used to determine the category of entity relationships in a target text based on the feature information and classification parameters of the target text. The parameter optimization layer is used to optimize the classification parameters. The classification parameters are determined by the meta-information of the text category.

[0029] According to a device for processing entity relationships in text provided by the present invention, the processing module is specifically used for:

[0030] The target text is input into the encoding layer, and the encoding layer outputs the extracted feature information of the target text;

[0031] Input the feature information of the target text into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer;

[0032] The feature information of a preset number of target texts and the categories of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts.

[0033] According to a device for processing entity relationships in texts provided by the present invention, the processing module is specifically used in the process of inputting feature information of a preset number of target texts and categories of the target texts into a parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts:

[0034] The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm;

[0035] The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm;

[0036] The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm;

[0037] The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

[0038] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned methods for processing entity relationships in text are implemented.

[0039] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for processing entity relationships in text are implemented.

[0040] The method, device, electronic device and storage medium for processing entity relationships in text provided by the present invention classify entity relationships in text through an entity relationship processing model. The model can apply classification parameters determined by the metadata of the category to the classification process, and complete the calculation and determination of the category of the entity relationship in the text with the feature information of the text, thereby realizing the use of the metadata of the category as a judgment guide for the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 It is a flowchart of the method for processing entity relationships in text provided by the present invention;

[0043] Figure 2 It is a structural schematic diagram of the device for processing entity relations in text provided by the present invention;

[0044] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] Combine the following Figure 1-Figure 3 The present invention describes a method, device, electronic device and storage medium for processing entity relationships in text.

[0047] Figure 1 A schematic diagram showing a flow chart of a method for processing entity relationships in a text provided by the present invention is shown in FIG. Figure 1 , the method comprises the following steps:

[0048] S11, obtaining a target text to be processed with respect to entity relations;

[0049] S12. Input the target text into a preset entity relationship processing model to obtain the category of entity relationships in the target text; the entity relationship processing model is a model that uses the feature information of the training text and the category of entity relationships in the training text as input and is obtained through machine learning training to determine the category of entity relationships in the text; the entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer, the encoding layer is used to determine the feature information based on the target text, the classification layer is used to determine the category of entity relationships in the target text based on the feature information of the target text and classification parameters, and the parameter optimization layer is used to optimize the classification parameters; the classification parameters are determined by the metadata of the text category.

[0050] In this regard, it should be noted that in the present invention, in the information age, massive amounts of data are generated every day. Names, place names, time, date and other proper nouns and things in the data are represented as entities. The relationships between entities are extracted from the data to establish a knowledge graph. The knowledge graph includes the categories of entity relationships and the relationships between entities. For this reason, after extracting entity relationships from new texts, the categories of the entity relationships are also determined to be stored in the knowledge graph.

[0051] First, the target text to be processed for entity relations is obtained, which can be an article, or a paragraph or a sentence in the article.

[0052] Then the target text is input into a preset entity relationship processing model, a category judgment process of the entity relationship in the target text is performed in the model, and the category of the entity relationship of the target text is output.

[0053] The entity relationship processing model is a model that uses feature information of a training text and the category of entity relationships in the training text as input and is obtained through machine learning training to determine the category of entity relationships in a text.

[0054] The feature information of the text is the key information obtained by judging the key information of the text, and the key information is the basis for determining the entity relationship and judging the entity relationship category. For example, the feature vector represented by each character in the text is the key information of the text.

[0055] The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on the target text, the classification layer is used to determine the category of the entity relationship in the target text based on the feature information and classification parameters of the target text, and the parameter optimization layer is used to optimize the classification parameters; the classification parameters are determined by the meta-information of the text category.

[0056] Since the entity relationship processing model aims to classify the entity relationships in the target text, it is reflected in the determination of entity relationships and the classification of entity relationships. Therefore, in view of the association between text and category, the meta-information of the category is used as a guide for judging the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient.

[0057] In the present invention, a category is a word name, and the meaning of the word name is analyzed and explained by meta information. The meta information is a description of multiple words that characterize the meaning of the category. For example, if the category is "Tsinghua", the meta information may include: it is a university, ranked first in China, and is as famous as Peking University, etc. The classification parameters can be obtained by extracting and calculating the features of these meta information.

[0058] In the present invention, the target text is input into the model, the encoding layer analyzes the target text, extracts the feature information of the text, and inputs it into the classification layer. The classification layer calls the current classification parameters from the parameter optimization layer, analyzes and calculates the feature information of the target text, and obtains the category of the entity relationship in the target text. The parameter optimization layer can realize the dynamic update of the classification parameters, so that the updated classification parameters are used in the classification layer, and the accuracy of the classification layer in classifying the entity relationship of the target text is improved.

[0059] The method for processing entity relationships in text provided by the present invention classifies entity relationships in text through an entity relationship processing model. The model can apply classification parameters determined by the meta-information of the category to the classification process, and complete the calculation and determination of the category of the entity relationship in the text with the feature information of the text, thereby realizing the use of the meta-information of the category as a judgment guide for the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient.

[0060] In the further description of the above method, the acquisition process of the entity relationship processing model is mainly explained, as follows:

[0061] The present invention provides a model framework based on meta-information guidance, which provides guidance for the initialization and self-adaptation of the model by using the semantic concepts of the category as meta-information. Specifically, it effectively initializes and adapts by establishing a connection between samples and semantic information.

[0062] In the present invention, the model is trained by few-sample learning. In few-sample learning, the N-way-K-shot model is generally adopted for training and verification, that is, N categories are randomly selected from the data set each time, and K samples are selected for each category. In other words, the model training process of the present invention can obtain a better model for relationship extraction results when 1 to 5 samples are provided for each category.

[0063] The model uses K samples of each class (a total of N*K) as support samples (Support) for rapid adaptation. After the model is adapted, the remaining N*Q query samples (Query) are used for testing. The training set can calculate the loss function, thereby calculating the gradient to update the model parameters, and the test set can be used to calculate the accuracy.

[0064] Generally speaking, the larger K is, the more data the model uses to quickly adapt, and the easier it is to learn. Few-shot learning refers to the case where K is smaller (such as 5-way-5-shot, 5-way-1-shot, or even 5-way-0-shot).

[0065] The four stages of model acquisition of the present invention are introduced below:

[0066] Step 1: For a set of N-way-K-shot (and N*Q test samples), first use the BERT algorithm as an encoder to encode the N*Q support samples into a vector representation (i.e., a feature vector matrix) as the input of the classifier and the key information of the attention mechanism. On the other hand, the semantic concept information (Meta-information) corresponding to the N categories is used as input to generate the initial parameters of the classifier and the query information of the attention mechanism through the trained MLP network.

[0067] Step 2: The vector representation of the support samples obtained by the encoder is classified by the classifier, and then the softmax cross entropy is used to obtain the value of the loss function (that is, the loss value of each support sample), and the loss value of each support sample is used as the Value information of the Attention mechanism.

[0068] Step 3: Use the Attention mechanism to calculate the gradient of parameter update (Grad step). Specifically, the present invention uses the simplest method of taking the dot product of Key, Query and Value and passing it through a Softmax function as the gradient ratio of each supporting sample, and then updates the classification parameters of the classifier according to the gradient value and gradient ratio of step 2 to achieve the effect of rapid adaptation (this process is generally repeated about 10 times). It should be noted that the final gradient value is obtained by weighted average of the gradient values ​​according to the gradient ratio, and the final gradient value is used to update the classification parameters.

[0069] Step 4: Use the fast-adapted parameters to calculate the accuracy and loss function for the query example, and use the value of the loss function to update the encoder (BERT) and the MLP network used to process Meta-information to update the model.

[0070] Compared with random initialization and sharing the same set of parameters for all categories, using meta-information related to the category to generate a set of initialization parameters for each group of categories allows the model to reach the optimal parameter point more quickly; using the attention mechanism guided by meta-information, it is possible to distinguish the "good" and "bad" of samples and reduce the negative impact of noise in the samples.

[0071] In the further description of the above method, the target text is input into a preset entity relationship processing model to obtain the category of the entity relationship in the target text, which is specifically used for:

[0072] Input the target text into the encoding layer, and the encoding layer outputs the feature information of the target text;

[0073] Input the feature information of the target text into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer;

[0074] The feature information of a preset number of target texts and the meta-information of the categories of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts.

[0075] In this regard, it should be noted that the target text is input into the encoding layer, the encoding layer analyzes the target text, extracts feature information of the text, and inputs it into the classification layer.

[0076] The classification layer calls the current classification parameters from the parameter optimization layer, analyzes and calculates the feature information of the target text, and obtains the category of the entity relationship in the target text.

[0077] After a certain number of target texts are processed for entity relationship classification, the parameter optimization layer obtains the feature information of these target texts and the category meta-information of these target texts, and calculates the data used to update the current classification parameters based on the feature information of the target texts and the category meta-information of the target texts, thereby completing the dynamic update of the current classification parameters, so that the updated classification parameters are used for the classification layer, thereby improving the accuracy of the classification layer in classifying the entity relationships of the target texts.

[0078] The present invention further provides a method for processing entity relationships in text, which classifies entity relationships in text through an entity relationship processing model. The model can apply classification parameters determined by category metadata to the classification process, and complete calculations with the feature information of the text to determine the category of the entity relationship in the text, thereby using the category metadata as a judgment guide for the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient.

[0079] In the further description of the above method, the feature information of the target text output by the encoding layer is mainly as follows:

[0080] The encoding layer uses the BERT algorithm to vectorize all characters in the target text to obtain a feature vector matrix, which is output as the feature information of the target text.

[0081] In this regard, it should be noted that, in the present invention, the BERT algorithm is used to perform vector representation on all characters in the target text, so that the target text can be numerically vectorized, which is convenient for calculation and processing during the classification process.

[0082] In the further description of the above method, the processing process of determining the category of the entity relationship in the target text by the classification layer according to the feature information of the target text and the classification parameters called from the parameter optimization layer is mainly explained as follows:

[0083] The classification layer obtains the normalized values ​​corresponding to the preset categories of the entity relationships in the target text according to the feature vector matrix and classification parameters;

[0084] The category corresponding to the normalized value with the largest value is selected as the category of the entity relationship in the target text.

[0085] In this regard, it should be noted that in the present invention, the classification layer analyzes the feature vector matrix to determine the entity relationship in the target text, and then calculates the probability value of the entity relationship on each preset category according to the feature vector corresponding to the entity relationship and the classification parameter, that is, the sum of each probability value is 1, so the probability value can be a normalized value. Then the category corresponding to the normalized value with the largest value is selected as the category of the entity relationship in the target text.

[0086] The present invention further provides a method for processing entity relationships in text, which applies classification parameters determined by category metadata to the classification process, and completes calculation with the feature information of the text to determine the category of the entity relationship in the text, thereby using the category metadata as a judgment guide for the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient.

[0087] In the further description of the above method, the feature information of a preset number of target texts and the meta information of the category of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta information of the category of the target texts. The specific process is as follows:

[0088] The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm;

[0089] The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm;

[0090] The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm;

[0091] The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

[0092] In this regard, it should be noted that in the present invention, after a certain number of target texts are subjected to entity relationship classification processing, the parameter optimization layer obtains the feature information of these target texts, as well as the category meta-information of these target texts, and calculates the key information, query information and value information (the gradient value of each target text) based on the attention mechanism algorithm according to the feature information of the target texts and the category meta-information of the target texts, and then determines the gradient ratio according to the key information, query information and value information of the attention mechanism algorithm, so that the gradient value and the gradient ratio determine the final gradient value, and updates the current classification parameters according to the gradient value, so that the updated classification parameters are used for the classification layer, thereby improving the accuracy of the classification layer in classifying the entity relationships of the target texts.

[0093] The text entity relationship processing device provided by the present invention is described below. The text entity relationship processing device described below and the text entity relationship processing method described above can be referenced to each other.

[0094] Figure 2 The schematic diagram of the structure of the text entity relationship processing device provided by the present invention is shown in FIG. Figure 2 The device comprises an acquisition module 21 and a processing module 22, wherein:

[0095] An acquisition module 21 is used to acquire a target text to be processed with entity relations;

[0096] A processing module 22, used for inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text;

[0097] The entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of entity relationships in the training text as input, and is used to determine the category of entity relationships in a text;

[0098] The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on a target text, the classification layer is used to determine the category of the entity relationship in the target text based on the feature information and classification parameters of the target text, and the parameter optimization layer is used to optimize the classification parameters; the classification parameters are determined by the meta-information of the text category.

[0099] In a further description of the above device, the processing module is specifically used for:

[0100] Input the target text into the encoding layer, and the encoding layer outputs the feature information of the target text;

[0101] Input the feature information of the target text into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer;

[0102] The feature information of a preset number of target texts and the categories of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts.

[0103] In a further description of the above device, the processing module is specifically used to:

[0104] The encoding layer uses the BERT algorithm to vectorize all characters in the target text to obtain a feature vector matrix, which is output as the feature information of the target text.

[0105] In a further description of the above device, the processing module is specifically used for:

[0106] The classification layer obtains the normalized values ​​corresponding to the preset categories of the entity relationships in the target text according to the feature vector matrix and classification parameters;

[0107] The category corresponding to the normalized value with the largest value is selected as the category of the entity relationship in the target text.

[0108] In a further description of the above device, the processing module is specifically used for: inputting feature information of a preset number of target texts and the categories of the target texts into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts:

[0109] The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm;

[0110] The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm;

[0111] The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm;

[0112] The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

[0113] Since the principle of the device described in the embodiment of the present invention is the same as that of the method described in the above embodiment, a more detailed explanation will not be repeated here.

[0114] It should be noted that, in the embodiment of the present invention, the relevant functional modules can be implemented by a hardware processor.

[0115] The method for processing entity relationships in text provided by the present invention classifies entity relationships in text through an entity relationship processing model. The model can apply classification parameters determined by the meta-information of the category to the classification process, and complete the calculation and determination of the category of the entity relationship in the text with the feature information of the text, thereby realizing the use of the meta-information of the category as a judgment guide for the characteristic information of the text, making the classification of entity relationships in the text more accurate and efficient.

[0116] Figure 3 A schematic diagram of the physical structure of an electronic device is shown. Figure 3 As shown, the electronic device may include: a processor 31, a communication interface 32, a memory 33 and a communication bus 34, wherein the processor 31, the communication interface 32 and the memory 33 communicate with each other through the communication bus 34. The processor 31 may call the logic instructions in the memory 33 to execute the method for processing entity relations in text, the method comprising: obtaining a target text to be processed with entity relations; inputting the target text into a preset entity relation processing model to obtain the category of entity relations in the target text; the entity relation processing model is a model obtained by machine learning training using the feature information of the training text and the category of entity relations in the training text as input, and is used to determine the category of entity relations in the text; the entity relation processing model comprises a coding layer, a parameter optimization layer and a classification layer, the coding layer is used to determine the feature information according to the target text, the classification layer is used to determine the category of entity relations in the target text according to the feature information of the target text and the classification parameter, and the parameter optimization layer is used to optimize the classification parameter; the classification parameter is determined by the meta information of the category of the text.

[0117] In addition, the logic instructions in the above-mentioned memory 33 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0118] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the entity relationship processing method in the text provided by the above-mentioned methods, and the method includes: obtaining a target text to be processed with entity relationships; inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text; the entity relationship processing model is a model obtained by machine learning training using the feature information of the training text and the category of the entity relationship in the training text as input; the entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer, the encoding layer is used to determine the feature information according to the target text, the classification layer is used to determine the category of the entity relationship in the target text according to the feature information and classification parameters of the target text, and the parameter optimization layer is used to optimize the classification parameters; the classification parameters are determined by the metadata of the text category.

[0119] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned entity relationship processing methods in texts, the methods comprising: obtaining a target text to be processed with entity relationships; inputting the target text into a preset entity relationship processing model to obtain the category of entity relationships in the target text; the entity relationship processing model is a model obtained by machine learning training using the feature information of a training text and the category of entity relationships in the training text as input; the entity relationship processing model comprises an encoding layer, a parameter optimization layer and a classification layer, the encoding layer being used to determine feature information based on the target text, the classification layer being used to determine the category of entity relationships in the target text based on the feature information and classification parameters of the target text, and the parameter optimization layer being used to optimize the classification parameters; the classification parameters are determined by the metadata of the text category.

[0120] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0121] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0122] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for processing entity relationships in text, characterized in that: Obtain the target text to be processed with respect to entity relations; The target text is input into a preset entity relationship processing model to obtain the category of the entity relationship in the target text, including: the encoding layer uses the BERT algorithm to vectorize all characters in the target text to obtain a feature vector matrix, and the feature vector matrix is ​​output as the feature information of the target text; the feature information of the target text is input into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer; the feature information of a preset number of target texts and the meta information of the category of the target text are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target text and the meta information of the category of the target text; The entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of entity relationships in the training text as input, and is used to determine the category of entity relationships in a text; The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on a target text. The classification layer is used to determine the category of the entity relationship in the target text based on the feature information and classification parameters of the target text. The parameter optimization layer is used to optimize the classification parameters. The classification parameters are determined by the meta-information of the text category.

2. The method for processing entity relationships in text according to claim 1, characterized in that: The classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer, including: The classification layer obtains the normalized values ​​corresponding to the preset categories of the entity relationships in the target text according to the feature vector matrix and classification parameters; The category corresponding to the normalized value with the largest value is selected as the category of the entity relationship in the target text.

3. The method for processing entity relationships in text according to claim 2, characterized in that: The feature information of a preset number of target texts and the meta information of the categories of the target texts are input into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta information of the categories of the target texts, including: The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm; The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm; The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm; The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

4. A device for processing entity relationships in text, characterized in that: An acquisition module is used to acquire a target text to be processed with respect to an entity relationship; A processing module, for inputting the target text into a preset entity relationship processing model to obtain the category of the entity relationship in the target text, including: using the BERT algorithm in the encoding layer to vectorize all characters in the target text to obtain a feature vector matrix, and outputting the feature vector matrix as feature information of the target text; inputting the feature information of the target text into the classification layer, and the classification layer determines the category of the entity relationship in the target text according to the feature information of the target text and the classification parameters called from the parameter optimization layer; inputting the feature information of a preset number of target texts and the meta information of the category of the target text into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target text and the meta information of the category of the target text; The entity relationship processing model is a model obtained by machine learning training using feature information of a training text and the category of entity relationships in the training text as input, and is used to determine the category of entity relationships in a text; The entity relationship processing model includes an encoding layer, a parameter optimization layer and a classification layer. The encoding layer is used to determine feature information based on a target text. The classification layer is used to determine the category of entity relationships in a target text based on the feature information and classification parameters of the target text. The parameter optimization layer is used to optimize the classification parameters. The classification parameters are determined by the meta-information of the text category.

5. The device for processing entity relationships in text according to claim 4, characterized in that: The processing module is specifically used for: during the process of inputting feature information of a preset number of target texts and the categories of the target texts into the parameter optimization layer, and the parameter optimization layer updates the current classification parameters according to the feature information of the target texts and the meta-information of the categories of the target texts: The feature vector matrix of a preset number of target texts is used as the key information of the attention mechanism algorithm; The meta-information of the categories of a preset number of target texts is processed using an MLP network to obtain a category matrix, and the category matrix is ​​used as query information for the attention mechanism algorithm; The meta-information of the categories of the preset number of target texts is used to obtain the loss value using softmax cross entropy, and the gradient value of each target text is calculated based on the loss value, and the gradient value is used as the value information of the attention mechanism algorithm; The gradient ratio is determined according to the key information, query information and value information of the attention mechanism algorithm, and the current classification parameters are updated according to the gradient value and gradient ratio.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for processing entity relationships in text as described in any one of claims 1 to 3 are implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for processing entity relationships in a text as described in any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Attention model training method and device, equipment and storage medium

    CN110929869A

  • System of text classification model and training method thereof

    CN111309919A