WO2022110730A1 - Label-based optimization model training method, apparatus, device, and storage medium - Google Patents

Label-based optimization model training method, apparatus, device, and storage medium Download PDF

Info

Publication number
WO2022110730A1
WO2022110730A1 PCT/CN2021/097136 CN2021097136W WO2022110730A1 WO 2022110730 A1 WO2022110730 A1 WO 2022110730A1 CN 2021097136 W CN2021097136 W CN 2021097136W WO 2022110730 A1 WO2022110730 A1 WO 2022110730A1
Authority
WO
WIPO (PCT)
Prior art keywords
text data
hidden layer
label
target
optimization model
Prior art date
Application number
PCT/CN2021/097136
Other languages
French (fr)
Chinese (zh)
Inventor
邓悦
郑立颖
徐亮
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022110730A1 publication Critical patent/WO2022110730A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/194Calculation of difference between files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Definitions

  • the present application relates to the technical field of neural networks, and in particular, to a label-based optimization model training method, apparatus, device, and storage medium.
  • the current method for identifying and optimizing models to correct grammar and adjust sentence fluency is to train a trainer for a specific task, and then use the trainer to correct grammar and adjust sentence fluency.
  • This adjustment method is only suitable for For a specific task, other tasks cannot be optimized, the flexibility of identifying and optimizing the model is low, and the accuracy of converting other tasks into text will be reduced.
  • the present application provides a label-based optimization model training method, device, equipment and storage medium, which improves the flexibility of identifying the optimization model and improves the accuracy of converting other tasks into text.
  • a first aspect of the present application provides a label-based optimization model training method, comprising: acquiring multiple original text data and multiple comparison text data, one original text data corresponding to one comparison text data; Each original text data is input into the preset encoder, and based on the self-attention mechanism and the query attention mechanism, multiple target content hidden layer vector groups are obtained; each target content hidden layer vector group is input into the preset decoder.
  • a second aspect of the present application provides a label-based optimization model training device, comprising a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor, the processor executing the
  • the computer-readable instructions When the computer-readable instructions are described, the following steps are implemented: obtaining multiple original text data and multiple comparison text data, one original text data corresponding to one comparison text data; inputting each original text data into a preset encoder, based on The self-attention mechanism and the inquiry attention mechanism can obtain multiple target content hidden layer vector groups; input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target labels group; train the model based on the multiple target label groups to obtain an initial optimization model; input the multiple original text data into the initial optimization model in turn to obtain multiple text data to be detected, and determine each text to be detected Whether the data matches the corresponding comparison text data; if the target text data to be detected does not match the corresponding comparison text data, adjust the parameters of the initial optimization model to
  • a third aspect of the present application provides a computer-readable storage medium, where computer instructions are stored in the computer-readable storage medium, and when the computer instructions are executed on a computer, the computer is caused to perform the following steps: acquiring a plurality of original texts data and multiple comparison text data, one original text data corresponds to one comparison text data; input each original text data into the preset encoder, and obtain multiple target contents based on the self-attention mechanism and the inquiry attention mechanism Hidden layer vector group; input each target content hidden layer vector group into the preset decoder, and perform label calculation in combination with the autoregressive mechanism to obtain multiple target label groups; train the model based on the multiple target label groups to obtain the initial optimization model; inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data; If the detected text data does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  • a fourth aspect of the present application provides a label-based optimization model training device, comprising: an acquisition module for acquiring a plurality of original text data and a plurality of comparison text data, where one original text data corresponds to one comparison text data;
  • the layer vector calculation module is used to input each original text data into the preset encoder, and based on the self-attention mechanism and the query attention mechanism, multiple target content hidden layer vector groups are obtained;
  • the label group calculation module is used to Each target content hidden layer vector group is input into the preset decoder, and the label calculation is performed in combination with the autoregressive mechanism to obtain multiple target label groups;
  • the training module is used to train the model based on the multiple target label groups to obtain the initial optimization.
  • a judgment module for sequentially inputting the plurality of original text data into the initial optimization model, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data ; Adjustment module, if the target text data to be detected does not match the corresponding comparison text data, it is used to adjust the parameters of the initial optimization model to obtain the target optimization model.
  • a plurality of original text data and a plurality of comparison text data are obtained, one original text data corresponds to one comparison text data; each original text data is input into a preset encoder, based on self-attention Force mechanism and query attention mechanism to obtain multiple target content hidden layer vector groups; input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
  • the model is trained based on the multiple target label groups to obtain an initial optimization model; the multiple original text data are sequentially input into the initial optimization model to obtain multiple text data to be detected, and it is determined whether each text data to be detected is Match with the corresponding comparison text data; if the target text data to be detected does not match the corresponding comparison text data, then adjust the parameters of the initial optimization model to obtain the target optimization model.
  • the self-attention mechanism of the encoder combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels
  • the initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
  • FIG. 1 is a schematic diagram of an embodiment of a label-based optimization model training method in an embodiment of the present invention
  • FIG. 2 is a schematic diagram of another embodiment of a label-based optimization model training method in an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of calculating a target content hidden layer vector group in an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of an embodiment of a label-based optimization model training device in an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of another embodiment of a label-based optimization model training apparatus in an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of an embodiment of a label-based optimization model training device in an embodiment of the present invention.
  • the embodiments of the present application provide a label-based optimization model training method, apparatus, device, and storage medium. "Three", “fourth”, etc., if present, are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It is to be understood that data so used may be interchanged under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein.
  • the terms "comprising” or “having” and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed steps or units, but may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
  • the first embodiment of the label-based optimization model training method in the embodiment of the present application includes:
  • the server obtains multiple pieces of original text data and multiple pieces of comparison text data that correspond one-to-one with the multiple pieces of original text data.
  • a plurality of original text data are text data obtained by music data being recognized by a speech recognition model.
  • the original text data are interview scene data, such as "I was born in 2000, and I am studying in college", “My The graduate school is school A, and I work in company B” and so on.
  • the comparison text data corresponding to the original text data of "I was born in 2000 and I am studying in university” are "I was born in 2000 and I am studying in university now", “My graduation school is school A, and I am in company B
  • the comparison text data corresponding to the original text data of "work” is "My graduation school is school A, and now I work in company B".
  • the execution body of the present application may be a label-based optimization model training device, and may also be a terminal or a server, which is not specifically limited here.
  • the embodiments of the present application take the server as an execution subject as an example for description.
  • the self-attention mechanism and the inquiry attention mechanism are collectively referred to as the dual-stream attention mechanism, through which the dual-stream attention mechanism can be used to predict what the next word is through the above.
  • the self-attention mechanism is the traditional self-attention mechanism, and the inquiry-attention mechanism modifies some things on the basis of the self-attention mechanism, so that it cannot see itself in the global information when predicting what the next word is, so that it can Use the above to predict what the next word will be.
  • the server inputs a raw text data into the preset encoder, and iteratively calculates the content hidden layer vector of each layer in the encoder based on the self-attention mechanism and the query attention mechanism in the encoder, so as to obtain one of the target content hidden layers vector group, the server then inputs other original text data into the preset encoder to obtain other target content hidden layer vector groups, of which one target content hidden layer vector group and other target content hidden layer vector groups constitute multiple target content hidden layers Layer vector set.
  • the server inputs each target content hidden layer vector group into the preset decoder for decoding, and combines the decoder's autoregressive mechanism to calculate labels based on each target content hidden layer vector group to obtain multiple target label groups. .
  • decoders there are two types, one of which is a decoder with an autoregressive mechanism, and the other is a decoder with a feed-forward mechanism.
  • the decoder with autoregressive mechanism is mainly described.
  • the autoregressive mechanism can be understood as using a layer of decoding and encoding attention mechanism to decode the target content hidden layer vector group to obtain the corresponding target label group.
  • the decoder may also be a decoder with a feedforward mechanism, and the decoder with a feedforward mechanism mainly superimposes a layer of Softmax for the target content hidden layer vector group to obtain the corresponding target label group.
  • multiple content hidden layer vector groups are C1, C2, and C3.
  • the autoregressive mechanism is used to decode C1 to obtain a target label group D1
  • the autoregressive mechanism is used to decode C2 to obtain a target label group D2
  • the autoregressive mechanism is used to decode C3 to obtain a target label group D3.
  • the server performs model training based on multiple target label groups to obtain an initial optimized model.
  • the server uses multiple target label groups to perform multiple iterative training to obtain an initial optimized model.
  • the server sequentially inputs a plurality of original text data into the initial optimization model for optimization, obtains a plurality of text data to be detected, and then determines whether each text data to be detected matches the corresponding comparison text data.
  • Inputting each original text data into the initial optimization model can obtain a plurality of text data to be detected. By comparing the text data to be detected with the comparison text data, the accuracy of the initial optimization model can be judged. The parameters of the initial text optimization model are updated and adjusted.
  • the original text data is "I was born in 2000, and I am studying in college”
  • the corresponding comparison text data is "I was born in 2000, and I am studying in college now”.
  • Input the original text data of "I was born in 2000, and I am studying in college” into the initial optimization model, and the text data to be detected is "I was born in 2000, and I am studying in college”
  • the server judges "I was born in In 2000, whether the text data to be tested is the same as the text data to be tested for "I was born in 2000 and I am currently studying in college”.
  • the target text data to be detected does not match the corresponding comparison text data, adjust the parameters of the initial optimization model to obtain the target optimization model.
  • the server determines that the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  • This embodiment also uses the example of step 105.
  • the text data to be detected is “I was born in 2000 and I am studying at a university”, and the comparison text data is “I was born in 2000 and I am studying in a university now”, and the server determines that it is to be detected. If the text data does not match the comparison text data, it means that the optimization accuracy of the initial optimization model is low. In this case, the parameters of the initial optimization model need to be adjusted to obtain the target optimization model.
  • the basis for adjusting the initial optimization model is a plurality of original text data and a plurality of corresponding comparison text data, a plurality of original text data
  • the process of optimizing the initial optimization model is the same as the corresponding comparison file data, so other optimization processes will not be described in detail in this embodiment.
  • the self-attention mechanism of the encoder combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels
  • the initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
  • another embodiment of the label-based optimization model training method in the embodiment of the present application includes:
  • the server obtains multiple pieces of original text data and multiple pieces of comparison text data that correspond one-to-one with the multiple pieces of original text data.
  • a plurality of original text data are text data obtained by music data being recognized by a speech recognition model.
  • the original text data are interview scene data, such as "I was born in 2000, and I am studying in college", “My The graduate school is school A, and I work in company B” and so on.
  • the comparison text data corresponding to the original text data of "I was born in 2000 and I am studying in university” are "I was born in 2000 and I am studying in university now", “My graduation school is school A, and I am in company B
  • the comparison text data corresponding to the original text data of "work” is "My graduation school is school A, and now I work in company B".
  • the self-attention mechanism and the inquiry attention mechanism are collectively referred to as the dual-stream attention mechanism, through which the dual-stream attention mechanism can be used to predict what the next word is through the above.
  • the self-attention mechanism is the traditional self-attention mechanism, and the inquiry-attention mechanism modifies some things on the basis of the self-attention mechanism, so that it cannot see itself in the global information when predicting what the next word is, so that it can Use the above to predict what the next word will be.
  • the server inputs a raw text data into the preset encoder, and iteratively calculates the content hidden layer vector of each layer in the encoder based on the self-attention mechanism and the query attention mechanism in the encoder, so as to obtain one of the target content hidden layers vector group, the server then inputs other original text data into the preset encoder to obtain other target content hidden layer vector groups, of which one target content hidden layer vector group and other target content hidden layer vector groups constitute multiple target content hidden layers Layer vector set.
  • the server extracts the corresponding original text sequence from each original text data; the server inputs each original text sequence into the preset encoder, and determines the corresponding original text sequence based on the attention mask mechanism of the encoder and each original text sequence.
  • the server calculates the hidden layer of each input sequence based on the self-attention mechanism and the inquiry attention mechanism, generates the corresponding content hidden layer vector group, and obtains multiple target content hidden layer vector groups.
  • the server inputs the original text sequence into the preset encoder, and changes the order of the original text sequence based on the encoder's attention mechanism, so as to obtain the corresponding input sequence , assuming the resulting input sequence is:
  • the server calculates the input sequence in multiple hidden layers based on the self-attention mechanism and the query attention mechanism, and generates a content hidden layer vector group corresponding to the original text sequence.
  • the content hidden layer vector group is obtained, and multiple content hidden layer vector groups are obtained.
  • the hidden layers in this embodiment are 12 layers.
  • the server inputs each original text sequence into the preset encoder, and the specific process of determining the corresponding input sequence based on the encoder's attention mask mechanism and each original text sequence is as follows:
  • the server first inputs each original text sequence into the preset encoder, and combines the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain multiple corresponding position masks; then the server integrates each original text. Multiple position masks corresponding to the sequence to obtain the input sequence corresponding to each original text sequence.
  • the attention mask mechanism of the encoder changes the order of objects in the original text sequence through a mask matrix to obtain a new input sequence.
  • the server predicts the position of "a”, there is no information in front of "a”, so the corresponding position mask is [0,0,0,0]; when the server predicts the position of "is”, it needs to use
  • the server calculates the hidden layer for each input sequence based on the self-attention mechanism and the inquiry attention mechanism, generates the corresponding content hidden layer vector group, and obtains multiple target content hidden layer vector groups.
  • the specific process is as follows:
  • the server extracts the corresponding input vector group based on each input sequence, and adopts the self-attention mechanism and the inquiry attention mechanism to calculate the target input vector group and the preset initialization vector in the first hidden layer, and obtain the corresponding first The content hidden layer vector group and the corresponding first query hidden layer vector group; the server adopts the self-attention mechanism and the inquiry attention mechanism, in the second hidden layer, the corresponding first content hidden layer vector group and the corresponding first query The hidden layer vector group is calculated, and the corresponding second content hidden layer vector group and the corresponding second query hidden layer vector group are obtained; The content hidden layer vector group and the corresponding query hidden layer vector group are calculated until the last hidden layer, and the corresponding target content hidden layer vector group is generated, and the corresponding target content hidden layer vector group is the corresponding target content hidden layer. Content hidden layer vector group; finally, the server uses the self-attention mechanism and the query attention mechanism to calculate other input sequences according to the above steps, and obtains multiple target content hidden layer vector groups.
  • e(x 1 ), e(x 2 ), e(x 3 ) and e(x 4 ) are the input vectors extracted based on the target input sequence respectively
  • w is the preset initialization vector
  • the server adopts The self-attention mechanism and the query attention mechanism calculate the target input vector and the preset initialization vector in the first hidden layer of the encoder, and obtain the first content hidden layer vector group g 1 (1) , g 2 (1) , g 3 (1) and g 4 (1) , the first query hidden layer vector groups h 1 (1) , h 2 (1) , h 3 (1) and h 4 (1)
  • the server adopts a self-attention mechanism
  • the query attention mechanism hides the first content hidden layer vector group g 1 (1) , g 2 (1) , g 3 (1) and g 4 (1) and the first query hidden layer in the second hidden layer of the encoder
  • the layer vector groups h 1 (1) , h 2 (1) , h 3 (1) and h 4 (1) are calculated to obtain the second content hidden layer vector groups
  • the server inputs each target content hidden layer vector group into the preset decoder for decoding, and combines the decoder's autoregressive mechanism to calculate labels based on each target content hidden layer vector group to obtain multiple target label groups. .
  • decoders there are two types, one of which is a decoder with an autoregressive mechanism, and the other is a decoder with a feed-forward mechanism.
  • the decoder with autoregressive mechanism is mainly described.
  • the autoregressive mechanism can be understood as using a layer of decoding and encoding attention mechanism to decode the target content hidden layer vector group to obtain the corresponding target label group.
  • the decoder may also be a decoder with a feedforward mechanism, and the decoder with a feedforward mechanism mainly superimposes a layer of Softmax for the target content hidden layer vector group to obtain the corresponding target label group.
  • multiple content hidden layer vector groups are C1, C2, and C3.
  • the autoregressive mechanism is used to decode C1 to obtain a target label group D1
  • the autoregressive mechanism is used to decode C2 to obtain a target label group D2
  • the autoregressive mechanism is used to decode C3 to obtain a target label group D3.
  • the corresponding content hidden layer dimension is read from each target content hidden layer vector group to obtain multiple content hidden layer dimensions; the multiple content hidden layer dimensions are sequentially input into the preset decoder, and the autoregressive mechanism is combined.
  • the read content hidden layer dimension is 1*4*768, where 1 represents the dimension of the sentence, and 4 represents the dimension of the sentence Sentence length, 768 represents the preset word vector dimension.
  • the server inputs the hidden layer dimension of the content into the preset decoder, and combines the autoregressive mechanism to generate the decoding dimension and the corresponding decoding label probability group.
  • the decoding dimension is 1*4*(2*D v ), where 1 represents the dimension of the sentence, 4 represents the length of the sentence, and 2*D v is the number of tags in the decoding tag group corresponding to the target content hidden vector group.
  • the label group determines the decoded label with the highest probability as the target label, thereby obtaining a target label group corresponding to the target original text data.
  • the server also performs the same calculation for other target content hidden layer vector groups, thereby obtaining multiple target label groups.
  • the server performs model training based on multiple target label groups to obtain an initial optimized model.
  • the server uses multiple target label groups to perform multiple iterative training to obtain an initial optimized model.
  • each original text data into the initial optimization model in turn to generate a plurality of tag groups to be replaced, and each tag group to be replaced at least includes a reserved tag, a deletion tag and/or a phrase tag;
  • the server sequentially inputs each original text data into the initial optimization model for optimization, and obtains a plurality of tag groups to be replaced that at least include retained tags, deleted tags and/or phrase tags.
  • Keep tags and delete tags are basic tags, and phrase tags are additional tags.
  • the phrase label in this embodiment is calculated based on the longest common subsequence, and the phrase label corresponds to a phrase, and the phrase needs to meet three conditions: a. The amount of data is small enough to prevent the generation of some irrelevant words; b. For The current original text data needs to have a high enough coverage; c. The frequency of occurrence is high.
  • phrase labels The specific process of generating phrase labels is as follows: using the longest common subsequence to compare the original text data with the corresponding comparison text data, extracting words that do not belong to the original text data from the comparison text sequence, and then using the label corresponding to the word Add to the initial set of phrase tags, and finally sort the set of phrase tags according to the frequency of word occurrence to obtain the final set of phrase tags.
  • phrase tags can be combined with retention tags and delete tags, for example, 'Keep now and ' Delete now', where 'now is a phrase tag, Keep is a retention tag, and Delete is a deletion tag.
  • the target phrase corresponding to the phrase tag is determined in the preset phrase set; the sub-text data corresponding to the reserved tag is retained in each original text data, the sub-text data corresponding to the deletion tag is deleted, and the sub-text data corresponding to the phrase tag is deleted in each original text data.
  • the corresponding sub-text data is replaced with the target phrase, the text data to be detected corresponding to each original text data is generated, and a plurality of text data to be detected is obtained.
  • the raw text data is: [I was born in 2000, and I am in college. ]
  • the corresponding label group to be replaced is: [Keep Keep Keep Keep Keep Keep Keep Keep Delete Delete 'Now Keep Keep Keep Keep Keep Keep]]
  • the server determines in the preset phrase set that the target phrase corresponding to 'now is "now"; the server will keep the label
  • the sub-text data corresponding to Keep is retained, the sub-text data corresponding to Delete is deleted, and the sub-text data corresponding to ' is replaced by the target phrase, so as to obtain the text data to be detected as [I was born in 2000, now in college. ].
  • the server determines that the text data to be detected all match the corresponding comparison text data.
  • the server determines that the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  • This embodiment also uses the example of step 206.
  • the text data to be detected is "I was born in 2000, and I am in college now.”
  • the comparison text data is "I was born in 2000, and I am currently studying in college”.
  • the server determines that If the text data to be detected matches the comparison text data, it means that the optimization accuracy of the initial optimization model is high, and the initial optimization model is determined as the target optimization model.
  • the basis for adjusting the initial optimization model is a plurality of original text data and a plurality of corresponding comparison text data, a plurality of original text data
  • the process of optimizing the initial optimization model is the same as the corresponding comparison file data, so other optimization processes will not be described in detail in this embodiment.
  • the self-attention mechanism of the encoder combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels
  • the initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
  • the label-based optimization model training method in the embodiment of the present application has been described above, and the label-based optimization model training device in the embodiment of the present application is described below. Please refer to FIG. 4 , the label-based optimization model training device in the embodiment of the present application.
  • One embodiment includes:
  • an acquisition module 401 configured to acquire multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
  • the hidden layer vector calculation module 402 is used to input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry attention mechanism;
  • the tag group calculation module 403 is configured to input each target content hidden layer vector group into the preset decoder, and perform tag calculation in combination with the autoregressive mechanism to obtain multiple target tag groups;
  • a training module 404 configured to train a model based on the multiple target label groups to obtain an initial optimization model
  • Judging module 405 configured to sequentially input the plurality of original text data into the initial optimization model, obtain a plurality of text data to be detected, and determine whether each text data to be detected matches the corresponding comparison text data;
  • the adjustment module 406 is configured to adjust the parameters of the initial optimization model to obtain the target optimization model if the target text data to be detected does not match the corresponding comparison text data.
  • the self-attention mechanism of the encoder combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels
  • the initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
  • another embodiment of the label-based optimization model training device in the embodiment of the present application includes:
  • an acquisition module 401 configured to acquire multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
  • the hidden layer vector calculation module 402 is used to input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry attention mechanism;
  • the tag group calculation module 403 is configured to input each target content hidden layer vector group into the preset decoder, and perform tag calculation in combination with the autoregressive mechanism to obtain multiple target tag groups;
  • a training module 404 configured to train a model based on the multiple target label groups to obtain an initial optimization model
  • Judging module 405 configured to sequentially input the plurality of original text data into the initial optimization model, obtain a plurality of text data to be detected, and determine whether each text data to be detected matches the corresponding comparison text data;
  • the adjustment module 406 is configured to adjust the parameters of the initial optimization model to obtain the target optimization model if the target text data to be detected does not match the corresponding comparison text data.
  • the hidden layer vector calculation module 402 includes:
  • Extraction unit 4021 for extracting the corresponding original text sequence from each original text data
  • the input sequence determination unit 4022 is used to input each original text sequence into a preset encoder, and determine the corresponding input sequence based on the attention mask mechanism and each original text sequence;
  • the hidden layer vector calculation unit 4023 is configured to perform hidden layer calculation on each input sequence based on the self-attention mechanism and the query attention mechanism, generate a corresponding content hidden layer vector group, and obtain multiple target content hidden layer vector groups.
  • the input sequence determination unit 4022 can also be specifically used for:
  • Integrate multiple position masks corresponding to each original text sequence to obtain the input sequence corresponding to each original text sequence.
  • the hidden layer vector calculation unit 4023 can also be specifically used for:
  • the corresponding input vector group is extracted, and the self-attention mechanism and the inquiry attention mechanism are used to calculate the target input vector group and the preset initialization vector in the first hidden layer to obtain the corresponding first content the hidden layer vector group and the corresponding first query hidden layer vector group;
  • the corresponding first content hidden layer vector group and the corresponding first query hidden layer vector group are calculated in the second hidden layer to obtain the corresponding The second content hidden layer vector group and the corresponding second query hidden layer vector group;
  • the corresponding content hidden layer vector group and the corresponding query hidden layer vector group are calculated in other hidden layers according to the above steps, until the last hidden layer is generated.
  • the corresponding target content hidden layer vector group, the corresponding target content hidden layer vector group is the content hidden layer vector group corresponding to the last hidden layer;
  • the self-attention mechanism and the query-attention mechanism are used to calculate other input sequences according to the above steps to obtain multiple target content hidden layer vector groups.
  • the tag group calculation module 403 can also be specifically used for:
  • a target label group corresponding to each original text data is determined from each decoding label group, and a plurality of target label groups are obtained.
  • the judgment module 405 includes:
  • the tag group generation unit 4051 to be replaced is used to sequentially input each original text data into the initial optimization model, and generate a plurality of tag groups to be replaced, each tag group to be replaced at least includes a reserved tag, a deletion tag and/or a phrase tag;
  • the replacement unit 4052 is used to sequentially replace the plurality of label groups to be replaced according to the preset replacement rules, obtain a plurality of text data to be detected, and determine whether each text data to be detected is consistent with the corresponding comparison text data. match.
  • the replacement unit 4052 can also be specifically used for:
  • each original text data the sub-text data corresponding to the reserved label is retained, the sub-text data corresponding to the deletion label is deleted, and the sub-text data corresponding to the phrase label is replaced with the target phrase, and the corresponding sub-text data corresponding to each original text data is generated.
  • the text data to be detected is obtained, and a plurality of text data to be detected is obtained.
  • the self-attention mechanism of the encoder combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels
  • the initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
  • the label-based optimization model training device 600 may vary greatly due to different configurations or performances, and may include one or more than one Central processing units (CPU) 610 (eg, one or more processors) and memory 620, one or more storage media 630 (eg, one or more mass storage devices) that store application programs 633 or data 632.
  • CPU Central processing units
  • storage media 630 eg, one or more mass storage devices
  • the memory 620 and the storage medium 630 may be short-term storage or persistent storage.
  • the program stored in the storage medium 630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the label-based optimization model training device 600 .
  • the processor 610 may be configured to communicate with the storage medium 630 to execute a series of instruction operations in the storage medium 630 on the label-based optimization model training device 600 .
  • the label-based optimization model training device 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input and output interfaces 660, and/or, one or more operating systems 631, For example Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc.
  • operating systems 631 For example Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc.
  • FIG. 5 does not constitute a limitation on the label-based optimization model training device, and may include more or less components than those shown in the figure, or a combination of certain components may be included. some components, or a different arrangement of components.
  • the computer usable storage medium may mainly include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, and the like; using the created data, etc.
  • the present application also provides a label-based optimization model training device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected by lines; the at least one processor The processor invokes the instructions in the memory, so that the label-based optimization model training device executes the steps in the label-based optimization model training method described above.
  • the present application also provides a computer-readable storage medium, and the computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
  • the computer-readable storage medium stores computer instructions, and when the computer instructions are executed on the computer, the computer performs the following steps:
  • each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
  • an initial optimization model is obtained
  • the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .
  • the blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

The present application relates to the field of artificial intelligence and discloses a label-based optimization model training method, an apparatus, a device, and a storage medium, which are used for improving the optimization flexibility of a target optimization model as well as the accuracy of an optimized text. The label-based optimization model training method comprises: obtaining original text data and comparison text data; inputting the original text data into a preconfigured encoder, and obtaining target content hidden layer vector groups; obtaining target label groups according to the target content hidden layer vector groups and a decoder; training an initial optimization model on the basis of the target label groups; obtaining text data to be evaluated according to the original text data and the initial optimization model, and determining whether the text data to be evaluated matches with the comparison text data; if target text data to be evaluated does not match with the comparison text data, performing adjustment on the initial optimization model, and obtaining a target optimization model. Additionally, the present application further relates to blockchain technology, and the text data to be evaluated may be stored in a blockchain.

Description

基于标签的优化模型训练方法、装置、设备及存储介质Label-based optimization model training method, device, equipment and storage medium
本申请要求于2020年11月27日提交中国专利局、申请号为202011353108.0、发明名称为“基于标签的优化模型训练方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。This application claims the priority of the Chinese patent application filed on November 27, 2020 with the application number 202011353108.0 and the invention titled "label-based optimization model training method, device, equipment and storage medium", the entire content of which is Incorporated in the application by reference.
技术领域technical field
本申请涉及神经网络技术领域,尤其涉及一种基于标签的优化模型训练方法、装置、设备及存储介质。The present application relates to the technical field of neural networks, and in particular, to a label-based optimization model training method, apparatus, device, and storage medium.
背景技术Background technique
在目前的招聘流程中,很多公司为了简化招聘流程和提高工作效率,采用人工智能面试系统进行面试,主要通过语音识别的方式将面试者的语音转化成文本,在将语音转化为文本的过程中会存在单词和句子识别错误的情况,所以还需要用到识别优化模型对文本修正语法以及调整语句通顺度。In the current recruitment process, in order to simplify the recruitment process and improve work efficiency, many companies use artificial intelligence interview systems for interviews, which mainly convert the interviewee's voice into text through speech recognition. There will be errors in word and sentence recognition, so it is also necessary to use the recognition optimization model to correct the grammar of the text and adjust the sentence fluency.
目前识别优化模型修正语法和调整语句通顺度的方法是训练特定任务的训练器,然后采用该训练器对文本进行语法的修正和语句通顺度的调整,发明人意识到,这种调整方式只适用于特定的任务,无法对其他的任务进行优化,识别优化模型的灵活性较低,而且会降低其他任务转化为文本的准确率。The current method for identifying and optimizing models to correct grammar and adjust sentence fluency is to train a trainer for a specific task, and then use the trainer to correct grammar and adjust sentence fluency. The inventor realized that this adjustment method is only suitable for For a specific task, other tasks cannot be optimized, the flexibility of identifying and optimizing the model is low, and the accuracy of converting other tasks into text will be reduced.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种基于标签的优化模型训练方法、装置、设备及存储介质,提高了识别优化模型的灵活性,而且提高了其他任务转化为文本的准确率。The present application provides a label-based optimization model training method, device, equipment and storage medium, which improves the flexibility of identifying the optimization model and improves the accuracy of converting other tasks into text.
为实现上述目的,本申请第一方面提供了一种基于标签的优化模型训练方法,包括:获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;基于所述多个目标标签组训练模型,得到初始优化模型;将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。In order to achieve the above purpose, a first aspect of the present application provides a label-based optimization model training method, comprising: acquiring multiple original text data and multiple comparison text data, one original text data corresponding to one comparison text data; Each original text data is input into the preset encoder, and based on the self-attention mechanism and the query attention mechanism, multiple target content hidden layer vector groups are obtained; each target content hidden layer vector group is input into the preset decoder. , perform label calculation in combination with the autoregressive mechanism to obtain multiple target label groups; train a model based on the multiple target label groups to obtain an initial optimization model; input the plurality of original text data into the initial optimization model in turn to obtain A plurality of text data to be detected, and determine whether each text data to be detected matches the corresponding comparison text data; if the target text data to be detected does not match the corresponding comparison text data, then adjust the initial optimization model. parameters to obtain the target optimization model.
本申请第二方面提供了一种基于标签的优化模型训练设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;基于所述多个目标标签组训练模型,得到初始优化模型;将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。A second aspect of the present application provides a label-based optimization model training device, comprising a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor, the processor executing the When the computer-readable instructions are described, the following steps are implemented: obtaining multiple original text data and multiple comparison text data, one original text data corresponding to one comparison text data; inputting each original text data into a preset encoder, based on The self-attention mechanism and the inquiry attention mechanism can obtain multiple target content hidden layer vector groups; input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target labels group; train the model based on the multiple target label groups to obtain an initial optimization model; input the multiple original text data into the initial optimization model in turn to obtain multiple text data to be detected, and determine each text to be detected Whether the data matches the corresponding comparison text data; if the target text data to be detected does not match the corresponding comparison text data, adjust the parameters of the initial optimization model to obtain the target optimization model.
本申请第三方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进 行标签计算,得到多个目标标签组;基于所述多个目标标签组训练模型,得到初始优化模型;将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。A third aspect of the present application provides a computer-readable storage medium, where computer instructions are stored in the computer-readable storage medium, and when the computer instructions are executed on a computer, the computer is caused to perform the following steps: acquiring a plurality of original texts data and multiple comparison text data, one original text data corresponds to one comparison text data; input each original text data into the preset encoder, and obtain multiple target contents based on the self-attention mechanism and the inquiry attention mechanism Hidden layer vector group; input each target content hidden layer vector group into the preset decoder, and perform label calculation in combination with the autoregressive mechanism to obtain multiple target label groups; train the model based on the multiple target label groups to obtain the initial optimization model; inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data; If the detected text data does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
本申请第四方面提供了一种基于标签的优化模型训练装置,包括:获取模块,用于获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;隐藏层向量计算模块,用于将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;标签组计算模块,用于将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;训练模块,用于基于所述多个目标标签组训练模型,得到初始优化模型;判断模块,用于将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;调整模块,若目标待检测文本数据与对应的比对文本数据不匹配,则用于调整所述初始优化模型的参数,得到目标优化模型。A fourth aspect of the present application provides a label-based optimization model training device, comprising: an acquisition module for acquiring a plurality of original text data and a plurality of comparison text data, where one original text data corresponds to one comparison text data; The layer vector calculation module is used to input each original text data into the preset encoder, and based on the self-attention mechanism and the query attention mechanism, multiple target content hidden layer vector groups are obtained; the label group calculation module is used to Each target content hidden layer vector group is input into the preset decoder, and the label calculation is performed in combination with the autoregressive mechanism to obtain multiple target label groups; the training module is used to train the model based on the multiple target label groups to obtain the initial optimization. model; a judgment module for sequentially inputting the plurality of original text data into the initial optimization model, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data ; Adjustment module, if the target text data to be detected does not match the corresponding comparison text data, it is used to adjust the parameters of the initial optimization model to obtain the target optimization model.
本申请提供的技术方案中,获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;基于所述多个目标标签组训练模型,得到初始优化模型;将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。本申请实施例中,结合编码器的自注意力机制、编码器的询问注意力机制和解码器的自回归机制,计算多个原始文本数据对应的多个目标标签组,然后根据多个目标标签组训练初始优化模型,最后基于比对文本数据和初始优化模型输出的待检测文本数据调整初始优化模型,得到目标优化模型,使得该目标优化模型适用多种优化任务,提高了目标优化模型的优化灵活性以及优化文本的准确率。In the technical solution provided by the present application, a plurality of original text data and a plurality of comparison text data are obtained, one original text data corresponds to one comparison text data; each original text data is input into a preset encoder, based on self-attention Force mechanism and query attention mechanism to obtain multiple target content hidden layer vector groups; input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups; The model is trained based on the multiple target label groups to obtain an initial optimization model; the multiple original text data are sequentially input into the initial optimization model to obtain multiple text data to be detected, and it is determined whether each text data to be detected is Match with the corresponding comparison text data; if the target text data to be detected does not match the corresponding comparison text data, then adjust the parameters of the initial optimization model to obtain the target optimization model. In the embodiment of the present application, combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels The initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
附图说明Description of drawings
图1为本发明实施例中基于标签的优化模型训练方法的一个实施例示意图;1 is a schematic diagram of an embodiment of a label-based optimization model training method in an embodiment of the present invention;
图2为本发明实施例中基于标签的优化模型训练方法的另一个实施例示意图;2 is a schematic diagram of another embodiment of a label-based optimization model training method in an embodiment of the present invention;
图3为本发明实施例中计算目标内容隐藏层向量组的示意图;3 is a schematic diagram of calculating a target content hidden layer vector group in an embodiment of the present invention;
图4为本发明实施例中基于标签的优化模型训练装置的一个实施例示意图;4 is a schematic diagram of an embodiment of a label-based optimization model training device in an embodiment of the present invention;
图5为本发明实施例中基于标签的优化模型训练装置的另一个实施例示意图;5 is a schematic diagram of another embodiment of a label-based optimization model training apparatus in an embodiment of the present invention;
图6为本发明实施例中基于标签的优化模型训练设备的一个实施例示意图。FIG. 6 is a schematic diagram of an embodiment of a label-based optimization model training device in an embodiment of the present invention.
具体实施方式Detailed ways
本申请实施例提供了一种基于标签的优化模型训练方法、装置、设备及存储介质,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”或“具有”及其任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The embodiments of the present application provide a label-based optimization model training method, apparatus, device, and storage medium. "Three", "fourth", etc., if present, are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It is to be understood that data so used may be interchanged under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" or "having" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed steps or units, but may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
为便于理解,下面对本申请实施例的具体流程进行描述,请参阅图1,本申请实施例 中基于标签的优化模型训练方法的第一个实施例包括:For ease of understanding, the specific flow of the embodiment of the present application is described below, referring to Fig. 1, the first embodiment of the label-based optimization model training method in the embodiment of the present application includes:
101、获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;101. Obtain multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
服务器获取多个原始文本数据和与多个原始文本数据一一对应的多个比对文本数据。The server obtains multiple pieces of original text data and multiple pieces of comparison text data that correspond one-to-one with the multiple pieces of original text data.
多个原始文本数据用来训练优化模型,多个比对文本数据用来调整优化模型。多个原始文本数据为音乐数据经过语音识别模型识别得到的文本数据,在本实施例中,原始文本数据为面试场景数据,例如“我是出生于2000年,和我在读大学”,“我的毕业学校为学校A,我在公司B工作”等。“我是出生于2000年,和我在读大学”的原始文本数据对应的比对文本数据为“我是出生于2000年,现在在读大学”,“我的毕业学校为学校A,我在公司B工作”的原始文本数据对应的比对文本数据为“我的毕业学校为学校A,现在在公司B工作”。Multiple raw text data are used to train the optimized model, and multiple comparison text data are used to adjust the optimized model. A plurality of original text data are text data obtained by music data being recognized by a speech recognition model. In this embodiment, the original text data are interview scene data, such as "I was born in 2000, and I am studying in college", "My The graduate school is school A, and I work in company B” and so on. The comparison text data corresponding to the original text data of "I was born in 2000 and I am studying in university" are "I was born in 2000 and I am studying in university now", "My graduation school is school A, and I am in company B The comparison text data corresponding to the original text data of "work" is "My graduation school is school A, and now I work in company B".
可以理解的是,本申请的执行主体可以为基于标签的优化模型训练装置,还可以是终端或者服务器,具体此处不做限定。本申请实施例以服务器为执行主体为例进行说明。It can be understood that the execution body of the present application may be a label-based optimization model training device, and may also be a terminal or a server, which is not specifically limited here. The embodiments of the present application take the server as an execution subject as an example for description.
102、将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;102. Input each original text data into a preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
将每个原始文本数据输入预置的编码器中,基于编码器的自注意力机制和询问注意力机制计算内容隐藏层向量,得到多个目标内容隐藏层向量组。Input each original text data into the preset encoder, calculate the content hidden layer vector based on the encoder's self-attention mechanism and query attention mechanism, and obtain multiple target content hidden layer vector groups.
需要说明的是,自注意力机制和询问注意力机制统称为双流注意力机制,通过该双流注意力机制可以通过上文来预测下一个单词是什么。其中自注意力机制为传统的自注意力机制,而询问注意力机制在自注意力机制的基础上修改部分东西,从而在预测下一个单词是什么时在全局信息中无法看到自己,从而可以通过上文来预测下一个单词是什么。服务器将一个原始文本数据输入预置的编码器中,在编码器中基于自注意力机制和询问注意力机制迭代计算编码器中的每一层内容隐藏层向量,从而得到其中一个目标内容隐藏层向量组,服务器再将其他原始文本数据输入预置的编码器中,得到其他目标内容隐藏层向量组,其中一个目标内容隐藏层向量组和其他目标内容隐藏层向量组构成了多个目标内容隐藏层向量组。It should be noted that the self-attention mechanism and the inquiry attention mechanism are collectively referred to as the dual-stream attention mechanism, through which the dual-stream attention mechanism can be used to predict what the next word is through the above. The self-attention mechanism is the traditional self-attention mechanism, and the inquiry-attention mechanism modifies some things on the basis of the self-attention mechanism, so that it cannot see itself in the global information when predicting what the next word is, so that it can Use the above to predict what the next word will be. The server inputs a raw text data into the preset encoder, and iteratively calculates the content hidden layer vector of each layer in the encoder based on the self-attention mechanism and the query attention mechanism in the encoder, so as to obtain one of the target content hidden layers vector group, the server then inputs other original text data into the preset encoder to obtain other target content hidden layer vector groups, of which one target content hidden layer vector group and other target content hidden layer vector groups constitute multiple target content hidden layers Layer vector set.
103、将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;103. Input each target content hidden layer vector group into the preset decoder, and perform label calculation in combination with the autoregressive mechanism to obtain multiple target label groups;
服务器将每个目标内容隐藏层向量组输入预置的解码器中进行解码,在解码器中结合解码器的自回归机制对基于每个目标内容隐藏层向量组计算标签,得到多个目标标签组。The server inputs each target content hidden layer vector group into the preset decoder for decoding, and combines the decoder's autoregressive mechanism to calculate labels based on each target content hidden layer vector group to obtain multiple target label groups. .
需要说明的是,解码器为两种,其中一种是具有自回归机制的解码器,另一种是具有前馈机制的解码器。在本实施例中,主要对具有自回归机制的解码器进行说明,自回归机制可以理解为采用一层解码和编码注意力机制对目标内容隐藏层向量组进行解码,得到对应的目标标签组。在其他实施例中,解码器还可以为具有前馈机制的解码器,具有前馈机制的解码器主要是为目标内容隐藏层向量组叠加一层Softmax,从而得到对应的目标标签组。It should be noted that there are two types of decoders, one of which is a decoder with an autoregressive mechanism, and the other is a decoder with a feed-forward mechanism. In this embodiment, the decoder with autoregressive mechanism is mainly described. The autoregressive mechanism can be understood as using a layer of decoding and encoding attention mechanism to decode the target content hidden layer vector group to obtain the corresponding target label group. In other embodiments, the decoder may also be a decoder with a feedforward mechanism, and the decoder with a feedforward mechanism mainly superimposes a layer of Softmax for the target content hidden layer vector group to obtain the corresponding target label group.
例如,其中多个内容隐藏层向量组为C1、C2和C3,将C1、C2和C3依次输入预置的解码器中,首先采用自回归机制对C1进行解码,得到一个目标标签组D1,然后采用自回归机制对C2进行解码,得到一个目标标签组D2,最后采用自回归机制对C3进行解码,得到一个目标标签组D3。For example, multiple content hidden layer vector groups are C1, C2, and C3. Input C1, C2, and C3 into the preset decoder in turn. First, the autoregressive mechanism is used to decode C1 to obtain a target label group D1, and then The autoregressive mechanism is used to decode C2 to obtain a target label group D2, and finally the autoregressive mechanism is used to decode C3 to obtain a target label group D3.
104、基于多个目标标签组训练模型,得到初始优化模型;104. Train a model based on multiple target label groups to obtain an initial optimization model;
服务器基于多个目标标签组进行模型训练,得到初始优化模型。The server performs model training based on multiple target label groups to obtain an initial optimized model.
服务器采用多个目标标签组进行多次迭代训练,得到初始优化模型。The server uses multiple target label groups to perform multiple iterative training to obtain an initial optimized model.
105、将多个原始文本数据依次输入初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;105. Inputting a plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
服务器将多个原始文本数据依次输入初始优化模型中进行优化,得到多个待检测文本数据,然后判断每个待检测文本数据是否与对应的比对文本数据匹配。The server sequentially inputs a plurality of original text data into the initial optimization model for optimization, obtains a plurality of text data to be detected, and then determines whether each text data to be detected matches the corresponding comparison text data.
将每个原始文本数据输入初始优化模型中,能够得到多个待检测文本数据,将待检测文本数据与比对文本数据进行对比,能够判断初始优化模型的准确度,若不准确,则可以对初始文本优化模型的参数进行更新与调整。Inputting each original text data into the initial optimization model can obtain a plurality of text data to be detected. By comparing the text data to be detected with the comparison text data, the accuracy of the initial optimization model can be judged. The parameters of the initial text optimization model are updated and adjusted.
例如,原始文本数据为“我是出生于2000年,和我在读大学”,对应的比对文本数据为“我是出生于2000年,现在在读大学”。将“我是出生于2000年,和我在读大学”的原始文本数据输入初始优化模型中,得到待检测文本数据为“我是出生于2000年,和读大学”,服务器判断“我是出生于2000年,和读大学”的待检测文本数据是否与“我是出生于2000年,现在在读大学”的比对文本数据相同。For example, the original text data is "I was born in 2000, and I am studying in college", and the corresponding comparison text data is "I was born in 2000, and I am studying in college now". Input the original text data of "I was born in 2000, and I am studying in college" into the initial optimization model, and the text data to be detected is "I was born in 2000, and I am studying in college", and the server judges "I was born in In 2000, whether the text data to be tested is the same as the text data to be tested for "I was born in 2000 and I am currently studying in college".
106、若目标待检测文本数据与对应的比对文本数据不匹配,则调整初始优化模型的参数,得到目标优化模型。106. If the target text data to be detected does not match the corresponding comparison text data, adjust the parameters of the initial optimization model to obtain the target optimization model.
如果服务器判定目标待检测文本数据与对应的比对文本数据不匹配,则调整初始优化模型的参数,得到目标优化模型。If the server determines that the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
本实施例还沿用步骤105的例子,待检测文本数据为“我是出生于2000年,和读大学”,比对文本数据为“我是出生于2000年,现在在读大学”,服务器判定待检测文本数据与比对文本数据不匹配,则说明初始优化模型的优化精确度较低,此时需要调整初始优化模型的参数,从而得到目标优化模型。This embodiment also uses the example of step 105. The text data to be detected is “I was born in 2000 and I am studying at a university”, and the comparison text data is “I was born in 2000 and I am studying in a university now”, and the server determines that it is to be detected. If the text data does not match the comparison text data, it means that the optimization accuracy of the initial optimization model is low. In this case, the parameters of the initial optimization model need to be adjusted to obtain the target optimization model.
需要说明的是,在本实施例中,只是以一个例子进行了说明,实际上用于调整初始优化模型的依据为多个原始文本数据和对应的多个比对文本数据,多个原始文本数据和对应的对比文件数据对初始优化模型优化的过程相同,因此本实施例对其他的优化过程不加赘述。It should be noted that, in this embodiment, only one example is used for description. In fact, the basis for adjusting the initial optimization model is a plurality of original text data and a plurality of corresponding comparison text data, a plurality of original text data The process of optimizing the initial optimization model is the same as the corresponding comparison file data, so other optimization processes will not be described in detail in this embodiment.
本申请实施例中,结合编码器的自注意力机制、编码器的询问注意力机制和解码器的自回归机制,计算多个原始文本数据对应的多个目标标签组,然后根据多个目标标签组训练初始优化模型,最后基于比对文本数据和初始优化模型输出的待检测文本数据调整初始优化模型,得到目标优化模型,使得该目标优化模型适用多种优化任务,提高了目标优化模型的优化灵活性以及优化文本的准确率。In the embodiment of the present application, combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels The initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
请参阅图2,本申请实施例中基于标签的优化模型训练方法的另一个实施例包括:Referring to FIG. 2, another embodiment of the label-based optimization model training method in the embodiment of the present application includes:
201、获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;201. Obtain multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
服务器获取多个原始文本数据和与多个原始文本数据一一对应的多个比对文本数据。The server obtains multiple pieces of original text data and multiple pieces of comparison text data that correspond one-to-one with the multiple pieces of original text data.
多个原始文本数据用来训练优化模型,多个比对文本数据用来调整优化模型。多个原始文本数据为音乐数据经过语音识别模型识别得到的文本数据,在本实施例中,原始文本数据为面试场景数据,例如“我是出生于2000年,和我在读大学”,“我的毕业学校为学校A,我在公司B工作”等。“我是出生于2000年,和我在读大学”的原始文本数据对应的比对文本数据为“我是出生于2000年,现在在读大学”,“我的毕业学校为学校A,我在公司B工作”的原始文本数据对应的比对文本数据为“我的毕业学校为学校A,现在在公司B工作”。Multiple raw text data are used to train the optimized model, and multiple comparison text data are used to adjust the optimized model. A plurality of original text data are text data obtained by music data being recognized by a speech recognition model. In this embodiment, the original text data are interview scene data, such as "I was born in 2000, and I am studying in college", "My The graduate school is school A, and I work in company B” and so on. The comparison text data corresponding to the original text data of "I was born in 2000 and I am studying in university" are "I was born in 2000 and I am studying in university now", "My graduation school is school A, and I am in company B The comparison text data corresponding to the original text data of "work" is "My graduation school is school A, and now I work in company B".
202、将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;202. Input each original text data into a preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
将每个原始文本数据输入预置的编码器中,基于编码器的自注意力机制和询问注意力 机制计算内容隐藏层向量,得到多个目标内容隐藏层向量组。Input each original text data into the preset encoder, calculate the content hidden layer vector based on the encoder's self-attention mechanism and query attention mechanism, and obtain multiple target content hidden layer vector groups.
需要说明的是,自注意力机制和询问注意力机制统称为双流注意力机制,通过该双流注意力机制可以通过上文来预测下一个单词是什么。其中自注意力机制为传统的自注意力机制,而询问注意力机制在自注意力机制的基础上修改部分东西,从而在预测下一个单词是什么时在全局信息中无法看到自己,从而可以通过上文来预测下一个单词是什么。服务器将一个原始文本数据输入预置的编码器中,在编码器中基于自注意力机制和询问注意力机制迭代计算编码器中的每一层内容隐藏层向量,从而得到其中一个目标内容隐藏层向量组,服务器再将其他原始文本数据输入预置的编码器中,得到其他目标内容隐藏层向量组,其中一个目标内容隐藏层向量组和其他目标内容隐藏层向量组构成了多个目标内容隐藏层向量组。It should be noted that the self-attention mechanism and the inquiry attention mechanism are collectively referred to as the dual-stream attention mechanism, through which the dual-stream attention mechanism can be used to predict what the next word is through the above. The self-attention mechanism is the traditional self-attention mechanism, and the inquiry-attention mechanism modifies some things on the basis of the self-attention mechanism, so that it cannot see itself in the global information when predicting what the next word is, so that it can Use the above to predict what the next word will be. The server inputs a raw text data into the preset encoder, and iteratively calculates the content hidden layer vector of each layer in the encoder based on the self-attention mechanism and the query attention mechanism in the encoder, so as to obtain one of the target content hidden layers vector group, the server then inputs other original text data into the preset encoder to obtain other target content hidden layer vector groups, of which one target content hidden layer vector group and other target content hidden layer vector groups constitute multiple target content hidden layers Layer vector set.
具体的,服务器从每个原始文本数据中提取对应的原始文本序列;服务器将每个原始文本序列输入预置的编码器中,基于编码器的注意力掩码机制和每个原始文本序列确定对应的输入序列;服务器基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组。Specifically, the server extracts the corresponding original text sequence from each original text data; the server inputs each original text sequence into the preset encoder, and determines the corresponding original text sequence based on the attention mask mechanism of the encoder and each original text sequence. The server calculates the hidden layer of each input sequence based on the self-attention mechanism and the inquiry attention mechanism, generates the corresponding content hidden layer vector group, and obtains multiple target content hidden layer vector groups.
例如,原始文本序列为[This,is,a,sentence],服务器将原始文本序列输入预置的编码器中,基于编码器的注意力机制来改变原始文本序列的顺序,从而得到对应的输入序列,假设得到的输入序列为:For example, if the original text sequence is [This,is,a,sentence], the server inputs the original text sequence into the preset encoder, and changes the order of the original text sequence based on the encoder's attention mechanism, so as to obtain the corresponding input sequence , assuming the resulting input sequence is:
Figure PCTCN2021097136-appb-000001
Figure PCTCN2021097136-appb-000001
服务器基于自注意力机制和询问注意力机制在对该输入序列在多个隐藏层中进行计算,生成与原始文本序列对应的内容隐藏层向量组,按照这种方式生成多个原始文本序列对应的内容隐藏层向量组,得到多个内容隐藏层向量组。The server calculates the input sequence in multiple hidden layers based on the self-attention mechanism and the query attention mechanism, and generates a content hidden layer vector group corresponding to the original text sequence. The content hidden layer vector group is obtained, and multiple content hidden layer vector groups are obtained.
需要说明的是,本实施例的隐藏层为12层。It should be noted that the hidden layers in this embodiment are 12 layers.
服务器将每个原始文本序列输入预置的编码器中,基于编码器的注意力掩码机制和每个原始文本序列确定对应的输入序列的具体过程为:The server inputs each original text sequence into the preset encoder, and the specific process of determining the corresponding input sequence based on the encoder's attention mask mechanism and each original text sequence is as follows:
服务器首先将每个原始文本序列输入预置的编码器中,结合注意力掩码机制对每个原始文本序列进行多次迭代预测,得到对应的多个位置掩码;然后服务器整合每个原始文本序列对应的多个位置掩码,得到每个原始文本序列对应的输入序列。The server first inputs each original text sequence into the preset encoder, and combines the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain multiple corresponding position masks; then the server integrates each original text. Multiple position masks corresponding to the sequence to obtain the input sequence corresponding to each original text sequence.
为了便于理解,下面结合具体场景进行说明:For ease of understanding, the following description is combined with specific scenarios:
假设有一个原始文本序列为[This,is,a,sentence],基于现有的模型进行预测结果时,通常会得到4!种排列可能的结果。在本实施例中,编码器的注意力掩码机制会通过一个掩码矩阵来改变原始文本序列中对象的顺序,得到一个新的输入序列。假设,当服务器预测“a”的位置时,“a”的前面没有信息,所以对应的位置掩码为[0,0,0,0];当服务器预测“is”的位置时,需要用到|“a”的位置,服务器则确定对应的位置掩码为[0,0,1,0];当服务器预测“sentence”的位置时,结合“is”和“a”的位置,服务器得到对应的位置掩码为[0,1,1,0],同理,当服务器预测This的位置时,得到对应的位置掩码为[0,1,1,1]。最后服务器整合这些位置掩码,得到与[This,is,a,sentence]原始文本序列对应的输入序列为:Suppose there is an original text sequence [This,is,a,sentence], when predicting the result based on the existing model, we usually get 4! permutations of possible outcomes. In this embodiment, the attention mask mechanism of the encoder changes the order of objects in the original text sequence through a mask matrix to obtain a new input sequence. Suppose, when the server predicts the position of "a", there is no information in front of "a", so the corresponding position mask is [0,0,0,0]; when the server predicts the position of "is", it needs to use |The location of "a", the server determines that the corresponding location mask is [0, 0, 1, 0]; when the server predicts the location of "sentence", combining the locations of "is" and "a", the server obtains the corresponding location The location mask of This is [0,1,1,0]. Similarly, when the server predicts the location of This, the corresponding location mask is [0,1,1,1]. Finally, the server integrates these position masks to obtain the input sequence corresponding to the original text sequence of [This,is,a,sentence] as:
Figure PCTCN2021097136-appb-000002
Figure PCTCN2021097136-appb-000002
服务器基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组的具体过程为:The server calculates the hidden layer for each input sequence based on the self-attention mechanism and the inquiry attention mechanism, generates the corresponding content hidden layer vector group, and obtains multiple target content hidden layer vector groups. The specific process is as follows:
服务器基于每个输入序列提取对应的输入向量组,并采用自注意力机制和询问注意力机制,在第一层隐藏层对目标输入向量组和预置的初始化向量进行计算,得到对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组;服务器采用自注意力机制和询问注意力机制,在第二层隐藏层对对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组进行计算,得到对应的第二内容隐藏层向量组和对应的第二查询隐藏层向量组;服务器采用自注意力机制和询问注意力机制,按照上述步骤在其他层隐藏层对对应的内容隐藏层向量组和对应的查询隐藏层向量组进行计算,直至最后一层隐藏层,生成对应的目标内容隐藏层向量组,对应的目标内容隐藏层向量组为最后一层隐藏层对应的内容隐藏层向量组;最后服务器采用自注意力机制和询问注意力机制按照上述步骤对其他输入序列进行计算,得到多个目标内容隐藏层向量组。The server extracts the corresponding input vector group based on each input sequence, and adopts the self-attention mechanism and the inquiry attention mechanism to calculate the target input vector group and the preset initialization vector in the first hidden layer, and obtain the corresponding first The content hidden layer vector group and the corresponding first query hidden layer vector group; the server adopts the self-attention mechanism and the inquiry attention mechanism, in the second hidden layer, the corresponding first content hidden layer vector group and the corresponding first query The hidden layer vector group is calculated, and the corresponding second content hidden layer vector group and the corresponding second query hidden layer vector group are obtained; The content hidden layer vector group and the corresponding query hidden layer vector group are calculated until the last hidden layer, and the corresponding target content hidden layer vector group is generated, and the corresponding target content hidden layer vector group is the corresponding target content hidden layer. Content hidden layer vector group; finally, the server uses the self-attention mechanism and the query attention mechanism to calculate other input sequences according to the above steps, and obtains multiple target content hidden layer vector groups.
请参阅图3,e(x 1)、e(x 2)、e(x 3)和e(x 4)分别为基于目标输入序列中提取的输入向量,w为预置的初始化向量,服务器采用自注意力机制和询问注意力机制在编码器的第一层隐藏层对目标输入向量和预置的初始化向量进行计算,得到第一内容隐藏层向量组g 1 (1)、g 2 (1)、g 3 (1)和g 4 (1),第一查询隐藏层向量组h 1 (1)、h 2 (1)、h 3 (1)以及h 4 (1);服务器采用自注意力机制和询问注意力机制在编码器的第二层隐藏层对第一内容隐藏层向量组g 1 (1)、g 2 (1)、g 3 (1)和g 4 (1)以及第一查询隐藏层向量组h 1 (1)、h 2 (1)、h 3 (1)和h 4 (1)进行计算,得到第二内容隐藏层向量组g 1 (2)、g 2 (2)、g 3 (2)和g 4 (3),得到第二查询隐藏层向量组为h 1 (2)、h 2 (2)、h 3 (2)和h 4 (2);按照此方法,以上一层隐藏层的输出作为下一层隐藏层的输入,结合自注意力机制和询问注意力机制进行计算,得到每一层隐藏层的查询隐藏层向量组和每一层隐藏层的内容隐藏层向量组。将最后一层(第12层)隐藏层输出的内容隐藏层向量组作为目标内容隐藏层向量组,即图中的x 1、x 2、x 3和x 4Please refer to Figure 3, e(x 1 ), e(x 2 ), e(x 3 ) and e(x 4 ) are the input vectors extracted based on the target input sequence respectively, w is the preset initialization vector, the server adopts The self-attention mechanism and the query attention mechanism calculate the target input vector and the preset initialization vector in the first hidden layer of the encoder, and obtain the first content hidden layer vector group g 1 (1) , g 2 (1) , g 3 (1) and g 4 (1) , the first query hidden layer vector groups h 1 (1) , h 2 (1) , h 3 (1) and h 4 (1) ; the server adopts a self-attention mechanism And the query attention mechanism hides the first content hidden layer vector group g 1 (1) , g 2 (1) , g 3 (1) and g 4 (1) and the first query hidden layer in the second hidden layer of the encoder The layer vector groups h 1 (1) , h 2 (1) , h 3 (1) and h 4 (1) are calculated to obtain the second content hidden layer vector groups g 1 (2) , g 2 (2) , g 3 (2) and g 4 (3) , the second query hidden layer vector group is obtained as h 1 (2) , h 2 (2) , h 3 (2) and h 4 (2) ; according to this method, the above one The output of the hidden layer of each layer is used as the input of the next hidden layer, and is calculated by combining the self-attention mechanism and the query attention mechanism to obtain the query hidden layer vector group of each hidden layer and the content hidden layer vector of each hidden layer. Group. The content hidden layer vector group output by the hidden layer of the last layer (the 12th layer) is used as the target content hidden layer vector group, namely x 1 , x 2 , x 3 and x 4 in the figure.
203、将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;203. Input each target content hidden layer vector group into a preset decoder, and perform label calculation in combination with an autoregressive mechanism to obtain multiple target label groups;
服务器将每个目标内容隐藏层向量组输入预置的解码器中进行解码,在解码器中结合解码器的自回归机制对基于每个目标内容隐藏层向量组计算标签,得到多个目标标签组。The server inputs each target content hidden layer vector group into the preset decoder for decoding, and combines the decoder's autoregressive mechanism to calculate labels based on each target content hidden layer vector group to obtain multiple target label groups. .
需要说明的是,解码器为两种,其中一种是具有自回归机制的解码器,另一种是具有前馈机制的解码器。在本实施例中,主要对具有自回归机制的解码器进行说明,自回归机制可以理解为采用一层解码和编码注意力机制对目标内容隐藏层向量组进行解码,得到对应的目标标签组。在其他实施例中,解码器还可以为具有前馈机制的解码器,具有前馈机制的解码器主要是为目标内容隐藏层向量组叠加一层Softmax,从而得到对应的目标标签组。It should be noted that there are two types of decoders, one of which is a decoder with an autoregressive mechanism, and the other is a decoder with a feed-forward mechanism. In this embodiment, the decoder with autoregressive mechanism is mainly described. The autoregressive mechanism can be understood as using a layer of decoding and encoding attention mechanism to decode the target content hidden layer vector group to obtain the corresponding target label group. In other embodiments, the decoder may also be a decoder with a feedforward mechanism, and the decoder with a feedforward mechanism mainly superimposes a layer of Softmax for the target content hidden layer vector group to obtain the corresponding target label group.
例如,其中多个内容隐藏层向量组为C1、C2和C3,将C1、C2和C3依次输入预置的解码器中,首先采用自回归机制对C1进行解码,得到一个目标标签组D1,然后采用自回归机制对C2进行解码,得到一个目标标签组D2,最后采用自回归机制对C3进行解码,得到一个目标标签组D3。For example, multiple content hidden layer vector groups are C1, C2, and C3. Input C1, C2, and C3 into the preset decoder in turn. First, the autoregressive mechanism is used to decode C1 to obtain a target label group D1, and then The autoregressive mechanism is used to decode C2 to obtain a target label group D2, and finally the autoregressive mechanism is used to decode C3 to obtain a target label group D3.
具体的,从每个目标内容隐藏层向量组中读取对应的内容隐藏层维度,得到多个内容隐藏层维度;将多个内容隐藏层维度依次输入预置的解码器中,结合自回归机制生成多个解码标签组和对应的多个解码标签概率组;基于每个解码标签组对应的解码标签概率组,从每个解码标签组中确定与每个原始文本数据对应的目标标签组,得到多个目标标签组。Specifically, the corresponding content hidden layer dimension is read from each target content hidden layer vector group to obtain multiple content hidden layer dimensions; the multiple content hidden layer dimensions are sequentially input into the preset decoder, and the autoregressive mechanism is combined. Generate multiple decoding tag groups and corresponding multiple decoding tag probability groups; based on the decoding tag probability group corresponding to each decoding tag group, determine the target tag group corresponding to each original text data from each decoding tag group, and obtain Multiple target label groups.
为了便于理解,结合具体场景进行说明:In order to facilitate understanding, the description is combined with specific scenarios:
假设服务器从上述步骤202得到的目标内容隐藏层向量组x 1、x 2、x 3和x 4,读取的内容隐藏层维度为1*4*768,其中,1代表句子的维度,4代表句子长度,768代表预设的单词向量维度。然后服务器将该内容隐藏层维度输入预置的解码器中,结合自回归机制,生成解码维度和对应的解码标签概率组。解码维度为1*4*(2*D v),其中1代表句子的维度,4代表句子长度,2*D v为目标内容隐藏向量组对应的解码标签组中的标签个数,服务器在解码标签组基于每个对应的解码标签概率,确定概率最大的解码标签为目标标签,从而得到一个与目标原始文本数据对应的目标标签组。服务器针对其他目标内容隐藏层向量组也进行相同的计算,从而得到多个目标标签组。 Assuming that the server obtains the target content hidden layer vector groups x 1 , x 2 , x 3 and x 4 from the above step 202, the read content hidden layer dimension is 1*4*768, where 1 represents the dimension of the sentence, and 4 represents the dimension of the sentence Sentence length, 768 represents the preset word vector dimension. Then the server inputs the hidden layer dimension of the content into the preset decoder, and combines the autoregressive mechanism to generate the decoding dimension and the corresponding decoding label probability group. The decoding dimension is 1*4*(2*D v ), where 1 represents the dimension of the sentence, 4 represents the length of the sentence, and 2*D v is the number of tags in the decoding tag group corresponding to the target content hidden vector group. Based on the probability of each corresponding decoded label, the label group determines the decoded label with the highest probability as the target label, thereby obtaining a target label group corresponding to the target original text data. The server also performs the same calculation for other target content hidden layer vector groups, thereby obtaining multiple target label groups.
204、基于多个目标标签组训练模型,得到初始优化模型;204. Train a model based on multiple target label groups to obtain an initial optimization model;
服务器基于多个目标标签组进行模型训练,得到初始优化模型。The server performs model training based on multiple target label groups to obtain an initial optimized model.
服务器采用多个目标标签组进行多次迭代训练,得到初始优化模型。The server uses multiple target label groups to perform multiple iterative training to obtain an initial optimized model.
205、将每个原始文本数据依次输入初始优化模型中,生成多个待替换标签组,每个待替换标签组至少包括保留标签、删除标签和/或短语标签;205. Input each original text data into the initial optimization model in turn to generate a plurality of tag groups to be replaced, and each tag group to be replaced at least includes a reserved tag, a deletion tag and/or a phrase tag;
服务器将每个原始文本数据依次输入初始优化模型中进行优化,得到多个至少包括保留标签、删除标签和/或短语标签的待替换标签组。The server sequentially inputs each original text data into the initial optimization model for optimization, and obtains a plurality of tag groups to be replaced that at least include retained tags, deleted tags and/or phrase tags.
保留标签和删除标签为基本标签,短语标签为附加标签。本实施例中的短语标签是基于最长公共子序列计算得到的,短语标签对应短语,该短语需要满足三个条件:a、数据量足够小,用于防止生成一些无关的单词;b、对于当前原始文本数据需要拥有足够高的覆盖率;c、出现的频率较高。生成短语标签的具体过程为:采用最长公共子序列对原始文本数据与对应的比对文本数据进行对比,从比对文本序列中提取不属于原始文本数据的单词,然后将该单词对应的标签添加初始的短语标签集合中,最后对该短语标签集合按照单词出现的频率进行排序,得到最终的短语标签集合。Keep tags and delete tags are basic tags, and phrase tags are additional tags. The phrase label in this embodiment is calculated based on the longest common subsequence, and the phrase label corresponds to a phrase, and the phrase needs to meet three conditions: a. The amount of data is small enough to prevent the generation of some irrelevant words; b. For The current original text data needs to have a high enough coverage; c. The frequency of occurrence is high. The specific process of generating phrase labels is as follows: using the longest common subsequence to compare the original text data with the corresponding comparison text data, extracting words that do not belong to the original text data from the comparison text sequence, and then using the label corresponding to the word Add to the initial set of phrase tags, and finally sort the set of phrase tags according to the frequency of word occurrence to obtain the final set of phrase tags.
需要说明的是,短语标签可以与保留标签和删除标签组合,例如 '现在Keep和 '现在Delete,其中, '现在为短语标签,Keep为保留标签,Delete为删除标签。 It should be noted that phrase tags can be combined with retention tags and delete tags, for example, 'Keep now and ' Delete now', where 'now is a phrase tag, Keep is a retention tag, and Delete is a deletion tag.
206、按照预置的替换规则依次对多个待替换标签组进行替换,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;206. Replacing a plurality of label groups to be replaced in sequence according to a preset replacement rule, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
具体的,在预置的短语集合中确定与短语标签对应的目标短语;在每个原始文本数据中保留与保留标签对应的子文本数据、删除与删除标签对应的子文本数据以及将与短语标签对应的子文本数据替换为目标短语,生成与每个原始文本数据对应的待检测文本数据,得到多个待检测文本数据。Specifically, the target phrase corresponding to the phrase tag is determined in the preset phrase set; the sub-text data corresponding to the reserved tag is retained in each original text data, the sub-text data corresponding to the deletion tag is deleted, and the sub-text data corresponding to the phrase tag is deleted in each original text data. The corresponding sub-text data is replaced with the target phrase, the text data to be detected corresponding to each original text data is generated, and a plurality of text data to be detected is obtained.
例如原始文本数据为:[我是出生于2000年,和我在上大学。],对应的待替换标签组为:[Keep Keep Keep Keep Keep Keep Delete Delete  '现在Keep Keep Keep Keep],服务器在预置短语集中确定与 '现在对应的目标短语为“现在”;服务器将保留标签Keep对应的子文本数据保留,删除Delete对应的子文本数据,将 '现在对应的子文本数据替换为目标短语,从而得到待检测文本数据为[我是出生于2000年,现在在上大学。]。然后服务器判断该待检测文本数据是都与对应的比对文本数据相匹配。 For example the raw text data is: [I was born in 2000, and I am in college. ], the corresponding label group to be replaced is: [Keep Keep Keep Keep Keep Keep Keep Delete Delete 'Now Keep Keep Keep Keep], the server determines in the preset phrase set that the target phrase corresponding to 'now is "now"; the server will keep the label The sub-text data corresponding to Keep is retained, the sub-text data corresponding to Delete is deleted, and the sub-text data corresponding to ' is replaced by the target phrase, so as to obtain the text data to be detected as [I was born in 2000, now in college. ]. Then, the server determines that the text data to be detected all match the corresponding comparison text data.
207、若目标待检测文本数据与对应的比对文本数据不匹配,则调整初始优化模型的参 数,得到目标优化模型。207. If the target text data to be detected does not match the corresponding comparison text data, adjust the parameters of the initial optimization model to obtain the target optimization model.
如果服务器判定目标待检测文本数据与对应的比对文本数据不匹配,则调整初始优化模型的参数,得到目标优化模型。If the server determines that the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
本实施例还沿用步骤206的例子,待检测文本数据为“我是出生于2000年,现在在上大学。”,比对文本数据为“我是出生于2000年,现在在读大学”,服务器判定待检测文本数据与比对文本数据匹配,则说明初始优化模型的优化精确度较高,将初始优化模型确定为目标优化模型。This embodiment also uses the example of step 206. The text data to be detected is "I was born in 2000, and I am in college now.", and the comparison text data is "I was born in 2000, and I am currently studying in college". The server determines that If the text data to be detected matches the comparison text data, it means that the optimization accuracy of the initial optimization model is high, and the initial optimization model is determined as the target optimization model.
需要说明的是,在本实施例中,只是以一个例子进行了说明,实际上用于调整初始优化模型的依据为多个原始文本数据和对应的多个比对文本数据,多个原始文本数据和对应的对比文件数据对初始优化模型优化的过程相同,因此本实施例对其他的优化过程不加赘述。It should be noted that, in this embodiment, only one example is used for description. In fact, the basis for adjusting the initial optimization model is a plurality of original text data and a plurality of corresponding comparison text data, a plurality of original text data The process of optimizing the initial optimization model is the same as the corresponding comparison file data, so other optimization processes will not be described in detail in this embodiment.
本申请实施例中,结合编码器的自注意力机制、编码器的询问注意力机制和解码器的自回归机制,计算多个原始文本数据对应的多个目标标签组,然后根据多个目标标签组训练初始优化模型,最后基于比对文本数据和初始优化模型输出的待检测文本数据调整初始优化模型,得到目标优化模型,使得该目标优化模型适用多种优化任务,提高了目标优化模型的优化灵活性以及优化文本的准确率。In the embodiment of the present application, combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels The initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
上面对本申请实施例中基于标签的优化模型训练方法进行了描述,下面对本申请实施例中基于标签的优化模型训练装置进行描述,请参阅图4,本申请实施例中基于标签的优化模型训练装置一个实施例包括:The label-based optimization model training method in the embodiment of the present application has been described above, and the label-based optimization model training device in the embodiment of the present application is described below. Please refer to FIG. 4 , the label-based optimization model training device in the embodiment of the present application. One embodiment includes:
获取模块401,用于获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;an acquisition module 401, configured to acquire multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
隐藏层向量计算模402,用于将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;The hidden layer vector calculation module 402 is used to input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry attention mechanism;
标签组计算模块403,用于将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;The tag group calculation module 403 is configured to input each target content hidden layer vector group into the preset decoder, and perform tag calculation in combination with the autoregressive mechanism to obtain multiple target tag groups;
训练模块404,用于基于所述多个目标标签组训练模型,得到初始优化模型;A training module 404, configured to train a model based on the multiple target label groups to obtain an initial optimization model;
判断模块405,用于将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Judging module 405, configured to sequentially input the plurality of original text data into the initial optimization model, obtain a plurality of text data to be detected, and determine whether each text data to be detected matches the corresponding comparison text data;
调整模块406,若目标待检测文本数据与对应的比对文本数据不匹配,则用于调整所述初始优化模型的参数,得到目标优化模型。The adjustment module 406 is configured to adjust the parameters of the initial optimization model to obtain the target optimization model if the target text data to be detected does not match the corresponding comparison text data.
本申请实施例中,结合编码器的自注意力机制、编码器的询问注意力机制和解码器的自回归机制,计算多个原始文本数据对应的多个目标标签组,然后根据多个目标标签组训练初始优化模型,最后基于比对文本数据和初始优化模型输出的待检测文本数据调整初始优化模型,得到目标优化模型,使得该目标优化模型适用多种优化任务,提高了目标优化模型的优化灵活性以及优化文本的准确率。In the embodiment of the present application, combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels The initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
请参阅图5,本申请实施例中基于标签的优化模型训练装置的另一个实施例包括:Referring to FIG. 5, another embodiment of the label-based optimization model training device in the embodiment of the present application includes:
获取模块401,用于获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;an acquisition module 401, configured to acquire multiple original text data and multiple comparison text data, where one original text data corresponds to one comparison text data;
隐藏层向量计算模块402,用于将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;The hidden layer vector calculation module 402 is used to input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry attention mechanism;
标签组计算模块403,用于将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;The tag group calculation module 403 is configured to input each target content hidden layer vector group into the preset decoder, and perform tag calculation in combination with the autoregressive mechanism to obtain multiple target tag groups;
训练模块404,用于基于所述多个目标标签组训练模型,得到初始优化模型;A training module 404, configured to train a model based on the multiple target label groups to obtain an initial optimization model;
判断模块405,用于将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Judging module 405, configured to sequentially input the plurality of original text data into the initial optimization model, obtain a plurality of text data to be detected, and determine whether each text data to be detected matches the corresponding comparison text data;
调整模块406,若目标待检测文本数据与对应的比对文本数据不匹配,则用于调整所述初始优化模型的参数,得到目标优化模型。The adjustment module 406 is configured to adjust the parameters of the initial optimization model to obtain the target optimization model if the target text data to be detected does not match the corresponding comparison text data.
可选的,隐藏层向量计算模块402包括:Optionally, the hidden layer vector calculation module 402 includes:
提取单元4021,用于从每个原始文本数据中提取对应的原始文本序列; Extraction unit 4021, for extracting the corresponding original text sequence from each original text data;
输入序列确定单元4022,用于将每个原始文本序列输入预置的编码器中,基于注意力掩码机制和每个原始文本序列确定对应的输入序列;The input sequence determination unit 4022 is used to input each original text sequence into a preset encoder, and determine the corresponding input sequence based on the attention mask mechanism and each original text sequence;
隐藏层向量计算单元4023,用于基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组。The hidden layer vector calculation unit 4023 is configured to perform hidden layer calculation on each input sequence based on the self-attention mechanism and the query attention mechanism, generate a corresponding content hidden layer vector group, and obtain multiple target content hidden layer vector groups.
可选的,输入序列确定单元4022还可以具体用于:Optionally, the input sequence determination unit 4022 can also be specifically used for:
将每个原始文本序列输入预置的编码器中,结合注意力掩码机制对每个原始文本序列进行多次迭代预测,得到对应的多个位置掩码;Input each original text sequence into the preset encoder, and combine the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain corresponding multiple position masks;
整合每个原始文本序列对应的多个位置掩码,得到每个原始文本序列对应的输入序列。Integrate multiple position masks corresponding to each original text sequence to obtain the input sequence corresponding to each original text sequence.
可选的,隐藏层向量计算单元4023还可以具体用于:Optionally, the hidden layer vector calculation unit 4023 can also be specifically used for:
基于每个输入序列提取对应的输入向量组,并采用自注意力机制和询问注意力机制,在第一层隐藏层对目标输入向量组和预置的初始化向量进行计算,得到对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组;Based on each input sequence, the corresponding input vector group is extracted, and the self-attention mechanism and the inquiry attention mechanism are used to calculate the target input vector group and the preset initialization vector in the first hidden layer to obtain the corresponding first content the hidden layer vector group and the corresponding first query hidden layer vector group;
采用所述自注意力机制和所述询问注意力机制,在第二层隐藏层对所述对应的第一内容隐藏层向量组和所述对应的第一查询隐藏层向量组进行计算,得到对应的第二内容隐藏层向量组和对应的第二查询隐藏层向量组;Using the self-attention mechanism and the query attention mechanism, the corresponding first content hidden layer vector group and the corresponding first query hidden layer vector group are calculated in the second hidden layer to obtain the corresponding The second content hidden layer vector group and the corresponding second query hidden layer vector group;
采用所述自注意力机制和所述询问注意力机制,按照上述步骤在其他层隐藏层对对应的内容隐藏层向量组和对应的查询隐藏层向量组进行计算,直至最后一层隐藏层,生成对应的目标内容隐藏层向量组,所述对应的目标内容隐藏层向量组为最后一层隐藏层对应的内容隐藏层向量组;Using the self-attention mechanism and the query-attention mechanism, the corresponding content hidden layer vector group and the corresponding query hidden layer vector group are calculated in other hidden layers according to the above steps, until the last hidden layer is generated. The corresponding target content hidden layer vector group, the corresponding target content hidden layer vector group is the content hidden layer vector group corresponding to the last hidden layer;
采用所述自注意力机制和所述询问注意力机制按照上述步骤对其他输入序列进行计算,得到多个目标内容隐藏层向量组。The self-attention mechanism and the query-attention mechanism are used to calculate other input sequences according to the above steps to obtain multiple target content hidden layer vector groups.
可选的,标签组计算模块403还可以具体用于:Optionally, the tag group calculation module 403 can also be specifically used for:
从每个目标内容隐藏层向量组中读取对应的内容隐藏层维度,得到多个内容隐藏层维度;Read the corresponding content hidden layer dimension from each target content hidden layer vector group to obtain multiple content hidden layer dimensions;
将所述多个内容隐藏层维度依次输入预置的解码器中,结合自回归机制生成多个解码标签组和对应的多个解码标签概率组;Inputting the multiple content hidden layer dimensions into the preset decoder in turn, and combining the autoregressive mechanism to generate multiple decoding label groups and corresponding multiple decoding label probability groups;
基于每个解码标签组对应的解码标签概率组,从每个解码标签组中确定与每个原始文本数据对应的目标标签组,得到多个目标标签组。Based on the decoding label probability group corresponding to each decoding label group, a target label group corresponding to each original text data is determined from each decoding label group, and a plurality of target label groups are obtained.
可选的,判断模块405包括:Optionally, the judgment module 405 includes:
待替换标签组生成单元4051,用于将每个原始文本数据依次输入初始优化模型中,生成多个待替换标签组,每个待替换标签组至少包括保留标签、删除标签和/或短语标签;The tag group generation unit 4051 to be replaced is used to sequentially input each original text data into the initial optimization model, and generate a plurality of tag groups to be replaced, each tag group to be replaced at least includes a reserved tag, a deletion tag and/or a phrase tag;
替换单元4052,用于按照预置的替换规则依次对所述多个待替换标签组进行替换,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配。The replacement unit 4052 is used to sequentially replace the plurality of label groups to be replaced according to the preset replacement rules, obtain a plurality of text data to be detected, and determine whether each text data to be detected is consistent with the corresponding comparison text data. match.
可选的,替换单元4052还可以具体用于:Optionally, the replacement unit 4052 can also be specifically used for:
在预置的短语集合中确定与短语标签对应的目标短语;Determine the target phrase corresponding to the phrase tag in the preset phrase set;
在每个原始文本数据中保留与保留标签对应的子文本数据、删除与删除标签对应的子文本数据以及将与短语标签对应的子文本数据替换为目标短语,生成与每个原始文本数据 对应的待检测文本数据,得到多个待检测文本数据。In each original text data, the sub-text data corresponding to the reserved label is retained, the sub-text data corresponding to the deletion label is deleted, and the sub-text data corresponding to the phrase label is replaced with the target phrase, and the corresponding sub-text data corresponding to each original text data is generated. The text data to be detected is obtained, and a plurality of text data to be detected is obtained.
本申请实施例中,结合编码器的自注意力机制、编码器的询问注意力机制和解码器的自回归机制,计算多个原始文本数据对应的多个目标标签组,然后根据多个目标标签组训练初始优化模型,最后基于比对文本数据和初始优化模型输出的待检测文本数据调整初始优化模型,得到目标优化模型,使得该目标优化模型适用多种优化任务,提高了目标优化模型的优化灵活性以及优化文本的准确率。In the embodiment of the present application, combining the self-attention mechanism of the encoder, the query attention mechanism of the encoder, and the autoregressive mechanism of the decoder, multiple target label groups corresponding to multiple original text data are calculated, and then according to the multiple target labels The initial optimization model is trained in groups, and finally the initial optimization model is adjusted based on the comparison text data and the text data to be detected output by the initial optimization model to obtain the target optimization model, which makes the target optimization model suitable for a variety of optimization tasks and improves the optimization of the target optimization model. Flexibility and accuracy of optimized text.
上面图4和图5从模块化功能实体的角度对本申请实施例中的基于标签的优化模型训练装置进行详细描述,下面从硬件处理的角度对本申请实施例中基于标签的优化模型训练设备进行详细描述。4 and 5 above describe in detail the label-based optimization model training device in the embodiment of the present application from the perspective of modular functional entities, and the following describes the label-based optimization model training device in the embodiment of the present application from the perspective of hardware processing in detail. describe.
图6是本申请实施例提供的一种基于标签的优化模型训练设备的结构示意图,该基于标签的优化模型训练设备600可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units,CPU)610(例如,一个或一个以上处理器)和存储器620,一个或一个以上存储应用程序633或数据632的存储介质630(例如一个或一个以上海量存储设备)。其中,存储器620和存储介质630可以是短暂存储或持久存储。存储在存储介质630的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对基于标签的优化模型训练设备600中的一系列指令操作。更进一步地,处理器610可以设置为与存储介质630通信,在基于标签的优化模型训练设备600上执行存储介质630中的一系列指令操作。6 is a schematic structural diagram of a label-based optimization model training device provided by an embodiment of the present application. The label-based optimization model training device 600 may vary greatly due to different configurations or performances, and may include one or more than one Central processing units (CPU) 610 (eg, one or more processors) and memory 620, one or more storage media 630 (eg, one or more mass storage devices) that store application programs 633 or data 632. Among them, the memory 620 and the storage medium 630 may be short-term storage or persistent storage. The program stored in the storage medium 630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the label-based optimization model training device 600 . Furthermore, the processor 610 may be configured to communicate with the storage medium 630 to execute a series of instruction operations in the storage medium 630 on the label-based optimization model training device 600 .
基于标签的优化模型训练设备600还可以包括一个或一个以上电源640,一个或一个以上有线或无线网络接口650,一个或一个以上输入输出接口660,和/或,一个或一个以上操作系统631,例如Windows Serve,Mac OS X,Unix,Linux,FreeBSD等等。本领域技术人员可以理解,图5示出的基于标签的优化模型训练设备结构并不构成对基于标签的优化模型训练设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。The label-based optimization model training device 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input and output interfaces 660, and/or, one or more operating systems 631, For example Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art can understand that the structure of the label-based optimization model training device shown in FIG. 5 does not constitute a limitation on the label-based optimization model training device, and may include more or less components than those shown in the figure, or a combination of certain components may be included. some components, or a different arrangement of components.
进一步地,所述计算机可用存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。Further, the computer usable storage medium may mainly include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, and the like; using the created data, etc.
本申请还提供一种基于标签的优化模型训练设备,包括:存储器和至少一个处理器,所述存储器中存储有指令,所述存储器和所述至少一个处理器通过线路互连;所述至少一个处理器调用所述存储器中的所述指令,以使得所述基于标签的优化模型训练设备执行上述基于标签的优化模型训练方法中的步骤。The present application also provides a label-based optimization model training device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected by lines; the at least one processor The processor invokes the instructions in the memory, so that the label-based optimization model training device executes the steps in the label-based optimization model training method described above.
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以为易失性计算机可读存储介质。计算机可读存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:The present application also provides a computer-readable storage medium, and the computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on the computer, the computer performs the following steps:
获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;Obtain multiple original text data and multiple comparison text data, one original text data corresponds to one comparison text data;
将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;Input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;Input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
基于所述多个目标标签组训练模型,得到初始优化模型;Based on the multiple target label group training models, an initial optimization model is obtained;
将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。If the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above may refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .
本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand: The technical solutions recorded in the embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions in the embodiments of the present application.

