WO2021082842A1 - Quality perception-based text generation method and apparatus, device, and storage medium - Google Patents

Quality perception-based text generation method and apparatus, device, and storage medium Download PDF

Info

Publication number
WO2021082842A1
WO2021082842A1 PCT/CN2020/118114 CN2020118114W WO2021082842A1 WO 2021082842 A1 WO2021082842 A1 WO 2021082842A1 CN 2020118114 W CN2020118114 W CN 2020118114W WO 2021082842 A1 WO2021082842 A1 WO 2021082842A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
word
replaced
language model
draft
Prior art date
Application number
PCT/CN2020/118114
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 WO2021082842A1 publication Critical patent/WO2021082842A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • G06F16/355Class or cluster creation or modification
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/26Speech to text systems

Definitions

  • This application relates to the technical field of artificial intelligence, and in particular to a method, equipment, storage medium, and device for text generation based on quality perception.
  • the inventor realizes that the existing text generation method is mainly based on the single-round generation method of the sequence-to-sequence model (Seq2seq).
  • the model is written verbatim from left to right (or from right to left).
  • To generate only consider the text information that has been generated before. Once the previous text generation effect is not good, it will have a greater impact on the later generated text, resulting in accumulation of deviations.
  • the current multi-round iteration technology uses a simple update of each word from left to right, and manually sets the iteration rounds, which is equivalent to completely regenerating the entire text.
  • the main purpose of this application is to provide a method, equipment, storage medium and device for text generation based on quality perception, aiming to solve the technical problem of poor quality of automatically generated text in the prior art.
  • the text generation method based on quality perception includes the following steps:
  • replace the target word with the word to be replaced to obtain the first iteration text use the first iteration text as a new text draft, and return to the
  • the new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  • this application also proposes a text generation device based on quality perception.
  • the text generation device based on quality perception includes a memory, a processor, and a device stored on the memory and available on the processor.
  • a running text generation program based on quality perception, and the text generation program based on quality perception is configured to implement the following steps:
  • replace the target word with the word to be replaced to obtain the first iteration text use the first iteration text as a new text draft, and return to the
  • the new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  • the present application also proposes a storage medium that stores a quality-perception-based text generation program, and when the quality-perception-based text generation program is executed by a processor, the following steps are implemented:
  • replace the target word with the word to be replaced to obtain the first iteration text use the first iteration text as a new text draft, and return to the
  • the new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  • this application also proposes a text generation device based on quality perception, and the text generation device based on quality perception includes:
  • a generating module used to obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model
  • a prediction module configured to predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced;
  • the prediction module is further configured to predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location;
  • the iteration module is used to replace the target word with the word to be replaced by the trained quality perception occlusion language model to obtain the first iteration text, and use the first iteration text as a new text draft, Return to the step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new text draft, and obtaining the target position of the word to be replaced, until all All the words to be replaced in the draft text are replaced, the iteration is terminated, and the updated target text is obtained.
  • This application can be based on artificial intelligence and improve the quality of text generation through multiple iterations.
  • FIG. 1 is a schematic structural diagram of a text generation device based on quality perception in a hardware operating environment related to a solution of an embodiment of the present application;
  • FIG. 2 is a schematic flowchart of a first embodiment of a text generation method based on quality perception according to this application;
  • FIG. 3 is a schematic flowchart of a second embodiment of a text generation method based on quality perception according to this application;
  • FIG. 4 is a schematic flowchart of a third embodiment of a text generation method based on quality perception according to this application;
  • Fig. 5 is a structural block diagram of a first embodiment of a text generation device based on quality perception in this application.
  • the technical solution of this application can be applied to the fields of artificial intelligence, blockchain and/or big data technology, and the data involved, such as text, can be stored in a database, or can be stored in a blockchain, such as distributed through a blockchain Storage, this application is not limited.
  • Fig. 1 is a schematic structural diagram of a text generation device based on quality perception in a hardware operating environment involved in a solution of an embodiment of the application.
  • the text generation device based on quality perception may include a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the wired interface of the user interface 1003 may be a USB interface in this application.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (for example, a wireless fidelity (WI-FI) interface).
  • WI-FI wireless fidelity
  • the memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable memory (Non-volatile Memory, NVM), such as a disk memory.
  • RAM Random Access Memory
  • NVM Non-volatile Memory
  • the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
  • FIG. 1 does not constitute a limitation on the text generation device based on quality perception, and may include more or less components than shown in the figure, or a combination of certain components, or different components. Component arrangement.
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a text generation program based on quality perception.
  • the network interface 1004 is mainly used to connect to a back-end server for data communication with the back-end server; the user interface 1003 is mainly used to connect to user equipment;
  • the text generation device calls the quality perception-based text generation program stored in the memory 1005 through the processor 1001, and executes the quality perception-based text generation method provided in the embodiments of the present application.
  • the text generation method based on quality perception includes the following steps:
  • Step S10 Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model.
  • the execution subject of this embodiment is the text generation device based on quality perception
  • the text generation device based on quality perception may be an electronic device such as a smart phone, a personal computer, or a server.
  • Automatic text generation can be applied to a variety of application scenarios, such as artificial intelligence (AI) to automatically generate lyrics.
  • AI artificial intelligence
  • the model generates sentences according to the keywords, outputs the first sentence, and then inputs the first sentence into the sequence-to-sequence model, and the sequence-to-sequence model generates a second sentence according to the first sentence, Then input the second sentence into the sequence to the sequence model, and repeat the process until the text draft is generated.
  • a multi-threaded processor may be used to perform multi-thread processing on the to-be-processed corpus, thereby generating multiple drafts of the text.
  • the user asks questions, performs voice recognition, collects user voice, and converts the user voice into text, that is, the to-be-processed corpus.
  • the content of the corpus to be processed may not accurately express the true intentions conveyed by the video conference.
  • the corpus to be processed needs to be processed through the sequence to sequence model, sequence to sequence model (Sequence to Sequence network or Encoder Decoder) network, Seq2Seq) is a model composed of two encoders and decoders.
  • the encoder reads the input sequence and outputs a single vector, and the decoder reads the vector to produce the output sequence.
  • the encoder uses the seq2seq model, the encoder creates a single vector, and ideally encodes the "meaning" of the input sequence into a single vector-a single point in the N-dimensional space of the sentence, thereby generating the text draft.
  • this embodiment proposes a trained quality-aware occlusion language model, which predicts the semantics of the masked word by the position of the masked word, and realizes the prediction by learning the context information of the masked word.
  • Step S20 Predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced.
  • the draft text includes at least one sentence, and one sentence, two sentences, three sentences or multiple sentences in the draft text can be input into the trained quality perception occlusion language model, and
  • QAM Quality Aware-Masked Language Model
  • the trained quality perception occlusion language model is obtained by training the quality perception occlusion language model to be trained, and the quality perception occlusion language model to be trained may be based on an improved bidirectional encoder representation (Bidirectional Encoder Representations from Transformers, BERT) model, the input of the BERT model is two sentences: the first sentence and the second sentence. It can predict whether the next sentence of the first sentence is the second sentence, but it can’t analyze the words in the sentence. The quality of the forecast.
  • BERT Bidirectional Encoder Representations from Transformers
  • the quality perception occlusion language model to be trained is established; a large amount of standard text is obtained, and characters in the standard text are randomly replaced to obtain the replacement text; according to a large number of pairs of the standard text and the replacement text
  • the quality-aware occlusion language model to be trained is trained to obtain a trained quality-aware occlusion language model.
  • the trained quality-aware occlusion language model can predict whether the quality of each word in the sentence is poor, so that the predicted quality words are replaced.
  • the input is not only two sentences, but also one sentence or three sentences. One sentence or more, the trained quality perception occlusion language model has better quality perception ability.
  • Step S30 Predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location.
  • the masked language model in the trained quality-aware occlusion language model occludes the words to be replaced at the target location, and fuses the context of the left and right sides of the target location , That is, the context information, predicts the semantics of the target position to be occluded, and predicts a better quality word, that is, the target word.
  • Step S40 Using the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to all The steps of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new draft text, and obtaining the target position of the word to be replaced, until the text All the words to be replaced in the draft are replaced, the iteration is terminated, and the updated target text is obtained.
  • replacing the target word with the word to be replaced to obtain the first iteration text, using the first iteration text as a new draft text, and continuing to input the trained quality perception occlusion language model Through the trained quality perception occlusion language model, predict the position of the word to be replaced in the first iterative text according to the first iterative text to obtain the target position of the word to be replaced;
  • the trained quality-aware occlusion language model is used to predict the semantics of the target location based on the context information to obtain the target word corresponding to the target location; through the trained quality-aware occlusion language model,
  • the target word replaces the word to be replaced, obtains the second iteration text, realizes another iteration, uses the second iteration text as a new draft text, and continues to input the trained quality perception occlusion language model, Until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
  • the method further includes: judging whether the target position is a second preset value; if the target position is not the second preset value, determining that the target position is not the second preset value; If there are unreplaced words to be replaced in the draft text, continue to iterate, execute the trained quality-aware occlusion language model, and predict the semantics of the target location based on the context information to obtain In the step of the target word corresponding to the target position, until the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained .
  • the second preset value is equal to the first preset value, and is used to determine whether there is a word to be replaced in the draft text that is perceived, and if no word to be replaced is perceived, then it is determined that all the words to be replaced in the draft text are to be replaced The words are replaced.
  • the draft lyric text is iteratively updated through the trained quality-aware occlusion language model to obtain the target lyric text.
  • the iterative update first predict all possible positions of the word to be replaced in the draft text, and then mask the characters in these positions, and input the draft text into the trained quality-aware occlusion language model to predict The corresponding character.
  • the predicted characters are more suitable than the original characters in terms of semantic consistency and consistency. Therefore, the characters in the draft text are replaced with predicted characters, and an iterative update step is completed.
  • the corpus to be processed is multi-threaded, and a text draft is generated through a sequence-to-sequence model.
  • the trained quality-aware occlusion language model is used to Predict the position of the word to be replaced in the draft text, obtain the target position of the word to be replaced, predict the position, and improve the accuracy of the prediction; through the trained quality perception occlusion language model, according to the target position
  • the contextual context information predicts the semantics of the target location to obtain the target word corresponding to the target location.
  • Combining the contextual context can improve the accuracy of semantic prediction and can predict better quality words; through the training Good quality perception occlusion language model, replace the target word with the word to be replaced, obtain the first iteration text, use the first iteration text as a new text draft, and return the new text according to the The draft predicts the position of the word to be replaced in the new draft text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the word to be replaced in the draft text Words are replaced, the iteration is terminated, and the updated target text is obtained. Based on artificial intelligence, the quality of text generation is improved through multiple iterations.
  • Figure 3 is a schematic flowchart of the second embodiment of the text generation method based on quality perception of this application. Based on the first embodiment shown in Figure 2 above, a second implementation of the text generation method based on quality perception of this application is proposed. example.
  • the method before the step S20, the method further includes:
  • Step S101 Obtain a standard text, perform random replacement of words in the standard text, and obtain a replacement text.
  • the standard text is a training text with accurate semantic expression, and characters or words in the standard text are randomly replaced, and the text with replacement words or words is the replacement text.
  • the original words or words in the standard text are the words or words with the best semantic expression quality, and the replaced words or words are the words or words of poor quality.
  • the replacement text includes: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a standard text of a third preset ratio;
  • the step S101 includes:
  • the first preset ratio is the The ratio of the first replacement text to all the replacement text
  • any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement text, and the position label of the replaced word is recorded.
  • the second preset ratio is The proportion of the second replacement text in all the replacement text;
  • the third ratio is the ratio of the standard text to all the replacement text.
  • the first preset ratio, the second preset ratio, and the third preset ratio are set differently according to the training process.
  • Set the ratio calculate the prediction time to obtain the final predicted text. The shorter the prediction time, the setting of the ratio is beneficial to the training process, so as to determine the best first preset ratio, second preset ratio, and third preset proportion.
  • Set the ratio and the third preset ratio For example, the first preset ratio is 60%, the second preset ratio is 20%, and the third preset ratio is 20%. details as follows:
  • Step S102 Establish a to-be-trained quality-aware occlusion language model.
  • the quality-aware occlusion language model to be trained may be a BERT model based on an improved two-way encoder.
  • the quality-aware occlusion language model to be trained first predicts the position of a poor character, and then predicts the position of the poor character On the character. Training the quality-aware occlusion language model to be trained through a large amount of sample data to obtain the trained quality-aware occlusion language model.
  • Step S103 Training the quality-aware occlusion language model to be trained according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
  • the quality-perceived occlusion language model to be trained is a language model based on the BERT model, and the basic perceptual occlusion language model is used to iterate the replacement text according to the context information of the standard text Update, specifically, predicting the position of the word or word of poor quality in the replacement text (that is, the word to be updated) according to the context information of the standard text, and obtaining the predicted position of the word of poor quality , And then predict the real semantics of the predicted location in combination with the contextual information, that is, predict to obtain a predicted word representing the real semantics, and replace the predicted word with the word to be updated, thereby realizing the update of the replacement text, repeating the above Step, until all the characters or words to be updated in the replacement text are replaced, the iteration stops.
  • the quality-aware occlusion language model to be trained is trained to be the trained quality-aware occlusion language model, and the trained quality-aware occlusion language model can accurately identify the position of the word to be replaced in the draft text, And predict the semantics of the position, that is, the target word with better quality, replace the target word with the word to be replaced, obtain the first iteration text, realize one iteration, and use the first iteration text as the new draft text , And return to the step of predicting the position of the word to be replaced in the draft text, until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text is obtained.
  • step S103 includes:
  • the to-be-trained quality perception occlusion language model predict the position of the word to be updated in the first replacement text or the second replacement text to obtain Update the predicted position of the word;
  • the predicted word is replaced by the to-be-updated word, the first predicted text is obtained, and one iteration is realized.
  • the first predicted text is used as the new replacement text and returned to all
  • Poetry anthologies include poems of the Tang, Song, Yuan, Ming and Qing dynasties. Approximately 130,525 poems were selected from the poetry corpus, with a total of 905,790 poems , Used for model training and evaluation, each filtered poem contains four or more of the four poem lines, and each poem line contains seven characters.
  • the method further includes:
  • the first ratio, the second ratio, and the third ratio are adjusted to obtain a new first ratio and a new second ratio And the new third ratio;
  • the first replacement text of the first preset ratio, the second replacement text of the second preset ratio, and the third preset are set.
  • the preset similarity threshold can be set according to the level of the output text quality requirements in actual applications, for example, the preset similarity threshold is set to 80%.
  • the word segmentation process is performed on the predicted text and the standard text, all first words of the predicted text and all second words of the standard text are obtained, and the frequency of the first word word frequency reverse file (Term Frequency-Inverse Document Frequency, TF-IDF) value and the TF-IDF value of the second word, and both the predicted text and the standard text are expressed as words composed of the word and the TF-IDF value of the word Vector, calculating the cosine distance between the word vector corresponding to the predicted text and the word vector corresponding to the standard text, and using the cosine distance as the text similarity.
  • TF-IDF Term Frequency-Inverse Document Frequency
  • the text similarity does not exceed the preset similarity threshold, it indicates that the quality perception ability of the trained quality perception occlusion language model is poor at this time, and the first ratio and the second ratio can be reduced.
  • Ratio increase the third ratio, adjust the first ratio, the second ratio, and the third ratio to obtain a new first ratio, a new second ratio, and a new third ratio, according to
  • the replacement text of the new first ratio, the new second ratio, and the new third ratio trains the to-be-trained quality-aware occlusion language model to obtain a new predictive text, and returns to the computing office
  • the text similarity between the predicted text and the standard text until the text similarity exceeds the preset similarity threshold, stop comparing the first ratio, the second ratio, and the third ratio Adjustment.
  • the text generated by using the trained quality perception occlusion language model is:
  • the trained quality-aware occlusion language model can generate better quality text.
  • the standard text is obtained, the characters in the standard text are randomly replaced, the replacement text is obtained, the quality perception occlusion language model to be trained is established, and the standard text and the replacement text are compared to the to-be-trained language model.
  • Train the quality-aware occlusion language model for training obtain a trained quality-aware occlusion language model, mask the position and then predict, realize the prediction by learning all context information, improve the predictive ability of the trained quality-aware occlusion language model, and improve the text Build quality.
  • Figure 4 is a schematic flowchart of the third embodiment of the text generation method based on quality perception of this application. Based on the above-mentioned first or second embodiment, the third implementation of the text generation method based on quality perception of this application is proposed. example. This embodiment is described based on the first embodiment.
  • step S40 includes:
  • Step S401 Using the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to all The step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new draft of the text, obtaining the target position of the word to be replaced, and determining the target Whether the position is the second preset value, if the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained .
  • the second preset value is usually set to 0.
  • the target position of the word to be replaced is predicted to be 0, it means that all the words in the current text are appropriate, and no further iterative update is required, and it is also reserved in the training language.
  • the real position is 0, that is, 20% of the text corpus has not been randomly replaced, so this part of the corpus is still high-quality text and does not need to be updated iteratively.
  • the quality-aware occlusion language model predicts the position of the word to be replaced in the new draft text, and obtains the target position of the word to be replaced.
  • the method further includes:
  • the text draft is vectorized to obtain the input vector of the trained quality-aware occlusion language model.
  • step S20 includes:
  • the position of the word to be replaced in the input vector is predicted to obtain the target position of the word to be replaced.
  • the draft text needs to be expressed in a vector form in order to iterate through the preset quality perception occlusion language model to generate a better quality target text.
  • the text draft is expressed in vector form, and the input vector of the trained quality-aware occlusion language model is obtained, so that the position of the word to be replaced in the input vector is performed through the trained quality-aware occlusion language model. Predict and obtain the target position of the word to be replaced.
  • step S30 includes:
  • the word at the target location is occluded to obtain occluded text, and the trained quality perception occlusion language model is used according to the occluded text, and the context information of the target location is used to compare the target of the occluded text.
  • the semantics of the position are predicted, and the target word corresponding to the target position is obtained.
  • the target position is the second preset value
  • it is determined that all the words to be replaced in the draft text have been replaced Iterative termination, obtain the updated target text of the iteration, and realize the automatic termination of the iteration, which significantly improves the text generation effect and quality, avoids the iterative process of simply regenerating the existing method from left to right, and also avoids Unable to choose a suitable iteration round, and the amount of calculation is too large.
  • an embodiment of the present application also proposes a storage medium, the storage medium stores a quality-perception-based text generation program, and when the quality-perception-based text generation program is executed by a processor, the quality-based The steps of a perceptual text generation method.
  • the storage medium involved in this application may be a computer-readable storage medium, and the storage medium, such as a computer-readable storage medium, may be non-volatile or volatile.
  • an embodiment of the present application also proposes a text generation device based on quality perception, and the text generation device based on quality perception includes:
  • the generating module 10 is configured to obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model.
  • automatic text generation can be applied to a variety of application scenarios, such as artificial intelligence (AI) to automatically generate lyrics.
  • AI artificial intelligence
  • the sequence-to-sequence model generates sentences according to the keywords, outputs the first sentence, and then inputs the first sentence into the sequence-to-sequence model, and the sequence-to-sequence model is generated according to the first sentence
  • For the second sentence input the second sentence into the sequence to the sequence model, and repeat the process until the text draft is generated.
  • a multi-threaded processor may be used to perform multi-thread processing on the to-be-processed corpus, thereby generating multiple drafts of the text.
  • the user asks questions, performs voice recognition, collects user voice, and converts the user voice into text, that is, the to-be-processed corpus.
  • the content of the corpus to be processed may not accurately express the true intentions conveyed by the video conference.
  • the corpus to be processed needs to be processed through the sequence to sequence model, sequence to sequence model (Sequence to Sequence network or Encoder Decoder) network, Seq2Seq) is a model composed of two encoders and decoders.
  • the encoder reads the input sequence and outputs a single vector, and the decoder reads the vector to produce the output sequence.
  • the encoder uses the seq2seq model, the encoder creates a single vector, and ideally encodes the "meaning" of the input sequence into a single vector-a single point in the N-dimensional space of the sentence, thereby generating the text draft.
  • this embodiment proposes a trained quality-aware occlusion language model, which predicts the semantics of the masked word by the position of the masked word, and realizes the prediction by learning the context information of the masked word.
  • the prediction module 20 is configured to predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced.
  • the draft text includes at least one sentence, and one sentence, two sentences, three sentences or multiple sentences in the draft text can be input into the trained quality perception occlusion language model, and
  • QAM Quality Aware-Masked Language Model
  • the trained quality perception occlusion language model is obtained by training the quality perception occlusion language model to be trained, and the quality perception occlusion language model to be trained may be based on an improved bidirectional encoder representation (Bidirectional Encoder Representations from Transformers, BERT) model, the input of the BERT model is two sentences: the first sentence and the second sentence. It can predict whether the next sentence of the first sentence is the second sentence, but it can’t analyze the words in the sentence. The quality of the forecast.
  • BERT Bidirectional Encoder Representations from Transformers
  • the quality perception occlusion language model to be trained is established; a large amount of standard text is obtained, and characters in the standard text are randomly replaced to obtain the replacement text; according to a large number of pairs of the standard text and the replacement text
  • the quality-aware occlusion language model to be trained is trained to obtain a trained quality-aware occlusion language model.
  • the trained quality-aware occlusion language model can predict whether the quality of each word in the sentence is poor, so that the predicted quality words are replaced.
  • the input is not only two sentences, but also one sentence or three sentences. One sentence or more, the trained quality perception occlusion language model has better quality perception ability.
  • the prediction module 20 is also used to predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location .
  • the masked language model in the trained quality-aware occlusion language model occludes the words to be replaced at the target location, and fuses the context of the left and right sides of the target location , That is, the context information, predicts the semantics of the target position to be occluded, and predicts a better quality word, that is, the target word.
  • the iteration module 30 is configured to replace the target word with the word to be replaced by the trained quality perception occlusion language model to obtain the first iteration text, and use the first iteration text as a new text draft , Return to the step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new text draft, and obtaining the target position of the word to be replaced, until All the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
  • replacing the target word with the word to be replaced to obtain the first iteration text, using the first iteration text as a new draft text, and continuing to input the trained quality perception occlusion language model Through the trained quality perception occlusion language model, predict the position of the word to be replaced in the first iterative text according to the first iterative text to obtain the target position of the word to be replaced;
  • the trained quality-aware occlusion language model is used to predict the semantics of the target location based on the context information to obtain the target word corresponding to the target location; through the trained quality-aware occlusion language model,
  • the target word replaces the word to be replaced, obtains the second iteration text, realizes another iteration, uses the second iteration text as a new draft text, and continues to input the trained quality perception occlusion language model, Until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
  • the method further includes: judging whether the target position is a second preset value; if the target position is not the second preset value, determining that the target position is not the second preset value; If there are unreplaced words to be replaced in the draft text, continue to iterate, execute the trained quality-aware occlusion language model, and predict the semantics of the target location based on the context information to obtain In the step of the target word corresponding to the target position, until the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained .
  • the second preset value is equal to the first preset value, and is used to determine whether there is a word to be replaced in the draft text that is perceived, and if no word to be replaced is perceived, then it is determined that all the words to be replaced in the draft text are to be replaced The words are replaced.
  • the draft lyric text is iteratively updated through the trained quality-aware occlusion language model to obtain the target lyric text.
  • the iterative update first predict all possible positions of the word to be replaced in the draft text, and then mask the characters in these positions, and input the draft text into the trained quality-aware occlusion language model to predict The corresponding character.
  • the predicted characters are more suitable than the original characters in terms of semantic consistency and consistency. Therefore, the characters in the draft text are replaced with predicted characters, and an iterative update step is completed.
  • the corpus to be processed is multi-threaded, and a text draft is generated through a sequence-to-sequence model.
  • the trained quality-aware occlusion language model is used to Predict the position of the word to be replaced in the draft text, obtain the target position of the word to be replaced, predict the position, and improve the accuracy of the prediction; through the trained quality perception occlusion language model, according to the target position
  • the contextual context information predicts the semantics of the target location to obtain the target word corresponding to the target location.
  • Combining the contextual context can improve the accuracy of semantic prediction and can predict better quality words; through the training Good quality perception occlusion language model, replace the target word with the word to be replaced, obtain the first iteration text, use the first iteration text as a new text draft, and return the new text according to the The draft predicts the position of the word to be replaced in the new draft text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the word to be replaced in the draft text Words are replaced, the iteration is terminated, and the updated target text is obtained. Based on artificial intelligence, the quality of text generation is improved through multiple iterations.
  • the apparatus for generating text based on quality perception further includes:
  • the random replacement module is used to obtain the standard text, and randomly replace the words in the standard text to obtain the replacement text;
  • the establishment module is used to establish the quality perception occlusion language model to be trained
  • the training module is configured to train the to-be-trained quality-aware occlusion language model according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
  • the replacement text includes: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a standard text of a third preset ratio;
  • the random replacement module is also used to randomly replace any word in each sentence of the standard text with another word to obtain the first replacement text by random marking, and record the position label of the replaced word.
  • the first preset ratio is the ratio of the first replacement text to all replacement texts; through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement Text, and record the position label of the word to be replaced, the second preset ratio is the ratio of the second replacement text to all replacement text; keeping the standard text unchanged, using the standard text as the replacement text, The position label is recorded as the first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
  • the prediction module 20 is further configured to perform the quality perception occlusion language model for training according to the first replacement text or the second replacement text, and perform the evaluation of the first replacement text or the second replacement text.
  • the position of the word to be updated in the second replacement text is predicted to obtain the predicted position of the word to be updated; the semantics of the word at the predicted position is predicted through the to-be-trained quality perception occlusion language model to obtain the predicted position Predicted words; through the to-be-trained quality perception occlusion language model, the predicted words are replaced by the to-be-updated words to obtain the first predicted text, and one iteration is realized, and the first predicted text is used as the new replacement text , Return to the step of predicting the position of the word to be updated in the new replacement text and obtaining the predicted position of the word to be updated through the quality perception occlusion language model to be trained according to the new replacement text, until all If all the words to be updated in the first replacement text or the second replacement text are replaced, the iteration is
  • the apparatus for generating text based on quality perception further includes:
  • a judging module for judging whether the text similarity exceeds a preset similarity threshold
  • the adjustment module is configured to adjust the first ratio, the second ratio, and the third ratio when the text similarity does not exceed the preset similarity threshold to obtain a new first ratio, New second ratio and new third ratio;
  • the training module is further configured to train the to-be-trained quality perception occlusion language model according to the replacement text of the new first ratio, the new second ratio, and the new third ratio until all If the text similarity exceeds the preset similarity threshold, stop adjusting the first ratio, the second ratio, and the third ratio.
  • the apparatus for generating text based on quality perception further includes:
  • the judgment module is also used to judge whether the target position is a second preset value
  • the iteration module 30 is further configured to, if the target position is the second preset value, determine that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained .
  • the prediction module 20 is further configured to occlude the characters at the target location to obtain occluded text, and according to the occluded text, pass the trained quality perception occlusion language model in combination with the target
  • the contextual information of the position predicts the semantics of the target position of the occluded text, and obtains the target word corresponding to the target position.
  • Memory image ROM/Random Access Memory (RAM, magnetic disk, CD-ROM), including several instructions to enable a terminal device (can be a mobile phone, computer, server, air conditioner, or network device Etc.) Perform the methods described in the various embodiments of the present application.
  • a terminal device can be a mobile phone, computer, server, air conditioner, or network device Etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Acoustics & Sound (AREA)
  • Human Computer Interaction (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Machine Translation (AREA)

Abstract

A quality perception-based text generation method and apparatus, a device, and a storage medium. The method comprises: acquiring a corpus to be processed, and performing multi-threaded processing on said corpus by means of a sequence-to-sequence model to generate a draft text (S10); predicting, according to the draft text by means of a trained quality perception occlusion language model, the position of a word to be replaced in the draft text to obtain a target position of the word to be replaced (S20); predicting the semantics of the target position according to the context of the target position by means of the trained quality perception occlusion language model to obtain a target word corresponding to the target position (S30); and replacing the word to be replaced with the target word by means of the trained quality perception occlusion language model to obtain a first iteration text, using the first iteration text as a new draft text and returning to the step of predicting the position of the word to be replaced in the new draft text according to the new draft text by means of the trained quality perception occlusion language model to obtain the target position of the word to be replaced, until all the words to be replaced in the draft text are replaced, terminating the iteration, and obtaining a target text after iterations (S40). On the basis of artificial intelligence, the text generation quality is improved by means of multiple iterations.

Description

基于质量感知的文本生成方法、设备、存储介质及装置Quality perception-based text generation method, equipment, storage medium and device
本申请要求于2019年10月29日提交中国专利局、申请号为201911040951.0,发明名称为“基于质量感知的文本生成方法、设备、存储介质及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on October 29, 2019, the application number is 201911040951.0, and the invention title is "Quality Perception-based Text Generation Method, Equipment, Storage Medium, and Device", and its entire content Incorporated in this application by reference.
技术领域Technical field
本申请涉及人工智能的技术领域,尤其涉及一种基于质量感知的文本生成方法、设备、存储介质及装置。This application relates to the technical field of artificial intelligence, and in particular to a method, equipment, storage medium, and device for text generation based on quality perception.
背景技术Background technique
发明人意识到,现有的文本生成方法主要是基于序列到序列的模型(Seq2seq)的单轮生成方法,该模型在文本生成阶段,是由左到右(或由右到左)逐字单向生成的,只考虑了前面已经生成的文本信息,一旦前面文本生成效果不好,则会对后生成的文本产生较大影响,造成偏差累积。目前的多轮迭代技术,采用的也是简单的从左到右每个字都更新一次,人工设定迭代轮次,相当于完全重新生成了整个文本。该方法存在三个关键问题:第一,无法判断生成的文本中哪些字词需要修改,哪些字词可以保留;第二,不能获得更符合该语境的字?第三,人工设定迭代轮次非常的经验化,无法明确迭代终止的客观条件是什么,导致自动生成的文本质量不佳。The inventor realizes that the existing text generation method is mainly based on the single-round generation method of the sequence-to-sequence model (Seq2seq). In the text generation stage, the model is written verbatim from left to right (or from right to left). To generate, only consider the text information that has been generated before. Once the previous text generation effect is not good, it will have a greater impact on the later generated text, resulting in accumulation of deviations. The current multi-round iteration technology uses a simple update of each word from left to right, and manually sets the iteration rounds, which is equivalent to completely regenerating the entire text. There are three key problems with this method: First, it is impossible to determine which words in the generated text need to be modified and which words can be retained; second, it is impossible to obtain words that are more in line with the context? Third, the manual setting of iteration rounds is very empirical, and it is impossible to clarify the objective conditions for the termination of the iteration, resulting in poor quality of the automatically generated text.
上述内容仅用于辅助理解本申请的技术方案,并不代表承认上述内容是现有技术。The above content is only used to assist the understanding of the technical solutions of this application, and does not mean that the above content is recognized as prior art.
发明内容Summary of the invention
本申请的主要目的在于提供一种基于质量感知的文本生成方法、设备、存储介质及装置,旨在解决现有技术中自动生成的文本质量不佳的技术问题。The main purpose of this application is to provide a method, equipment, storage medium and device for text generation based on quality perception, aiming to solve the technical problem of poor quality of automatically generated text in the prior art.
为实现上述目的,本申请提供一种基于质量感知的文本生成方法,所述基于质量感知的文本生成方法包括以下步骤:In order to achieve the above objective, the present application provides a text generation method based on quality perception. The text generation method based on quality perception includes the following steps:
获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
此外,为实现上述目的,本申请还提出一种基于质量感知的文本生成设备,所述基于质量感知的文本生成设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的基于质量感知的文本生成程序,所述基于质量感知的文本生成程序配置为实现以下步骤:In addition, in order to achieve the above-mentioned object, this application also proposes a text generation device based on quality perception. The text generation device based on quality perception includes a memory, a processor, and a device stored on the memory and available on the processor. A running text generation program based on quality perception, and the text generation program based on quality perception is configured to implement the following steps:
获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第 一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
此外,为实现上述目的,本申请还提出一种存储介质,所述存储介质上存储有基于质量感知的文本生成程序,所述基于质量感知的文本生成程序被处理器执行时实现以下步骤:In addition, in order to achieve the above objective, the present application also proposes a storage medium that stores a quality-perception-based text generation program, and when the quality-perception-based text generation program is executed by a processor, the following steps are implemented:
获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
此外,为实现上述目的,本申请还提出一种基于质量感知的文本生成装置,所述基于质量感知的文本生成装置包括:In addition, in order to achieve the above objective, this application also proposes a text generation device based on quality perception, and the text generation device based on quality perception includes:
生成模块,用于获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;A generating module, used to obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
预测模块,用于根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;A prediction module, configured to predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced;
所述预测模块,还用于通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;The prediction module is further configured to predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location;
迭代模块,用于通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。The iteration module is used to replace the target word with the word to be replaced by the trained quality perception occlusion language model to obtain the first iteration text, and use the first iteration text as a new text draft, Return to the step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new text draft, and obtaining the target position of the word to be replaced, until all All the words to be replaced in the draft text are replaced, the iteration is terminated, and the updated target text is obtained.
本申请能够基于人工智能,通过多次迭代提高文本生成质量。This application can be based on artificial intelligence and improve the quality of text generation through multiple iterations.
附图说明Description of the drawings
图1是本申请实施例方案涉及的硬件运行环境的基于质量感知的文本生成设备的结构示意图;FIG. 1 is a schematic structural diagram of a text generation device based on quality perception in a hardware operating environment related to a solution of an embodiment of the present application;
图2为本申请基于质量感知的文本生成方法第一实施例的流程示意图;2 is a schematic flowchart of a first embodiment of a text generation method based on quality perception according to this application;
图3为本申请基于质量感知的文本生成方法第二实施例的流程示意图;3 is a schematic flowchart of a second embodiment of a text generation method based on quality perception according to this application;
图4为本申请基于质量感知的文本生成方法第三实施例的流程示意图;4 is a schematic flowchart of a third embodiment of a text generation method based on quality perception according to this application;
图5为本申请基于质量感知的文本生成装置第一实施例的结构框图。Fig. 5 is a structural block diagram of a first embodiment of a text generation device based on quality perception in this application.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the application, and not used to limit the application.
本申请的技术方案可应用于人工智能、区块链和/或大数据技术领域,涉及的数据如文本等可存储于数据库中,或者可以存储于区块链中,比如通过区块链分布式存储,本申请不做限定。The technical solution of this application can be applied to the fields of artificial intelligence, blockchain and/or big data technology, and the data involved, such as text, can be stored in a database, or can be stored in a blockchain, such as distributed through a blockchain Storage, this application is not limited.
参照图1,图1为本申请实施例方案涉及的硬件运行环境的基于质量感知的文本生成 设备结构示意图。Referring to Fig. 1, Fig. 1 is a schematic structural diagram of a text generation device based on quality perception in a hardware operating environment involved in a solution of an embodiment of the application.
如图1所示,该基于质量感知的文本生成设备可以包括:处理器1001,例如中央处理器(Central Processing Unit,CPU),通信总线1002、用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display),可选用户接口1003还可以包括标准的有线接口、无线接口,对于用户接口1003的有线接口在本申请中可为USB接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如无线保真(WIreless-FIdelity,WI-FI)接口)。存储器1005可以是高速的随机存取存储器(Random Access Memory,RAM)存储器,也可以是稳定的存储器(Non-volatile Memory,NVM),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1, the text generation device based on quality perception may include a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to implement connection and communication between these components. The user interface 1003 may include a display screen (Display), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in this application. The network interface 1004 may optionally include a standard wired interface and a wireless interface (for example, a wireless fidelity (WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable memory (Non-volatile Memory, NVM), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
本领域技术人员可以理解,图1中示出的结构并不构成对基于质量感知的文本生成设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 1 does not constitute a limitation on the text generation device based on quality perception, and may include more or less components than shown in the figure, or a combination of certain components, or different components. Component arrangement.
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及基于质量感知的文本生成程序。As shown in FIG. 1, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a text generation program based on quality perception.
在图1所示的基于质量感知的文本生成设备中,网络接口1004主要用于连接后台服务器,与所述后台服务器进行数据通信;用户接口1003主要用于连接用户设备;所述基于质量感知的文本生成设备通过处理器1001调用存储器1005中存储的基于质量感知的文本生成程序,并执行本申请实施例提供的基于质量感知的文本生成方法。In the text generation device based on quality perception shown in FIG. 1, the network interface 1004 is mainly used to connect to a back-end server for data communication with the back-end server; the user interface 1003 is mainly used to connect to user equipment; The text generation device calls the quality perception-based text generation program stored in the memory 1005 through the processor 1001, and executes the quality perception-based text generation method provided in the embodiments of the present application.
基于上述硬件结构,提出本申请基于质量感知的文本生成方法的实施例。Based on the above hardware structure, an embodiment of the text generation method based on quality perception of the present application is proposed.
参照图2,图2为本申请基于质量感知的文本生成方法第一实施例的流程示意图,提出本申请基于质量感知的文本生成方法第一实施例。2, which is a schematic flowchart of the first embodiment of the text generation method based on quality perception of this application, and the first embodiment of the text generation method based on quality perception of this application is proposed.
在第一实施例中,所述基于质量感知的文本生成方法包括以下步骤:In the first embodiment, the text generation method based on quality perception includes the following steps:
步骤S10:获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿。Step S10: Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model.
应理解的是,本实施例的执行主体是所述基于质量感知的文本生成设备,其中,所述基于质量感知的文本生成设备可为智能手机、个人电脑或服务器等电子设备,本实施例对此不加以限制。文本自动生成能应用于多种应用场景,比如人工智能(Artificial Intelligence,AI)自动生成歌词,首先,设定一个关键词,将所述关键词输入所述序列到序列模型,所述序列到序列模型根据所述关键词生成句子,输出第一句话,将所述第一句话再输入所述序列到序列模型,所述序列到序列模型根据所述第一句话生成第二句话,再将所述第二句话输入所述序列到序列模型,如此重复,直至生成所述文本草稿。为了提高效率,可通过多线程处理器对所述待处理语料集进行多线程处理,从而生成多个所述文本草稿。It should be understood that the execution subject of this embodiment is the text generation device based on quality perception, where the text generation device based on quality perception may be an electronic device such as a smart phone, a personal computer, or a server. This is not restricted. Automatic text generation can be applied to a variety of application scenarios, such as artificial intelligence (AI) to automatically generate lyrics. First, set a keyword and input the keyword into the sequence model, and the sequence to sequence The model generates sentences according to the keywords, outputs the first sentence, and then inputs the first sentence into the sequence-to-sequence model, and the sequence-to-sequence model generates a second sentence according to the first sentence, Then input the second sentence into the sequence to the sequence model, and repeat the process until the text draft is generated. In order to improve efficiency, a multi-threaded processor may be used to perform multi-thread processing on the to-be-processed corpus, thereby generating multiple drafts of the text.
在具体实现中,还有其他很多应用场景,比如人工客服等场景,用户提出问题,进行语音识别,采集用户语音,并将所述用户语音转换为文本,即所述待处理语料集,所述待处理语料集的内容可能不能准确表达出视频会议传达的真实意图,此时需要通过所述序列到序列模型对所述待处理语料集进行处理,序列到序列模型(Sequence to Sequence network or Encoder Decoder network,Seq2Seq)是由两个称为编码器和解码器组成的模型。编码器读取输入序列并输出单个矢量,解码器读取该矢量以产生输出序列。使用seq2seq模型,编码器会创建一个单一的矢量,在理想的情况下,将输入序列的“含义”编码为单个矢量-句子的N维空间中的单个点,从而生成所述文本草稿。In specific implementation, there are many other application scenarios, such as manual customer service and other scenarios. The user asks questions, performs voice recognition, collects user voice, and converts the user voice into text, that is, the to-be-processed corpus. The content of the corpus to be processed may not accurately express the true intentions conveyed by the video conference. At this time, the corpus to be processed needs to be processed through the sequence to sequence model, sequence to sequence model (Sequence to Sequence network or Encoder Decoder) network, Seq2Seq) is a model composed of two encoders and decoders. The encoder reads the input sequence and outputs a single vector, and the decoder reads the vector to produce the output sequence. Using the seq2seq model, the encoder creates a single vector, and ideally encodes the "meaning" of the input sequence into a single vector-a single point in the N-dimensional space of the sentence, thereby generating the text draft.
需要说明的是,上述编码-解码的方式生成文本草稿存在缺陷,在解码过程中,由左到右(或由右到左)逐字单向生成的,只考虑了前面已经生成的文本信息,一旦前面文本生成效果不好,则会对后生成的文本产生较大影响,造成偏差累积。因此,本实施例提出一种训练好的质量感知遮挡语言模型,通过掩盖字的位置然后对掩盖字的语义进行预测,通 过学习所述掩盖字的上下文信息来实现预测。It should be noted that the above-mentioned encoding-decoding method has defects in generating text drafts. During the decoding process, the text is generated from left to right (or from right to left) verbatim, and only the text information that has been generated before is considered. Once the previous text generation effect is not good, it will have a greater impact on the later generated text, resulting in deviation accumulation. Therefore, this embodiment proposes a trained quality-aware occlusion language model, which predicts the semantics of the masked word by the position of the masked word, and realizes the prediction by learning the context information of the masked word.
步骤S20:根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置。Step S20: Predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced.
可理解的是,所述文本草稿包括至少一句话,可将所述文本草稿中的一句话、两句话、三句话或者多句话输入所述训练好的质量感知遮挡语言模型,所述训练好的质量感知遮挡语言(Quality Aware-Masked Language Model,QA-MLM)模型,根据上下文语境信息对所述文本草稿中所述待替换字的位置进行预测,比如,输入一句话包含7个字,Sg=[s1,s2,s3,s4,s5,s6,s7],对这句话中7个字,也就是有7个分类,结合上下文语境判断是否存在质量较差的字,即是否存在所述待替换字,若预测到位置P=2为是质量较差的字,则所述目标位置为P=2。It is understandable that the draft text includes at least one sentence, and one sentence, two sentences, three sentences or multiple sentences in the draft text can be input into the trained quality perception occlusion language model, and The trained Quality Aware-Masked Language Model (QA-MLM) model predicts the position of the word to be replaced in the draft text according to the context information, for example, the input sentence contains 7 words Words, Sg=[s1, s2, s3, s4, s5, s6, s7], for the 7 words in this sentence, that is, there are 7 classifications, combined with the context to determine whether there are poor quality words, that is Whether there is the word to be replaced, if it is predicted that the position P=2 is a poor quality word, then the target position is P=2.
应理解的是,所述训练好的质量感知遮挡语言模型通过对待训练质量感知遮挡语言模型训练而获得,所述待训练质量感知遮挡语言模型可以是基于改进的双向编码器表征(Bidirectional Encoder Representations from Transformers,BERT)模型,所述BERT模型的输入为两句话:第一句话和第二句话,能够预测第一句话的下一句是否为第二句话,但是不能对句子中的字的质量进行预测。本实施例中,通过建立待训练质量感知遮挡语言模型;获取大量的标准文本,对所述标准文本中的字进行随机替换,获得替换文本;根据大量的所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。所述训练好的质量感知遮挡语言模型具备预测句子中每个字的质量是否较差,从而对预测的质量较差的字进行替换,输入不仅仅只是两句话,还可以是一句话、三句话或多句话,训练好的质量感知遮挡语言模型具备更好的质量感知能力。It should be understood that the trained quality perception occlusion language model is obtained by training the quality perception occlusion language model to be trained, and the quality perception occlusion language model to be trained may be based on an improved bidirectional encoder representation (Bidirectional Encoder Representations from Transformers, BERT) model, the input of the BERT model is two sentences: the first sentence and the second sentence. It can predict whether the next sentence of the first sentence is the second sentence, but it can’t analyze the words in the sentence. The quality of the forecast. In this embodiment, the quality perception occlusion language model to be trained is established; a large amount of standard text is obtained, and characters in the standard text are randomly replaced to obtain the replacement text; according to a large number of pairs of the standard text and the replacement text The quality-aware occlusion language model to be trained is trained to obtain a trained quality-aware occlusion language model. The trained quality-aware occlusion language model can predict whether the quality of each word in the sentence is poor, so that the predicted quality words are replaced. The input is not only two sentences, but also one sentence or three sentences. One sentence or more, the trained quality perception occlusion language model has better quality perception ability.
步骤S30:通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字。Step S30: Predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location.
需要说明的是,所述训练好的质量感知遮挡语言模型中的遮蔽语言模型(masked language model,MLM)对所述目标位置的待替换字进行遮挡,融合所述目标位置的左右两侧语境,即所述上下文语境信息,对进行遮挡的所述目标位置的语义进行预测,预测出质量更好的字,即所述目标字。It should be noted that the masked language model (masked language model, MLM) in the trained quality-aware occlusion language model occludes the words to be replaced at the target location, and fuses the context of the left and right sides of the target location , That is, the context information, predicts the semantics of the target position to be occluded, and predicts a better quality word, that is, the target word.
步骤S40:通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Step S40: Using the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to all The steps of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new draft text, and obtaining the target position of the word to be replaced, until the text All the words to be replaced in the draft are replaced, the iteration is terminated, and the updated target text is obtained.
应理解的是,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,继续输入所述训练好的质量感知遮挡语言模型,通过训练好的质量感知遮挡语言模型,根据所述第一次迭代文本对所述第一次迭代文本中所述待替换字的位置进行预测,获得所述待替换字的目标位置;通过所述训练好的质量感知遮挡语言模型,根据所述上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第二次迭代文本,实现又一次迭代,将所述第二次迭代文本作为新的文本草稿,继续输入所述训练好的质量感知遮挡语言模型,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。It should be understood that replacing the target word with the word to be replaced to obtain the first iteration text, using the first iteration text as a new draft text, and continuing to input the trained quality perception occlusion language model , Through the trained quality perception occlusion language model, predict the position of the word to be replaced in the first iterative text according to the first iterative text to obtain the target position of the word to be replaced; The trained quality-aware occlusion language model is used to predict the semantics of the target location based on the context information to obtain the target word corresponding to the target location; through the trained quality-aware occlusion language model, The target word replaces the word to be replaced, obtains the second iteration text, realizes another iteration, uses the second iteration text as a new draft text, and continues to input the trained quality perception occlusion language model, Until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
需要说明的是,在预测所述待替换字的目标位置之后,还包括:判断所述目标位置是否为第二预设值;若所述目标位置不是所述第二预设值,则认定所述文本草稿中还存在未被替换的待替换字,继续迭代,执行所述通过所述训练好的质量感知遮挡语言模型,根据所述上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字的 步骤,直至所述目标位置是所述第二预设值,则认定所述文本草稿中所有待替换字均被替换,迭代终止,获得迭代更新后的目标文本。所述第二预设值等于所述第一预设值,用于判断所述文本草稿中是否存在待替换字被感知,若没有待替换字被感知,则认定所述文本草稿中所有待替换字均被替换。It should be noted that after predicting the target position of the word to be replaced, the method further includes: judging whether the target position is a second preset value; if the target position is not the second preset value, determining that the target position is not the second preset value; If there are unreplaced words to be replaced in the draft text, continue to iterate, execute the trained quality-aware occlusion language model, and predict the semantics of the target location based on the context information to obtain In the step of the target word corresponding to the target position, until the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained . The second preset value is equal to the first preset value, and is used to determine whether there is a word to be replaced in the draft text that is perceived, and if no word to be replaced is perceived, then it is determined that all the words to be replaced in the draft text are to be replaced The words are replaced.
具体应用中,通过所述训练好的质量感知遮挡语言模型对所述歌词文本草稿进行迭代更新,获得目标歌词文本。In a specific application, the draft lyric text is iteratively updated through the trained quality-aware occlusion language model to obtain the target lyric text.
在进行迭代更新期间,首先预测所有具有待替换字在所述文本草稿的可能位置,再屏蔽这些位置上的字符,通过所述文本草稿输入到所述训练好的质量感知遮挡语言模型,可以预测相应的字符。结合上下文语境,在语义一致性和一致性方面,预测字符比原来的字符更合适。因此,用预测的字符替换所述文本草稿中的字符,完成一个迭代更新步骤,可以多次迭代更新所述文本草稿,直至所述预设质量感知掩蔽语言模型预测到预设终止位置(P=0)。During the iterative update, first predict all possible positions of the word to be replaced in the draft text, and then mask the characters in these positions, and input the draft text into the trained quality-aware occlusion language model to predict The corresponding character. Combined with the context, the predicted characters are more suitable than the original characters in terms of semantic consistency and consistency. Therefore, the characters in the draft text are replaced with predicted characters, and an iterative update step is completed. The draft text can be updated multiple iterations until the preset quality perception masking language model predicts a preset end position (P= 0).
本实施例中,通过获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿,根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置,对位置进行预测,提高预测的精准度;通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字,结合上下文语境能够提高语义预测的准确性,能够预测到质量更好的字;通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本,基于人工智能,通过多次迭代提高文本生成质量。In this embodiment, by acquiring the corpus to be processed, the corpus to be processed is multi-threaded, and a text draft is generated through a sequence-to-sequence model. According to the text draft, the trained quality-aware occlusion language model is used to Predict the position of the word to be replaced in the draft text, obtain the target position of the word to be replaced, predict the position, and improve the accuracy of the prediction; through the trained quality perception occlusion language model, according to the target position The contextual context information predicts the semantics of the target location to obtain the target word corresponding to the target location. Combining the contextual context can improve the accuracy of semantic prediction and can predict better quality words; through the training Good quality perception occlusion language model, replace the target word with the word to be replaced, obtain the first iteration text, use the first iteration text as a new text draft, and return the new text according to the The draft predicts the position of the word to be replaced in the new draft text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the word to be replaced in the draft text Words are replaced, the iteration is terminated, and the updated target text is obtained. Based on artificial intelligence, the quality of text generation is improved through multiple iterations.
参照图3,图3为本申请基于质量感知的文本生成方法第二实施例的流程示意图,基于上述图2所示的第一实施例,提出本申请基于质量感知的文本生成方法的第二实施例。Referring to Figure 3, Figure 3 is a schematic flowchart of the second embodiment of the text generation method based on quality perception of this application. Based on the first embodiment shown in Figure 2 above, a second implementation of the text generation method based on quality perception of this application is proposed. example.
在第二实施例中,所述步骤S20之前,还包括:In the second embodiment, before the step S20, the method further includes:
步骤S101:获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本。Step S101: Obtain a standard text, perform random replacement of words in the standard text, and obtain a replacement text.
应理解的是,所述标准文本为语义表达准确的训练文本,对所述标准文本中的字或词进行随机替换,存在替换字或词的文本即为所述替换文本。通常所述标准文本中原有的字或词均为语义表达质量最佳的字或词,则替换的字或词为质量较差的字词。It should be understood that the standard text is a training text with accurate semantic expression, and characters or words in the standard text are randomly replaced, and the text with replacement words or words is the replacement text. Generally, the original words or words in the standard text are the words or words with the best semantic expression quality, and the replaced words or words are the words or words of poor quality.
进一步地,在本实施例中,所述替换文本包括:第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本;Further, in this embodiment, the replacement text includes: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a standard text of a third preset ratio;
所述步骤S101,包括:The step S101 includes:
通过随机标记,选取所述标准文本中每句话中的任意一个字随机替换为另外一个字获得第一替换文本,并记录被替换的字的位置标签,所述第一预设比例为所述第一替换文本占所有替换文本的比例;Through random marking, any word in each sentence in the standard text is selected and randomly replaced with another word to obtain the first replacement text, and the position label of the replaced word is recorded. The first preset ratio is the The ratio of the first replacement text to all the replacement text;
通过随机标记,选取所述标准文本中每句话中的任意两个字随机替换为另外两个字获得第二替换文本,并记录被替换的字的位置标签,所述第二预设比例为所述第二替换文本占所有替换文本的比例;Through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement text, and the position label of the replaced word is recorded. The second preset ratio is The proportion of the second replacement text in all the replacement text;
保持所述标准文本不变,将所述标准文本作为替换文本,并将位置标签记录为第一预设值,所述第三比例为所述标准文本占所有替换文本的比例。Keep the standard text unchanged, use the standard text as the replacement text, and record the position label as a first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
需要说明的是,所述第一预设比例、第二预设比例和第三预设比例,根据训练过程中,设置不同的所述第一预设比例、第二预设比例和第三预设比例,计算获得最终预测文本的预测时间,预测时间越短,说明比例的设置有利于训练过程,从而确定出最佳的所述第一 预设比例、第二预设比例和第三预设比例。还可以计算每次迭代后的迭代文本与标准文本之间的相似度,形似度越高,说明比例的设置有利于质量感知,从而确定出最佳的所述第一预设比例、第二预设比例和第三预设比例。例如,所述第一预设比例为60%,所述第二预设比例为20%,所述第三预设比例为20%。具体如下:It should be noted that the first preset ratio, the second preset ratio, and the third preset ratio are set differently according to the training process. Set the ratio, calculate the prediction time to obtain the final predicted text. The shorter the prediction time, the setting of the ratio is beneficial to the training process, so as to determine the best first preset ratio, second preset ratio, and third preset proportion. It is also possible to calculate the similarity between the iterated text after each iteration and the standard text. The higher the similarity, the higher the degree of similarity indicates that the setting of the ratio is conducive to quality perception, so as to determine the best first preset ratio and second preset ratio. Set the ratio and the third preset ratio. For example, the first preset ratio is 60%, the second preset ratio is 20%, and the third preset ratio is 20%. details as follows:
60%的第一替换文本:通过随机标记,用一个字符替换一个字符,例如原始文本Sg=[s1,s2,s3,s4,s5,s6,s7]改为Sc=[s1,s2,si1,s4,s5,s6,s7],并且位置标签是p=3,则替换文本行是Sm=[s1,s2,MASK,s4,s5,s6,s7]。60% of the first replacement text: replace one character with one character through random marking, for example, the original text Sg=[s1,s2,s3,s4,s5,s6,s7] is changed to Sc=[s1,s2,si1, s4, s5, s6, s7], and the position label is p=3, then the replacement text line is Sm=[s1, s2, MASK, s4, s5, s6, s7].
20%的第二替换文本:用随机标记替换两个字符,例如原始文本Sg=[s1,s2,s3,s4,s5,s6,s7]改为Sc=[s1,si1,s3,s4,s5,si2,s7],并且位置标签是p=[2,6],则替换文本是Sm=[s1,MASK,s3,s4,s5,MASK,s7]20% of the second replacement text: replace two characters with random tags, for example, the original text Sg=[s1,s2,s3,s4,s5,s6,s7] is changed to Sc=[s1,si1,s3,s4,s5 ,si2,s7], and the position label is p=[2,6], the replacement text is Sm=[s1,MASK,s3,s4,s5,MASK,s7]
20%的标准文本:保持所述标准文本不变,则将位置标签设置为0,即Sg=Sc,位置标签是p=0。即可将所述第一预设值设置为0。20% standard text: Keep the standard text unchanged, then set the position label to 0, that is, Sg=Sc, and the position label is p=0. That is, the first preset value can be set to 0.
步骤S102:建立待训练质量感知遮挡语言模型。Step S102: Establish a to-be-trained quality-aware occlusion language model.
应理解的是,所述待训练质量感知遮挡语言模型可以是基于改进的双向编码器表征BERT模型,所述待训练质量感知遮挡语言模型首先预测较差字符的位置,然后预测该较差字符位置上的字符。通过大量的样本数据对所述待训练质量感知遮挡语言模型进行训练,以获得所述训练好的质量感知遮挡语言模型。按照以下方式构建训练语料,其中,被替换的位置可以表示为P=[pi1,pi2,...,pir],ir小于n,n为文本草稿中的总字符数量,而被遮挡的真实字符是si=[si1,si2,...,sir],被替换的位置数量r反映了待训练质量感知遮挡语言模型的学习能力,根据模型的容量和质量选择合适的r。It should be understood that the quality-aware occlusion language model to be trained may be a BERT model based on an improved two-way encoder. The quality-aware occlusion language model to be trained first predicts the position of a poor character, and then predicts the position of the poor character On the character. Training the quality-aware occlusion language model to be trained through a large amount of sample data to obtain the trained quality-aware occlusion language model. Construct the training corpus in the following way, where the replaced position can be expressed as P=[pi1, pi2,..., pir], ir is less than n, n is the total number of characters in the text draft, and the actual characters that are occluded It is si=[si1, si2,..., sir], the number of replaced positions r reflects the learning ability of the quality perception occlusion language model to be trained, and the appropriate r is selected according to the capacity and quality of the model.
步骤S103:根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Step S103: Training the quality-aware occlusion language model to be trained according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
可理解的是,所述待训练质量感知遮挡语言模型为以BERT模型为基础的语言模型,采用所述基础感知遮挡语言模型,根据所述标准文本的上下文语境信息对所述替换文本进行迭代更新,具体为,根据所述标准文本的上下文语境信息对所述替换文本中质量较差的字或词(即待更新字)的位置进行预测,获得所述质量较差的字的预测位置,再结合上下文语境信息预测所述预测位置的真实语义,即预测获得表示真实语义的预测字,将所述预测字替换所述待更新字,从而实现对所述替换文本的更新,重复上述步骤,直至所述替换文本中的所有待更新字或词均被替换完成,则迭代停止。所述待训练质量感知遮挡语言模型经过训练,即为所述训练好的质量感知遮挡语言模型,所述训练好的质量感知遮挡语言模型能够准确地识别出文本草稿中的待替换字的位置,并预测出该位置的语义,即质量更好的目标字,将目标字替换所述待替换字,获得第一次迭代文本,实现一次迭代,将所述第一次迭代文本作为新的文本草稿,并返回预测所述文本草稿中的待替换字的位置的步骤,直至所述文本草稿中所有的待替换字均被替换,迭代终止,获得目标文本。It is understandable that the quality-perceived occlusion language model to be trained is a language model based on the BERT model, and the basic perceptual occlusion language model is used to iterate the replacement text according to the context information of the standard text Update, specifically, predicting the position of the word or word of poor quality in the replacement text (that is, the word to be updated) according to the context information of the standard text, and obtaining the predicted position of the word of poor quality , And then predict the real semantics of the predicted location in combination with the contextual information, that is, predict to obtain a predicted word representing the real semantics, and replace the predicted word with the word to be updated, thereby realizing the update of the replacement text, repeating the above Step, until all the characters or words to be updated in the replacement text are replaced, the iteration stops. The quality-aware occlusion language model to be trained is trained to be the trained quality-aware occlusion language model, and the trained quality-aware occlusion language model can accurately identify the position of the word to be replaced in the draft text, And predict the semantics of the position, that is, the target word with better quality, replace the target word with the word to be replaced, obtain the first iteration text, realize one iteration, and use the first iteration text as the new draft text , And return to the step of predicting the position of the word to be replaced in the draft text, until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text is obtained.
进一步地,所述步骤S103,包括:Further, the step S103 includes:
根据所述第一替换文本或所述第二替换文本通过所述待训练质量感知遮挡语言模型,对所述第一替换文本或所述第二替换文本中待更新字的位置进行预测,获得待更新字的预测位置;According to the first replacement text or the second replacement text through the to-be-trained quality perception occlusion language model, predict the position of the word to be updated in the first replacement text or the second replacement text to obtain Update the predicted position of the word;
通过所述待训练质量感知遮挡语言模型对所述预测位置的字的语义进行预测,获得所述预测位置对应的预测字;Predicting the semantics of the word at the predicted position through the to-be-trained quality-perceived occlusion language model to obtain the predicted word corresponding to the predicted position;
通过所述待训练质量感知遮挡语言模型,将所述预测字替换所述待更新字,获得第一次预测文本,实现一次迭代,将所述第一次预测文本作为新的替换文本,返回所述根据所述新的替换文本通过所述待训练质量感知遮挡语言模型,对所述新的替换文本中待更新字的位置进行预测,获得待更新字的预测位置的步骤,直至所述第一替换文本或所述第二替 换文本中所有待更新字均被替换,则迭代终止,获得预测文本,并根据所述标准文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Through the to-be-trained quality perception occlusion language model, the predicted word is replaced by the to-be-updated word, the first predicted text is obtained, and one iteration is realized. The first predicted text is used as the new replacement text and returned to all The step of predicting the position of the word to be updated in the new replacement text according to the new replacement text through the quality perception occlusion language model to be trained, and obtaining the predicted position of the word to be updated, until the first If all the words to be updated in the replacement text or the second replacement text are replaced, the iteration is terminated, the predicted text is obtained, and the quality perception occlusion language model to be trained is trained according to the standard text to obtain the trained quality Perceptual occlusion language model.
应理解的是,以诗集作为所述标准文本为例,进行说明,诗集包括唐代、宋代、元代、明代和清代的诗,从诗歌语料库中筛选出大约130525首诗,共有905790个诗歌,用于模型训练和评价,每个过滤的诗歌包含四个诗歌行中的四个或多个,每个诗行包含七个字符。首先利用序列到序列的模型生成诗歌草稿。在诗歌草稿文本生成后,使用所述待训练质量感知遮挡语言模型进行迭代更新。首先预测哪个字符位置的语义质量最差,若该位置最差,则整合前后语境信息预测该位置的字,本例中每行诗七个字符,四行的总共二十八个位置,再添加一个结束位置(p=0)用以表征整首诗的产生足够好。如果预测到结束位置,认为诗歌的质量足够好,迭代替换过程自动终止。It should be understood that taking poetry anthologies as an example of the standard text for explanation. Poetry anthologies include poems of the Tang, Song, Yuan, Ming and Qing dynasties. Approximately 130,525 poems were selected from the poetry corpus, with a total of 905,790 poems , Used for model training and evaluation, each filtered poem contains four or more of the four poem lines, and each poem line contains seven characters. First, use the sequence-to-sequence model to generate a draft of the poem. After the poetry draft text is generated, the to-be-trained quality-aware occlusion language model is used for iterative update. First, predict which character position has the worst semantic quality. If the position is the worst, then integrate the context information to predict the character at that position. In this example, each line of poem has seven characters, and a total of 28 positions in four lines. Add an end position (p=0) to indicate that the whole poem is produced well enough. If the end position is predicted and the quality of the poem is considered to be good enough, the iterative replacement process automatically terminates.
进一步地,直至所述第一替换文本或所述第二替换文本中所有待更新字均被替换,则迭代终止,获得预测文本之后,还包括:Further, until all the words to be updated in the first replacement text or the second replacement text are replaced, the iteration is terminated, and after the predicted text is obtained, the method further includes:
计算所述预测文本与所述标准文本之间的文本相似度;Calculating the text similarity between the predicted text and the standard text;
判断所述文本相似度是否超过预设相似度阈值;Judging whether the text similarity exceeds a preset similarity threshold;
在所述文本相似度未超过所述预设相似度阈值时,对所述第一比例、所述第二比例和所述第三比例进行调整,获得新的第一比例、新的第二比例和新的第三比例;When the text similarity does not exceed the preset similarity threshold, the first ratio, the second ratio, and the third ratio are adjusted to obtain a new first ratio and a new second ratio And the new third ratio;
根据所述新的第一比例、所述新的第二比例和所述新的第三比例的替换文本对所述待训练质量感知遮挡语言模型进行训练,直至所述文本相似度超过所述预设相似度阈值,则停止对所述第一比例、所述第二比例和所述第三比例的调整。Training the to-be-trained quality perception occlusion language model according to the replacement text of the new first ratio, the new second ratio, and the new third ratio until the text similarity exceeds the predetermined If the similarity threshold is set, the adjustment of the first ratio, the second ratio, and the third ratio is stopped.
在具体实现中,为了提高所述待训练质量感知遮挡语言模型训练的有效性,在设置了第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本,还需要根据训练获得的预测文本的质量来判断所述第一预设比例、所述第二预设比例和所述第三预设比例是否设置合理。所述预设相似度阈值可根据实际应用中对输出文本质量要求的高低进行设置,比如设置所述预设相似度阈值为80%。In specific implementation, in order to improve the effectiveness of the training of the quality perception occlusion language model to be trained, the first replacement text of the first preset ratio, the second replacement text of the second preset ratio, and the third preset are set. For the standard text of the ratio, it is also necessary to judge whether the first preset ratio, the second preset ratio, and the third preset ratio are set reasonably according to the quality of the predicted text obtained by training. The preset similarity threshold can be set according to the level of the output text quality requirements in actual applications, for example, the preset similarity threshold is set to 80%.
应理解的是,对所述预测文本与所述标准文本进行分词处理,获得所述预测文本的所有第一词语和所述标准文本的所有第二词语,计算所述第一词语词频逆向文件频率(Term Frequency-Inverse Document Frequency,TF-IDF)值和所述第二词语的TF-IDF值,将所述预测文本与所述标准文本均表示为以词语和词语的TF-IDF值组成的词向量,计算所述预测文本对应的词向量与所述标准文本对应的词向量之间的余弦距离,并将该余弦距离作为所述文本相似度。It should be understood that the word segmentation process is performed on the predicted text and the standard text, all first words of the predicted text and all second words of the standard text are obtained, and the frequency of the first word word frequency reverse file (Term Frequency-Inverse Document Frequency, TF-IDF) value and the TF-IDF value of the second word, and both the predicted text and the standard text are expressed as words composed of the word and the TF-IDF value of the word Vector, calculating the cosine distance between the word vector corresponding to the predicted text and the word vector corresponding to the standard text, and using the cosine distance as the text similarity.
在所述文本相似度未超过所述预设相似度阈值时,说明此时所述训练好的质量感知遮挡语言模型的质量感知能力较差,则可降低所述第一比例和所述第二比例,提高所述第三比例,对所述第一比例、所述第二比例和所述第三比例进行调整,获得新的第一比例、新的第二比例和新的第三比例,根据所述新的第一比例、所述新的第二比例和所述新的第三比例的替换文本对所述待训练质量感知遮挡语言模型进行训练,获得新的预测文本,返回所述计算所述预测文本与所述标准文本之间的文本相似度,直至所述文本相似度超过所述预设相似度阈值,则停止对所述第一比例、所述第二比例和所述第三比例的调整。When the text similarity does not exceed the preset similarity threshold, it indicates that the quality perception ability of the trained quality perception occlusion language model is poor at this time, and the first ratio and the second ratio can be reduced. Ratio, increase the third ratio, adjust the first ratio, the second ratio, and the third ratio to obtain a new first ratio, a new second ratio, and a new third ratio, according to The replacement text of the new first ratio, the new second ratio, and the new third ratio trains the to-be-trained quality-aware occlusion language model to obtain a new predictive text, and returns to the computing office The text similarity between the predicted text and the standard text, until the text similarity exceeds the preset similarity threshold, stop comparing the first ratio, the second ratio, and the third ratio Adjustment.
在实际应用中,采用序列到序列模型生成的文本为:In practical applications, the text generated by the sequence-to-sequence model is:
寂寞春风鸟自狂,秋风吹雨满庭香。The lonely spring breeze bird is crazy, and the autumn breeze blows and rains the fragrance of the garden.
欲识故为归来晚,只有幽香伴钓芳。The desire to know is to come back late, only the fragrance is accompanied by Diaofang.
采用所述训练好的质量感知遮挡语言模型生成的文本为:The text generated by using the trained quality perception occlusion language model is:
寂寞春风鸟自狂,秋风吹雨满庭香。The lonely spring breeze bird is crazy, and the autumn breeze blows and rains the fragrance of the garden.
欲知故国归来晚,只有幽香伴众芳。If you want to know that the homeland is coming back late, only Youxiang will accompany the public.
可见,所述训练好的质量感知遮挡语言模型能够生成质量更好的文本。It can be seen that the trained quality-aware occlusion language model can generate better quality text.
在本实施例中,通过获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本,建立待训练质量感知遮挡语言模型,根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型,通过掩盖位置然后预测,通过学习所有上下文信息来实现预测,提高了训练好的质量感知遮挡语言模型的预测能力,提高文本生成质量。In this embodiment, the standard text is obtained, the characters in the standard text are randomly replaced, the replacement text is obtained, the quality perception occlusion language model to be trained is established, and the standard text and the replacement text are compared to the to-be-trained language model. Train the quality-aware occlusion language model for training, obtain a trained quality-aware occlusion language model, mask the position and then predict, realize the prediction by learning all context information, improve the predictive ability of the trained quality-aware occlusion language model, and improve the text Build quality.
参照图4,图4为本申请基于质量感知的文本生成方法第三实施例的流程示意图,基于上述第一实施例或第二实施例,提出本申请基于质量感知的文本生成方法的第三实施例。本实施例基于所述第一实施例进行说明。Referring to Figure 4, Figure 4 is a schematic flowchart of the third embodiment of the text generation method based on quality perception of this application. Based on the above-mentioned first or second embodiment, the third implementation of the text generation method based on quality perception of this application is proposed. example. This embodiment is described based on the first embodiment.
在第三实施例中,所述步骤S40,包括:In the third embodiment, the step S40 includes:
步骤S401:通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,判断所述目标位置是否为第二预设值,若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Step S401: Using the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to all The step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new draft of the text, obtaining the target position of the word to be replaced, and determining the target Whether the position is the second preset value, if the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained .
需要说明的是,所述第二预设值通常设置为0,当待替换字的目标位置预测为0时,即表示当前文本所有的字都恰当,无需进一步迭代更新,在训练语中也保留了真实的位置为0的情况,即20%的文本语料没有进行随机替换操作,因而这部分语料仍为高质量的文本,不需要迭代更新。It should be noted that the second preset value is usually set to 0. When the target position of the word to be replaced is predicted to be 0, it means that all the words in the current text are appropriate, and no further iterative update is required, and it is also reserved in the training language. The real position is 0, that is, 20% of the text corpus has not been randomly replaced, so this part of the corpus is still high-quality text and does not need to be updated iteratively.
例如,原始文本为Sg=[s1,s2,s3,s4,s5,s6,s7],将其中的一个字进行随机替换,改为Sc=[s1,s2,si1,s4,s5,s6,s7],并且位置标签是p=3,则替换文本行是Sm=[s1,s2,MASK,s4,s5,s6,s7]。通过所述训练好的质量感知遮挡语言模型,预测到所述待替换字的目标位置为p=3,将所述目标字替换所述待替换字,获得第一次迭代文本,若所述第一次迭代文本为Sg1=[s1,s2,s3,s4,s5,s6,s7],将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中所述待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,预测新的目标位置为P=0,判断0是所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。For example, the original text is Sg = [s1, s2, s3, s4, s5, s6, s7], randomly replace one of the words to Sc = [s1, s2, si1, s4, s5, s6, s7 ], and the position label is p=3, the replacement text line is Sm=[s1, s2, MASK, s4, s5, s6, s7]. Through the trained quality perception occlusion language model, it is predicted that the target position of the word to be replaced is p=3, the target word is replaced with the word to be replaced, and the first iteration text is obtained. One iteration text is Sg1=[s1, s2, s3, s4, s5, s6, s7], the first iteration text is taken as a new text draft, and the new text draft is returned according to the new text draft through training The quality-aware occlusion language model predicts the position of the word to be replaced in the new draft text, and obtains the target position of the word to be replaced. The new target position is predicted to be P=0, and the judgment 0 is According to the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained.
进一步地,在所述步骤S20之前,还包括:Further, before the step S20, the method further includes:
将所述文本草稿进行向量化获得训练好的质量感知遮挡语言模型的输入向量。The text draft is vectorized to obtain the input vector of the trained quality-aware occlusion language model.
相应地,所述步骤S20,包括:Correspondingly, the step S20 includes:
根据所述输入向量通过训练好的质量感知遮挡语言模型,对所述输入向量中待替换字的位置进行预测,获得所述待替换字的目标位置。According to the input vector through a trained quality perception occlusion language model, the position of the word to be replaced in the input vector is predicted to obtain the target position of the word to be replaced.
可理解的是,需要将所述文本草稿表示成向量形式,才能通过所述预设质量感知遮挡语言模型进行迭代,以生成质量更好的目标文本。将所述文本草稿表示成向量形式,获得训练好的质量感知遮挡语言模型的输入向量,从而通过所述训练好的质量感知遮挡语言模型,对所述输入向量中所述待替换字的位置进行预测,获得所述待替换字的目标位置。It is understandable that the draft text needs to be expressed in a vector form in order to iterate through the preset quality perception occlusion language model to generate a better quality target text. The text draft is expressed in vector form, and the input vector of the trained quality-aware occlusion language model is obtained, so that the position of the word to be replaced in the input vector is performed through the trained quality-aware occlusion language model. Predict and obtain the target position of the word to be replaced.
相应地,所述步骤S30,包括:Correspondingly, the step S30 includes:
对所述目标位置的字进行遮挡,获得遮挡文本,根据所述遮挡文本通过所述训练好的质量感知遮挡语言模型,结合所述目标位置的上下文语境信息对所述遮挡文本的所述目标位置的语义进行预测,获得所述目标位置对应的目标字。The word at the target location is occluded to obtain occluded text, and the trained quality perception occlusion language model is used according to the occluded text, and the context information of the target location is used to compare the target of the occluded text. The semantics of the position are predicted, and the target word corresponding to the target position is obtained.
可理解的是,所述训练好的质量感知遮挡语言模型中的遮蔽语言模型对所述目标位置的待替换字进行遮挡,获得所述遮挡文本,例如所述文本草稿Sg=[s1,s2,s3,s4,s5,s6,s7],所述目标位置是p=3,对p=3处的字进行遮挡,则所述遮挡文本是Sm=[s1,s2,MASK,s4,s5,s6,s7]。 将所述遮挡文本输入所述训练好的质量感知遮挡语言模型,所述训练好的质量感知遮挡语言模型结合所述目标位置p=3的左右两侧语境,即所述上下文语境信息,对所述遮挡文本中进行遮挡的所述目标位置p=3的语义进行预测,预测出质量更好的字,即所述目标字。It is understandable that the occlusion language model in the trained quality perception occlusion language model occludes the word to be replaced at the target location to obtain the occluded text, for example, the text draft Sg=[s1,s2, s3, s4, s5, s6, s7], the target position is p=3, and the word at p=3 is occluded, then the occluded text is Sm=[s1,s2,MASK,s4,s5,s6 ,s7]. The occlusion text is input into the trained quality-aware occlusion language model, and the trained quality-aware occlusion language model is combined with the context of the left and right sides of the target position p=3, that is, the contextual information, Predict the semantics of the target position p=3 in the occluded text, and predict a word with better quality, that is, the target word.
本实施例中,通过判断所述目标位置是否为第二预设值,若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本,实现自动迭代终止,显著地提升了文本生成效果和质量,避免了现有方法简单地从左到右地完全重新生成式的迭代过程,同时也避免了无法选择合适迭代轮次,且计算量偏大的问题。In this embodiment, by judging whether the target position is the second preset value, if the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, Iterative termination, obtain the updated target text of the iteration, and realize the automatic termination of the iteration, which significantly improves the text generation effect and quality, avoids the iterative process of simply regenerating the existing method from left to right, and also avoids Unable to choose a suitable iteration round, and the amount of calculation is too large.
此外,本申请实施例还提出一种存储介质,所述存储介质上存储有基于质量感知的文本生成程序,所述基于质量感知的文本生成程序被处理器执行时实现如上文所述的基于质量感知的文本生成方法的步骤。In addition, an embodiment of the present application also proposes a storage medium, the storage medium stores a quality-perception-based text generation program, and when the quality-perception-based text generation program is executed by a processor, the quality-based The steps of a perceptual text generation method.
可选的,本申请涉及的存储介质可以是计算机可读存储介质,该存储介质如计算机可读存储介质可以是非易失性的,也可以是易失性的。Optionally, the storage medium involved in this application may be a computer-readable storage medium, and the storage medium, such as a computer-readable storage medium, may be non-volatile or volatile.
此外,参照图5,本申请实施例还提出一种基于质量感知的文本生成装置,所述基于质量感知的文本生成装置包括:In addition, referring to FIG. 5, an embodiment of the present application also proposes a text generation device based on quality perception, and the text generation device based on quality perception includes:
生成模块10,用于获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿。The generating module 10 is configured to obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model.
应理解的是,文本自动生成能应用于多种应用场景,比如人工智能(Artificial Intelligence,AI)自动生成歌词,首先,设定一个关键词,将所述关键词输入所述序列到序列模型,所述序列到序列模型根据所述关键词生成句子,输出第一句话,将所述第一句话再输入所述序列到序列模型,所述序列到序列模型根据所述第一句话生成第二句话,再将所述第二句话输入所述序列到序列模型,如此重复,直至生成所述文本草稿。为了提高效率,可通过多线程处理器对所述待处理语料集进行多线程处理,从而生成多个所述文本草稿。It should be understood that automatic text generation can be applied to a variety of application scenarios, such as artificial intelligence (AI) to automatically generate lyrics. First, set a keyword and input the keyword into the sequence to the sequence model. The sequence-to-sequence model generates sentences according to the keywords, outputs the first sentence, and then inputs the first sentence into the sequence-to-sequence model, and the sequence-to-sequence model is generated according to the first sentence For the second sentence, input the second sentence into the sequence to the sequence model, and repeat the process until the text draft is generated. In order to improve efficiency, a multi-threaded processor may be used to perform multi-thread processing on the to-be-processed corpus, thereby generating multiple drafts of the text.
在具体实现中,还有其他很多应用场景,比如人工客服等场景,用户提出问题,进行语音识别,采集用户语音,并将所述用户语音转换为文本,即所述待处理语料集,所述待处理语料集的内容可能不能准确表达出视频会议传达的真实意图,此时需要通过所述序列到序列模型对所述待处理语料集进行处理,序列到序列模型(Sequence to Sequence network or Encoder Decoder network,Seq2Seq)是由两个称为编码器和解码器组成的模型。编码器读取输入序列并输出单个矢量,解码器读取该矢量以产生输出序列。使用seq2seq模型,编码器会创建一个单一的矢量,在理想的情况下,将输入序列的“含义”编码为单个矢量-句子的N维空间中的单个点,从而生成所述文本草稿。In specific implementation, there are many other application scenarios, such as manual customer service and other scenarios. The user asks questions, performs voice recognition, collects user voice, and converts the user voice into text, that is, the to-be-processed corpus. The content of the corpus to be processed may not accurately express the true intentions conveyed by the video conference. At this time, the corpus to be processed needs to be processed through the sequence to sequence model, sequence to sequence model (Sequence to Sequence network or Encoder Decoder) network, Seq2Seq) is a model composed of two encoders and decoders. The encoder reads the input sequence and outputs a single vector, and the decoder reads the vector to produce the output sequence. Using the seq2seq model, the encoder creates a single vector, and ideally encodes the "meaning" of the input sequence into a single vector-a single point in the N-dimensional space of the sentence, thereby generating the text draft.
需要说明的是,上述编码-解码的方式生成文本草稿存在缺陷,在解码过程中,由左到右(或由右到左)逐字单向生成的,只考虑了前面已经生成的文本信息,一旦前面文本生成效果不好,则会对后生成的文本产生较大影响,造成偏差累积。因此,本实施例提出一种训练好的质量感知遮挡语言模型,通过掩盖字的位置然后对掩盖字的语义进行预测,通过学习所述掩盖字的上下文信息来实现预测。It should be noted that the above-mentioned encoding-decoding method has defects in generating text drafts. During the decoding process, the text is generated from left to right (or from right to left) verbatim, and only the text information that has been generated before is considered. Once the previous text generation effect is not good, it will have a greater impact on the later generated text, resulting in deviation accumulation. Therefore, this embodiment proposes a trained quality-aware occlusion language model, which predicts the semantics of the masked word by the position of the masked word, and realizes the prediction by learning the context information of the masked word.
预测模块20,用于根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置。The prediction module 20 is configured to predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced.
可理解的是,所述文本草稿包括至少一句话,可将所述文本草稿中的一句话、两句话、三句话或者多句话输入所述训练好的质量感知遮挡语言模型,所述训练好的质量感知遮挡语言(Quality Aware-Masked Language Model,QA-MLM)模型,根据上下文语境信息对所述文本草稿中所述待替换字的位置进行预测,比如,输入一句话包含7个字,Sg=[s1,s2,s3,s4,s5,s6,s7],对这句话中7个字,也就是有7个分类,结合上下文语境判断是否存在质量较差的字,即是否存在所述待替换字,若预测到位置P=2为是质量较差的字, 则所述目标位置为P=2。It is understandable that the draft text includes at least one sentence, and one sentence, two sentences, three sentences or multiple sentences in the draft text can be input into the trained quality perception occlusion language model, and The trained Quality Aware-Masked Language Model (QA-MLM) model predicts the position of the word to be replaced in the draft text according to the context information, for example, the input sentence contains 7 words Words, Sg=[s1, s2, s3, s4, s5, s6, s7], for the 7 words in this sentence, that is, there are 7 classifications, combined with the context to determine whether there are poor quality words, that is Whether there is the word to be replaced, if it is predicted that the position P=2 is a word of poor quality, then the target position is P=2.
应理解的是,所述训练好的质量感知遮挡语言模型通过对待训练质量感知遮挡语言模型训练而获得,所述待训练质量感知遮挡语言模型可以是基于改进的双向编码器表征(Bidirectional Encoder Representations from Transformers,BERT)模型,所述BERT模型的输入为两句话:第一句话和第二句话,能够预测第一句话的下一句是否为第二句话,但是不能对句子中的字的质量进行预测。本实施例中,通过建立待训练质量感知遮挡语言模型;获取大量的标准文本,对所述标准文本中的字进行随机替换,获得替换文本;根据大量的所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。所述训练好的质量感知遮挡语言模型具备预测句子中每个字的质量是否较差,从而对预测的质量较差的字进行替换,输入不仅仅只是两句话,还可以是一句话、三句话或多句话,训练好的质量感知遮挡语言模型具备更好的质量感知能力。It should be understood that the trained quality perception occlusion language model is obtained by training the quality perception occlusion language model to be trained, and the quality perception occlusion language model to be trained may be based on an improved bidirectional encoder representation (Bidirectional Encoder Representations from Transformers, BERT) model, the input of the BERT model is two sentences: the first sentence and the second sentence. It can predict whether the next sentence of the first sentence is the second sentence, but it can’t analyze the words in the sentence. The quality of the forecast. In this embodiment, the quality perception occlusion language model to be trained is established; a large amount of standard text is obtained, and characters in the standard text are randomly replaced to obtain the replacement text; according to a large number of pairs of the standard text and the replacement text The quality-aware occlusion language model to be trained is trained to obtain a trained quality-aware occlusion language model. The trained quality-aware occlusion language model can predict whether the quality of each word in the sentence is poor, so that the predicted quality words are replaced. The input is not only two sentences, but also one sentence or three sentences. One sentence or more, the trained quality perception occlusion language model has better quality perception ability.
所述预测模块20,还用于通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字。The prediction module 20 is also used to predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location .
需要说明的是,所述训练好的质量感知遮挡语言模型中的遮蔽语言模型(masked language model,MLM)对所述目标位置的待替换字进行遮挡,融合所述目标位置的左右两侧语境,即所述上下文语境信息,对进行遮挡的所述目标位置的语义进行预测,预测出质量更好的字,即所述目标字。It should be noted that the masked language model (masked language model, MLM) in the trained quality-aware occlusion language model occludes the words to be replaced at the target location, and fuses the context of the left and right sides of the target location , That is, the context information, predicts the semantics of the target position to be occluded, and predicts a better quality word, that is, the target word.
迭代模块30,用于通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。The iteration module 30 is configured to replace the target word with the word to be replaced by the trained quality perception occlusion language model to obtain the first iteration text, and use the first iteration text as a new text draft , Return to the step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new text draft, and obtaining the target position of the word to be replaced, until All the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
应理解的是,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,继续输入所述训练好的质量感知遮挡语言模型,通过训练好的质量感知遮挡语言模型,根据所述第一次迭代文本对所述第一次迭代文本中所述待替换字的位置进行预测,获得所述待替换字的目标位置;通过所述训练好的质量感知遮挡语言模型,根据所述上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第二次迭代文本,实现又一次迭代,将所述第二次迭代文本作为新的文本草稿,继续输入所述训练好的质量感知遮挡语言模型,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。It should be understood that replacing the target word with the word to be replaced to obtain the first iteration text, using the first iteration text as a new draft text, and continuing to input the trained quality perception occlusion language model , Through the trained quality perception occlusion language model, predict the position of the word to be replaced in the first iterative text according to the first iterative text to obtain the target position of the word to be replaced; The trained quality-aware occlusion language model is used to predict the semantics of the target location based on the context information to obtain the target word corresponding to the target location; through the trained quality-aware occlusion language model, The target word replaces the word to be replaced, obtains the second iteration text, realizes another iteration, uses the second iteration text as a new draft text, and continues to input the trained quality perception occlusion language model, Until all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained.
需要说明的是,在预测所述待替换字的目标位置之后,还包括:判断所述目标位置是否为第二预设值;若所述目标位置不是所述第二预设值,则认定所述文本草稿中还存在未被替换的待替换字,继续迭代,执行所述通过所述训练好的质量感知遮挡语言模型,根据所述上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字的步骤,直至所述目标位置是所述第二预设值,则认定所述文本草稿中所有待替换字均被替换,迭代终止,获得迭代更新后的目标文本。所述第二预设值等于所述第一预设值,用于判断所述文本草稿中是否存在待替换字被感知,若没有待替换字被感知,则认定所述文本草稿中所有待替换字均被替换。It should be noted that after predicting the target position of the word to be replaced, the method further includes: judging whether the target position is a second preset value; if the target position is not the second preset value, determining that the target position is not the second preset value; If there are unreplaced words to be replaced in the draft text, continue to iterate, execute the trained quality-aware occlusion language model, and predict the semantics of the target location based on the context information to obtain In the step of the target word corresponding to the target position, until the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the iteratively updated target text is obtained . The second preset value is equal to the first preset value, and is used to determine whether there is a word to be replaced in the draft text that is perceived, and if no word to be replaced is perceived, then it is determined that all the words to be replaced in the draft text are to be replaced The words are replaced.
具体应用中,通过所述训练好的质量感知遮挡语言模型对所述歌词文本草稿进行迭代更新,获得目标歌词文本。In a specific application, the draft lyric text is iteratively updated through the trained quality-aware occlusion language model to obtain the target lyric text.
在进行迭代更新期间,首先预测所有具有待替换字在所述文本草稿的可能位置,再屏蔽这些位置上的字符,通过所述文本草稿输入到所述训练好的质量感知遮挡语言模型,可以预测相应的字符。结合上下文语境,在语义一致性和一致性方面,预测字符比原来的字 符更合适。因此,用预测的字符替换所述文本草稿中的字符,完成一个迭代更新步骤,可以多次迭代更新所述文本草稿,直至所述预设质量感知掩蔽语言模型预测到预设终止位置(P=0)。During the iterative update, first predict all possible positions of the word to be replaced in the draft text, and then mask the characters in these positions, and input the draft text into the trained quality-aware occlusion language model to predict The corresponding character. Combined with the context, the predicted characters are more suitable than the original characters in terms of semantic consistency and consistency. Therefore, the characters in the draft text are replaced with predicted characters, and an iterative update step is completed. The draft text can be updated multiple iterations until the preset quality perception masking language model predicts a preset end position (P= 0).
本实施例中,通过获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿,根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置,对位置进行预测,提高预测的精准度;通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字,结合上下文语境能够提高语义预测的准确性,能够预测到质量更好的字;通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本,基于人工智能,通过多次迭代提高文本生成质量。In this embodiment, by acquiring the corpus to be processed, the corpus to be processed is multi-threaded, and a text draft is generated through a sequence-to-sequence model. According to the text draft, the trained quality-aware occlusion language model is used to Predict the position of the word to be replaced in the draft text, obtain the target position of the word to be replaced, predict the position, and improve the accuracy of the prediction; through the trained quality perception occlusion language model, according to the target position The contextual context information predicts the semantics of the target location to obtain the target word corresponding to the target location. Combining the contextual context can improve the accuracy of semantic prediction and can predict better quality words; through the training Good quality perception occlusion language model, replace the target word with the word to be replaced, obtain the first iteration text, use the first iteration text as a new text draft, and return the new text according to the The draft predicts the position of the word to be replaced in the new draft text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the word to be replaced in the draft text Words are replaced, the iteration is terminated, and the updated target text is obtained. Based on artificial intelligence, the quality of text generation is improved through multiple iterations.
在一实施例中,所述基于质量感知的文本生成装置还包括:In an embodiment, the apparatus for generating text based on quality perception further includes:
随机替换模块,用于获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本;The random replacement module is used to obtain the standard text, and randomly replace the words in the standard text to obtain the replacement text;
建立模块,用于建立待训练质量感知遮挡语言模型;The establishment module is used to establish the quality perception occlusion language model to be trained;
训练模块,用于根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。The training module is configured to train the to-be-trained quality-aware occlusion language model according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
在一实施例中,所述替换文本包括:第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本;In an embodiment, the replacement text includes: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a standard text of a third preset ratio;
所述随机替换模块,还用于通过随机标记,选取所述标准文本中每句话中的任意一个字随机替换为另外一个字获得第一替换文本,并记录被替换的字的位置标签,所述第一预设比例为所述第一替换文本占所有替换文本的比例;通过随机标记,选取所述标准文本中每句话中的任意两个字随机替换为另外两个字获得第二替换文本,并记录被替换的字的位置标签,所述第二预设比例为所述第二替换文本占所有替换文本的比例;保持所述标准文本不变,将所述标准文本作为替换文本,并将位置标签记录为第一预设值,所述第三比例为所述标准文本占所有替换文本的比例。The random replacement module is also used to randomly replace any word in each sentence of the standard text with another word to obtain the first replacement text by random marking, and record the position label of the replaced word. The first preset ratio is the ratio of the first replacement text to all replacement texts; through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement Text, and record the position label of the word to be replaced, the second preset ratio is the ratio of the second replacement text to all replacement text; keeping the standard text unchanged, using the standard text as the replacement text, The position label is recorded as the first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
在一实施例中,所述预测模块20,还用于根据所述第一替换文本或所述第二替换文本通过所述待训练质量感知遮挡语言模型,对所述第一替换文本或所述第二替换文本中待更新字的位置进行预测,获得待更新字的预测位置;通过所述待训练质量感知遮挡语言模型对所述预测位置的字的语义进行预测,获得所述预测位置对应的预测字;通过所述待训练质量感知遮挡语言模型,将所述预测字替换所述待更新字,获得第一次预测文本,实现一次迭代,将所述第一次预测文本作为新的替换文本,返回所述根据所述新的替换文本通过所述待训练质量感知遮挡语言模型,对所述新的替换文本中待更新字的位置进行预测,获得待更新字的预测位置的步骤,直至所述第一替换文本或所述第二替换文本中所有待更新字均被替换,则迭代终止,获得预测文本,并根据所述标准文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。In one embodiment, the prediction module 20 is further configured to perform the quality perception occlusion language model for training according to the first replacement text or the second replacement text, and perform the evaluation of the first replacement text or the second replacement text. The position of the word to be updated in the second replacement text is predicted to obtain the predicted position of the word to be updated; the semantics of the word at the predicted position is predicted through the to-be-trained quality perception occlusion language model to obtain the predicted position Predicted words; through the to-be-trained quality perception occlusion language model, the predicted words are replaced by the to-be-updated words to obtain the first predicted text, and one iteration is realized, and the first predicted text is used as the new replacement text , Return to the step of predicting the position of the word to be updated in the new replacement text and obtaining the predicted position of the word to be updated through the quality perception occlusion language model to be trained according to the new replacement text, until all If all the words to be updated in the first replacement text or the second replacement text are replaced, the iteration is terminated, the predicted text is obtained, and the quality perception occlusion language model to be trained is trained according to the standard text to obtain training Good quality perception occlusion language model.
在一实施例中,所述基于质量感知的文本生成装置还包括:In an embodiment, the apparatus for generating text based on quality perception further includes:
计算模块,用于计算所述预测文本与所述标准文本之间的文本相似度;A calculation module for calculating the text similarity between the predicted text and the standard text;
判断模块,用于判断所述文本相似度是否超过预设相似度阈值;A judging module for judging whether the text similarity exceeds a preset similarity threshold;
调整模块,用于在所述文本相似度未超过所述预设相似度阈值时,对所述第一比例、所述第二比例和所述第三比例进行调整,获得新的第一比例、新的第二比例和新的第三比 例;The adjustment module is configured to adjust the first ratio, the second ratio, and the third ratio when the text similarity does not exceed the preset similarity threshold to obtain a new first ratio, New second ratio and new third ratio;
所述训练模块,还用于根据所述新的第一比例、所述新的第二比例和所述新的第三比例的替换文本对所述待训练质量感知遮挡语言模型进行训练,直至所述文本相似度超过所述预设相似度阈值,则停止对所述第一比例、所述第二比例和所述第三比例的调整。The training module is further configured to train the to-be-trained quality perception occlusion language model according to the replacement text of the new first ratio, the new second ratio, and the new third ratio until all If the text similarity exceeds the preset similarity threshold, stop adjusting the first ratio, the second ratio, and the third ratio.
在一实施例中,所述基于质量感知的文本生成装置还包括:In an embodiment, the apparatus for generating text based on quality perception further includes:
所述判断模块,还用于判断所述目标位置是否为第二预设值;The judgment module is also used to judge whether the target position is a second preset value;
所述迭代模块30,还用于若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。The iteration module 30 is further configured to, if the target position is the second preset value, determine that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained .
在一实施例中,所述预测模块20,还用于对所述目标位置的字进行遮挡,获得遮挡文本,根据所述遮挡文本通过所述训练好的质量感知遮挡语言模型,结合所述目标位置的上下文语境信息对所述遮挡文本的所述目标位置的语义进行预测,获得所述目标位置对应的目标字。In one embodiment, the prediction module 20 is further configured to occlude the characters at the target location to obtain occluded text, and according to the occluded text, pass the trained quality perception occlusion language model in combination with the target The contextual information of the position predicts the semantics of the target position of the occluded text, and obtains the target word corresponding to the target position.
本申请所述基于质量感知的文本生成装置的其他实施例或具体实现方式可参照上述各方法实施例,此处不再赘述。For other embodiments or specific implementations of the text generation device based on quality perception described in this application, reference may be made to the foregoing method embodiments, and details are not described herein again.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that in this article, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, It also includes other elements that are not explicitly listed, or elements inherent to the process, method, article, or system. Without more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, article, or system that includes the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。词语第一、第二、以及第三等的使用不表示任何顺序,可将这些词语解释为标识。The serial numbers of the foregoing embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments. In the unit claims that list several devices, several of these devices may be embodied in the same hardware item. The use of the words first, second, and third does not indicate any order, and these words may be interpreted as signs.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如只读存储器镜像(Read Only Memory image,ROM)/随机存取存储器(Random Access Memory,RAM)、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above implementation manners, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。 Based on this understanding, the technical solution of the present application essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as a read-only memory mirror (Read Only)). Memory image, ROM)/Random Access Memory (RAM, magnetic disk, CD-ROM), including several instructions to enable a terminal device (can be a mobile phone, computer, server, air conditioner, or network device Etc.) Perform the methods described in the various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of the application, and do not limit the scope of the patent for this application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of the application, or directly or indirectly applied to other related technical fields , The same reason is included in the scope of patent protection of this application.

