A method for generating structured information, an information generation device, and a storage medium
By cascading models, K extraction models are arranged sequentially to generate structured information corresponding to a preset generation format. This resolves the contradictions in the structured information extraction task and improves the applicability and accuracy of the models.
Patent Information
- Application Number
- CN202010448919.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-25
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2040-05-25
AI Technical Summary
In existing technologies, there is a contradiction between the structure of the extracted results and the uniformity of the model output in structured information extraction tasks, as well as a contradiction between the complexity of the language environment and the uniformity of the annotation results, which leads to a significant reduction in model performance.
By employing a model cascading approach, K extraction models are arranged sequentially. The output of the previous model and the text to be extracted are used as the input of the next model to generate structured information corresponding to the preset generation format. The influence of the output of the previous model on the current model is considered, which resolves the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results.
It enables the generation of structured information in a preset format under different target extraction tasks, meeting the needs of diversity, reducing error accumulation, and improving the applicability and accuracy of the model.
Smart Images

Figure CN113723138B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of structured information extraction, and specifically to a method for generating structured information, an information generating device, and a storage medium. Background Art
[0002] Throughout human development, knowledge has primarily been disseminated and accumulated in the form of natural language, resulting in a vast amount of information existing on the internet in the form of unstructured, plain text. However, with the rapid development of information technology and the continuous upgrading of hardware, particularly the advancement of big data and artificial intelligence, machines are gradually replacing humans in data processing and analysis. However, the ability of machines, or models, to utilize unstructured data is far weaker than their ability to utilize structured data. This has given rise to the task of structured information extraction (SIE). This task aims to extract structured information from unstructured natural language text for processing, analysis, and use by higher-level applications.
[0003] However, due to the contradiction between the structure of the extraction results and the uniformity of the model output, traditional solutions separate the extraction processes of each part of the structured information and perform them step by step like an assembly line. This causes the errors in each part of the assembly line to gradually accumulate, which greatly reduces the effectiveness of the final model. The subsequent proposed joint information extraction method combines the extraction processes of each element through parameter sharing and joint optimization objectives to perform end-to-end information extraction. Although this avoids error accumulation, in joint information extraction, the term extraction process and the structure combination process are still two separate and independent processes. The candidate set in the structure combination process must be generated by traversing the combination, which is often very large, resulting in an imbalance between positive and negative samples and greatly affecting the final effect of the model.
[0004] Furthermore, since annotation models can often only label a single entry, while the language environment can be extremely complex, traditional annotation-based information extraction methods simply define the structured information extraction task as a simple annotation problem, combining entries using clever annotation techniques. However, annotation models cannot solve problems such as overlapping annotation entries and multiple labels. Furthermore, when combining entries using annotation techniques, the label set becomes excessively large when there are many types of combinations. Therefore, traditional annotation-based information extraction methods are more effective in simple language environments. However, in even slightly more complex language environments, the model is unlikely to be able to correctly extract information.
[0005] Therefore, in the task of structured information extraction, the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results are problems that need to be solved urgently. Summary of the Invention
[0006] The embodiments of the present application provide a method for generating structured information, an information generation device, and a storage medium. Through model cascading, corresponding structured information extraction and generation are performed for different target extraction tasks. This is not only applicable to target extraction tasks in different situations, but also can resolve the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results.
[0007] In a first aspect, an embodiment of the present application provides a method for generating structured information, which is mainly applied to an information generation device, wherein the information generation device includes K extraction models corresponding to a target extraction task, wherein the target extraction task carries a preset generation format, and the K extraction models are obtained by training a text training sample using an encoder-decoder framework. The K extraction models are arranged in sequence, where K is an integer and K ≥ 2. The method may include:
[0008] Get the text to be extracted;
[0009] Structured information consisting of K extraction elements is generated according to the text to be extracted and the K extraction models, wherein the structured information consisting of the K extraction elements corresponds to the preset generation format, each of the extraction models outputs a set of extraction elements from the K sets of extraction elements, the types of the K extraction elements include enumeration values or extraction values, the input of the first extraction model is the text to be extracted, the input of the Mth extraction model is the text consisting of the text to be extracted and the first M-1 extraction elements, and each of the first M-1 extraction elements is traversed and output by the corresponding extraction model over the first M-1 extraction element sets, M is an integer, and 1<M≤K.
[0010] Through the above method, the output of the previous extraction model and the text to be extracted are used as the input of the next extraction model, realizing model cascading. Moreover, for different target extraction tasks, structured information corresponding to the preset generation format can be generated through this model cascade method, which greatly meets the needs of extracting structured information with differences. It also takes into account the influence of the output results of the previous extraction model on the output results of the current extraction model, and can resolve the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results.
[0011] Optionally, in combination with the first aspect above, in a first possible implementation, the K extracted elements include a first extracted element and K-1 Mth extracted elements, and generating structured information consisting of the K extracted elements based on the to-be-extracted text and the K extraction models may include:
[0012] Inputting the to-be-extracted text into the first extraction model to obtain a first set of extracted elements, wherein the first set of extracted elements includes the first extracted element, and the first extracted element is arranged at the first position among the K extracted elements;
[0013] Traversing the first M-1 extracted element sets to obtain at least one text consisting of the first M-1 extracted elements, wherein the first M-1 extracted elements have a pairing relationship;
[0014] Inputting the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain the M-th extraction element set, wherein the M-th extraction element set includes the M-th extraction element, and the M-th extraction element is arranged at the M-th position among the K extraction elements;
[0015] The first extracted element and K-1 of the M-th extracted elements generate structured information.
[0016] In the above manner, the extracted text is processed based on the first extraction model to obtain the first set of extracted elements arranged at the first position among the K extracted elements, and the extracted text and the text composed of M-1 extracted elements are processed based on the Mth extraction model to obtain the Mth set of extracted elements arranged at the Mth position, and the Mth set of extracted elements has K-1 elements. In this way, structured information corresponding to the preset generation format can be generated based on the first extracted element and the K-1 extracted elements, which greatly meets the needs of extracting structured information with differences.
[0017] Optionally, in combination with the first possible implementation of the first aspect, in a second possible implementation, the type of the first extraction element includes a first enumeration value or a first extraction value, and inputting the to-be-extracted text into the first extraction model to obtain a first set of extraction elements may include:
[0018] Inputting the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position;
[0019] When the first output value is greater than a preset threshold, a first enumeration value set is obtained based on the position information corresponding to the first output value, where the first enumeration value set includes the first enumeration value, and the first enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or
[0020] A first extraction value set is obtained based on the first starting position and the first ending position, where the first extraction value set includes the first extraction value, and the first extraction value includes an entity, a trigger word of the event, or an element value of the event.
[0021] Through the above method, the type of the first extracted element at the first position can be either the first enumeration value or the first extracted value, and the first extracted value can be understood as the information that the user wants to extract from the text to be extracted, and can be represented by the head and tail positions of the extracted element in the text to be extracted, or can be output using sequence labeling; and the first enumeration value can be understood as user-defined information that the user is more concerned about, and can be represented by the position ID of the extracted element in the text to be extracted, or can be output using sigmoid and other methods, providing a variety of expressions suitable for different extraction tasks, with strong applicability and portability.
[0022] Optionally, in combination with the first possible implementation of the first aspect, in a third possible implementation, the type of the Mth extraction element includes an Mth enumeration value or an Mth extraction value, and the text to be extracted and the text consisting of M-1 extraction elements are input into the Mth extraction model to obtain the Mth extraction element set, which may include:
[0023] Inputting the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, wherein the M-1 extraction elements include the enumeration value or the extraction value;
[0024] When the Mth output value is greater than a preset threshold, an Mth enumeration value set is obtained based on the position information corresponding to the Mth output value, the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or,
[0025] An Mth extraction value set is obtained based on the Mth starting position and the Mth ending position, the Mth extraction value set includes the Mth extraction value, and the Mth extraction value includes an entity, a trigger word of the event, or an element value of the event.
[0026] Through the above method, the type of the Mth extracted element at the Mth position can be either the Mth enumeration value or the Mth extraction value, and the Mth extraction value can be understood as the information that the user wants to extract from the text to be extracted, and can be represented by the head and tail positions of the extracted element in the text to be extracted, or can be output using sequence annotation; and the Mth enumeration value can be understood as user-defined information that the user is more concerned about, and can be represented by the position ID of the extracted element in the text to be extracted, or can be output using sigmoid and other methods. Similarly, it provides a variety of expressions suitable for different extraction tasks, which can be used not only for entity extraction tasks, but also for relationship extraction tasks and event extraction tasks.
[0027] Optionally, in combination with the second possible implementation manner of the first aspect above, in a fourth possible implementation manner, the first extraction model is composed of a preselected model of a first embedding layer, a preselected model of a first encoding layer, a preselected model of a first decoding layer, and a preselected model of a first output layer, and inputting the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position may include:
[0028] Inputting the text to be extracted into the preselected model of the first embedding layer to obtain a first word vector sequence;
[0029] Processing the first word vector sequence based on the preselected model of the first encoding layer to obtain a first semantic vector sequence;
[0030] The first semantic vector sequence is processed based on a preselected model of the first decoding layer and a preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
[0031] In the above manner, the text to be extracted is processed with the first embedding layer, the first encoding layer, the first decoding layer and the pre-selected model in the first output layer in the first extraction model. The pre-selected model of the first output layer can output a first output value for representing a first enumeration value, or a first starting position and a first ending position for representing a first extracted value, providing a variety of possible output methods, which is highly suitable for different extraction tasks.
[0032] Optionally, in combination with the third possible implementation manner of the first aspect above, in a fifth possible implementation manner, the Mth extraction model is composed of a pre-selected model of the Mth embedding layer, a pre-selected model of the Mth encoding layer, a pre-selected model of the Mth attention mechanism network layer, a pre-selected model of the Mth decoding layer, and a pre-selected model of the Mth output layer. The text to be extracted and the text consisting of M-1 extraction elements are input into the Mth extraction model to obtain the Mth output value, or the Mth starting position and the Mth ending position, including:
[0033] Input the text to be extracted and the text consisting of the first M-1 extracted elements into the pre-selected model of the Mth embedding layer to obtain a second word vector sequence and a third word vector sequence respectively;
[0034] Processing the second word vector and the M-1 third word vectors based on the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence, respectively;
[0035] Processing the second semantic vector sequence and the third semantic vector sequence based on the preselected model of the Mth attention mechanism network layer to obtain a first attention vector sequence;
[0036] The first attention vector sequence is processed based on the preselected model of the Mth decoding layer and the preselected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position.
[0037] Through the above method, the Mth embedding layer, Mth encoding layer, pre-selected model of the Mth attention mechanism network layer, Mth decoding layer, and pre-selected model of the Mth output layer in the Mth extraction model are used to process the text to be extracted and the text consisting of M-1 extracted elements. The pre-selected model of the Mth output layer can output the Mth output value used to represent the Mth enumeration value, or the Mth starting position and Mth ending position used to represent the Mth extracted value, providing multiple possible output methods and being highly suitable for different extraction tasks. Furthermore, the pre-selected model based on the Mth attention mechanism network layer can fuse the M-1 extracted elements output by the previous M-1 extraction models with the text to be extracted, taking into account the impact of the output results of the previous extraction models on the output results of the current extraction model, so that the final output results of the current extraction model meet the user's needs to the greatest extent.
[0038] Optionally, in combination with the first aspect above, in a sixth possible implementation manner, the method may further include:
[0039] Obtaining the text training sample and a text annotation set, wherein the text annotation set includes Q groups of preset structured information, each group of the preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample;
[0040] Determine a first structured information output set based on the text training sample, the text annotation set, and K initial text extraction models, each of the initial text extraction models outputs an output element in the first structured information output set, the input of the first initial text extraction model is the text training sample and the Q first text annotations, the input of the Mth initial text extraction model includes the text training sample and an element set consisting of the first M-1 deduplication label sets, each text annotation in the first M-1 deduplication label sets is correspondingly output by the first M-1 initial text extraction models, and the Q first text annotations are respectively arranged in the first position in each group of the preset structured information;
[0041] Processing the first structured information output set and the text annotation set using a loss function to obtain a loss function value, wherein the loss function value is used to represent the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summation of preset loss functions corresponding to the K initial text extraction models;
[0042] The K extraction models are obtained by training based on the loss function value and the K initial text extraction models.
[0043] In the above manner, the difference between the first structured information output set and the text annotation set is calculated from the overall loss function, and the K initial text extraction models are trained as a whole based on the loss function value, so as to obtain K extraction models that can be used to generate the aforementioned structured information.
[0044] Optionally, in combination with the sixth possible implementation of the first aspect, in a seventh possible implementation, the method may further include:
[0045] Inputting the text training sample into a first initial text extraction model to obtain a first output element set;
[0046] Processing the Q first text annotations to obtain a first deduplication label set, wherein the start position information and the end position information of each first text annotation in the first deduplication label set are different, or the output value of each first text annotation is different;
[0047] The first output element set and the first deduplication label set are processed by a preset loss function to obtain a first loss value, which is used to characterize the difference between each output element in the first output element set and each first text annotation in the first deduplication label set.
[0048] Through the above method, the Q first text annotations in the Q groups of preset structured information annotated by the user are deduplicated, so that there is no overlapping information in the first deduplicated label set, and the first loss value finally obtained lays the foundation for the overall loss function value.
[0049] Optionally, in combination with the sixth or seventh possible implementation of the first aspect, in an eighth possible implementation, the method may further include:
[0050] Sampling the element combinations formed by the first M-1 deduplication label sets to obtain a first sampling set, where the first sampling set includes M-1 sampling elements, and the M-1 sampling elements are respectively text annotations corresponding to any one loss value in the corresponding M-1th deduplication label set that is less than the loss threshold;
[0051] Inputting the text training sample and the first sampling set into the Mth initial text extraction model to obtain the Mth output element set;
[0052] Processing the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the start position information and the end position information of each M-th text annotation in the M-th duplicate removal label set are different, or the output value of each text annotation is different, and the Q M-th text annotations are respectively arranged at the M-th position of each set of the preset structured information;
[0053] The Mth output element set and the Mth deduplication label set are processed by the preset loss function to obtain the Mth loss value, and the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each Mth text annotation in the Mth deduplication label set.
[0054] Through the above method, the element combinations formed by the first M-1 output element sets are sampled, and the text training samples are combined with the first sampling set to be input into the Mth initial text extraction model. This can ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element is the result of the output under the premise of correct input, which reduces the possibility of erroneous output to a certain extent and solves the training contradictions caused by the mutual cooperation between the extraction models.
[0055] Optionally, in combination with the sixth or seventh possible implementation of the first aspect, in an eighth possible implementation, the method may further include:
[0056] Negative sampling is performed on the element combination formed by the first M-1 deduplication label sets to obtain a first negative sampling set, wherein the first negative sampling set includes X negative sampling elements and Y sampling elements, each of the negative sampling elements is a text annotation corresponding to any one of the loss values in the corresponding deduplication label set that is greater than the loss threshold, X+Y=M-1, and X and Y are positive integers;
[0057] Inputting the text training sample and the first negative sampling set into the Mth initial text extraction model to obtain an Mth output element set;
[0058] Processing the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the output corresponding to the text annotation at each I-th position in the M-th duplicate removal label set is empty, each I-th position is the same as the position of each negative sampling element, and I is a positive integer;
[0059] The Mth output element set and the Mth deduplication label set are processed by a preset loss function to obtain an Mth loss value, where the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each text annotation in the Mth deduplication label set.
[0060] Through the above method, negative sampling is performed on the element combination formed by the first M-1 deduplicated label sets, and the text training sample is combined with the first negative sampling set to be input into the Mth initial text extraction model. This can ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element can output the result under the premise of incorrect input, and the negative sampling elements can be used to correct the actual output Mth output element set, which reduces the possibility of incorrect output to a certain extent and solves the training contradictions caused by the mutual cooperation between the extraction models.
[0061] In a second aspect, an embodiment of the present application provides an information generation device, which may include K extraction models corresponding to a target extraction task, wherein the target extraction task carries a preset generation format, and the K extraction models are obtained by performing model training on text training samples using an encoder-decoder framework. The K extraction models are arranged in sequence, where K is an integer and K ≥ 2. The information generation device may include:
[0062] An acquisition unit, used to acquire the text to be extracted;
[0063] A processing unit is used to generate structured information consisting of K extraction elements based on the text to be extracted and the K extraction models obtained by the acquisition unit, wherein the structured information consisting of the K extraction elements corresponds to the preset generation format, each of the extraction models outputs a set of extraction elements in the K extraction element sets, and the types of the K extraction elements include enumeration values or extraction values. The input of the first extraction model is the text to be extracted, and the input of the Mth extraction model is the text consisting of the text to be extracted and the first M-1 extraction elements. Each of the first M-1 extraction elements is traversed and output by the corresponding extraction model for the first M-1 extraction element sets, M is an integer, and 1<M≤K.
[0064] Optionally, in combination with the second aspect, in a first possible implementation, the K extracted elements include a first extracted element and K-1 Mth extracted elements, and the processing unit may include:
[0065] a processing module, configured to input the to-be-extracted text into the first extraction model to obtain a first set of extracted elements, wherein the first set of extracted elements includes the first extracted element, and the first extracted element is arranged at a first position among the K extracted elements;
[0066] The processing module is used to traverse the first M-1 extraction element sets to obtain text composed of the first M-1 extraction elements, wherein the first M-1 extraction elements have a pairing relationship;
[0067] The processing module is configured to input the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain an M-th extraction element set, wherein the M-th extraction element set includes the M-th extraction element, and the M-th extraction element is arranged at the M-th position among the K extraction elements;
[0068] The processing module is configured to generate structured information by combining the first extracted element and K-1 of the M-th extracted elements.
[0069] Optionally, in combination with the first possible implementation of the second aspect, in a second possible implementation, the type of the first extracted element may include a first enumeration value or a first extracted value;
[0070] The processing module is configured to input the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position;
[0071] The processing module is configured to obtain a first enumeration value set based on position information corresponding to the first output value when the first output value is greater than a preset threshold, wherein the first enumeration value set includes the first enumeration value, and the first enumeration value may include an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or
[0072] The processing module is used to obtain a first extraction value set based on the first starting position and the first ending position. The first extraction value set includes the first extraction value, and the first extraction value may include an entity, a trigger word of the event, or an element value of the event.
[0073] Optionally, in combination with the first possible implementation of the second aspect, in a third possible implementation, the type of the Mth extracted element may include an Mth enumeration value or an Mth extracted value;
[0074] The processing module is configured to input the text to be extracted and the text consisting of M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, wherein the types of the M-1 extraction elements may include the enumeration value or the extraction value;
[0075] The processing module is configured to, when the Mth output value is greater than a preset threshold, obtain an Mth enumeration value set based on position information corresponding to the Mth output value, wherein the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value may include an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or
[0076] The processing module is used to obtain the Mth extraction value set based on the Mth starting position and the Mth ending position, the Mth extraction value set includes the Mth extraction value, and the Mth extraction value may include an entity, a trigger word of the event, or an element value of the event.
[0077] Optionally, in combination with the second possible implementation manner of the second aspect above, in a fourth possible implementation manner, the first extraction model is composed of a preselected model of the first embedding layer, a preselected model of the first encoding layer, a preselected model of the first decoding layer, and a preselected model of the first output layer;
[0078] The processing module is configured to input the text to be extracted into a preselected model of the first embedding layer to obtain a first word vector sequence;
[0079] The processing module is configured to process the first word vector sequence according to the preselected model of the first coding layer to obtain a first semantic vector sequence;
[0080] The processing module is used to process the first semantic vector sequence according to the preselected model of the first decoding layer and the preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
[0081] Optionally, in combination with the third possible implementation manner of the second aspect above, in a fifth possible implementation manner, the M-th extraction model is composed of a pre-selected model of the M-th embedding layer, a pre-selected model of the M-th encoding layer, a pre-selected model of the M-th attention mechanism network layer, a pre-selected model of the M-th decoding layer, and a pre-selected model of the M-th output layer;
[0082] The processing module is used to input the text to be extracted and the text consisting of the first M-1 extracted elements into the pre-selected model of the Mth embedding layer to obtain a second word vector sequence and a third word vector sequence respectively;
[0083] The processing module is used to process the second word vector sequence and the third word vector sequence according to the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence respectively;
[0084] The processing module is configured to process the second semantic vector sequence and the third semantic vector sequence according to the preselected model of the Mth attention mechanism network layer to obtain a first attention vector sequence;
[0085] The processing module is used to process the first attention vector sequence according to the pre-selected model of the Mth decoding layer and the pre-selected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position.
[0086] Optionally, in combination with the second aspect above, in a sixth possible implementation, the information generating device may further include: a training unit;
[0087] The acquisition unit is used to acquire the text training sample and a text annotation set, wherein the text annotation set includes Q groups of preset structured information, each group of the preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample;
[0088] The processing unit is used to determine a first structured information output set based on the text training sample, the text annotation set and K initial text extraction models, each of the initial text extraction models outputs an output element in the first structured information output set, the input of the first initial text extraction model is the text training sample and the Q first text annotations, the input of the Mth initial text extraction model includes the text training sample and an element set consisting of the first M-1 deduplication label sets, each text annotation in the first M-1 deduplication label sets is obtained by deduplication based on the corresponding Q Mth text annotations, the Q first text annotations are respectively arranged at the first position in each group of the preset structured information, and the Q Mth text annotations are respectively arranged at the Mth position in each group of the preset structured information;
[0089] The processing unit is configured to process the first structured information output set and the text annotation set using a loss function to obtain a loss function value, wherein the loss function value is used to characterize the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summation of preset loss functions corresponding to the K initial text extraction models;
[0090] The training unit is used to train the K extraction models based on the loss function value and the K initial text extraction models.
[0091] Optionally, in combination with the sixth possible implementation of the second aspect, in a seventh possible implementation, the processing unit is configured to input the text training sample into a first initial text extraction model to obtain a first output element set;
[0092] The processing unit is configured to process the Q first text annotations to obtain a first deduplication label set, wherein the start position information and the end position information of each first text annotation in the first deduplication label set are different, or the output value of each first text annotation is different, and the Q first text annotations are respectively arranged at the first position in each set of the preset structured information;
[0093] The processing unit is used to process the first output element set and the first deduplication label set through a preset loss function to obtain a first loss value, wherein the first loss value is used to characterize the difference between each output element in the first output element set and each first text annotation in the first deduplication label set.
[0094] Optionally, in combination with the sixth or seventh possible implementation of the second aspect, in an eighth possible implementation, the information generating device may further include: a sampling unit;
[0095] The sampling unit is configured to sample a combination of elements formed by the first M-1 deduplication label sets to obtain a first sampling set, wherein the first sampling set includes M-1 sampling elements, and the M-1 sampling elements are respectively the M-1th text annotations corresponding to any one loss value in the corresponding M-1th deduplication label set is less than a loss threshold;
[0096] The processing unit is configured to input the text training sample and the first sampling set into an M-th initial text extraction model to obtain an M-th output element set;
[0097] The processing unit is configured to process the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the start position information and the end position information of each M-th text annotation in the M-th duplicate removal label set are different, or the output value of each text annotation is different, and the Q M-th text annotations are respectively arranged at the M-th position of each set of the preset structured information;
[0098] The processing unit is used to process the Mth output element set and the Mth deduplication label set through the preset loss function to obtain the Mth loss value, and the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each Mth text annotation in the Mth deduplication label set.
[0099] Optionally, in combination with the sixth or seventh possible implementation of the second aspect, in a ninth possible implementation, the information generating device may further include: a negative sampling unit;
[0100] The negative sampling unit is configured to perform negative sampling on a combination of elements formed by the first M-1 deduplication label sets to obtain a first negative sampling set, wherein the first negative sampling set includes X negative sampling elements and Y sampling elements, each of the negative sampling elements being a text annotation corresponding to any one of the deduplication label sets when the loss value is greater than a loss threshold, X+Y=M-1, and X and Y are integers;
[0101] The processing unit is configured to input the text training sample and the first negative sampling set into the M-th initial text extraction model to obtain an M-th output element set;
[0102] The processing unit is configured to process the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the output corresponding to the text annotation at each I-th position in the M-th duplicate removal label set is empty, each I-th position is the same as the position of each negative sampling element, and I is a positive integer;
[0103] The processing unit is used to process the Mth output element set and the Mth deduplication label set through a preset loss function to obtain an Mth loss value, and the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each text annotation in the Mth deduplication label set.
[0104] In a third aspect, an embodiment of the present application provides a computer-readable storage medium comprising instructions, which, when executed on a computer, enables the computer to execute a method as in the first aspect or any possible implementation of the first aspect.
[0105] In a fourth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method of the first aspect or any possible implementation of the first aspect.
[0106] In a fifth aspect, an embodiment of the present application provides a chip system, which includes a processor for supporting an information generation device in implementing the functions involved in the first aspect or any possible implementation of the first aspect. In one possible design, the chip system also includes a memory for storing program instructions and data necessary for the information generation device. The chip system can be composed of a chip or can include a chip and other discrete devices.
[0107] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0108] In an embodiment of the present application, since the K extraction models corresponding to the target extraction task are arranged in sequence, by taking the text to be extracted as the input of the first extraction model, and taking the text to be extracted and the text consisting of the first M-1 extraction elements as the input of the Mth extraction model, each extraction model can output one set of extraction elements from the K sets of extraction elements, and each of the first M-1 extraction elements is traversed and output by the corresponding extraction model for the first M-1 sets of extraction elements, so that structured information consisting of K extraction elements is generated based on the text to be extracted and the K extraction models, and the structured information consisting of the K extraction elements corresponds to the preset generation format carried by the target extraction task. Through the above method, the output of the previous extraction model and the text to be extracted are used as the input of the next extraction model, realizing model cascading. Moreover, for different target extraction tasks, structured information corresponding to the preset generation format can be generated through this model cascade method, which greatly meets the needs of extracting structured information with differences. It also takes into account the influence of the output results of the previous extraction model on the output results of the current extraction model, and can resolve the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results. BRIEF DESCRIPTION OF THE DRAWINGS
[0109] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application.
[0110] Figure 1a This is a schematic diagram of a system architecture provided in an embodiment of the present application;
[0111] Figure 1b This is the MRC framework model diagram provided in the embodiments of the present application;
[0112] Figure 2 This is a schematic diagram of an embodiment of a method for generating structured information provided in an embodiment of the present application;
[0113] Figure 3 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0114] Figure 4 This is a schematic diagram of an encoder-decoder framework provided in an embodiment of the present application;
[0115] Figure 5 Schematic diagram of the structure of the preselected model of the embedding layer provided in the embodiment of the present application;
[0116] Figure 6Schematic diagram of the structure of the pre-selected model of the coding layer provided in the embodiment of the present application;
[0117] Figure 7 Schematic diagram of the structure of the pre-selected model of the decoding layer provided in the embodiment of the present application;
[0118] Figure 8 Schematic diagram of the structure of the preselected model of the output layer provided in the embodiment of the present application;
[0119] Figure 9 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0120] Figure 10 This is a schematic diagram of an extraction task targeting schema constraint attribute / relationship extraction provided in an embodiment of the present application;
[0121] Figure 11 Schematic diagram of an extraction task targeting open domain attribute / relationship extraction provided in an embodiment of the present application;
[0122] Figure 12 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0123] Figure 13 It is a schematic diagram of an extraction task with entity extraction as the target provided in an embodiment of the present application;
[0124] Figure 14 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0125] Figure 15 It is a schematic diagram of an extraction task with event extraction as the target provided in an embodiment of the present application;
[0126] Figure 16 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0127] Figure 17 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0128] Figure 18 is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application;
[0129] Figure 19 This is a schematic diagram of the hardware structure of the communication device provided in the embodiment of the present application;
[0130] Figure 20 It is a structural diagram of an information generating device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0131] The embodiments of the present application provide a method for generating structured information, an information generating device, and a storage medium, which are used to extract and generate corresponding structured information for different target extraction tasks through model cascading. It is not only suitable for target extraction tasks in different situations, but also can resolve the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results.
[0132] The terms "first," "second," "third," "fourth," etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential sequence. It should be understood that the numbers used in this way are interchangeable where appropriate so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or apparatus.
[0133] With the rapid development of information technology, the demand for extracting relevant information from text using deep learning models using massive amounts of data is growing. However, the ability of machines or models to utilize unstructured information is far weaker than their ability to utilize structured information. Therefore, the task of structured information extraction has emerged. In traditional joint information extraction, since the term extraction process and the structure combination process are still two separate and independent processes, the model output is single. However, the structured information extraction results must include not only the term type, the relationship between terms, and the relationship type, etc., which clearly shows that the joint information extraction process still faces a contradiction between the singleness of the model output and the structured nature of the structured information extraction results. In addition, in the traditional annotated information extraction process, only one relationship between annotated terms can be predicted. Due to the complexity of the language environment, traditional annotated information extraction cannot solve problems such as overlapping terms and multiple labels. Therefore, the traditional annotated information extraction process still faces a contradiction between the singleness of the annotation results and the complexity of the language environment.
[0134] In order to solve the above problems, the present application provides a method for generating structured information. This method is mainly used in the scenario of extracting text and generating corresponding structured information. Figure 1a , is a schematic diagram of a system architecture provided in an embodiment of the present application. Figure 1aAs can be seen, the system architecture includes K extraction models, such as: Model_1, Model_2, Model_3, ..., Model_K. Each extraction model corresponds to its own input (Input_i) and output (Output_i), and these K extraction models are sorted in sequence.
[0135] For each extraction model input by the user, you can refer to Figure 1b To understand, Figure 1b This is the MRC framework model diagram provided in the embodiment of this application, from Figure 1b It can be seen that the input of the extraction model Model_i corresponding to the extraction element E_i is the text to be extracted and the text composed of the extraction elements output by the preceding i-1 extraction models of the extraction model Model_i, that is, [E1, E2, ..., E_(i-1)]. The type of the corresponding output E_i of the extraction model Model_i can be an extraction value or an enumeration value. If the type of E_i is an extraction value, then Output_i should be output in the form of sequence annotation, and all the entries in the text to be extracted that can form structured information with [E1, E2, ..., E_(i-1)] are annotated. The corresponding Model_i is a single type annotation model; if the type of E_i is an enumeration value, then Output_i should be output in the form of Sigmoid discrimination or Softmax classification, and all the enumeration values in the text to be extracted that can form structured information with [E1, E2, ..., E_(i-1)] are annotated. The corresponding Model_i is a multi-type discrimination model or a single-type classification model.
[0136] For example, for the first extraction model (Model_1), the input of Model_1 is the text to be extracted, and the corresponding output is a set consisting of Q extracted elements E1, and each extracted element E1 is different; for the second extraction model (Model_2), by traversing the set consisting of Q extracted elements E1 output by Model_1, any one extracted element E1 is selected from the set, so that the input of Model_2 includes the text to be extracted and any one extracted element E1 among the Q extracted elements E1, and The corresponding output is a set consisting of L extracted elements E2. At this time, the L extracted elements E2 all have a certain pairing relationship with the input extracted element E1. For the third extraction model (Model_3), the input of Model_3 includes the text to be extracted and the text consisting of the extracted elements E1 and E2. At this time, the extracted elements E1 and E2 have a certain pairing relationship, and the extracted element E2 is any one of the set consisting of L extracted elements E2. The corresponding output is a set consisting of N extracted elements E3. Similarly, for the Kth extraction model (Model_K), the input of Model_K is the text to be extracted and the text consisting of the first K-1 extracted elements. Each of the K-1 extracted elements is output by the corresponding extraction model, and the corresponding output is a set consisting of J extracted elements Ek. In this way, the corresponding structured information can be generated for the K extracted elements with pairing relationships output by these K extraction models.
[0137] It should be noted that the aforementioned Q extracted elements E1, L extracted elements E2, N extracted elements E3, ..., J extracted elements Ek will not be limited in the embodiment of the present application in terms of the number of extracted elements E1, extracted elements E2, extracted elements E3, ..., extracted elements Ek; in addition, the number of K extraction models is an integer greater than 1.
[0138] In addition, the aforementioned K extraction models can be called by the information generating device and can be used by the information generating device to generate corresponding structured information for different target extraction tasks. The information generating device will not be limited in the embodiment of the present application. For example, the aforementioned information generating device includes but is not limited to a server, etc.
[0139] The method for generating structured information in this embodiment is applicable not only to the system architecture shown in FIG. 1 , but also to other system architectures, which are not specifically limited here.
[0140] To better understand the solution proposed in the embodiment of this application, the specific process of this embodiment is introduced below. Figure 2, is a schematic diagram of an embodiment of a method for generating structured information provided in an embodiment of the present application. The generation method may include:
[0141] 201. Obtain the text to be extracted.
[0142] In this embodiment, the text to be extracted may include but is not limited to unstructured corpus, text, etc., and will not be specifically limited in the embodiments of this application.
[0143] 202. Generate structured information consisting of K extracted elements based on the text to be extracted and K extraction models, wherein the structured information consisting of the K extracted elements corresponds to a preset generation format, each extraction model outputs a set of extracted elements from the K sets of extracted elements, the types of the K extracted elements include enumeration values or extraction values, the input of the first extraction model is the text to be extracted, the input of the Mth extraction model is the text to be extracted and the text consisting of the first M-1 extracted elements, each of the first M-1 extracted elements is traversed and output by the corresponding extraction model over the first M-1 sets of extracted elements, M and K are integers, and 1<M≤K, K≥2.
[0144] In this embodiment, since the information generating device can include or call K extraction models corresponding to the target extraction task, and corresponding preset generation formats will be pre-set for different target extraction tasks, the preset generation format is set mainly to make the arrangement order of the K extraction elements in the final generated structured information correspond to the preset generation format, so as to meet the needs of different users for different extraction tasks.
[0145] Generally speaking, the number of models in the K extracted models is equal to the number of elements in the preset generation format. For example, if the preset generation format is [e1, e2, e3], then the number of models in the extracted models should be 3. In actual applications, the number of models in the extracted models can also be other values, as long as the value is equal to the number of elements in the preset generation format. This will not be limited in the embodiments of this application.
[0146] For example, if the target extraction task is an entity extraction task, and the entity extraction task is generally used to extract a tuple consisting of an entity and an entity type, the user can pre-set the type of form in which the structured information of the generated tuple is represented for the entity extraction task according to actual needs, such as: [entity, entity label] or [entity label, entity], etc., which will not be limited in the specific embodiments of this application.
[0147] It is understood that the aforementioned K extraction models are obtained by sequentially training the text training samples using the encoder-decoder framework and are arranged in sequence. In addition, the number of models in the K extraction models is an integer greater than 1.
[0148] Therefore, users can set preset generation formats for different target extraction tasks according to different actual needs. In this way, after obtaining the text to be extracted, the text to be extracted can be input into the first extraction model, and the first extraction element set output by the first extraction model is traversed, thereby selecting any one (such as: E1) from the extraction elements contained in this first extraction element set, and inputting it into the second extraction model in combination with the text to be extracted; in this way, the second extraction element set output by the second extraction model can be traversed, and any one (such as: E2) from the extraction elements contained in the second extraction element set can be selected to form a text with the input E1, that is, to form an instance: [E1, E2], and input it into the third extraction model in combination with the text to be extracted. It should be noted that E1 and E2 at this time are two extraction elements with a pairing relationship. By analogy, the input of the Mth extraction model includes the text to be extracted and the text composed of the first M-1 extracted elements, that is: [E1, E2,…, E(M-1)], and each extracted element in the text [E1, E2,…, E(M-1)] composed of these M-1 extracted elements is output by the first M-1 corresponding extraction models, such as: E1 is obtained by traversing the first set of extracted elements output by the first extraction model, and is any extracted element in the first set of extracted elements, and E2 is obtained by traversing the second set of extracted elements output by the second extraction model, and is any extracted element in the second set of extracted elements, and E2 is paired with E1, that is, E1 and E2 are extracted elements that can be used to form structured information. By analogy, E(M-1) is obtained by traversing the M-1th set of extracted elements output by the M-1th extraction model, and is any extracted element in the M-1th set of extracted elements.
[0149] In this way, by analogy, the input of the K-th extraction model includes the text to be extracted and the text composed of the first K-1 extraction elements, that is: [E1, E2, ..., E(M-1), ..., E(K-1)], and each extraction element in the text composed of K-1 extraction elements [E1, E2, ..., E(M-1), ..., E(K-1)] is output by the corresponding extraction model, and there is a pairing relationship between E1, E2, ..., E(M-1), ..., and E(K-1), that is, E1 and E2 are paired. It is an extracted element that can be used to form structured information. For example, E1 is obtained by traversing the first set of extracted elements output by the first extraction model and is any first extracted element in the first set of extracted elements. E2 is obtained by traversing the second set of extracted elements output by the second extraction model and is any second extracted element in the second set of extracted elements. E2 is paired with E1, that is, E1 and E2 are extracted elements that can be used to form structured information. Similarly, E(K-1) is obtained by traversing the K-1th set of extracted elements output by the K-1th extraction model and is any one of the K-1th set of extracted elements. In this way, the text to be extracted and the text composed of the first K-1 extracted elements [E1, E2,…, E(M-1),…, E(K-1)] are input into the K-th extraction model, and then the K-th extraction model can output the corresponding M-th extraction element set, which includes the M-th extraction element, such as E(K).
[0150] In addition, it should be noted that the types of the aforementioned K extraction elements can include enumeration values or extraction values. Enumeration values can be understood as user-defined, user-concerned, and judgmental information, while extraction values can be understood as information that needs to be extracted from the text to be extracted.
[0151] In addition, the aforementioned first extraction element set, second extraction element set, ..., Mth extraction element set, etc. can correspondingly include at least one extraction element. In actual applications, each extraction element set may also not include an extraction element, but an empty set. In this case, it means that the information to be extracted does not exist in the text to be extracted.
[0152] It should be further explained that the target extraction tasks described above may include, but are not limited to, relationship extraction tasks, event extraction tasks, etc. in addition to entity extraction tasks. In the future, they may also be five-tuple extraction tasks, six-tuple extraction tasks, etc., which will not be limited in the specific embodiments of this application.
[0153] In addition, after obtaining the corresponding K sets of extracted elements through K extraction models, they can be combined with a preset generation format to generate structured information that corresponds one-to-one to the preset generation format.
[0154] For example, if the target extraction task is entity extraction, and the corresponding preset generation format is [name, place of origin], then the structured information generated by the two extracted elements [E1, E2] will conform to the format of [name, place of origin], such as [Zhang San, Guangdong Shenzhen]. In actual applications, there are other preset generation formats such as [name, age] and other structured information such as [Li Si, 18], which will not be limited in the embodiments of this application.
[0155] For example, if the target extraction task is a relationship extraction task, and the corresponding preset generation format is [father's name, son, son's name], then the structured information generated by the three extracted elements [E1, E2, E3] will conform to the format of [father's name, father and son, son's name], such as [Zhang San, son, Zhang Er], etc. Specifically, it can be understood as:
[0156] Suppose the text to be extracted is "Zhang San's sons are Zhang Wu and Zhang Liu, and Xiao Ming's father is Xiao Wang". Then, the first extraction model will take "Zhang San's sons are Zhang Wu and Zhang Liu, and Xiao Ming's father is Xiao Wang" as input, and output the first extraction element set as: [Zhang San, Xiao Wang]. In this way, by traversing each first extraction element in the first extraction element set, selecting "Zhang San", and combining it with the text to be extracted as the input of the second extraction model, the second extraction set output by the second extraction model is: [son]; similarly, traversing the text composed of [Zhang San, son], and combining it with the text to be extracted and inputting it into the third extraction model, the third extraction element set output by the third extraction model is: [Zhang Wu, Zhang Liu]. In this way, the structured information that can be generated is [Zhang San, son, Zhang Wu], [Zhang San, son, Zhang Liu]. It should be noted that the generation of corresponding structured information for "Xiao Wang" can also be understood by referring to the process of "Zhang San", which will not be repeated here.
[0157] Through the above method, the output of the previous extraction model and the text to be extracted are used as the input of the next extraction model, realizing model cascading. Moreover, for different target extraction tasks, structured information corresponding to the preset generation format can be generated through this model cascade method, which greatly meets the needs of extracting structured information with differences. It also takes into account the influence of the output results of the previous extraction model on the output results of the current extraction model, and can resolve the contradiction between the structure of the extraction results and the uniformity of the model output, as well as the contradiction between the complexity of the language environment and the uniformity of the annotation results.
[0158] In the above Figure 2Based on the above description, in order to further understand the solution proposed in the embodiment of the present application, the specific process of the embodiment will be introduced from the first extraction model and the Mth extraction model (1<M≤K). Figure 3 , is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0159] 301. Obtain the text to be extracted.
[0160] In this embodiment, step 301 can refer to the aforementioned Figure 2 The contents described in step 201 in FIG. 1 can be understood for simplicity and will not be described in detail here.
[0161] 302. Input the text to be extracted into the first extraction model to obtain a first set of extracted elements. The first set of extracted elements includes the first extracted element, and the first extracted element is arranged in the first position among the K extracted elements.
[0162] In this embodiment, the first extraction model is sorted in the first position among the K extraction models, so after obtaining the text to be extracted, the text to be extracted can be input into the first extraction model, and then the first extraction element set is obtained accordingly, and each extraction element included in the first extraction element set will be sorted in the first position among these K extraction elements.
[0163] Optionally, in some embodiments, since the type of the first extracted element sorted in the first position can be either the first extracted value or the first enumeration value, the main difference between the first extracted value and the first enumeration value is that the first extracted value can be output using a sequence annotation method, that is, the starting position and the ending position of the extracted element in the text to be extracted are used to represent it, while the first enumeration value can be output using a Sigmoid discriminant method, that is, the position ID of the extracted element in the text to be extracted is used to represent it. Therefore, for different output methods, the input of the text to be extracted into the first extraction model in step 302 to obtain the set of first extracted elements can also be understood in the following way:
[0164] Input the text to be extracted into the first extraction model to obtain the first output value, or the first starting position and the first ending position;
[0165] When the first output value is greater than a preset threshold, a first enumeration value set is obtained based on the position information corresponding to the first output value, the first enumeration value set includes a first enumeration value, and the first enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of an event; or,
[0166] A first extraction value is obtained based on the first start position and the first end position, where the first extraction value includes an entity, a trigger word of an event, or an element value of an event.
[0167] That is to say, after obtaining the text to be extracted, the text to be extracted is input into the first extraction model, and the first extraction model will output in different output modes.
[0168] The first type: The first extraction model outputs a first output value. If the first output value is greater than a preset threshold, it means that an enumeration value does exist at the position where the first output value is located. Then, based on the position information corresponding to the first output value, the first enumeration value set at the position can be extracted. The first enumeration value set includes the first enumeration value, and each first extracted value is different.
[0169] It is understandable that the first enumeration value may include but is not limited to entity tags, entity relationships, attribute types of events, or element types of events, etc., and will not be specifically limited in the embodiments of this application.
[0170] The second type: The first extraction model outputs the first starting position and the first ending position. This means that in the text to be extracted, there are corresponding extraction values at the first starting position and the first ending position. At this time, the first extraction value set can be extracted based on the first starting position and the first ending position. The first extraction value set includes at least one first extraction value, and each first extraction value is different.
[0171] It is understandable that the first extracted value may include but is not limited to an entity, a trigger word of an event, or an element value of an event, etc., and will not be specifically limited in the embodiments of the present application.
[0172] It should be noted that the premise of the first enumeration value obtained in the first way or the first extraction value obtained in the second way is that the first extraction model will selectively output the format of the pre-set element at the first position in the preset generation format.
[0173] For example, if the preset generation format is [name, female], it is obvious that "name" in the first position is an entity, and "female" in the second position is an entity tag, then the first extraction model will choose the second method to extract all the first extraction values in the text to be extracted as "name", thereby obtaining the first extraction value set. It should be understood that if the preset generation format is [male, name], it is obvious that "male" in the first position is an entity tag, and "name" in the second position is an entity, then the first extraction model will choose the first method to extract all the first enumeration values in the text to be extracted as "male", thereby obtaining the first enumeration value set. In actual applications, there may be other examples, which will not be limited to the specific examples in the embodiments of this application.
[0174] Alternatively, in some other embodiments, the general model can be composed of an embedding layer, an encoding layer, a decoding layer, and an output layer. Figure 4 , is a schematic diagram of an encoder-decoder framework provided in an embodiment of the present application. Figure 4 As can be seen from the figure, the first extraction model (Model_1) includes an embedding layer, an encoding layer, a decoding layer, and an output layer, and takes the text to be extracted as the input of the embedding layer, and outputs the corresponding extracted elements after being processed by the encoding layer, decoding layer, and output layer. The second extraction model (Model_2), the third extraction model (Model_3), and so on to the K-th extraction model (Model_K) are all composed of corresponding embedding layers, encoding layers, attention mechanism network layers, decoding layers, and output layers. The difference lies in the difference in the input of the embedding layer in the second extraction model (Model_2), the third extraction model (Model_3), and so on to the K-th extraction model (Model_K). For example, the input of the embedding layer in Model_2 is the text to be extracted and the output of Model_1, the input of the embedding layer in Model_3 is the text to be extracted, the output of Model_1, and the output of Model_2. Similarly, the input of the embedding layer in Model_K is the text to be extracted, the output of Model_1, the output of Model_2, ..., and the output of Model_(K-1).
[0175] It is worth noting that the embedding layer and encoding layer in Model_1, Model_2, ..., Model_K can share parameters, while the decoding layer in Model_1, Model_2, ..., Model_K cannot share parameters. In addition, the attention mechanism network layer in Model_2, ..., Model_K cannot share parameters either.
[0176] Optionally, in the above Figure 4Based on the described framework, see Figure 5 , is a schematic diagram of the structure of the preselected model of the embedding layer provided in the embodiment of the present application. Figure 5 As can be seen from the left embedding layer in the figure, the candidate models of the embedding layer can include bidirectional encoder representation from transformers (BERT), word embedding, character embedding, absolute position embedding, relative position embedding, etc., which can be used to vectorize each Chinese character in the input to convert it into a word vector sequence. In the process of generating structured information, users can select the required model from the pre-selected models of the embedding layer according to actual needs and drag it to Figure 4 Configure the position of the embedding layer in, for example, select BERT and POS Embedding to configure, so as to obtain the following Figure 5 Preselected models for the embedding layer shown.
[0177] It is understandable that one or more of BERT, Word Embedding, Char Embedding, POSEmbedding, and Position Embedding can be selected to configure the embedding layer, indicating that multiple embeddings are output in parallel to the encoding layer. It should be understood that in actual applications, the candidate models in the embedding layer may also be other models that can be used to convert input into word vector sequences, which will not be limited in the embodiments of this application.
[0178] Optionally, in the above Figure 4 Based on the described framework, see Figure 6 , is a schematic diagram of the structure of the preselected model of the coding layer provided in the embodiment of the present application. Figure 6As can be seen from the left encoding layer in the figure, the candidate models of the encoding layer may include long short-term memory (LSTM), gated recurrent unit (GRU), bidirectional LSTM (Bi-LSTM), bidirectional GRU (Bi-GRU), convolutional neural networks (CNN), dilate gated convolutional neural networks (DGCNN), fully connected neural networks (Dense), etc., which can be used to encode word vector sequences, that is, to extract features to convert them into semantic vector sequences. In the process of generating structured information, users can select the required model from the candidate models of the encoding layer according to actual needs and drag it to Figure 4 Configure the position of the encoding layer in , for example, select Bi-LSTM and Dense to configure, so as to obtain the following Figure 6 The pre-selected model for the encoding layer is shown.
[0179] It should be noted that one or more of LSTM, GRU, Bi-LSTM, Bi-GRU, CNN, DGCNN, and Dense can be selected to configure the encoding layer, indicating the superposition of multiple network layers. It should be understood that in actual applications, the candidate model in the encoding layer may also be other models that can be used to convert word vector sequences into semantic vector sequences, which will not be limited in the embodiments of this application.
[0180] Optionally, in the above Figure 4 Based on the described framework, see Figure 7 , is a schematic diagram of the structure of the preselected model of the decoding layer provided in the embodiment of the present application. Figure 7 As can be seen from the left decoding layer in the figure, the candidate models of the decoding layer can include LSTM, GRU, Bi-LSTM, Bi-GRU, CNN, DGCNN, Dense, etc., which can be used to process semantic vector sequences or attention vector sequences. In the process of generating structured information, users can select the required model from the candidate models of the decoding layer according to actual needs and drag it to Figure 4 For example, select Dense to configure the embedding layer of Model_1, and select Bi-LSTM and Dense to configure the embedding layers of Model_1, Model_2, ..., Model_K, so as to obtain the following: Figure 7 The pre-selected model for the decoding layer is shown.
[0181] It is worth noting that one or more of LSTM, GRU, Bi-LSTM, Bi-GRU, CNN, DGCNN, and Dense can be selected to configure the decoding layer. It should be understood that in actual applications, the candidate models in the decoding layer may also be other models that can be used to process semantic vector sequences or attention vector sequences, which will not be limited in the embodiments of this application.
[0182] Optionally, in the above Figure 4 Based on the described framework, see Figure 8 , is a schematic diagram of the structure of the preselected model of the output layer provided in the embodiment of the present application. Figure 8 As can be seen from the output layer on the left, the candidate models of the output layer can be divided into two categories. The first category is the sequence model (Sequence Model), which can include models such as Point Network or Conditional Random Field (CRF) that can be used to calculate the results of sequence labeling; the second category is the classification model (Classification Model), which can include models such as Softmax or Sigmoid that can output position IDs. In the process of generating structured information, users can select the required model from the candidate models of the output layer according to actual needs and the preset generation format, and drag it to Figure 4 For example, select Sigmoid to configure the output layer of Model_1, and select Point Network to configure the output layer of Model_2, ..., Model_K, so as to obtain the following: Figure 8 The preselected model for the output layer is shown.
[0183] In addition, one or more output layers of Point Network, CRF, Softmax, or Sigmoid can be selected for configuration, as long as they correspond to the output defined by the preset generation format. It should be understood that in actual applications, the candidate models in the output layer may also be other models, which will not be limited in the embodiments of this application.
[0184] Optionally, in the aforementioned Figure 4-Figure 8 Based on the described embodiments, this application will further explain the aforementioned first output value, or the first starting position and the first ending position, from the perspective of the pre-selected model of the first embedding layer, the pre-selected model of the first encoding layer, the pre-selected model of the first decoding layer, and the pre-selected model of the first output layer included in the first extraction model. This can be understood specifically in the following manner:
[0185] Input the text to be extracted into the pre-selected model of the first embedding layer to obtain the first word vector sequence;
[0186] Processing the first word vector sequence based on the preselected model of the first encoding layer to obtain a first semantic vector sequence;
[0187] The first semantic vector sequence is processed based on the preselected model of the first decoding layer and the preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
[0188] That is to say, after the user configures the first embedding layer, the first encoding layer, the first decoding layer and the first output layer in the first extraction model according to the target extraction task and the preset generation format, and obtains the pre-selected model of the first embedding layer, the pre-selected model of the first encoding layer, the pre-selected model of the first decoding layer and the pre-selected model of the first output layer respectively, the text to be extracted is segmented by the pre-selected model of the first embedding layer to obtain the first word vector sequence corresponding to the text to be extracted, and then the first word vector sequence is processed based on the pre-selected model of the first encoding layer to obtain a first semantic vector sequence, which can be used to represent the semantics of each word in the first word vector sequence, and then the first semantic vector sequence is processed by the pre-selected model of the first decoding layer and the pre-selected model of the first output layer to obtain a first output value, or a first start position and a first end position, the first output value can be used to indicate that the type of the extracted element existing at the corresponding position ID is an enumeration value, and the first start position and the first end position can be used to indicate that the type of the extracted element existing at the corresponding position is an extraction value.
[0189] However, it should be understood that when the first semantic vector sequence is processed based on the pre-selected model of the first decoding layer and the pre-selected model of the first output layer, the processing result obtained is the first output value or the first starting position and the first ending position, which depends on the pre-selected model of the first output layer. That is, if the pre-selected model of the first output layer is Point Network or CRF, then the corresponding output is the first starting position and the first ending position; if the pre-selected model of the first output layer is Softmax or Sigmoid, then the corresponding output is the first output value.
[0190] In order to easily distinguish different extraction models, this embodiment uses the corresponding first embedding layer, first encoding layer, first decoding layer and first output layer to represent Figure 4 The specific names of the embedding layer, encoding layer, decoding layer, and output layer in Model_1 described in the preceding text may not be limited in actual applications.
[0191] 303. Traverse the first M-1 extracted element sets to obtain at least one text consisting of the first M-1 extracted elements, wherein the first M-1 extracted elements have a pairing relationship.
[0192] In the embodiment, please refer to Figure 2 The step 202 in FIG. 1 is understood for clarity, and will not be described in detail here.
[0193] 304. Input the text to be extracted and any text consisting of the first M-1 extracted elements into the Mth extraction model to obtain the Mth extraction element set, the Mth extraction element set including the Mth extraction element, and the Mth extraction element is arranged at the Mth position among the K extraction elements.
[0194] In this embodiment, M is an integer not equal to 1. Therefore, after the first extraction model outputs the first set of extracted elements, the first set of extracted elements is traversed and one of the first set of extracted elements (such as E1) is arbitrarily selected from the first set of extracted elements, and this is combined with the text to be extracted as the input of the second extraction model. Similarly, after the second extraction model outputs the second set of extracted elements, each second extracted element in the second set of extracted elements is traversed and one of the second extracted elements (such as E2) is arbitrarily selected from the second set of extracted elements. This is combined with the first extracted element as input to form a text (such as [E1, E2]), and then combined with the text to be extracted as the input of the third extraction model.
[0195] Based on the same principle, for the Mth extraction model, after traversing the first extraction set output by the first extraction model, select any one (such as: E1), and traverse the second extraction set output by the second extraction model, and arbitrarily select a second extraction element from it that forms a text with E1 (such as: E2), and so on, until the M-1th extraction set output by the M-1th extraction model is traversed, and an M-1th extraction element that can form a text with E1, E2, ... E(M-2) is selected (such as: E(M-1)). In this way, the first M-1 extraction elements output by the first M-1 extraction models can be combined into a text, such as [E1, E2, ..., E(M-1)]. This is combined with the text to be extracted as the input of the Mth extraction model, thereby outputting the corresponding Mth extraction element set, which includes at least one Mth extraction element, and the Mth extraction element will be correspondingly sorted in the Mth position among the K extraction elements.
[0196] Optionally, in some embodiments, the type of the Mth extracted element sorted at the Mth position can be either the Mth extracted value or the Mth enumeration value. The difference between the Mth extracted value and the Mth enumeration value can be understood with reference to the description of step 302, and the details will not be repeated here. Therefore, for different output modes, the input of the text to be extracted and the first M-1 extracted elements into the Mth extraction model in step 304 to obtain the Mth set of extracted elements can also be understood with reference to the following:
[0197] Input the text to be extracted and the first M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, where the type of the M-1 extraction elements includes enumeration value or extraction value;
[0198] When the Mth output value is greater than a preset threshold, an Mth enumeration value set is obtained based on the position information corresponding to the Mth output value, the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of an event; or,
[0199] An Mth extraction value set is obtained based on the Mth starting position and the Mth ending position. The Mth extraction value set includes the Mth extraction value. The Mth extraction value includes the entity, the trigger word of the event, or the element value of the event.
[0200] That is to say, the text to be extracted and the text composed of the first M-1 extraction elements are input into the Mth extraction model, and the Mth extraction model will output in different output modes.
[0201] The first type: the Mth extraction model outputs the Mth output value. If the Mth output value is greater than the preset threshold, it means that the type of the extracted element at the position where the Mth output value is located is an enumeration value. Then, the Mth enumeration value at this position can be extracted based on the position information corresponding to the Mth output value.
[0202] It can be understood that the Mth enumeration value may include but is not limited to entity tags, entity relationships, attribute types of events or element types of events, etc., and will not be specifically limited in the embodiments of this application.
[0203] The second type: The Mth extraction model outputs the Mth starting position and the Mth ending position. This means that in the text to be extracted, the type of the extraction elements at the Mth starting position and the Mth ending position is the extraction value. In this case, the Mth extraction value can be obtained based on the Mth starting position and the Mth ending position.
[0204] It can be understood that the Mth extracted value may include but is not limited to an entity, a trigger word of an event, or an element value of an event, etc., and will not be specifically limited in the embodiments of this application.
[0205] It should be noted that the Mth enumeration value obtained in the first way is still the same as the Mth extraction value obtained in the second way, under the premise that the Mth extraction model will selectively output the format pre-set at the Mth position in the preset generation format.
[0206] For example, if the preset generation format is [father's name, father and son, son's name], it is obvious that the "father's name" in the first position is an entity, and the "father and son" in the second position is an entity relationship, and the "son's name" in the third position is an entity. Assuming that the text to be extracted is "Zhang San's sons are Zhang Wu and Zhang Liu, and Xiao Ming's father is Xiao Wang", then the first extraction model will use "Zhang San's sons are Zhang Wu and Zhang Liu, and Xiao Ming's father is Xiao Wang" as input, and choose the second method to extract all the first extracted values in the text to be extracted that are "father's name", such as: "Zhang San, Xiao Wang", so as to obtain the first extracted value set; by traversing each extracted value in the first extracted value set, all the first extracted values in the first extracted value set are "father's name" " is randomly selected from the text, such as "Zhang San", and the text to be extracted is "Zhang San's sons are Zhang Wu and Zhang Liu, Xiao Ming's father is Xiao Wang" as the input of the second extraction model, and the first method is selected to extract all the second enumeration values in the text to be extracted as "father and son", so as to obtain the second enumeration value set; similarly, by traversing each enumeration value in the second enumeration value set, and combining the first extraction value selected from the first extraction value set to form the corresponding text, such as: [Zhang San, father and son], so as to combine the text to be extracted as "Zhang San's sons are Zhang Wu and Zhang Liu, Xiao Ming's father is Xiao Wang" as the input of the second extraction model, and select the second method to extract all the third extraction values in the text to be extracted as "son's name", such as: "Zhang Wu, Zhang Liu", to obtain the third extraction value set.
[0207] It should be noted that since the traversal method is used, in actual applications, "Zhang San" and "Xiao Wang" can be used as inputs of the second extraction model at the same time, and so on. The above description of the input of "Zhang San" is mainly to clearly illustrate the relationship of the model cascade proposed in this application, and should not be used as a limitation here.
[0208] It should be understood that the aforementioned preset generation format [father's name, father and son, son's name] is merely an illustrative description. In actual applications, it can also be [father's name, son's name, father and son], or [son's name, father and son, father's name], etc., and will not be limited in the embodiments of this application. In addition, the aforementioned text to be extracted, "Zhang San's sons are Zhang Wu and Zhang Liu, and Xiao Ming's father is Xiao Wang," is also merely an illustrative description. In actual applications, it can also be other texts to be extracted, and will not be limited in the embodiments of this application.
[0209] Optionally, in the aforementioned Figure 4-Figure 8 Based on the described embodiments, this application will further explain the aforementioned M-th output value, or the M-th starting position and the M-th ending position, from the pre-selected model of the M-th embedding layer, the pre-selected model of the M-th encoding layer, the pre-selected model of the M-th attention mechanism network layer, the pre-selected model of the M-th decoding layer, and the pre-selected model of the M-th output layer included in the M-th extraction model. This can be understood specifically in the following way:
[0210] Input the text to be extracted and the text consisting of M-1 extracted elements into the pre-selected model of the Mth embedding layer to obtain the second word vector sequence and the third word vector sequence respectively;
[0211] The second word vector sequence and the third word vector sequence are processed based on the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence respectively;
[0212] Processing the second semantic vector sequence and the third semantic vector sequence based on the pre-selected model of the Mth attention mechanism network layer to obtain a first attention vector sequence;
[0213] The first attention vector sequence is processed based on the pre-selected model of the M-th decoding layer and the pre-selected model of the M-th output layer to obtain the M-th output value, or the M-th starting position and the M-th ending position.
[0214] That is to say, based on Figure 4-Figure 8The Mth embedding layer, Mth encoding layer, Mth attention mechanism network layer, Mth decoding layer and Mth output layer in the Mth extraction model are configured, and the text to be extracted and the text composed of M-1 extracted elements are segmented respectively through the pre-selected model of the Mth embedding layer to obtain the second word vector sequence corresponding to the text to be extracted and the third word vector sequence corresponding to the M-1 extracted elements. Then, the second word vector sequence and the third word vector sequence are processed based on the pre-selected model of the Mth encoding layer to obtain the second semantic vector sequence and the third semantic vector sequence, respectively, wherein the second semantic vector sequence can be used to represent the semantics of each word in the second word vector sequence, and the third semantic vector sequence can be used to represent the semantics of each element in the corresponding third word vector sequence.
[0215] At this time, the second and third semantic vector sequences are processed based on the preselected model of the Mth attention mechanism network layer. The purpose is to enable the third semantic vector sequence to perform an attention operation on the second semantic vector sequence. That is, it is necessary to notice those elements in the text to be extracted that have a structural relationship with the third semantic vector sequence, thereby obtaining the corresponding first attention vector sequence. This can also be understood as fusing the text to be extracted with M-1 extracted elements. The first attention vector sequence is then processed by the preselected model of the Mth decoding layer and the preselected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position. The Mth output value can be used to indicate that the type of the extracted element at the corresponding position ID is an enumeration value, while the Mth starting position and the Mth ending position can be used to indicate that the type of the extracted element at the corresponding position is an extracted value.
[0216] However, it should be noted that the first attention vector sequence is processed based on the pre-selected model of the Mth decoding layer and the pre-selected model of the Mth output layer. The processing result is the Mth output value or the Mth starting position and the Mth ending position, which depends on the pre-selected model of the Mth output layer. That is, if the pre-selected model of the Mth output layer is Point Network or CRF, then the corresponding output is the Mth starting position and the Mth ending position; if the pre-selected model of the Mth output layer is Softmax or Sigmoid, then the corresponding output is the Mth output value.
[0217] In addition, it should be noted that the Mth embedding layer and the Mth encoding layer in this embodiment can share parameters with the first embedding layer and the first encoding layer described in the aforementioned step 302. In addition, in order to conveniently distinguish different extraction models, the corresponding Mth embedding layer, Mth encoding layer, Mth attention mechanism network layer, Mth decoding layer and Mth output layer are used to represent Figure 4The specific names of the embedding layer, encoding layer, attention mechanism network layer, decoding layer, and output layer of Model_M described in the figure may not be limited in practical applications.
[0218] 305. Generate structured information using the first extracted element and K-1 Mth extracted elements.
[0219] In this embodiment, after obtaining the first extracted element based on the first extraction model, the corresponding second extracted element is obtained in sequence through the second extraction model, and so on, after obtaining the corresponding Kth extracted element through the Kth extraction model, structured information corresponding one-to-one to the preset generation format can be generated according to the preset generation format.
[0220] In the above manner, the extracted text is processed based on the first extraction model to obtain the first extracted element arranged in the first position among the K extracted elements, and the extracted text and the text composed of M-1 extracted elements are processed based on the Mth extraction model to obtain the Mth extracted element arranged in the Mth position and there are K-1 Mth extracted elements. In this way, the corresponding structured information can be generated according to the preset generation format based on the first extracted element and the K-1 extracted elements, which greatly meets the needs of extracting structured information with differences.
[0221] In the aforementioned Figures 2 to 8 On the basis of the described embodiment, in order to further understand the solution proposed in the embodiment of the present application, the specific process in this embodiment will be introduced below in combination with the target extraction task being the relationship extraction task, and the relationship extraction task can be further subdivided into schema constraint attribute / relationship extraction and open domain attribute / relationship extraction. It should be understood that since the relationship extraction task is generally a task for extracting at least two entities and the relationship between entities, it is hoped to generate triples of structured information. Therefore, three extraction models will be used for the relationship extraction task, namely the first extraction model, the second extraction model and the third extraction model arranged in sequence. The following will explain different relationship extraction tasks:
[0222] 1. Schema constraint attribute / relationship extraction.
[0223] See also Figure 9 , is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0224] 901. Obtain the text to be extracted.
[0225] 902. Input the text to be extracted into the first extraction model to obtain a first set of extracted elements.
[0226] In this embodiment, the first extraction model can refer to the aforementioned Figures 2 to 8 The above description is for your understanding and will not be elaborated here. It is worth noting that each first extraction element included in the first extraction element set is different. In addition, after obtaining each first extraction element, it is necessary to traverse each first extraction element and randomly select any first extraction element from them, so that the randomly selected first extraction element serves as the input of the second extraction model.
[0227] In addition, for the extraction task of schema constraint attribute / relationship, since schema constraint attribute / relationship extraction generally hopes to generate triples of structured information from the text to be extracted, and an enumeration value is expected to appear in the triple, that is, the predicate in the triple is user-defined and of particular interest to the user. Therefore, for the extraction of schema constraint attribute / relationship, the corresponding preset generation format generally appears One of the following situations:
[0228] ①[enumeration value, extraction value 1, extraction value 2];
[0229] ②[enumeration value, extraction value 2, extraction value 1];
[0230] ③[extracted value 1, enumeration value, extracted value 2];
[0231] ④[extracted value 1, extracted value 2, enumeration value];
[0232] ⑤[extracted value 2, enumeration value, extracted value 1];
[0233] ⑥[extracted value 2, extracted value 1, enumeration value];
[0234] In a triple, the enumeration value can also be called a predicate, and the extracted value 1 or the extracted value 2 can be called a subject or an object.
[0235] Therefore, when the preset generation format is ① or ②, Figure 8 From the description, we know that the pre-selected model of the first output layer of the first extraction model will choose to use Softmax or Sigmoid, so the types of the aforementioned n first extraction elements should all be enumeration values, such as entity relationships, etc. Similarly, if the preset generation format is any of ③-⑥, from Figure 8 From the description, it can be seen that the pre-selected model of the first output layer of the first extraction model will choose to use PointNetwork or CRF, so that the types of the aforementioned n first extraction elements should all be extraction values, such as entities, subjects or objects.
[0236] 903. Input the text to be extracted and the first target element into a second extraction model to obtain a second set of extracted elements, wherein the first target element is any one in the first set of extracted elements.
[0237] In this embodiment, the second extracted element set includes m (m is an integer and m ≥ 0) second extracted elements, and these m second extracted elements are all extracted elements that can form structured information with the first target element, that is, all m second extracted elements are paired with the first target element. In addition, referring to step 902, when the preset generation format is any of ①②④⑥, the type of the m second extracted elements should all be extracted values, such as subjects or objects such as entities; when the preset generation format is ③ or ⑤, the type of the m second extracted elements should all be enumerated values, such as predicates such as entity tags.
[0238] It is worth noting that the m second extracted elements obtained are all different. In addition, after obtaining the second extracted element set, it is necessary to traverse the m second extracted elements in the second extracted element set and randomly select any second extracted element from them, so that the text composed of the randomly selected second extracted element and the aforementioned first target element serves as the input of the third extraction model.
[0239] 904. Input the text to be extracted and the text consisting of the first target element and the second target element into a third extraction model to obtain a third set of extracted elements, wherein the second target element is any one in the second set of extracted elements.
[0240] In this embodiment, the third extraction element set includes w (w is an integer and w ≥ 0) third extraction elements, and these w third extraction elements are all extraction elements that can form structured information with the first target element and the second target element, that is, the w third extraction elements are paired with the first target element and the second target element. In addition, referring to the understanding of step 902, in any of the preset generation formats ①②④⑥, the types of the w third extraction elements should all be extraction values, such as: subject or object such as entity 1, entity 2; in the case of the preset generation format ③ or ⑤, the types of the w third extraction elements should all be enumeration values, such as: predicate such as entity relationship, that is, the relationship between entity 1 and entity 2.
[0241] 905. Generate structured information from the first target element, the second target element, and each third extracted element in the set of third extracted elements.
[0242] For examples, see Figure 10 , is a schematic diagram of an extraction task with schema constraint attribute / relationship extraction as the target provided in the embodiment of the present application. Figure 10It can be seen that the preset generation format is [enumeration value, extraction value 1, extraction value 2]. It should be understood that in actual applications, other preset generation formats can also be used as examples, which will not be limited in the embodiments of this application.
[0243] 2. Open domain attribute / relationship extraction.
[0244] In this embodiment, the principle of extracting open domain attributes / relationships to generate structured information is the same as that described above. Figure 9 The principle of generating structured information by schema-constrained attribute / relation extraction is basically the same as that described above. The difference lies in the open domain attribute / relation extraction task. Since open domain attribute / relation extraction generally hopes to directly extract and generate triples of structured information from the text to be extracted, that is, the predicates in the triples also hope to be extracted from the text to be extracted. Therefore, for this open domain attribute / relation extraction, the corresponding preset generation format will generally appear. One of the following situations: permuting and combining the extraction value 1, extraction value 2, and extraction value 3. Figure 11 , is a schematic diagram of an extraction task with open domain attribute / relationship extraction as the target provided in the embodiment of this application. Figure 11 It can be seen that the preset generation format is [extracted value 1, extracted value 2, extracted value 3], which will not be limited in the embodiments of this application.
[0245] It is worth noting that, since in open domain attribute / relationship extraction, the extracted values can all represent the subject, object, and predicate, in actual applications, there is no limitation on whether the structured information generated by the first extraction model, the second extraction model, and the third extraction model is [subject, object, predicate], [subject, predicate, object], or [object, subject, predicate], etc.
[0246] Based on the model cascade approach, it provides multiple implementation methods for generating structured information corresponding to relationship extraction tasks, greatly meeting user needs and having strong applicability and portability.
[0247] The above mainly introduces the method for generating structured information in this application from the perspective of relationship extraction tasks. The following will introduce the specific process of this embodiment in combination with the target extraction task as the entity extraction task. It should be understood that since the entity extraction task is generally a task for extracting an entity and an entity label, it is hoped that a binary group of structured information can be generated. Therefore, two extraction models will be used for the entity extraction task, namely the first extraction model and the second extraction model arranged in sequence. The entity extraction task will be explained below:
[0248] See also Figure 12, is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0249] 1201. Obtain the text to be extracted.
[0250] 1202. Input the text to be extracted into the first extraction model to obtain a first set of extracted elements.
[0251] In this embodiment, step 1202 can refer to the aforementioned Figure 9 The step 902 described above can be understood and will not be described in detail here.
[0252] It should be understood that for entity extraction tasks, since entity extraction tasks generally also hope to generate a tuple of structured information from the text to be extracted, and an enumeration value is expected to appear in the tuple, that is, the entity label in the tuple is user-defined and of particular interest to the user. Therefore, for entity extraction tasks, the corresponding preset generation format generally has one of two situations, namely: ① [enumeration value, extracted value], ② [extracted value, enumeration value], and in the tuple, the enumeration value can also be called an entity label (entity label), which is used to indicate the type of entity, and the extracted value can be called an entity (entity).
[0253] Therefore, when the preset generation format is ①, Figure 8 From the description, we know that the pre-selected model of the first output layer of the first extraction model will choose to use Softmax or Sigmoid, so the types of the aforementioned r first extraction elements should all be enumeration values, such as entity labels, etc. Similarly, if the preset generation format is ②, from Figure 8 From the description, we can see that the pre-selected model of the first output layer of the first extraction model will choose to use Point Network or CRF, so the types of the aforementioned r first extraction elements should all be extraction values, such as entities.
[0254] 1203. Input the text to be extracted and the first target element into a second extraction model to obtain a second set of extracted elements, wherein the first target element is any one in the first set of extracted elements.
[0255] In this embodiment, each of the second extracted elements is an extracted element that can form structured information with the first target element, that is, each second extracted element is paired with the first target element. Furthermore, as can be understood with reference to step 1202, when the preset generation format is ①, the type of each second extracted element should be an extracted value, such as "entity"; when the preset generation format is ②, the type of each second extracted element should be an enumerated value, such as "entity tag".
[0256] It should be noted that each of the obtained second extracted elements is different.
[0257] 1204. Generate structured information by combining the first target element with each second extracted element in the second extracted element set.
[0258] For examples, see Figure 13 , is a schematic diagram of an extraction task with entity extraction as the target provided in the embodiment of the present application. Figure 13 It can be seen that the preset generation format is [enumeration value, extraction value]. It should be understood that in actual applications, other preset generation formats can also be used as examples, which will not be limited in the embodiments of this application.
[0259] Based on the model cascade approach, it provides multiple implementation methods for generating structured information corresponding to entity extraction tasks, greatly meeting user needs and having strong applicability and transferability.
[0260] The above mainly introduces the method for generating structured information in this application from the perspective of relationship extraction tasks and entity extraction tasks. In order to further understand the solution proposed in the embodiment of this application, the specific process in this embodiment will be introduced in combination with the target extraction task as an event extraction task. It should be understood that since the event extraction task is generally used to extract a multi-relationship, it is hoped to generate a quadruple of structured information. Therefore, four extraction models will be used for the relationship extraction task, namely the first extraction model, the second extraction model, the third extraction model and the fourth extraction model arranged in sequence. The event extraction task will be explained below:
[0261] See also Figure 14 , is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0262] 1401. Obtain the text to be extracted.
[0263] 1402. Input the text to be extracted into the first extraction model to obtain a first set of extracted elements.
[0264] In this embodiment, the first extraction model can refer to the aforementioned Figures 2 to 8 The contents described above can be understood, and will not be described in detail here. In addition, step 1402 of this embodiment can also refer to Figure 9 The step 902 described above can be understood and will not be described in detail here.
[0265] In addition, for event extraction tasks, it is generally hoped that a quadruple of structured information can be generated from the text to be extracted, and two enumeration values may appear in the quadruple, that is, the attribute type (type) of the event or the element type (element type) of the event in the quadruple, which are user-defined and of particular interest. Therefore, for this event extraction task, the corresponding preset generation format generally appears One of the situations, that is: permuting and combining enumeration value 1, enumeration value 2, extraction value 1, and extraction value 2 to form 24 different combinations, such as: ①[enumeration value 1, extraction value 1, enumeration value 2, extraction value 2], ②[enumeration value 2, extraction value 2, enumeration value 1, extraction value 1], etc., which are not listed here.
[0266] Therefore, if the first element in the preset generation format is enumeration value 1 or enumeration value 2, Figure 8 As can be seen from the description, the pre-selected model of the first output layer of the first extraction model will choose to use Softmax or Sigmoid, so the type of each first extraction element in the aforementioned first extraction element set should be an enumeration value, such as: the attribute type of the event or the element type of the event. Similarly, if the first element in the preset generation format is extraction value 1 or extraction value 2, Figure 8 From the description, it can be seen that the pre-selected model of the first output layer of the first extraction model will choose to use Point Network or CRF, so that the type of each first extraction element in the aforementioned first extraction element set should be an extraction value, such as: the trigger word of the event or the element value of the event, etc.
[0267] 1403. Input the text to be extracted and the first target element into the second extraction model to obtain a second set of extracted elements, wherein the first target element is any one in the first set of extracted elements.
[0268] In this embodiment, each second extracted element in the second extracted element set is an extracted element that can form structured information with the first target element, that is, each second extracted element has a pairing relationship with the first target element. In addition, referring to the understanding of step 1402, when the second element in the preset generation format is extraction value 1 or extraction value 2, the type of each second extracted element should be an extraction value, such as: the trigger word of the event or the element value of the event; when the second element in the preset generation format is enumeration value 1 or enumeration value 2, the type of each second extracted element should be an enumeration value, such as: the attribute type of the event or the element type of the event.
[0269] In addition, it is worth noting that each second extracted element is different. For the specific step 1403, please refer to Figure 9 Step 903 described above can be understood and will not be described in detail here.
[0270] 1404. Input the text to be extracted and the text consisting of the first target element and the second target element into the third extraction model to obtain a third set of extracted elements, wherein the second target element is any one of the second set of extracted elements.
[0271] In this embodiment, each third extracted element in the third extracted element set is an extracted element that can form structured information with the first target element and the second target element, that is, each third extracted element has a pairing relationship with the first target element and the second target element. In addition, referring to the understanding of step 1402, when the third element in the preset generation format is extraction value 1 or extraction value 2, the type of each third extracted element should be an extraction value, such as: the trigger word of the event or the element value of the event; when the third element in the preset generation format is enumeration value 1 or enumeration value 2, the type of each third extracted element should be an enumeration value, such as: the attribute type of the event or the element type of the event.
[0272] It is worth noting that each third extracted element is different. In addition, after obtaining each third extracted element, it is necessary to traverse each third extracted element and randomly select any third extracted element from them, so that the text composed of the randomly selected third extracted element, the first target element, and the second target element is used as the input of the fourth extraction model.
[0273] 1405. Input the text to be extracted and the text consisting of the first target element, the second target element and the third target element into the fourth extraction model to obtain a fourth extraction element set, wherein the third target element is any one in the third extraction element set.
[0274] In this embodiment, each fourth extracted element in the fourth extracted element set is an extracted element that can form structured information with the first target element, the second target element, and the third target element, that is, each fourth extracted element has a pairing relationship with the first target element, the second target element, and the third target element. In addition, referring to the understanding of step 1402, when the fourth element in the preset generation format is an extracted value 1 or an extracted value 2, the type of each fourth extracted element should be an extracted value, such as: a trigger word of an event or an element value of an event; when the fourth element in the preset generation format is an enumeration value 1 or an enumeration value 2, the type of each fourth extracted element should be an enumeration value, such as: an attribute type of an event or an element type of an event.
[0275] 1406. Generate structured information by combining the first target element, the second target element, the third target element, and each fourth extracted element in the fourth extracted element set.
[0276] For examples, see Figure 15 , is a schematic diagram of an event extraction task as a target extraction task provided in an embodiment of the present application. Figure 15 It can be seen that the preset generation format is [enumeration value 1, extraction value 1, enumeration value 2, extraction value 2]. It should be understood that in actual applications, other preset generation formats can also be used as examples, which will not be limited in the embodiments of this application.
[0277] Based on the model cascade approach, it provides a variety of implementation methods for generating structured information corresponding to event extraction tasks, greatly meeting user needs and having strong applicability and portability.
[0278] It should be understood that the method for generating structured information described in this application is not only applicable to relationship extraction tasks, entity extraction tasks, and event extraction tasks, but in actual applications, it may also be applicable to quintuple extraction tasks, sextuple extraction tasks, etc., which will not be limited in the embodiments of this application.
[0279] The above mainly describes the process of generating structured information by using K extraction models. The following will further explain the training process of K extraction models.
[0280] See also Figure 16 , is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0281] 1601. Obtain a text training sample and a text annotation set, where the text annotation set includes Q groups of preset structured information, each group of preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample.
[0282] In this embodiment, the text annotation set is a set of text annotations formed after the user has pre-annotated the text training samples. It can include Q groups of preset structured information pre-annotated by the user. Its purpose is to compare with the structured information actually generated by the initial text extraction model, so as to repeatedly correct the training parameters of the initial extraction model to obtain the final extraction model. It is worth noting that each set of preset structured information can include K text annotations, and all text annotations in the Q groups of preset structured information may contain overlapping information. Therefore, it is necessary to deduplicate the text annotations in the Q groups of preset structured information, that is, delete the text annotations with the same starting position and end position, or the same output value, and only retain one.
[0283] 1602. Determine a first structured information output set based on a text training sample, a text annotation set, and K initial text extraction models. Each initial text extraction model outputs an output element in the first structured information output set. The input of the first initial text extraction model is a text training sample and Q first text annotations. The input of the Mth initial text extraction model includes an element set consisting of a text training sample and the first M-1 deduplicated label sets. Each text annotation in the first M-1 deduplicated label sets is obtained by performing deduplication processing based on the corresponding Q Mth text annotations. The Q first text annotations are respectively arranged at the first position in each set of preset structured information, and the Q Mth text annotations are respectively arranged at the Mth position in each set of preset structured information.
[0284] 1603. Process the first structured information output set and the text annotation set using a loss function to obtain a loss function value.
[0285] In the embodiment, the loss function value is used to characterize the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summing the preset loss functions corresponding to the K initial text extraction models. That is to say, based on the preset loss function corresponding to each initial text extraction model, these K preset loss functions are weighted summed to obtain an overall loss function, and then the obtained overall loss function is used to train the K initial text extraction models to obtain the aforementioned K extraction models, or after obtaining each corresponding loss value based on the preset loss function corresponding to each initial text extraction model, these K loss values are weighted summed to obtain a total loss function value, and the K initial text extraction models are trained to obtain the aforementioned K extraction models.
[0286] 1604. K extraction models are obtained by training according to the loss function value and the K initial text extraction models.
[0287] That is to say, it is understood that the difference between the first structured information output set and the text annotation set is calculated from the overall loss function, and then the K initial text extraction models are trained as a whole based on the loss function value, so as to obtain K extraction models that can be used to generate the aforementioned structured information.
[0288] Optionally, in other embodiments, the aforementioned step 1602 may be understood in the following manner. Figure 17 , is a schematic diagram of another embodiment of a method for generating structured information provided in an embodiment of the present application. The generating method may include:
[0289] 1701. Input the text training sample into the first initial text extraction model to obtain the first output element set.
[0290] In this embodiment, the first output element set is a set of output elements at the first position in the actually generated structured information. The first output element set may include at least one output element.
[0291] 1702. Process the Q first text annotations to obtain a first deduplicated label set.
[0292] In this embodiment, since the Q groups of preset structured information are messy and unprocessed, there are a large number of repeated and overlapping text annotations. Therefore, after obtaining the Q groups of preset structured information, it is necessary to extract the text annotation at the first position of each group of preset structured information from the Q groups of preset structured information, thereby obtaining Q first text annotations, so that the Q first text annotations can be deduplicated. Specifically, the first text annotations with the same starting position and ending position in the Q first text annotations are deleted, leaving only one first text annotation with the same starting position and ending position; or the first text annotations with the same output value in the Q first text annotations are deleted, leaving only one first text annotation with the same output value. In this way, the first deduplication label set after deduplication can be obtained, so that the starting position information and ending position information of each first text annotation in the first deduplication label set are different, or the output value of each first text annotation is different, and the Q first text annotations are respectively arranged in the first position of each corresponding group of preset structured information. It can be understood that the first deduplication label set at this time is the expected output at the first position.
[0293] 1703. Process the first output element set and the first deduplication label set using a preset loss function to obtain a first loss value.
[0294] In this embodiment, the preset loss function is selected by the user according to actual needs, and will not be limited in the embodiments of this application. It is worth understanding that the first loss value can be used to characterize the difference between each output element in the first output element set and each first text annotation in the first deduplication label set, that is, the difference between the output element at the first position in the actually generated structured information and the text annotation at the first position in the expected structured information. The smaller the difference, the more consistent the output element at the first position is with the expected text annotation at the first position.
[0295] 1704 . Sample the element combination formed by the first M-1 deduplication label sets to obtain a first sampling set, where the first sampling set includes M-1 sampling elements.
[0296] In this embodiment, sampling actually involves selecting a correct combination from the combinations of elements formed by the first M-1 deduplication label sets, that is, selecting any text annotation from the first M-1 deduplication label sets when the loss value is less than the loss threshold. In this way, a first sampling set can be obtained based on the sampled M-1 text annotations. In other words, the M-1 sampling elements in the first sampling set are respectively the text annotations corresponding to any one of the M-1 deduplication label sets when the loss value is less than the loss threshold.
[0297] 1705. Input the text training sample and the first sampling set into the Mth initial text extraction model to obtain the Mth output element set.
[0298] In the embodiment, the first sampling set is combined with the input to the Mth initial text extraction model. Its purpose is to ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element is the result of the output under the premise of correct input, which reduces the possibility of erroneous output to a certain extent.
[0299] 1706. Process the Q Mth text annotations and the first M-1 duplicate-free label sets to obtain the Mth duplicate-free label set.
[0300] In this embodiment, the start position information and end position information of each text annotation in the Mth deduplication tag set are different, or the output value of each text annotation is different, and the Q Mth text annotations are respectively arranged at the Mth position of each set of preset structured information. Specifically, the principle of deduplication can be processed with reference to step 1702, and the details will not be repeated here.
[0301] 1707. Process the Mth output element set and the Mth deduplication label set using a preset loss function to obtain an Mth loss value.
[0302] In this embodiment, the Mth loss value is used to represent the difference between each output element in the Mth output element set and each Mth text annotation in the Mth deduplication label set. The specific processing process can also be processed with reference to step 1703, and will not be described in detail here.
[0303] It should be understood that after obtaining the aforementioned first loss value and the remaining K-1 loss values based on the Mth loss value, the first loss value and the K-1 Mth loss values can be weighted and summed to obtain the overall loss function value, which can be used to train the K initial text extraction models to obtain the aforementioned K extraction models. For details, see Figure 16 The step 1604 in FIG. 1 is understood for simplicity and will not be described in detail here.
[0304] For example, if the text training sample is "Zhang San's wife is Li Si, and his sons are Zhang Er and Zhang Wu," and the preset generation format is [enumeration value, extraction value, extraction value], then after the user annotates this text training sample, the text annotation set obtained includes four sets of preset structured information: [wife, Zhang San, Li Si], [son, Zhang San, Zhang Er], [son, Zhang San, Zhang Wu], and [husband, Li Si, Zhang San]. The four first text annotations at this time are: wife, son, son, husband. Therefore, after deduplicating these four first text annotations, the first deduplicated label set can be obtained as [wife, son, husband], which only includes three enumeration values, and only one enumeration value for son is retained.
[0305] Therefore, the text training sample "Zhang San's wife is Li Si, and his sons are Zhang Er and Zhang Wu" is input into the first initial text extraction model, and the first output element set can include enumeration values of actual outputs such as wife, son, and husband.
[0306] Furthermore, an enumeration value is arbitrarily selected from the first deduplication tag set, that is, one of wife, son, and husband is selected, such as son.
[0307] In this way, the text training sample and the sampled "son" can be input into the second initial text extraction model. Then the second output element set can include the actual output extraction values of Zhang San and others, and the expected output in the second deduplication label set at this time should also be: Zhang San.
[0308] Similarly, an enumeration value is arbitrarily selected from the first deduplication label set, and an extraction value is arbitrarily selected from the second deduplication label set, such as: the formed element combination is [son, Zhang San].
[0309] In this way, the text training sample and the element combination of [son, Zhang San] formed after sampling can be input into the third initial text extraction model. Then the third output element set can include the actual output extraction values of Zhang Er, Zhang Wu, etc., and the expected output in the third deduplication label set at this time should also be: Zhang Er, Zhang Wu.
[0310] It should be understood that the aforementioned text training sample is "Zhang San's wife is Li Si, and his sons are Zhang Er and Zhang Wu", and assuming that the preset generation format is [enumeration value, extraction value, extraction value] is only a schematic description and will not be limited in the embodiments of this application.
[0311] Through the above method, the element combinations formed by the first M-1 output element sets are sampled, and the text training samples are combined with the first sampling set to be input into the Mth initial text extraction model. This can ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element is the result of the output under the premise of correct input, which reduces the possibility of erroneous output to a certain extent and solves the training contradictions caused by the mutual cooperation between the extraction models.
[0312] Alternatively, in other embodiments, Figure 16 Step 1602 in the above example can also be understood by referring to the following method. Negative sampling can also be used to make any output element in the M-th output element set obtained by the M-th initial text extraction model be output under the premise of incorrect input. Figure 18 , which is a schematic diagram of another embodiment of the method for generating structured information provided in an embodiment of the present application, is as follows:
[0313] 1801. Input the text training sample into the first initial text extraction model to obtain the first output element set.
[0314] 1802. Process the Q first text annotations to obtain a first deduplicated label set.
[0315] 1803. Process the first output element set and the first deduplication label set using a preset loss function to obtain a first loss value.
[0316] In the embodiment, steps 1801-1803 can refer to Figure 16 Steps 1701-1703 in the above process are processed, and the details will not be repeated here.
[0317] 1804. Negative sampling is performed on the elements formed by the first M-1 deduplicated label sets to obtain a first negative sampling set. The first negative sampling set includes X negative sampling elements and Y sampling elements.
[0318] In the embodiment, negative sampling is actually selecting an erroneous combination from the element combination formed by the first M-1 output element sets, and this erroneous combination may include X negative sampling elements and Y sampling elements.
[0319] It can be understood that the X negative sampling elements are the output elements corresponding to any one of the loss values in the corresponding output element set that is greater than the loss threshold. It can also be understood that the X negative sampling elements do not exist in the M-1 output element set or that such elements do not exist in the text training sample. In addition, the Y sampling elements are the text annotations corresponding to any one of the loss values in the corresponding deduplication label set that is less than the loss threshold, that is, the elements that can actually be obtained from the text training sample. It is worth understanding that X+Y=M-1, and X and Y are both positive integers, and the positions of the X negative sampling elements and the Y sampling elements in the first negative sampling set are not limited. For example, the X negative sampling elements and the Y sampling elements can be arranged alternately, or the Y sampling elements can be arranged first and then the X negative sampling elements, etc.
[0320] 1805. Input the text training sample and the first negative sampling set into the Mth initial text extraction model to obtain the Mth output element set.
[0321] In the embodiment, the first negative sampling set is combined with the input to the Mth initial text extraction model. Its purpose is to ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element can output the result under the premise of erroneous input, and the negative sampling elements can be used to correct the actual output Mth output element set, thereby reducing the possibility of erroneous output to a certain extent.
[0322] 1806. Process the Q M-th text annotations and the first M-1 deduplication label sets to obtain the M-th deduplication label set, where the output corresponding to the text annotation at each I-th position in the M-th deduplication label set is empty, each I-th position is the same as the position of each negative sampling element, and I is a positive integer.
[0323] In the embodiment, the specific principle of deduplication can be processed with reference to step 1706, and the details will not be repeated here. However, it should be understood that the difference between this and step 1706 is that the output corresponding to the text annotation at each I-th position in the M-th deduplication label combination here is empty, so that in the M-th output element set, each negative sampling element corresponding to each I-th position is not given a weight or a lower weight when performing subsequent loss value calculations, thereby correcting the parameters of the M-th initial text extraction model.
[0324] 1807. The Mth output element set and the Mth deduplication label set are processed by a preset loss function to obtain an Mth loss value.
[0325] In this embodiment, the Mth loss value is used to represent the difference between each output element in the Mth output element set and each Mth text annotation in the Mth deduplication label set. The specific processing process can also be processed with reference to step 1707, and will not be described in detail here.
[0326] For example, in Figure 16 Based on the above example, if negative sampling is performed on the first deduplicated label set, a random enumeration value not included in the first output element set, such as "daughter," is selected. Then, the text training sample and the negatively sampled "daughter" can be input into the second initial text extraction model. The output of the second output element set is actually determined by the input of the second initial text extraction model, and the output at the second position in the second deduplicated label set is now empty.
[0327] Similarly, negative sampling can also be performed from the first deduplication label set and the second deduplication label set. For example, if "son" is sampled from the first deduplication label set and "Zhang Er" is negatively sampled from the second deduplication label set, the element combination formed is [son, Zhang Er].
[0328] In this way, the element combination of the text training sample and [son, Zhang Er] formed after negative sampling can be input into the third initial text extraction model. Then the output of the third output element set is actually determined by the input of the second initial text extraction model, and the result output at the third position in the third deduplication label set should also be empty.
[0329] It should be understood that the aforementioned text training sample is "Zhang San's wife is Li Si, and his sons are Zhang Er and Zhang Wu", and assuming that the preset generation format is [enumeration value, extraction value, extraction value] is only a schematic description. In addition, the elements of negative sampling are also only a schematic description and will not be limited in the embodiments of this application.
[0330] Through the above method, negative sampling is performed on the element combination formed by the first M-1 deduplicated label sets, and the text training sample is combined with the first negative sampling set to be input into the Mth initial text extraction model. This can ensure that in the Mth output element set obtained by the Mth initial text extraction model, each output element can output the result under the premise of incorrect input, and the negative sampling elements can be used to correct the actual output Mth output element set, which reduces the possibility of incorrect output to a certain extent and solves the training contradictions caused by the mutual cooperation between the extraction models.
[0331] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of method. It is understandable that, in order to realize the above functions, the above-mentioned information generating device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the functions described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0332] Described from the perspective of a physical device, the above-mentioned information generating device can be implemented by one physical device, or by multiple physical devices together, or it can be a logical functional unit within a physical device. The embodiments of the present application do not make specific limitations on this.
[0333] For example, the information generating device may be Figure 19 This is achieved by the communication equipment in. Figure 19 Schematic diagram of the hardware structure of a communication device provided in an embodiment of the present application. The communication device includes at least one processor 1901, a memory 1902, a communication line 1903, and a transceiver 1904.
[0334] The processor 1901 can be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (server IC), or one or more integrated circuits used to control the execution of the program of the present application.
[0335] The communication link 1903 may include a path to transmit information between the above components.
[0336] Transceiver 1904, which may be any transceiver-like device, is used to communicate with other devices or communication networks, such as Ethernet, radio access networks (RAN), and wireless local area networks (WLAN). Transceiver 1904 may also be a transceiver circuit or a transceiver. The communication device may also include a communication interface 1906.
[0337] The memory 1902 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, a random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. The memory may be independent and connected to the processor 1901 via a communication line 1903. The memory 1902 may also be integrated with the processor 1901.
[0338] Memory 1902 is used to store computer-executable instructions for executing the solution of the present application, and is controlled by processor 1901. Processor 1901 is used to execute the computer-executable instructions stored in memory 1902, thereby implementing the method for generating structured information provided by the above method embodiment of the present application.
[0339] In one possible implementation, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, which is not specifically limited in the embodiments of the present application.
[0340] In a specific implementation, as an embodiment, the processor 1901 may include one or more CPUs, such as Figure 19 CPU0 and CPU1 in.
[0341] In a specific implementation, as an embodiment, the communication device may include multiple processors, such as Figure 19 1 and 1905. Each of these processors can be a single-CPU processor or a multi-CPU processor. A processor herein can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., executing computer instructions).
[0342] From the perspective of functional units, the present application can divide the information generating device into functional units according to the above method embodiments. For example, each functional unit can be divided into different functional units corresponding to each function, or two or more functions can be integrated into one functional unit. The above integrated functional units can be implemented in the form of hardware or software functional units.
[0343] For example, when the functional units are divided in an integrated manner, Figure 20 FIG. 1 shows a schematic diagram of the structure of an information generating device. Figure 20 As shown, an embodiment of the information generation device of the present application may include K extraction models corresponding to the target extraction task, the target extraction task carries a preset generation format, the K extraction models are obtained by training the text training samples by the encoder-decoder framework, the K extraction models are arranged in sequence, K is an integer, and K ≥ 2, the information generation device may include:
[0344] An acquisition unit 2001 is used to acquire the text to be extracted;
[0345] Processing unit 2002 is used to generate structured information consisting of K extraction elements based on the text to be extracted and K extraction models, wherein the structured information consisting of K extraction elements corresponds to the preset generation format, each of the extraction models outputs a set of extraction elements in the K extraction element sets, the types of the K extraction elements include enumeration values or extraction values, the input of the first extraction model is the text to be extracted, the input of the Mth extraction model is the text consisting of the text to be extracted and the first M-1 extraction elements, and each of the first M-1 extraction elements is traversed and output by the corresponding extraction model for the first M-1 extraction element sets, M is an integer, and 1<M≤K.
[0346] In some embodiments of the present application, the K extracted elements include a first extracted element and K-1 Mth extracted elements, and the processing unit 2002 may include:
[0347] a processing module, configured to input the to-be-extracted text into the first extraction model to obtain a first set of extracted elements, wherein the first set of extracted elements includes the first extracted element, and the first extracted element is arranged at a first position among the K extracted elements;
[0348] The processing module is used to traverse the first M-1 extraction element sets to obtain at least one text composed of the first M-1 extraction elements, wherein the first M-1 extraction elements have a pairing relationship;
[0349] The processing module is configured to input the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain an M-th extraction element set, wherein the M-th extraction element set includes the M-th extraction element, and the M-th extraction element is arranged at the M-th position among the K extraction elements;
[0350] The processing module is configured to generate structured information by combining the first extracted element and K-1 of the M-th extracted elements.
[0351] In some embodiments of the present application, the type of the first extracted element may include a first enumeration value or a first extracted value;
[0352] The processing module is configured to input the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position;
[0353] The processing module is configured to obtain, based on the position information corresponding to the first output value when the first output value is greater than a preset threshold, a first enumeration value or a first enumeration value set, wherein the first enumeration value set includes the first enumeration value, and the first enumeration value may include an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or
[0354] The processing module is used to obtain a first extraction value set based on the first starting position and the first ending position. The first extraction value set includes the first extraction value, and the first extraction value may include an entity, a trigger word of the event, or an element value of the event.
[0355] In some embodiments of the present application, the type of the Mth extraction element may include an Mth enumeration value or an Mth extraction value;
[0356] The processing module is configured to input the text to be extracted and the text consisting of M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, wherein the types of the M-1 extraction elements may include the enumeration value or the extraction value;
[0357] The processing module is configured to, when the Mth output value is greater than a preset threshold, obtain an Mth enumeration value set based on position information corresponding to the Mth output value, wherein the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value may include an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or
[0358] The processing module is used to obtain the Mth extraction value set based on the Mth starting position and the Mth ending position, the Mth extraction value set includes the Mth extraction value, and the Mth extraction value may include an entity, a trigger word of the event, or an element value of the event.
[0359] In some embodiments of the present application, the first extraction model is composed of a preselected model of the first embedding layer, a preselected model of the first encoding layer, a preselected model of the first decoding layer, and a preselected model of the first output layer;
[0360] The processing module is configured to input the text to be extracted into a preselected model of the first embedding layer to obtain a first word vector sequence;
[0361] The processing module is configured to process the first word vector sequence according to the preselected model of the first coding layer to obtain a first semantic vector sequence;
[0362] The processing module is used to process the first semantic vector sequence according to the preselected model of the first decoding layer and the preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
[0363] In some embodiments of the present application, the Mth extraction model is composed of a pre-selected model of the Mth embedding layer, a pre-selected model of the Mth encoding layer, a pre-selected model of the Mth attention mechanism network layer, a pre-selected model of the Mth decoding layer, and a pre-selected model of the Mth output layer;
[0364] The processing module is used to input the text to be extracted and the text consisting of the first M-1 extracted elements into the pre-selected model of the Mth embedding layer to obtain a second word vector sequence and a third word vector sequence respectively;
[0365] The processing module is used to process the second word vector sequence and the third word vector sequence according to the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence respectively;
[0366] The processing module is configured to process the second semantic vector sequence and the third semantic vector sequence according to the preselected model of the Mth attention mechanism network layer to obtain a first attention vector sequence;
[0367] The processing module is used to process the first attention vector sequence according to the pre-selected model of the Mth decoding layer and the pre-selected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position.
[0368] In some embodiments of the present application, the information generating device may further include: a training unit;
[0369] The acquisition unit 2001 is configured to acquire the text training sample and a text annotation set, wherein the text annotation set includes Q groups of preset structured information, each group of the preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample;
[0370] The processing unit 2002 is used to determine a first structured information output set based on the text training sample, the text annotation set and K initial text extraction models, each of the initial text extraction models outputs an output element in the first structured information output set, the input of the first initial text extraction model is the text training sample and the Q first text annotations, the input of the Mth initial text extraction model includes the text training sample and an element set consisting of the first M-1 deduplication label sets, each text annotation in the first M-1 deduplication label sets is obtained by deduplication based on the corresponding Q Mth text annotations, the Q first text annotations are respectively arranged at the first position in each group of the preset structured information, and the Q Mth text annotations are respectively arranged at the Mth position in each group of the preset structured information;
[0371] The processing unit 2002 is configured to process the first structured information output set and the text annotation set using a loss function to obtain a loss function value, wherein the loss function value is used to represent the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summation of preset loss functions corresponding to the K initial text extraction models;
[0372] The training unit is used to train the K extraction models based on the loss function value and the K initial text extraction models.
[0373] In some embodiments of the present application, the processing unit 2002 is configured to input the text training sample into a first initial text extraction model to obtain a first output element set;
[0374] The processing unit 2002 is configured to process the Q first text annotations to obtain a first deduplication label set, wherein the start position information and the end position information of each first text annotation in the first deduplication label set are different, or the output value of each first text annotation is different, and the Q first text annotations are respectively arranged at the first position in each set of the preset structured information;
[0375] The processing unit 2002 is used to process the first output element set and the first deduplication label set through a preset loss function to obtain a first loss value, and the first loss value is used to characterize the difference between each output element in the first output element set and each first text annotation in the first deduplication label set.
[0376] In some embodiments of the present application, the information generating device may further include: a sampling unit;
[0377] The sampling unit is configured to sample a combination of elements formed by the first M-1 deduplication label sets to obtain a first sampling set, wherein the first sampling set includes M-1 sampling elements, and the M-1 sampling elements are respectively the M-1th text annotations corresponding to any one loss value in the corresponding M-1th deduplication label set is less than a loss threshold;
[0378] The processing unit 2002 is configured to input the text training sample and the first sampling set into an M-th initial text extraction model to obtain an M-th output element set;
[0379] The processing unit 2002 is configured to process the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the start position information and the end position information of each M-th text annotation in the M-th duplicate removal label set are different, or the output value of each text annotation is different, and the Q M-th text annotations are respectively arranged at the M-th position of each set of the preset structured information;
[0380] The processing unit 2002 is used to process the Mth output element set and the Mth deduplication label set through the preset loss function to obtain the Mth loss value, and the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each Mth text annotation in the Mth deduplication label set.
[0381] In some embodiments of the present application, the information generating device may further include: a negative sampling unit;
[0382] The negative sampling unit is configured to perform negative sampling on a combination of elements formed by the first M-1 deduplication label sets to obtain a first negative sampling set, wherein the first negative sampling set includes X negative sampling elements and Y sampling elements, each of the negative sampling elements being a text annotation corresponding to any one of the deduplication label sets when the loss value is greater than a loss threshold, X+Y=M-1, and X and Y are integers;
[0383] The processing unit 2002 is configured to input the text training sample and the first negative sampling set into the M-th initial text extraction model to obtain an M-th output element set;
[0384] The processing unit 2002 is configured to process the Q M-th text annotations and the first M-1 duplicate removal label sets to obtain an M-th duplicate removal label set, wherein the output corresponding to the text annotation at each I-th position in the M-th duplicate removal label set is empty, each I-th position is the same as the position of each negative sampling element, and I is a positive integer;
[0385] The processing unit 2002 is used to process the Mth output element set and the Mth deduplication label set through a preset loss function to obtain an Mth loss value, and the Mth loss value is used to characterize the difference between each output element in the Mth output element set and each text annotation in the Mth deduplication label set.
[0386] The information generating device provided in the embodiment of the present application is used to perform Figures 2 to 18 The method in any corresponding method embodiment, so the embodiments of this application can refer to Figures 2 to 18 Please understand the relevant parts of the corresponding method embodiments.
[0387] In the embodiment of the present application, the information generating device is presented in the form of dividing each functional unit in an integrated manner. The "functional unit" here may refer to an application-specific integrated circuit (ASIC), a processor and memory that executes one or more software or firmware programs, an integrated logic circuit, and / or other devices that can provide the above functions. In a simple embodiment, those skilled in the art can imagine that the information generating device can be used Figure 19 The form shown.
[0388] for example, Figure 19 The processor 1901 can call the computer execution instruction stored in the memory 1902 to make the information generating device execute Figures 2 to 18 The method executed by the information generating device in any corresponding method embodiment.
[0389] Specifically, Figure 20 The functions / implementation processes of the acquisition unit 2001 and the processing unit 2002 can be realized by Figure 19 The processor 1901 in the embodiment transfers the computer execution instructions stored in the memory 1902 to implement. Or, Figure 20 The function / implementation process of the processing unit 2002 can be achieved by Figure 19The processor 1901 in the embodiment calls the computer execution instruction stored in the memory 1902 to implement the above. Figure 20 The function / implementation process of the acquisition unit 2001 can be achieved by Figure 19 This is achieved by the transceiver 1904 in .
[0390] Since the information generating device provided in the embodiment of the present application can be used to perform Figures 2 to 18 Therefore, the technical effects that can be obtained by the embodiments of this application can be referred to Figures 2 to 18 Any corresponding method embodiment will not be repeated here.
[0391] In this application Figure 20The various components in the device are communicatively connected, that is, the processing unit (or processor), the storage unit (or memory) and the transceiver unit (transceiver) communicate with each other through internal connection paths to transmit control and / or data signals. The above-mentioned method embodiments of the present application can be applied to a processor, or the steps of the above-mentioned method embodiments can be implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above-mentioned method embodiments can be completed by hardware integrated logic circuits in the processor or instructions in the form of software. The above-mentioned processor can be a central processing unit (CPU), a network processor (NP) or a combination of CPU and NP, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in this application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. Although only one processor is shown in the figure, the device may include multiple processors or the processor may include multiple processing units. Specifically, the processor may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor.
[0392] The memory is used to store computer instructions executed by the processor. The memory can be a storage circuit or a memory. The memory can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory or a flash memory. The volatile memory can be a random access memory, which is used as an external cache. The memory can be independent of the processor or can be a storage unit in the processor, which is not limited here. Although only one memory is shown in the figure, the device can also include multiple memories or the memory can include multiple storage units.
[0393] The transceiver is used to implement content interaction between the processor and other units or network elements. Specifically, the transceiver can be a communication interface of the device, or a transceiver circuit or a communication unit, or a transceiver. The transceiver can also be a communication interface or transceiver circuit of the processor. Optionally, the transceiver can be a transceiver chip. The transceiver can also include a transmitting unit and / or a receiving unit. In one possible implementation, the transceiver can include at least one communication interface. In another possible implementation, the transceiver can also be a unit implemented in software form. In various embodiments of the present application, the processor can interact with other units or network elements through the transceiver. For example, the processor obtains or receives content from other network elements through the transceiver. If the processor and the transceiver are two physically separate components, the processor can interact with other units of the device without going through the transceiver.
[0394] In one possible implementation, the processor, memory, and transceiver may be interconnected via a bus. The bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, and the like.
[0395] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0396] In the various embodiments of the present application, various examples are provided for ease of understanding. However, these examples are merely examples and are not intended to be the best way to implement the present application.
[0397] The above embodiments may be implemented in whole or in part through software, hardware, firmware, or any combination thereof. When implemented using software, they may be implemented in whole or in part in the form of a computer program product.
[0398] The computer program product includes one or more computer instructions. When the computer execution instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction can be transmitted from a website, a computer, a server, or a data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website, a computer, a server, or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium can be a magnetic medium, (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive Solid State Disk (SSD)), etc.
[0399] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used in the present application to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for generating structured information, characterized in that: The method is applied to an information generation device, the information generation device including K extraction models corresponding to a target extraction task, the target extraction task carrying a preset generation format, the K extraction models being obtained by performing model training on text training samples using an encoder-decoder framework, the K extraction models being arranged in sequence, K being an integer, and K≥2, the method comprising: Get the text to be extracted; Structured information consisting of K extraction elements is generated according to the text to be extracted and the K extraction models, wherein the structured information consisting of the K extraction elements corresponds to the preset generation format, each of the extraction models outputs a set of extraction elements from the K sets of extraction elements, the types of the K extraction elements include enumeration values or extraction values, the input of the first extraction model is the text to be extracted, the input of the Mth extraction model is the text consisting of the text to be extracted and the first M-1 extraction elements, and each of the first M-1 extraction elements is traversed and output by the corresponding extraction model over the first M-1 extraction element sets, M is an integer, and 1<M≤K.
2. The method according to claim 1, characterized in that The K extracted elements include a first extracted element and K-1 Mth extracted elements, and generating structured information consisting of the K extracted elements according to the to-be-extracted text and the K extraction models includes: Inputting the to-be-extracted text into the first extraction model to obtain a first set of extracted elements, wherein the first set of extracted elements includes the first extracted element, and the first extracted element is arranged at the first position among the K extracted elements; Traversing the first M-1 extracted element sets to obtain at least one text consisting of the first M-1 extracted elements, wherein the first M-1 extracted elements have a pairing relationship; Inputting the to-be-extracted text and any one of the texts consisting of the first M-1 extraction elements into the M-th extraction model to obtain the M-th extraction element set, wherein the M-th extraction element set includes the M-th extraction element, and the M-th extraction element is arranged at the M-th position among the K extraction elements; The first extracted element and K-1 of the M-th extracted elements are used to generate the structured information.
3. The method according to claim 2, characterized in that The type of the first extraction element includes a first enumeration value or a first extraction value. The text to be extracted is input into the first extraction model to obtain a first extraction element set, including: Inputting the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position; When the first output value is greater than a preset threshold, a first enumeration value set is obtained based on the position information corresponding to the first output value, where the first enumeration value set includes the first enumeration value, and the first enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or A first extraction value set is obtained based on the first starting position and the first ending position, where the first extraction value set includes the first extraction value, and the first extraction value includes an entity, a trigger word of the event, or an element value of the event.
4. The method according to claim 2, characterized in that The type of the Mth extraction element includes the Mth enumeration value or the Mth extraction value, and the text to be extracted and the text composed of the first M-1 extraction elements are input into the Mth extraction model to obtain the Mth extraction element set, including: Inputting the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, wherein the types of the M-1 extraction elements include the enumeration value or the extraction value; When the Mth output value is greater than a preset threshold, an Mth enumeration value set is obtained based on the position information corresponding to the Mth output value, the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or, An Mth extraction value set is obtained based on the Mth starting position and the Mth ending position, the Mth extraction value set includes the Mth extraction value, and the Mth extraction value includes an entity, a trigger word of the event, or an element value of the event.
5. The method according to claim 3, characterized in that The first extraction model is composed of a preselected model of a first embedding layer, a preselected model of a first encoding layer, a preselected model of a first decoding layer, and a preselected model of a first output layer. Inputting the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position includes: Inputting the text to be extracted into the preselected model of the first embedding layer to obtain a first word vector sequence; Processing the first word vector sequence based on the preselected model of the first encoding layer to obtain a first semantic vector sequence; The first semantic vector sequence is processed based on a preselected model of the first decoding layer and a preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
6. The method according to claim 4, characterized in that The Mth extraction model is composed of a pre-selected model of the Mth embedding layer, a pre-selected model of the Mth encoding layer, a pre-selected model of the Mth attention mechanism network layer, a pre-selected model of the Mth decoding layer, and a pre-selected model of the Mth output layer. The text to be extracted and the text consisting of M-1 extraction elements are input into the Mth extraction model to obtain the Mth output value, or the Mth starting position and the Mth ending position, including: Input the text to be extracted and the text consisting of the M-1 extracted elements into the preselected model of the Mth embedding layer to obtain a second word vector sequence and a third word vector sequence respectively; Processing the second word vector sequence and the third word vector sequence based on the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence, respectively; Processing the second semantic vector sequence and the third semantic vector sequence based on the preselected model of the Mth attention mechanism network layer to obtain a first attention vector sequence; The first attention vector sequence is processed based on the preselected model of the Mth decoding layer and the preselected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position.
7. The method according to claim 1, characterized in that The method further comprises: Obtaining the text training sample and a text annotation set, wherein the text annotation set includes Q groups of preset structured information, each group of the preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample; Determine a first structured information output set based on the text training sample, the text annotation set, and K initial text extraction models, each of the initial text extraction models outputs an output element in the first structured information output set, the input of the first initial text extraction model is the text training sample and Q first text annotations, the input of the Mth initial text extraction model includes the text training sample and an element set consisting of the first M-1 deduplication label sets, each text annotation in the first M-1 deduplication label sets is correspondingly output by the first M-1 initial text extraction models, and the Q first text annotations are respectively arranged in the first position in each group of the preset structured information; Processing the first structured information output set and the text annotation set using a loss function to obtain a loss function value, wherein the loss function value is used to represent the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summation of preset loss functions corresponding to the K initial text extraction models; The K extraction models are obtained by training based on the loss function value and the K initial text extraction models.
8. An information generating device, characterized in that The information generation device includes K extraction models corresponding to a target extraction task, the target extraction task carries a preset generation format, the K extraction models are obtained by performing model training on text training samples using an encoder-decoder framework, the K extraction models are arranged in sequence, K is an integer, and K≥2, the information generation device includes: An acquisition unit, used to acquire the text to be extracted; A processing unit is used to generate structured information consisting of K extraction elements based on the text to be extracted and the K extraction models obtained by the acquisition unit, wherein the structured information consisting of the K extraction elements corresponds to the preset generation format, each of the extraction models outputs a set of extraction elements in the K extraction element sets, and the types of the K extraction elements include enumeration values or extraction values. The input of the first extraction model is the text to be extracted, and the input of the Mth extraction model is the text consisting of the text to be extracted and the first M-1 extraction elements. Each of the first M-1 extraction elements is traversed and output by the corresponding extraction model for the first M-1 extraction element sets, M is an integer, and 1<M≤K.
9. The information generating device according to claim 8, characterized in that The K extracted elements include a first extracted element and K-1 Mth extracted elements, and the processing unit includes: a processing module, configured to input the to-be-extracted text into the first extraction model to obtain a first set of extracted elements, wherein the first set of extracted elements includes the first extracted element, and the first extracted element is arranged at a first position among the K extracted elements; The processing module is used to traverse the first M-1 extraction element sets to obtain at least one text composed of the first M-1 extraction elements, wherein the first M-1 extraction elements have a pairing relationship; The processing module is configured to input the to-be-extracted text and the text consisting of the first M-1 extraction elements into the M-th extraction model to obtain an M-th extraction element set, wherein the M-th extraction element set includes the M-th extraction element, and the M-th extraction element is arranged at the M-th position among the K extraction elements; The processing module is configured to generate structured information by combining the first extracted element and K-1 of the M-th extracted elements.
10. The information generating device according to claim 9, characterized in that The type of the first extracted element includes a first enumeration value or a first extracted value; The processing module is configured to input the text to be extracted into the first extraction model to obtain a first output value, or a first starting position and a first ending position; The processing module is configured to obtain a first enumeration value set based on position information corresponding to the first output value when the first output value is greater than a preset threshold, wherein the first enumeration value set includes the first enumeration value, and the first enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or The processing module is used to obtain a first extraction value set based on the first starting position and the first ending position, where the first extraction value set includes the first extraction value, and the first extraction value includes an entity, a trigger word of the event, or an element value of the event.
11. The information generating device according to claim 9, wherein The type of the Mth extracted element includes the Mth enumeration value or the Mth extracted value; The processing module is configured to input the text to be extracted and the text consisting of M-1 extraction elements into the M-th extraction model to obtain the M-th output value, or the M-th starting position and the M-th ending position, wherein the types of the M-1 extraction elements include the enumeration value or the extraction value; The processing module is configured to, when the Mth output value is greater than a preset threshold, obtain an Mth enumeration value set based on position information corresponding to the Mth output value, wherein the Mth enumeration value set includes the Mth enumeration value, and the Mth enumeration value includes an entity tag, an entity relationship, an attribute type of an event, or an element type of the event; or The processing module is used to obtain the Mth extraction value set based on the Mth starting position and the Mth ending position, the Mth extraction value set includes the Mth extraction value, and the Mth extraction value includes an entity, a trigger word of the event, or an element value of the event.
12. The information generating device according to claim 10, wherein The first extraction model is composed of a preselected model of the first embedding layer, a preselected model of the first encoding layer, a preselected model of the first decoding layer, and a preselected model of the first output layer; The processing module is configured to input the text to be extracted into a preselected model of the first embedding layer to obtain a first word vector sequence; The processing module is configured to process the first word vector sequence according to the preselected model of the first coding layer to obtain a first semantic vector sequence; The processing module is used to process the first semantic vector sequence according to the preselected model of the first decoding layer and the preselected model of the first output layer to obtain a first output value, or a first starting position and a first ending position.
13. The information generating device according to claim 11, wherein The Mth extraction model is composed of a pre-selected model of the Mth embedding layer, a pre-selected model of the Mth encoding layer, a pre-selected model of the Mth attention mechanism network layer, a pre-selected model of the Mth decoding layer, and a pre-selected model of the Mth output layer; The processing module is used to input the text to be extracted and the text consisting of the first M-1 extracted elements into the pre-selected model of the Mth embedding layer to obtain a second word vector sequence and a third word vector sequence respectively; The processing module is used to process the second word vector sequence and the third word vector sequence according to the preselected model of the Mth encoding layer to obtain a second semantic vector sequence and a third semantic vector sequence respectively; The processing module is configured to process the second semantic vector sequence and the three semantic vector sequences according to the preselected model of the Mth attention mechanism network layer to obtain a first attention vector sequence; The processing module is used to process the first attention vector sequence according to the pre-selected model of the Mth decoding layer and the pre-selected model of the Mth output layer to obtain the Mth output value, or the Mth starting position and the Mth ending position.
14. The information generating device according to claim 8, characterized in that The information generating device further includes: a training unit; The acquisition unit is used to acquire the text training sample and a text annotation set, wherein the text annotation set includes Q groups of preset structured information, each group of the preset structured information includes K text annotations, and each text annotation is used to represent an output element in the text training sample; The processing unit is used to determine a first structured information output set based on the text training sample, the text annotation set and K initial text extraction models, each of the initial text extraction models outputs an output element in the first structured information output set, the input of the first initial text extraction model is the text training sample and Q first text annotations, the input of the Mth initial text extraction model includes the text training sample and an element set consisting of the first M-1 deduplication label sets, each text annotation in the first M-1 deduplication label sets is correspondingly output by the first M-1 initial text extraction models, and the Q first text annotations are respectively arranged in the first position in each group of the preset structured information; The processing unit is configured to process the first structured information output set and the text annotation set using a loss function to obtain a loss function value, wherein the loss function value is used to characterize the difference between each output element in the first structured information output set and the text annotation set, and the loss function is obtained by weighted summation of preset loss functions corresponding to the K initial text extraction models; The training unit is used to train the K extraction models based on the loss function value and the K initial text extraction models.
15. An information generating device, characterized in that include: processor, memory; The processor and the memory communicate with each other; The memory is used to store instructions; The processor is configured to execute the instructions in the memory to perform the method according to any one of claims 1 to 7.
16. A computer-readable storage medium comprising instructions, which, when executed on a computer, causes the computer to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Biomedical event extraction method integrated with structured element recognition
CN107818141A
Text generation method and device and storage medium
CN109635150A