Claims (20)

  1. 一种基于标签的优化模型训练方法,包括:A label-based optimization model training method, including:
    获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;Obtain multiple original text data and multiple comparison text data, one original text data corresponds to one comparison text data;
    将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;Input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
    将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;Input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
    基于所述多个目标标签组训练模型,得到初始优化模型;Based on the multiple target label group training models, an initial optimization model is obtained;
    将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
    若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。If the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  2. 根据权利要求1所述的基于标签的优化模型训练方法,其中,所述将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组包括:The label-based optimization model training method according to claim 1, wherein the inputting each original text data into a preset encoder, based on a self-attention mechanism and an inquiry-attention mechanism, obtains multiple target content hidden The layer vector group includes:
    从每个原始文本数据中提取对应的原始文本序列;Extract the corresponding original text sequence from each original text data;
    将每个原始文本序列输入预置的编码器中,基于注意力掩码机制和每个原始文本序列确定对应的输入序列;Input each original text sequence into the preset encoder, and determine the corresponding input sequence based on the attention mask mechanism and each original text sequence;
    基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组。Based on the self-attention mechanism and the query attention mechanism, the hidden layer calculation is performed for each input sequence, and the corresponding content hidden layer vector group is generated, and multiple target content hidden layer vector groups are obtained.
  3. 根据权利要求2所述的基于标签的优化模型训练方法,其中,所述将每个原始文本序列输入预置的编码器中,基于注意力掩码机制和每个原始文本序列确定对应的输入序列包括:The label-based optimization model training method according to claim 2, wherein each original text sequence is input into a preset encoder, and the corresponding input sequence is determined based on an attention mask mechanism and each original text sequence include:
    将每个原始文本序列输入预置的编码器中,结合注意力掩码机制对每个原始文本序列进行多次迭代预测,得到对应的多个位置掩码;Input each original text sequence into the preset encoder, and combine the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain corresponding multiple position masks;
    整合每个原始文本序列对应的多个位置掩码,得到每个原始文本序列对应的输入序列。Integrate multiple position masks corresponding to each original text sequence to obtain the input sequence corresponding to each original text sequence.
  4. 根据权利要求3所述的基于标签的优化模型训练方法,其中,所述基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组包括:The label-based optimization model training method according to claim 3, wherein the hidden layer calculation is performed on each input sequence based on the self-attention mechanism and the inquiry-attention mechanism, and a corresponding content hidden layer vector group is generated to obtain multiple The target content hidden layer vector group includes:
    基于每个输入序列提取对应的输入向量组,并采用自注意力机制和询问注意力机制,在第一层隐藏层对目标输入向量组和预置的初始化向量进行计算,得到对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组;Based on each input sequence, the corresponding input vector group is extracted, and the self-attention mechanism and the inquiry attention mechanism are used to calculate the target input vector group and the preset initialization vector in the first hidden layer to obtain the corresponding first content the hidden layer vector group and the corresponding first query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,在第二层隐藏层对所述对应的第一内容隐藏层向量组和所述对应的第一查询隐藏层向量组进行计算,得到对应的第二内容隐藏层向量组和对应的第二查询隐藏层向量组;Using the self-attention mechanism and the query attention mechanism, the corresponding first content hidden layer vector group and the corresponding first query hidden layer vector group are calculated in the second hidden layer to obtain the corresponding The second content hidden layer vector group and the corresponding second query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,按照上述步骤在其他层隐藏层对对应的内容隐藏层向量组和对应的查询隐藏层向量组进行计算,直至最后一层隐藏层,生成对应的目标内容隐藏层向量组,所述对应的目标内容隐藏层向量组为最后一层隐藏层对应的内容隐藏层向量组;Using the self-attention mechanism and the query-attention mechanism, the corresponding content hidden layer vector group and the corresponding query hidden layer vector group are calculated in other hidden layers according to the above steps, until the last hidden layer is generated. The corresponding target content hidden layer vector group, the corresponding target content hidden layer vector group is the content hidden layer vector group corresponding to the last hidden layer;
    采用所述自注意力机制和所述询问注意力机制按照上述步骤对其他输入序列进行计算,得到多个目标内容隐藏层向量组。The self-attention mechanism and the query-attention mechanism are used to calculate other input sequences according to the above steps to obtain multiple target content hidden layer vector groups.
  5. 根据权利要求1所述的基于标签的优化模型训练方法,其中,所述将每个目标内容 隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组包括:The label-based optimization model training method according to claim 1, wherein the hidden layer vector group of each target content is input into a preset decoder, and a label calculation is performed in combination with an autoregressive mechanism to obtain a plurality of target label groups include:
    从每个目标内容隐藏层向量组中读取对应的内容隐藏层维度,得到多个内容隐藏层维度;Read the corresponding content hidden layer dimension from each target content hidden layer vector group to obtain multiple content hidden layer dimensions;
    将所述多个内容隐藏层维度依次输入预置的解码器中,结合自回归机制生成多个解码标签组和对应的多个解码标签概率组;Inputting the multiple content hidden layer dimensions into the preset decoder in turn, and combining the autoregressive mechanism to generate multiple decoding label groups and corresponding multiple decoding label probability groups;
    基于每个解码标签组对应的解码标签概率组,从每个解码标签组中确定与每个原始文本数据对应的目标标签组,得到多个目标标签组。Based on the decoding label probability group corresponding to each decoding label group, a target label group corresponding to each original text data is determined from each decoding label group, and a plurality of target label groups are obtained.
  6. 根据权利要求1-5中任意一项所述的基于标签的优化模型训练方法,其中,所述将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配包括:The label-based optimization model training method according to any one of claims 1-5, wherein the plurality of original text data are sequentially input into the initial optimization model to obtain a plurality of text data to be detected, And judging whether each text data to be detected matches the corresponding comparison text data includes:
    将每个原始文本数据依次输入初始优化模型中,生成多个待替换标签组,每个待替换标签组至少包括保留标签、删除标签和/或短语标签;Input each original text data into the initial optimization model in turn, and generate a plurality of tag groups to be replaced, and each tag group to be replaced includes at least a reserved tag, a deletion tag and/or a phrase tag;
    按照预置的替换规则依次对所述多个待替换标签组进行替换,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配。The multiple tag groups to be replaced are sequentially replaced according to a preset replacement rule to obtain multiple text data to be detected, and it is determined whether each text data to be detected matches the corresponding comparison text data.
  7. 根据权利要求6所述的基于标签的优化模型训练方法,其中,所述按照预置的替换规则依次对所述多个待替换标签组进行替换,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配包括:The label-based optimization model training method according to claim 6, wherein the plurality of label groups to be replaced are sequentially replaced according to a preset replacement rule, to obtain a plurality of text data to be detected, and to determine each Whether the text data to be detected matches the corresponding comparison text data includes:
    在预置的短语集合中确定与短语标签对应的目标短语;Determine the target phrase corresponding to the phrase tag in the preset phrase set;
    在每个原始文本数据中保留与保留标签对应的子文本数据、删除与删除标签对应的子文本数据以及将与短语标签对应的子文本数据替换为目标短语,生成与每个原始文本数据对应的待检测文本数据,得到多个待检测文本数据。In each original text data, the sub-text data corresponding to the reserved label is retained, the sub-text data corresponding to the deletion label is deleted, and the sub-text data corresponding to the phrase label is replaced with the target phrase, and the corresponding sub-text data corresponding to each original text data is generated. The text data to be detected is obtained, and a plurality of text data to be detected is obtained.
  8. 一种基于标签的优化模型训练设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A label-based optimization model training device, comprising a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor, which are implemented when the processor executes the computer-readable instructions Follow the steps below:
    获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;Obtain multiple original text data and multiple comparison text data, one original text data corresponds to one comparison text data;
    将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;Input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
    将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;Input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
    基于所述多个目标标签组训练模型,得到初始优化模型;Based on the multiple target label group training models, an initial optimization model is obtained;
    将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
    若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。If the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  9. 根据权利要求8所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claim 8, wherein the processor further implements the following steps when executing the computer program:
    从每个原始文本数据中提取对应的原始文本序列;Extract the corresponding original text sequence from each original text data;
    将每个原始文本序列输入预置的编码器中,基于注意力掩码机制和每个原始文本序列确定对应的输入序列;Input each original text sequence into the preset encoder, and determine the corresponding input sequence based on the attention mask mechanism and each original text sequence;
    基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组。Based on the self-attention mechanism and the query attention mechanism, the hidden layer calculation is performed for each input sequence, and the corresponding content hidden layer vector group is generated, and multiple target content hidden layer vector groups are obtained.
  10. 根据权利要求9所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claim 9, wherein the processor further implements the following steps when executing the computer program:
    将每个原始文本序列输入预置的编码器中,结合注意力掩码机制对每个原始文本序列进行多次迭代预测,得到对应的多个位置掩码;Input each original text sequence into the preset encoder, and combine the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain corresponding multiple position masks;
    整合每个原始文本序列对应的多个位置掩码,得到每个原始文本序列对应的输入序列。Integrate multiple position masks corresponding to each original text sequence to obtain the input sequence corresponding to each original text sequence.
  11. 根据权利要求10所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claim 10, wherein the processor further implements the following steps when executing the computer program:
    基于每个输入序列提取对应的输入向量组,并采用自注意力机制和询问注意力机制,在第一层隐藏层对目标输入向量组和预置的初始化向量进行计算,得到对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组;Based on each input sequence, the corresponding input vector group is extracted, and the self-attention mechanism and the inquiry attention mechanism are used to calculate the target input vector group and the preset initialization vector in the first hidden layer to obtain the corresponding first content the hidden layer vector group and the corresponding first query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,在第二层隐藏层对所述对应的第一内容隐藏层向量组和所述对应的第一查询隐藏层向量组进行计算,得到对应的第二内容隐藏层向量组和对应的第二查询隐藏层向量组;Using the self-attention mechanism and the query attention mechanism, the corresponding first content hidden layer vector group and the corresponding first query hidden layer vector group are calculated in the second hidden layer to obtain the corresponding The second content hidden layer vector group and the corresponding second query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,按照上述步骤在其他层隐藏层对对应的内容隐藏层向量组和对应的查询隐藏层向量组进行计算,直至最后一层隐藏层,生成对应的目标内容隐藏层向量组,所述对应的目标内容隐藏层向量组为最后一层隐藏层对应的内容隐藏层向量组;Using the self-attention mechanism and the query-attention mechanism, the corresponding content hidden layer vector group and the corresponding query hidden layer vector group are calculated in other hidden layers according to the above steps, until the last hidden layer is generated. The corresponding target content hidden layer vector group, the corresponding target content hidden layer vector group is the content hidden layer vector group corresponding to the last hidden layer;
    采用所述自注意力机制和所述询问注意力机制按照上述步骤对其他输入序列进行计算,得到多个目标内容隐藏层向量组。The self-attention mechanism and the query-attention mechanism are used to calculate other input sequences according to the above steps to obtain multiple target content hidden layer vector groups.
  12. 根据权利要求8所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claim 8, wherein the processor further implements the following steps when executing the computer program:
    从每个目标内容隐藏层向量组中读取对应的内容隐藏层维度,得到多个内容隐藏层维度;Read the corresponding content hidden layer dimension from each target content hidden layer vector group to obtain multiple content hidden layer dimensions;
    将所述多个内容隐藏层维度依次输入预置的解码器中,结合自回归机制生成多个解码标签组和对应的多个解码标签概率组;Inputting the multiple content hidden layer dimensions into the preset decoder in turn, and combining the autoregressive mechanism to generate multiple decoding label groups and corresponding multiple decoding label probability groups;
    基于每个解码标签组对应的解码标签概率组,从每个解码标签组中确定与每个原始文本数据对应的目标标签组,得到多个目标标签组。Based on the decoding label probability group corresponding to each decoding label group, a target label group corresponding to each original text data is determined from each decoding label group, and a plurality of target label groups are obtained.
  13. 根据权利要求8-12所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claims 8-12, wherein the processor further implements the following steps when executing the computer program:
    将每个原始文本数据依次输入初始优化模型中,生成多个待替换标签组,每个待替换标签组至少包括保留标签、删除标签和/或短语标签;Input each original text data into the initial optimization model in turn, and generate a plurality of tag groups to be replaced, and each tag group to be replaced includes at least a reserved tag, a deletion tag and/or a phrase tag;
    按照预置的替换规则依次对所述多个待替换标签组进行替换,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配。The multiple tag groups to be replaced are sequentially replaced according to a preset replacement rule to obtain multiple text data to be detected, and it is determined whether each text data to be detected matches the corresponding comparison text data.
  14. 根据权利要求13所述的基于标签的优化模型训练设备,所述处理器执行所述计算机程序时还实现以下步骤:The label-based optimization model training device according to claim 13, wherein the processor further implements the following steps when executing the computer program:
    在预置的短语集合中确定与短语标签对应的目标短语;Determine the target phrase corresponding to the phrase tag in the preset phrase set;
    在每个原始文本数据中保留与保留标签对应的子文本数据、删除与删除标签对应的子文本数据以及将与短语标签对应的子文本数据替换为目标短语,生成与每个原始文本数据对应的待检测文本数据,得到多个待检测文本数据。In each original text data, the sub-text data corresponding to the reserved label is retained, the sub-text data corresponding to the deletion label is deleted, and the sub-text data corresponding to the phrase label is replaced with the target phrase, and the corresponding sub-text data corresponding to each original text data is generated. The text data to be detected is obtained, and a plurality of text data to be detected is obtained.
  15. 一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:A computer-readable storage medium, storing computer instructions in the computer-readable storage medium, when the computer instructions are executed on a computer, the computer is made to perform the following steps:
    获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;Obtain multiple original text data and multiple comparison text data, one original text data corresponds to one comparison text data;
    将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;Input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry-attention mechanism;
    将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;Input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
    基于所述多个目标标签组训练模型,得到初始优化模型;Based on the multiple target label group training models, an initial optimization model is obtained;
    将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;Inputting the plurality of original text data into the initial optimization model in turn, obtaining a plurality of text data to be detected, and judging whether each text data to be detected matches the corresponding comparison text data;
    若目标待检测文本数据与对应的比对文本数据不匹配,则调整所述初始优化模型的参数,得到目标优化模型。If the target text data to be detected does not match the corresponding comparison text data, the parameters of the initial optimization model are adjusted to obtain the target optimization model.
  16. 根据权利要求15所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:The computer-readable storage medium of claim 15, when the computer instructions are executed on a computer, causing the computer to further perform the following steps:
    从每个原始文本数据中提取对应的原始文本序列;Extract the corresponding original text sequence from each original text data;
    将每个原始文本序列输入预置的编码器中,基于注意力掩码机制和每个原始文本序列确定对应的输入序列;Input each original text sequence into the preset encoder, and determine the corresponding input sequence based on the attention mask mechanism and each original text sequence;
    基于自注意力机制和询问注意力机制对每个输入序列进行隐藏层计算,生成对应的内容隐藏层向量组,得到多个目标内容隐藏层向量组。Based on the self-attention mechanism and the query attention mechanism, the hidden layer calculation is performed for each input sequence, and the corresponding content hidden layer vector group is generated, and multiple target content hidden layer vector groups are obtained.
  17. 根据权利要求16所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:The computer-readable storage medium of claim 16, when the computer instructions are executed on a computer, causing the computer to further perform the following steps:
    将每个原始文本序列输入预置的编码器中,结合注意力掩码机制对每个原始文本序列进行多次迭代预测,得到对应的多个位置掩码;Input each original text sequence into the preset encoder, and combine the attention mask mechanism to perform multiple iterative predictions on each original text sequence to obtain corresponding multiple position masks;
    整合每个原始文本序列对应的多个位置掩码,得到每个原始文本序列对应的输入序列。Integrate multiple position masks corresponding to each original text sequence to obtain the input sequence corresponding to each original text sequence.
  18. 根据权利要求17所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:The computer-readable storage medium of claim 17, which, when executed on a computer, causes the computer to further perform the following steps:
    基于每个输入序列提取对应的输入向量组,并采用自注意力机制和询问注意力机制,在第一层隐藏层对目标输入向量组和预置的初始化向量进行计算,得到对应的第一内容隐藏层向量组和对应的第一查询隐藏层向量组;Based on each input sequence, the corresponding input vector group is extracted, and the self-attention mechanism and the inquiry attention mechanism are used to calculate the target input vector group and the preset initialization vector in the first hidden layer to obtain the corresponding first content the hidden layer vector group and the corresponding first query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,在第二层隐藏层对所述对应的第一内容隐藏层向量组和所述对应的第一查询隐藏层向量组进行计算,得到对应的第二内容隐藏层向量组和对应的第二查询隐藏层向量组;Using the self-attention mechanism and the query attention mechanism, the corresponding first content hidden layer vector group and the corresponding first query hidden layer vector group are calculated in the second hidden layer to obtain the corresponding The second content hidden layer vector group and the corresponding second query hidden layer vector group;
    采用所述自注意力机制和所述询问注意力机制,按照上述步骤在其他层隐藏层对对应的内容隐藏层向量组和对应的查询隐藏层向量组进行计算,直至最后一层隐藏层,生成对应的目标内容隐藏层向量组,所述对应的目标内容隐藏层向量组为最后一层隐藏层对应的内容隐藏层向量组;Using the self-attention mechanism and the inquiry attention mechanism, according to the above steps, the corresponding content hidden layer vector groups and the corresponding query hidden layer vector groups are calculated in other hidden layers, until the last hidden layer is generated. The corresponding target content hidden layer vector group, the corresponding target content hidden layer vector group is the content hidden layer vector group corresponding to the last hidden layer;
    采用所述自注意力机制和所述询问注意力机制按照上述步骤对其他输入序列进行计算,得到多个目标内容隐藏层向量组。The self-attention mechanism and the query-attention mechanism are used to calculate other input sequences according to the above steps to obtain multiple target content hidden layer vector groups.
  19. 根据权利要求15所述的计算机可读存储介质,当所述计算机指令在计算机上运行时,使得计算机还执行以下步骤:The computer-readable storage medium of claim 15, when the computer instructions are executed on a computer, causing the computer to further perform the following steps:
    从每个目标内容隐藏层向量组中读取对应的内容隐藏层维度,得到多个内容隐藏层维度;Read the corresponding content hidden layer dimension from each target content hidden layer vector group to obtain multiple content hidden layer dimensions;
    将所述多个内容隐藏层维度依次输入预置的解码器中,结合自回归机制生成多个解码标签组和对应的多个解码标签概率组;Inputting the multiple content hidden layer dimensions into the preset decoder in turn, and generating multiple decoding tag groups and corresponding multiple decoding tag probability groups in combination with the autoregressive mechanism;
    基于每个解码标签组对应的解码标签概率组,从每个解码标签组中确定与每个原始文本数据对应的目标标签组,得到多个目标标签组。Based on the decoding label probability group corresponding to each decoding label group, a target label group corresponding to each original text data is determined from each decoding label group, and a plurality of target label groups are obtained.
  20. 一种基于标签的优化模型训练装置,所述基于标签的优化模型训练装置包括:A label-based optimization model training device, the label-based optimization model training device includes:
    获取模块,用于获取多个原始文本数据和多个比对文本数据,一个原始文本数据对应一个比对文本数据;an acquisition module, used for acquiring multiple original text data and multiple comparison text data, one original text data corresponds to one comparison text data;
    隐藏层向量计算模块,用于将每个原始文本数据输入预置的编码器中,基于自注意力机制和询问注意力机制,得到多个目标内容隐藏层向量组;The hidden layer vector calculation module is used to input each original text data into the preset encoder, and obtain multiple target content hidden layer vector groups based on the self-attention mechanism and the inquiry attention mechanism;
    标签组计算模块,用于将每个目标内容隐藏层向量组输入预置的解码器中,结合自回归机制进行标签计算,得到多个目标标签组;The label group calculation module is used to input each target content hidden layer vector group into the preset decoder, and combine the autoregressive mechanism to perform label calculation to obtain multiple target label groups;
    训练模块,用于基于所述多个目标标签组训练模型,得到初始优化模型;a training module for training a model based on the multiple target label groups to obtain an initial optimization model;
    判断模块,用于将所述多个原始文本数据依次输入所述初始优化模型中,得到多个待检测文本数据,并判断每个待检测文本数据是否与对应的比对文本数据相匹配;a judgment module, configured to sequentially input the plurality of original text data into the initial optimization model, obtain a plurality of text data to be detected, and judge whether each text data to be detected matches the corresponding comparison text data;
    调整模块,若目标待检测文本数据与对应的比对文本数据不匹配,则用于调整所述初始优化模型的参数,得到目标优化模型。The adjustment module is used to adjust the parameters of the initial optimization model to obtain the target optimization model if the target text data to be detected does not match the corresponding comparison text data.