Claims (20)

  1. 一种基于质量感知的文本生成方法,其中,所述基于质量感知的文本生成方法包括以下步骤:A method for generating text based on quality perception, wherein the method for generating text based on quality perception includes the following steps:
    获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
    根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
    通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
    通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  2. 如权利要求1所述的基于质量感知的文本生成方法,其中,所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成方法还包括:The method for generating text based on quality perception according to claim 1, wherein the position of the word to be replaced in the draft text is predicted by using a trained quality perception occlusion language model according to the draft text to obtain all Before describing the target position of the word to be replaced, the quality perception-based text generation method further includes:
    获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本;Obtain the standard text, perform random replacement of words in the standard text to obtain the replacement text;
    建立待训练质量感知遮挡语言模型;Establish a language model for training quality perception occlusion;
    根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Training the quality-aware occlusion language model to be trained according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
  3. 如权利要求2所述的基于质量感知的文本生成方法,其中,所述替换文本包括:第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本;The method for generating text based on quality perception according to claim 2, wherein the replacement text comprises: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a third preset ratio Standard text;
    所述获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本,包括:The obtaining the standard text, randomly replacing words in the standard text to obtain the replacement text, includes:
    通过随机标记,选取所述标准文本中每句话中的任意一个字随机替换为另外一个字获得第一替换文本,并记录被替换的字的位置标签,所述第一预设比例为所述第一替换文本占所有替换文本的比例;Through random marking, any word in each sentence in the standard text is selected and randomly replaced with another word to obtain the first replacement text, and the position label of the replaced word is recorded. The first preset ratio is the The ratio of the first replacement text to all the replacement text;
    通过随机标记,选取所述标准文本中每句话中的任意两个字随机替换为另外两个字获得第二替换文本,并记录被替换的字的位置标签,所述第二预设比例为所述第二替换文本占所有替换文本的比例;Through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement text, and the position label of the replaced word is recorded. The second preset ratio is The proportion of the second replacement text in all the replacement text;
    保持所述标准文本不变,将所述标准文本作为替换文本,并将位置标签记录为第一预设值,所述第三比例为所述标准文本占所有替换文本的比例。Keep the standard text unchanged, use the standard text as the replacement text, and record the position label as a first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
  4. 如权利要求3所述的基于质量感知的文本生成方法,其中,所述根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型,包括:The method for generating quality-perception-based text according to claim 3, wherein said training the quality-aware occlusion language model to be trained according to said standard text and said replacement text to obtain a trained quality-aware occlusion language Models, including:
    根据所述第一替换文本或所述第二替换文本通过所述待训练质量感知遮挡语言模型,对所述第一替换文本或所述第二替换文本中待更新字的位置进行预测,获得待更新字的预测位置;According to the first replacement text or the second replacement text through the to-be-trained quality perception occlusion language model, predict the position of the word to be updated in the first replacement text or the second replacement text to obtain Update the predicted position of the word;
    通过所述待训练质量感知遮挡语言模型对所述预测位置的字的语义进行预测,获得所述预测位置对应的预测字;Predicting the semantics of the word at the predicted position through the to-be-trained quality-perceived occlusion language model to obtain the predicted word corresponding to the predicted position;
    通过所述待训练质量感知遮挡语言模型,将所述预测字替换所述待更新字,获得第一次预测文本,实现一次迭代,将所述第一次预测文本作为新的替换文本,返回所述根据所述新的替换文本通过所述待训练质量感知遮挡语言模型,对所述新的替换文本中待更新字的位置进行预测,获得待更新字的预测位置的步骤,直至所述第一替换文本或所述第二替 换文本中所有待更新字均被替换,则迭代终止,获得预测文本,并根据所述标准文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Through the to-be-trained quality perception occlusion language model, the predicted word is replaced by the to-be-updated word, the first predicted text is obtained, and one iteration is realized. The first predicted text is used as the new replacement text and returned to all The step of predicting the position of the word to be updated in the new replacement text according to the new replacement text through the quality perception occlusion language model to be trained, and obtaining the predicted position of the word to be updated, until the first If all the words to be updated in the replacement text or the second replacement text are replaced, the iteration is terminated, the predicted text is obtained, and the quality perception occlusion language model to be trained is trained according to the standard text to obtain the trained quality Perceptual occlusion language model.
  5. 如权利要求4所述的基于质量感知的文本生成方法,其中,直至所述第一替换文本或所述第二替换文本中所有待更新字均被替换,则迭代终止,获得预测文本之后,包括:The method for generating text based on quality perception according to claim 4, wherein, until all the words to be updated in the first replacement text or the second replacement text are replaced, the iteration is terminated, and after the predicted text is obtained, it includes :
    计算所述预测文本与所述标准文本之间的文本相似度;Calculating the text similarity between the predicted text and the standard text;
    判断所述文本相似度是否超过预设相似度阈值;Judging whether the text similarity exceeds a preset similarity threshold;
    在所述文本相似度未超过所述预设相似度阈值时,对所述第一比例、所述第二比例和所述第三比例进行调整,获得新的第一比例、新的第二比例和新的第三比例;When the text similarity does not exceed the preset similarity threshold, the first ratio, the second ratio, and the third ratio are adjusted to obtain a new first ratio and a new second ratio And the new third ratio;
    根据所述新的第一比例、所述新的第二比例和所述新的第三比例的替换文本对所述待训练质量感知遮挡语言模型进行训练,直至所述文本相似度超过所述预设相似度阈值,则停止对所述第一比例、所述第二比例和所述第三比例的调整。Training the to-be-trained quality perception occlusion language model according to the replacement text of the new first ratio, the new second ratio, and the new third ratio until the text similarity exceeds the predetermined If the similarity threshold is set, the adjustment of the first ratio, the second ratio, and the third ratio is stopped.
  6. 如权利要求1所述的基于质量感知的文本生成方法,其中,所述直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本,包括:The method for generating text based on quality perception according to claim 1, wherein all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after iterative update is obtained, comprising:
    判断所述目标位置是否为第二预设值;Judging whether the target position is a second preset value;
    若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。If the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained.
  7. 如权利要求1-6中任一项所述的基于质量感知的文本生成方法,其中,所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成方法还包括:The quality perception-based text generation method according to any one of claims 1-6, wherein the quality perception occlusion language model is trained according to the text draft, and the words to be replaced in the text draft Position prediction and before obtaining the target position of the word to be replaced, the quality perception-based text generation method further includes:
    将所述文本草稿进行向量化获得训练好的质量感知遮挡语言模型的输入向量;Vectorizing the draft text to obtain an input vector of a trained quality-aware occlusion language model;
    所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置,包括:The predicting the position of the word to be replaced in the draft text according to the text draft through a trained quality perception occlusion language model to obtain the target position of the word to be replaced includes:
    根据所述输入向量通过训练好的质量感知遮挡语言模型,对所述输入向量中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the input vector through the trained quality perception occlusion language model according to the input vector to obtain the target position of the word to be replaced;
    所述通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字,包括:The predicting the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model to obtain the target word corresponding to the target location includes:
    对所述目标位置的字进行遮挡,获得遮挡文本,根据所述遮挡文本通过所述训练好的质量感知遮挡语言模型,结合所述目标位置的上下文语境信息对所述遮挡文本的所述目标位置的语义进行预测,获得所述目标位置对应的目标字。The word at the target location is occluded to obtain occluded text, and the trained quality perception occlusion language model is used according to the occluded text, and the context information of the target location is used to compare the target of the occluded text. The semantics of the position are predicted, and the target word corresponding to the target position is obtained.
  8. 一种基于质量感知的文本生成设备,其中,所述基于质量感知的文本生成设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的基于质量感知的文本生成程序,所述基于质量感知的文本生成程序被所述处理器执行时实现以下步骤:A text generation device based on quality perception, wherein the text generation device based on quality perception includes: a memory, a processor, and a quality perception-based text generation that is stored in the memory and can run on the processor A program, when the quality perception-based text generation program is executed by the processor, the following steps are implemented:
    获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
    根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
    通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
    通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  9. 如权利要求8所述的基于质量感知的文本生成设备,其中,所述根据所述文本草稿 通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成程序被所述处理器执行还用于实现以下步骤:The device for generating text based on quality perception according to claim 8, wherein the position of the word to be replaced in the draft text is predicted by using a trained quality perception occlusion language model according to the draft text, and the result is obtained. Before describing the target position of the word to be replaced, the quality perception-based text generation program is executed by the processor and is also used to implement the following steps:
    获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本;Obtain the standard text, perform random replacement of words in the standard text to obtain the replacement text;
    建立待训练质量感知遮挡语言模型;Establish a language model for quality perception occlusion to be trained;
    根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Training the quality-aware occlusion language model to be trained according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
  10. 如权利要求9所述的基于质量感知的文本生成设备,其中,所述替换文本包括:第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本;9. The text generation device based on quality perception according to claim 9, wherein the replacement text comprises: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a third preset ratio Standard text;
    所述获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本时,具体实现以下步骤:The standard text is obtained, and words in the standard text are randomly replaced. When the replacement text is obtained, the following steps are specifically implemented:
    通过随机标记,选取所述标准文本中每句话中的任意一个字随机替换为另外一个字获得第一替换文本,并记录被替换的字的位置标签,所述第一预设比例为所述第一替换文本占所有替换文本的比例;Through random marking, any word in each sentence in the standard text is selected and randomly replaced with another word to obtain the first replacement text, and the position label of the replaced word is recorded. The first preset ratio is the The ratio of the first replacement text to all the replacement text;
    通过随机标记,选取所述标准文本中每句话中的任意两个字随机替换为另外两个字获得第二替换文本,并记录被替换的字的位置标签,所述第二预设比例为所述第二替换文本占所有替换文本的比例;Through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement text, and the position label of the replaced word is recorded. The second preset ratio is The proportion of the second replacement text in all the replacement text;
    保持所述标准文本不变,将所述标准文本作为替换文本,并将位置标签记录为第一预设值,所述第三比例为所述标准文本占所有替换文本的比例。Keep the standard text unchanged, use the standard text as the replacement text, and record the position label as a first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
  11. 如权利要求10所述的基于质量感知的文本生成设备,其中,所述根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型时,具体实现以下步骤:The text generation device based on quality perception according to claim 10, wherein the training quality perception occlusion language model to be trained is performed according to the standard text and the replacement text to obtain a trained quality perception occlusion language When modeling, implement the following steps:
    根据所述第一替换文本或所述第二替换文本通过所述待训练质量感知遮挡语言模型,对所述第一替换文本或所述第二替换文本中待更新字的位置进行预测,获得待更新字的预测位置;According to the first replacement text or the second replacement text through the to-be-trained quality perception occlusion language model, predict the position of the word to be updated in the first replacement text or the second replacement text to obtain Update the predicted position of the word;
    通过所述待训练质量感知遮挡语言模型对所述预测位置的字的语义进行预测,获得所述预测位置对应的预测字;Predicting the semantics of the word at the predicted position through the to-be-trained quality-perceived occlusion language model to obtain the predicted word corresponding to the predicted position;
    通过所述待训练质量感知遮挡语言模型,将所述预测字替换所述待更新字,获得第一次预测文本,实现一次迭代,将所述第一次预测文本作为新的替换文本,返回所述根据所述新的替换文本通过所述待训练质量感知遮挡语言模型,对所述新的替换文本中待更新字的位置进行预测,获得待更新字的预测位置的步骤,直至所述第一替换文本或所述第二替换文本中所有待更新字均被替换,则迭代终止,获得预测文本,并根据所述标准文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Through the to-be-trained quality perception occlusion language model, the predicted word is replaced by the to-be-updated word, the first predicted text is obtained, and one iteration is realized. The first predicted text is used as the new replacement text and returned to all The step of predicting the position of the word to be updated in the new replacement text according to the new replacement text through the quality perception occlusion language model to be trained, and obtaining the predicted position of the word to be updated, until the first If all the words to be updated in the replacement text or the second replacement text are replaced, the iteration is terminated, the predicted text is obtained, and the quality perception occlusion language model to be trained is trained according to the standard text to obtain the trained quality Perceptual occlusion language model.
  12. 如权利要求11所述的基于质量感知的文本生成设备,其中,直至所述第一替换文本或所述第二替换文本中所有待更新字均被替换,则迭代终止,获得预测文本之后,所述基于质量感知的文本生成程序被所述处理器执行还用于实现以下步骤:The text generation device based on quality perception according to claim 11, wherein, until all the words to be updated in the first replacement text or the second replacement text are replaced, the iteration is terminated, and after the predicted text is obtained, the The quality perception-based text generation program executed by the processor is also used to implement the following steps:
    计算所述预测文本与所述标准文本之间的文本相似度;Calculating the text similarity between the predicted text and the standard text;
    判断所述文本相似度是否超过预设相似度阈值;Judging whether the text similarity exceeds a preset similarity threshold;
    在所述文本相似度未超过所述预设相似度阈值时,对所述第一比例、所述第二比例和所述第三比例进行调整,获得新的第一比例、新的第二比例和新的第三比例;When the text similarity does not exceed the preset similarity threshold, the first ratio, the second ratio, and the third ratio are adjusted to obtain a new first ratio and a new second ratio And the new third ratio;
    根据所述新的第一比例、所述新的第二比例和所述新的第三比例的替换文本对所述待训练质量感知遮挡语言模型进行训练,直至所述文本相似度超过所述预设相似度阈值,则停止对所述第一比例、所述第二比例和所述第三比例的调整。Training the to-be-trained quality perception occlusion language model according to the replacement text of the new first ratio, the new second ratio, and the new third ratio until the text similarity exceeds the predetermined If the similarity threshold is set, the adjustment of the first ratio, the second ratio, and the third ratio is stopped.
  13. 如权利要求8所述的基于质量感知的文本生成设备,其中,所述直至所述文本草 稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本时,具体实现以下步骤:8. The text generation device based on quality perception according to claim 8, wherein, when all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after the iteration is obtained, specifically the following is achieved step:
    判断所述目标位置是否为第二预设值;Judging whether the target position is a second preset value;
    若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。If the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained.
  14. 如权利要求8-13中任一项所述的基于质量感知的文本生成设备,其中,所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成程序被所述处理器执行还用于实现以下步骤:The text generation device based on quality perception according to any one of claims 8-13, wherein the quality perception occlusion language model is trained according to the text draft, and the words to be replaced in the text draft The position is predicted, and before the target position of the word to be replaced is obtained, the quality perception-based text generation program is executed by the processor and is also used to implement the following steps:
    将所述文本草稿进行向量化获得训练好的质量感知遮挡语言模型的输入向量;Vectorizing the draft text to obtain an input vector of a trained quality-aware occlusion language model;
    所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置时,具体实现以下步骤:When the position of the word to be replaced in the draft text is predicted through the trained quality perception occlusion language model according to the draft text, and the target position of the word to be replaced is obtained, the following steps are specifically implemented:
    根据所述输入向量通过训练好的质量感知遮挡语言模型,对所述输入向量中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the input vector through the trained quality perception occlusion language model according to the input vector to obtain the target position of the word to be replaced;
    所述通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字时,具体实现以下步骤:When the trained quality perception occlusion language model predicts the semantics of the target location according to the context information of the target location, and obtains the target word corresponding to the target location, the following steps are specifically implemented:
    对所述目标位置的字进行遮挡,获得遮挡文本,根据所述遮挡文本通过所述训练好的质量感知遮挡语言模型,结合所述目标位置的上下文语境信息对所述遮挡文本的所述目标位置的语义进行预测,获得所述目标位置对应的目标字。The word at the target location is occluded to obtain occluded text, and the trained quality perception occlusion language model is used according to the occluded text, and the context information of the target location is used to compare the target of the occluded text. The semantics of the position are predicted, and the target word corresponding to the target position is obtained.
  15. 一种存储介质,其中,所述存储介质上存储有基于质量感知的文本生成程序,所述基于质量感知的文本生成程序被处理器执行时实现以下步骤:A storage medium, wherein a quality perception-based text generation program is stored on the storage medium, and the following steps are implemented when the quality perception-based text generation program is executed by a processor:
    获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;Obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
    根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the draft text according to the trained quality perception occlusion language model to obtain the target position of the word to be replaced;
    通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;Predicting the semantics of the target location according to the context information of the target location through the trained quality-aware occlusion language model to obtain the target word corresponding to the target location;
    通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。Through the trained quality perception occlusion language model, replace the target word with the word to be replaced to obtain the first iteration text, use the first iteration text as a new text draft, and return to the The new draft of the text predicts the position of the word to be replaced in the new draft of the text through the trained quality perception occlusion language model, and obtains the target position of the word to be replaced, until all the words in the draft are The words to be replaced are all replaced, the iteration is terminated, and the updated target text is obtained.
  16. 如权利要求15所述的存储介质,其中,所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成程序被所述处理器执行时还用于实现以下步骤:The storage medium according to claim 15, wherein the position of the word to be replaced in the draft text is predicted by the trained quality perception occlusion language model according to the draft text, and the information of the word to be replaced is obtained. Before the target location, when the quality perception-based text generation program is executed by the processor, it is also used to implement the following steps:
    获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本;Obtain the standard text, perform random replacement of words in the standard text to obtain the replacement text;
    建立待训练质量感知遮挡语言模型;Establish a language model for training quality perception occlusion;
    根据所述标准文本和所述替换文本对所述待训练质量感知遮挡语言模型进行训练,获得训练好的质量感知遮挡语言模型。Training the quality-aware occlusion language model to be trained according to the standard text and the replacement text to obtain a trained quality-aware occlusion language model.
  17. 如权利要求16所述的存储介质,其中,所述替换文本包括:第一预设比例的第一替换文本、第二预设比例的第二替换文本和第三预设比例的标准文本;15. The storage medium of claim 16, wherein the replacement text comprises: a first replacement text of a first preset ratio, a second replacement text of a second preset ratio, and a standard text of a third preset ratio;
    所述获取标准文本,对所述标准文本中的字进行随机替换,获得替换文本时,具体实现以下步骤:The standard text is obtained, and words in the standard text are randomly replaced. When the replacement text is obtained, the following steps are specifically implemented:
    通过随机标记,选取所述标准文本中每句话中的任意一个字随机替换为另外一个字获 得第一替换文本,并记录被替换的字的位置标签,所述第一预设比例为所述第一替换文本占所有替换文本的比例;Through random marking, any word in each sentence in the standard text is selected and randomly replaced with another word to obtain the first replacement text, and the position label of the replaced word is recorded. The first preset ratio is the The ratio of the first replacement text to all the replacement text;
    通过随机标记,选取所述标准文本中每句话中的任意两个字随机替换为另外两个字获得第二替换文本,并记录被替换的字的位置标签,所述第二预设比例为所述第二替换文本占所有替换文本的比例;Through random marking, any two words in each sentence in the standard text are selected and randomly replaced with other two words to obtain the second replacement text, and the position label of the replaced word is recorded. The second preset ratio is The proportion of the second replacement text in all the replacement text;
    保持所述标准文本不变,将所述标准文本作为替换文本,并将位置标签记录为第一预设值,所述第三比例为所述标准文本占所有替换文本的比例。Keep the standard text unchanged, use the standard text as the replacement text, and record the position label as a first preset value, and the third ratio is the ratio of the standard text to all the replacement text.
  18. 如权利要求15所述的存储介质,其中,所述直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本时,具体实现以下步骤:15. The storage medium according to claim 15, wherein, when all the words to be replaced in the draft text are replaced, the iteration is terminated, and the target text after iterative update is obtained, the following steps are specifically implemented:
    判断所述目标位置是否为第二预设值;Judging whether the target position is a second preset value;
    若所述目标位置为所述第二预设值,则认定所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。If the target position is the second preset value, it is determined that all the words to be replaced in the draft text have been replaced, the iteration is terminated, and the target text after the iteration is obtained.
  19. 如权利要求15-18中任一项所述的存储介质,其中,所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置之前,所述基于质量感知的文本生成程序被所述处理器执行时还用于实现以下步骤:The storage medium according to any one of claims 15-18, wherein the position of the word to be replaced in the draft text is predicted by using a trained quality perception occlusion language model according to the draft text to obtain Before the target position of the word to be replaced, when the quality perception-based text generation program is executed by the processor, the following steps are further implemented:
    将所述文本草稿进行向量化获得训练好的质量感知遮挡语言模型的输入向量;Vectorizing the draft text to obtain an input vector of a trained quality-aware occlusion language model;
    所述根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置时,具体实现以下步骤:When the position of the word to be replaced in the draft text is predicted through the trained quality perception occlusion language model according to the draft text, and the target position of the word to be replaced is obtained, the following steps are specifically implemented:
    根据所述输入向量通过训练好的质量感知遮挡语言模型,对所述输入向量中待替换字的位置进行预测,获得所述待替换字的目标位置;Predicting the position of the word to be replaced in the input vector through the trained quality perception occlusion language model according to the input vector to obtain the target position of the word to be replaced;
    所述通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字时,具体实现以下步骤:When the trained quality perception occlusion language model predicts the semantics of the target location according to the context information of the target location, and obtains the target word corresponding to the target location, the following steps are specifically implemented:
    对所述目标位置的字进行遮挡,获得遮挡文本,根据所述遮挡文本通过所述训练好的质量感知遮挡语言模型,结合所述目标位置的上下文语境信息对所述遮挡文本的所述目标位置的语义进行预测,获得所述目标位置对应的目标字。The word at the target location is occluded to obtain occluded text, and the trained quality perception occlusion language model is used according to the occluded text, and the context information of the target location is used to compare the target of the occluded text. The semantics of the position are predicted, and the target word corresponding to the target position is obtained.
  20. 一种基于质量感知的文本生成装置,其中,所述基于质量感知的文本生成装置包括:A text generation device based on quality perception, wherein the text generation device based on quality perception includes:
    生成模块,用于获取待处理语料集,将所述待处理语料集进行多线程处理,通过序列到序列模型生成文本草稿;A generating module, used to obtain a corpus to be processed, perform multi-thread processing on the corpus to be processed, and generate a text draft through a sequence-to-sequence model;
    预测模块,用于根据所述文本草稿通过训练好的质量感知遮挡语言模型,对所述文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置;A prediction module, configured to predict the position of the word to be replaced in the text draft through the trained quality perception occlusion language model according to the text draft, and obtain the target position of the word to be replaced;
    所述预测模块,还用于通过所述训练好的质量感知遮挡语言模型,根据所述目标位置的上下文语境信息对所述目标位置的语义进行预测,获得所述目标位置对应的目标字;The prediction module is further configured to predict the semantics of the target location according to the context information of the target location through the trained quality perception occlusion language model, and obtain the target word corresponding to the target location;
    迭代模块,用于通过所述训练好的质量感知遮挡语言模型,将所述目标字替换所述待替换字,获得第一次迭代文本,将所述第一次迭代文本作为新的文本草稿,返回所述根据所述新的文本草稿通过训练好的质量感知遮挡语言模型,对所述新的文本草稿中待替换字的位置进行预测,获得所述待替换字的目标位置的步骤,直至所述文本草稿中所有所述待替换字均被替换,迭代终止,获得迭代更新后的目标文本。The iteration module is used to replace the target word with the word to be replaced by the trained quality perception occlusion language model to obtain the first iteration text, and use the first iteration text as a new text draft, Return to the step of predicting the position of the word to be replaced in the new text draft through the trained quality perception occlusion language model according to the new text draft, and obtaining the target position of the word to be replaced, until all All the words to be replaced in the draft text are replaced, the iteration is terminated, and the updated target text is obtained.
PCT/CN2020/118114 2019-10-29 2020-09-27 Quality perception-based text generation method and apparatus, device, and storage medium WO2021082842A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911040951.0A CN111061867B (en) 2019-10-29 2019-10-29 Text generation method, equipment, storage medium and device based on quality perception
CN201911040951.0 2019-10-29

Publications (1)

Publication Number Publication Date
WO2021082842A1 true WO2021082842A1 (en) 2021-05-06

Family

ID=70297629

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/118114 WO2021082842A1 (en) 2019-10-29 2020-09-27 Quality perception-based text generation method and apparatus, device, and storage medium

Country Status (2)

Country Link
CN (1) CN111061867B (en)
WO (1) WO2021082842A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061867B (en) * 2019-10-29 2022-10-25 平安科技(深圳)有限公司 Text generation method, equipment, storage medium and device based on quality perception
CN111309908B (en) * 2020-02-12 2023-08-25 支付宝(杭州)信息技术有限公司 Text data processing method and device
CN111401037B (en) * 2020-06-05 2020-11-06 平安国际智慧城市科技股份有限公司 Natural language generation method and device, electronic equipment and storage medium
CN111695342B (en) * 2020-06-12 2023-04-25 复旦大学 Text content correction method based on context information
CN111783413A (en) * 2020-06-30 2020-10-16 平安科技(深圳)有限公司 Lyric recomposing method, apparatus, computer device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110137653A1 (en) * 2009-12-04 2011-06-09 At&T Intellectual Property I, L.P. System and method for restricting large language models
CN109918630A (en) * 2019-01-23 2019-06-21 平安科技(深圳)有限公司 Document creation method, device, computer equipment and storage medium
CN110032644A (en) * 2019-04-03 2019-07-19 人立方智能科技有限公司 Language model pre-training method
CN110287494A (en) * 2019-07-01 2019-09-27 济南浪潮高新科技投资发展有限公司 A method of the short text Similarity matching based on deep learning BERT algorithm
CN110347799A (en) * 2019-07-12 2019-10-18 腾讯科技(深圳)有限公司 Language model training method, device and computer equipment
CN111061867A (en) * 2019-10-29 2020-04-24 平安科技(深圳)有限公司 Text generation method, equipment, storage medium and device based on quality perception

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8442813B1 (en) * 2009-02-05 2013-05-14 Google Inc. Methods and systems for assessing the quality of automatically generated text
US9898458B2 (en) * 2015-05-08 2018-02-20 International Business Machines Corporation Generating distributed word embeddings using structured information
EP3358471A1 (en) * 2017-02-04 2018-08-08 Tata Consultancy Services Limited Systems and methods for assessing quality of input text using recurrent neural networks
US10901604B2 (en) * 2017-11-28 2021-01-26 Microsoft Technology Licensing, Llc Transformation of data object based on context
CN108363697B (en) * 2018-03-08 2022-02-22 腾讯科技(深圳)有限公司 Text information generation method and device, storage medium and equipment
US10825227B2 (en) * 2018-04-03 2020-11-03 Sri International Artificial intelligence for generating structured descriptions of scenes
JP2019185551A (en) * 2018-04-13 2019-10-24 株式会社Preferred Networks Annotation added text data expanding method, annotation added text data expanding program, annotation added text data expanding apparatus, and training method of text classification model
CN109117485B (en) * 2018-09-06 2023-08-08 北京汇钧科技有限公司 Method and device for generating blessing language text and computer readable storage medium
CN109684501B (en) * 2018-11-26 2023-08-22 平安科技(深圳)有限公司 Lyric information generation method and device
CN110134968B (en) * 2019-05-22 2023-11-24 网易(杭州)网络有限公司 Poem generation method, device, equipment and storage medium based on deep learning
CN110196894B (en) * 2019-05-30 2021-06-08 北京百度网讯科技有限公司 Language model training method and language model prediction method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110137653A1 (en) * 2009-12-04 2011-06-09 At&T Intellectual Property I, L.P. System and method for restricting large language models
CN109918630A (en) * 2019-01-23 2019-06-21 平安科技(深圳)有限公司 Document creation method, device, computer equipment and storage medium
CN110032644A (en) * 2019-04-03 2019-07-19 人立方智能科技有限公司 Language model pre-training method
CN110287494A (en) * 2019-07-01 2019-09-27 济南浪潮高新科技投资发展有限公司 A method of the short text Similarity matching based on deep learning BERT algorithm
CN110347799A (en) * 2019-07-12 2019-10-18 腾讯科技(深圳)有限公司 Language model training method, device and computer equipment
CN111061867A (en) * 2019-10-29 2020-04-24 平安科技(深圳)有限公司 Text generation method, equipment, storage medium and device based on quality perception