PCT/CN2021/097136 2020-11-27 2021-05-31 Label-based optimization model training method, apparatus, device, and storage medium WO2022110730A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011353108.0 2020-11-27
CN202011353108.0A CN112464637B (en) 2020-11-27 2020-11-27 Label-based optimization model training method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022110730A1 true WO2022110730A1 (en) 2022-06-02

Family

ID=74808888

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/097136 WO2022110730A1 (en) 2020-11-27 2021-05-31 Label-based optimization model training method, apparatus, device, and storage medium

Country Status (2)

Country Link
CN (1) CN112464637B (en)
WO (1) WO2022110730A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112464637B (en) * 2020-11-27 2024-02-27 平安科技(深圳)有限公司 Label-based optimization model training method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120323968A1 (en) * 2011-06-14 2012-12-20 Microsoft Corporation Learning Discriminative Projections for Text Similarity Measures
CN107169001A (en) * 2017-03-31 2017-09-15 华东师范大学 A kind of textual classification model optimization method based on mass-rent feedback and Active Learning
CN108806668A (en) * 2018-06-08 2018-11-13 国家计算机网络与信息安全管理中心 A kind of audio and video various dimensions mark and model optimization method
CN112464637A (en) * 2020-11-27 2021-03-09 平安科技(深圳)有限公司 Label-based optimization model training method, device, equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
RU2678716C1 (en) * 2017-12-11 2019-01-31 Общество с ограниченной ответственностью "Аби Продакшн" Use of autoencoders for learning text classifiers in natural language
CN110263324B (en) * 2019-05-16 2021-02-12 华为技术有限公司 Text processing method, model training method and device
CN110347839B (en) * 2019-07-18 2021-07-16 湖南数定智能科技有限公司 Text classification method based on generative multi-task learning model
CN110619053A (en) * 2019-09-18 2019-12-27 北京百度网讯科技有限公司 Training method of entity relation extraction model and method for extracting entity relation
CN111160000B (en) * 2019-12-10 2022-02-22 深圳信息职业技术学院 Composition automatic scoring method, device terminal equipment and storage medium
CN111444311A (en) * 2020-02-26 2020-07-24 平安科技(深圳)有限公司 Semantic understanding model training method and device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120323968A1 (en) * 2011-06-14 2012-12-20 Microsoft Corporation Learning Discriminative Projections for Text Similarity Measures
CN107169001A (en) * 2017-03-31 2017-09-15 华东师范大学 A kind of textual classification model optimization method based on mass-rent feedback and Active Learning
CN108806668A (en) * 2018-06-08 2018-11-13 国家计算机网络与信息安全管理中心 A kind of audio and video various dimensions mark and model optimization method
CN112464637A (en) * 2020-11-27 2021-03-09 平安科技(深圳)有限公司 Label-based optimization model training method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN112464637A (en) 2021-03-09
CN112464637B (en) 2024-02-27