Also Published As

Publication number Publication date
CN111061867B (en) 2022-10-25
CN111061867A (en) 2020-04-24

Similar Documents

Publication Publication Date Title
WO2021082842A1 (en) Quality perception-based text generation method and apparatus, device, and storage medium
US20230015665A1 (en) Multi-turn dialogue response generation with template generation
US10971141B2 (en) Session information processing method and device and storage medium
WO2022178969A1 (en) Voice conversation data processing method and apparatus, and computer device and storage medium
WO2024066920A1 (en) Processing method and apparatus for dialogue in virtual scene, and electronic device, computer program product and computer storage medium
WO2021208460A1 (en) Sentence completion method and device, and readable storage medium
CN110399473B (en) Method and device for determining answers to user questions
WO2022052484A1 (en) Method and apparatus for recognizing emotions in text, terminal device, and storage medium
CN112735374A (en) Automatic voice interaction method and device
CN117709311B (en) Cloud-based lecture manuscript management method, device, equipment and storage medium
CN115132209B (en) Speech recognition method, apparatus, device and medium
CN112084752A (en) Statement marking method, device, equipment and storage medium based on natural language
CN111402864A (en) Voice processing method and electronic equipment
CN115525740A (en) Method and device for generating dialogue response sentence, electronic equipment and storage medium
JP2021108095A (en) Method for outputting information on analysis abnormality in speech comprehension
CN111324344A (en) Code statement generation method, device, equipment and readable storage medium
US11989528B2 (en) Method and server for training a machine learning algorithm for executing translation
CN114417827A (en) Text context processing method and device, electronic equipment and storage medium
CN114911814A (en) Consultation service method and system based on knowledge resource library updating
CN114595318A (en) Customer service reply quality evaluation method and system
CN114328910A (en) Text clustering method and related device
CN113378561A (en) Word prediction template generation method and device
CN113378543B (en) Data analysis method, method for training data analysis model and electronic equipment
CN114492457B (en) Semantic recognition method, semantic recognition device, electronic equipment and storage medium
CN117521674B (en) Method, device, computer equipment and storage medium for generating countermeasure information

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: 20881872

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: 20881872

Country of ref document: EP

Kind code of ref document: A1