Similar Documents

Publication Publication Date Title
CN110704588B (en) Multi-round dialogue semantic analysis method and system based on long-short-term memory network
Lee et al. Deterministic non-autoregressive neural sequence modeling by iterative refinement
US11972365B2 (en) Question responding apparatus, question responding method and program
WO2022121166A1 (en) Method, apparatus and device for predicting heteronym pronunciation, and storage medium
US9558748B2 (en) Methods for hybrid GPU/CPU data processing
CN108804428A (en) Correcting method, system and the relevant apparatus of term mistranslation in a kind of translation
CN112215013B (en) Clone code semantic detection method based on deep learning
JP2015075706A (en) Error correction model learning device and program
JP2008165786A (en) Sequence classification for machine translation
WO2022048363A1 (en) Website classification method and apparatus, computer device, and storage medium
CN109857846B (en) Method and device for matching user question and knowledge point
JP2023544336A (en) System and method for multilingual speech recognition framework
CN111695343A (en) Wrong word correcting method, device, equipment and storage medium
CN112905737B (en) Text error correction method, device, equipment and storage medium
WO2019235103A1 (en) Question generation device, question generation method, and program
WO2022110730A1 (en) Label-based optimization model training method, apparatus, device, and storage medium
Moriya et al. Evolution-strategy-based automation of system development for high-performance speech recognition
WO2020040255A1 (en) Word coding device, analysis device, language model learning device, method, and program
Zapotoczny et al. Lattice Generation in Attention-Based Speech Recognition Models.
EP3655862B1 (en) Multiscale quantization for fast similarity search
Watanabe et al. Structural Bayesian linear regression for hidden Markov models
Chen et al. Unsupervised speaker verification using pre-trained model and label correction
CN115906854A (en) Multi-level confrontation-based cross-language named entity recognition model training method
Scharenborg et al. Building an asr system for mboshi using a cross-language definition of acoustic units approach
WO2020162240A1 (en) Language model score calculation device, language model creation device, methods therefor, program, and recording medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21896240

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21896240

Country of ref document: EP

Kind code of ref document: A1