Training method for text paraphrasing model, text paraphrasing method and device
By using vocabulary control and grammatical control conditions in the text retelling model for training, the problem of insufficient diversity and accuracy of text retelling in the prior art is solved, and a more efficient text retelling effect is achieved.
Patent Information
- Application Number
- CN202210333098.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-30
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-03-30
AI Technical Summary
The prior art is difficult to improve the diversity and accuracy of text retelling while keeping the semantics unchanged.
By obtaining the training text pair, vocabulary control conditions and grammatical control conditions are generated, and the original training text, vocabulary control conditions and grammatical control conditions are input into the text retelling model to be trained, and the model parameters are updated for training. The text retelling model includes a pre-trained language model and a decoder for prediction of retelling texts based on vocabulary control and grammatical control conditions.
It realizes the consideration of vocabulary replacement and grammatical transformation in the process of text retelling, and improves the diversity and accuracy of text retelling. At the same time, the model is built using pre-trained language models and decoders, which enhances the universality of the model.
Smart Images

Figure CN114818684B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and more particularly to a text retelling model training method, a text retelling method and a device. Background Art
[0002] Text paraphrasing refers to changing the way a text is expressed while keeping its semantics unchanged. Text paraphrasing is widely used in machine translation, information retrieval, question-answering systems, and other fields. How to improve the diversity and accuracy of text paraphrasing has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] In view of this, the present specification provides a training method for a text retelling model, a text retelling method and a device.
[0004] Specifically, this specification is implemented through the following technical solutions:
[0005] A training method for a text retelling model, comprising:
[0006] Acquire a training text pair, wherein the training text pair includes an original training text and a paraphrase training text;
[0007] generating a vocabulary control condition and a grammar control condition for the retelling training text;
[0008] Inputting the original training text, the vocabulary control conditions and the grammar control conditions into the text paraphrase model to be trained, and obtaining the paraphrase prediction text output by the text paraphrase model;
[0009] Based on the difference between the paraphrase prediction text and the paraphrase training text, updating the parameters of the text paraphrase model to train the text paraphrase model;
[0010] The text retelling model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the vocabulary control conditions and the grammatical control conditions as constraints, and output a semantic representation vector of the original training text. The decoder is used to predict the retelling text based on the semantic representation vector and output the retelling prediction text.
[0011] Optionally, the grammatical control condition is to repeat a sample text;
[0012] The step of generating grammatical control conditions for the retelling training text includes:
[0013] Generating a truncated linearized component tree LCT for the paraphrase training text;
[0014] Look up the paraphrased example text that matches the truncated LCT in the example dictionary as the syntactic control condition for the paraphrasing training text; wherein, the example dictionary includes the mapping relationship between the truncated LCT and the paraphrased example text.
[0015] Optionally, the step of looking up the paraphrased example text that matches the truncated LCT in the example dictionary includes:
[0016] Calculate the syntactic edit distance between the truncated LCT of the paraphrasing training text and each truncated LCT in the example dictionary;
[0017] Determine the paraphrased example text corresponding to the truncated LCT with the minimum syntactic edit distance calculated in the example dictionary as the matching paraphrased example text.
[0018] Optionally, the method for generating the example dictionary includes:
[0019] Generate a truncated LCT for the paraphrasing training text in each training text pair to obtain the mapping relationship between the truncated LCT and the paraphrasing training text;
[0020] For each truncated LCT, in the case where the truncated LCT corresponds to multiple paraphrasing training texts, select one of the paraphrasing training texts as the paraphrased example text; in the case where the truncated LCT corresponds to one paraphrasing training text, determine the paraphrasing training text as the paraphrased example text;
[0021] Generate an example dictionary based on the mapping relationship between the truncated LCT and the paraphrased example text.
[0022] Optionally, the step of generating a truncated LCT for the paraphrasing training text includes:
[0023] Generate an LCT for the paraphrasing training text;
[0024] Filter out the part-of-speech tags of the leaf nodes in the LCT to obtain the truncated LCT.
[0025] Optionally, the step of generating a lexical control condition for the paraphrasing training text includes:
[0026] Use a keyword extraction algorithm to extract keywords from the paraphrasing training text as the lexical control condition for the paraphrasing training text.
[0027] Optionally, the syntactic control condition includes one of the part-of-speech tagging, LCT, syntactic framework template, and paraphrased example text of the paraphrasing training text, and the text paraphrasing model corresponds to the syntactic control condition.
[0028] A text paraphrasing method includes:
[0029] Obtain the text to be paraphrased and the control conditions for the text to be paraphrased;
[0030] Input the text to be paraphrased and the control conditions into the trained text paraphrasing model to obtain the text paraphrasing result output by the text paraphrasing model;
[0031] Among them, the text paraphrasing model is trained based on the foregoing method.
[0032] Optionally, the control conditions include lexical control conditions and syntactic control conditions, and the trained text paraphrasing model corresponds to the syntactic control conditions.
[0033] A training device for a text paraphrasing model, comprising:
[0034] A sample acquisition unit that acquires training text pairs, where the training text pairs include original training texts and paraphrased training texts;
[0035] A condition generation unit that generates lexical control conditions and syntactic control conditions for the paraphrased training texts;
[0036] A model input unit that inputs the original training text, the lexical control conditions, and the syntactic control conditions into the text paraphrasing model to be trained to obtain the paraphrased prediction text output by the text paraphrasing model;
[0037] A parameter update unit that updates the parameters of the text paraphrasing model based on the difference between the paraphrased prediction text and the paraphrased training text to train the text paraphrasing model;
[0038] Among them, the text paraphrasing model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the lexical control conditions and the syntactic control conditions as constraints and output the semantic representation vector of the original training text. The decoder is used to predict the paraphrased text based on the semantic representation vector and output the paraphrased prediction text.
[0039] A text paraphrasing device, comprising:
[0040] A text acquisition unit that acquires the text to be paraphrased and the control conditions for the text to be paraphrased;
[0041] A text paraphrasing unit that inputs the text to be paraphrased and the control conditions into the trained text paraphrasing model to obtain the text paraphrasing result output by the text paraphrasing model;
[0042] Among them, the text paraphrasing model is trained based on the foregoing method.
[0043] A training device for a text paraphrasing model, comprising:
[0044] Processor;
[0045] A memory for storing machine - executable instructions;
[0046] Wherein, by reading and executing the machine - executable instructions stored in the memory corresponding to the training logic of the text repetition model, the processor is caused to:
[0047] Obtain a training text pair, the training text pair including an original training text and a repeated training text;
[0048] Generate a vocabulary control condition and a grammar control condition for the repeated training text;
[0049] Input the original training text, the vocabulary control condition, and the grammar control condition into a text repetition model to be trained, and obtain a repeated prediction text output by the text repetition model;
[0050] Based on the difference between the repeated prediction text and the repeated training text, update the parameters of the text repetition model to train the text repetition model;
[0051] Wherein, the text repetition model includes a pre - trained language model and a decoder. The pre - trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints, and output a semantic representation vector of the original training text. The decoder is used to predict a repeated text based on the semantic representation vector and output a repeated prediction text.
[0052] A text repetition device, comprising:
[0053] Processor;
[0054] A memory for storing machine - executable instructions;
[0055] Wherein, by reading and executing the machine - executable instructions stored in the memory corresponding to the text repetition logic, the processor is caused to:
[0056] Obtain a text to be repeated and a control condition of the text to be repeated;
[0057] Input the text to be repeated and the control condition into a trained text repetition model, and obtain a text repetition result output by the text repetition model;
[0058] Wherein, the text repetition model is trained based on the foregoing method.
[0059] With the above - described embodiments, when this specification trains a text paraphrasing model, the vocabulary control condition and the grammar control condition for paraphrasing the training text are used as the input of the text paraphrasing model, so that the text paraphrasing model can predict the paraphrased text with the vocabulary control and grammar control conditions as constraints. By combining the vocabulary control condition and the grammar control condition for model training, both vocabulary replacement and grammar transformation in the text paraphrasing process can be taken into account, and the trained text paraphrasing model can improve the diversity and accuracy of text paraphrasing. On the other hand, this specification constructs a text paraphrasing model using a pre - trained language model and a decoder, which can be compatible with current mainstream pre - trained language models and has better generality. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 FIG. is a schematic flowchart of a method for training a text paraphrasing model shown in an exemplary embodiment of this specification.
[0061] Figure 2 FIG. is a schematic framework diagram of a text paraphrasing model shown in an exemplary embodiment of this specification.
[0062] Figure 3 FIG. is a schematic diagram of another method for training a text paraphrasing model shown in an exemplary embodiment of this specification.
[0063] Figure 4 FIG. is a schematic flowchart of a method for generating an example dictionary shown in an exemplary embodiment of this specification.
[0064] Figure 5 FIG. is a schematic flowchart of a method for generating a paraphrased example text for a paraphrasing training text shown in an exemplary embodiment of this specification.
[0065] Figure 6 FIG. is a schematic flowchart of a text paraphrasing method shown in an exemplary embodiment of this specification.
[0066] Figure 7 FIG. is a hardware structure diagram of an electronic device where a training device for a text paraphrasing model is located shown in an exemplary embodiment of this specification.
[0067] Figure 8 FIG. is a block diagram of a training device for a text paraphrasing model shown in an exemplary embodiment of this specification.
[0068] Figure 9 FIG. is a block diagram of a text paraphrasing device shown in an exemplary embodiment of this specification. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0069] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.
[0070] The terms used in this specification are for the purpose of describing particular embodiments only and are not intended to limit this specification. The singular forms "a", "the", and "said" used in this specification and the appended claims are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0071] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".
[0072] Text paraphrasing refers to changing the expression of a text while maintaining its semantics. Text paraphrasing has a wide range of applications in fields such as machine translation, information retrieval, and question answering systems.
[0073] Text paraphrasing may include lexical substitution, that is, using synonyms to replace the specified words in the original text. Text paraphrasing may also include syntactic structure transformation. For example, transforming the original text in the active voice into the passive voice, etc. However, current text paraphrasing only focuses on lexical or syntactic structure transformation and cannot meet the diverse and accurate needs of users.
[0074] This specification provides a training scheme for a text paraphrasing model. Using the text paraphrasing model trained according to this specification for text paraphrasing can solve the problems of text paraphrasing diversity and accuracy simultaneously.
[0075] Figure 1 It is a schematic flowchart of a training method for a text paraphrasing model shown in an exemplary embodiment of this specification.
[0076] Please refer to Figure 1 , the training method of the text paraphrasing model may include the following steps:
[0077] Step 102: Obtain training text pairs, where each training text pair includes an original training text and a paraphrased training text.
[0078] In this specification, samples for training a text paraphrasing model can be obtained first. The samples usually consist of text pairs for training, and each training text pair includes an original training text and its corresponding paraphrased training text.
[0079] For example, if the original training text is “No one’s home?”, the corresponding paraphrased training text can be “Is anyone home?”.
[0080] Another example, if the original training text is “There was a picture of the revolving earth that have emerged.”, the corresponding paraphrased training text can be “A picture of the rotating earth showed up.”
[0081] In this specification, the original training text and its corresponding paraphrased training text can be sentences or phrases. The languages of the original training text and its corresponding paraphrased training text are usually the same, which can be the English text in the aforementioned examples, or Chinese text or text in other languages. This specification does not impose special restrictions on this.
[0082] Step 104: Generate lexical control conditions and syntactic control conditions for the paraphrased training text.
[0083] In this specification, for each group of training text pairs, corresponding lexical control conditions and syntactic control conditions can be generated for the paraphrased training text in this group of training text pairs.
[0084] In this specification, the lexical control conditions represent the constraint conditions on lexical substitution, which can control that the generated paraphrased text must contain the specified vocabulary.
[0085] For example, a keyword extraction algorithm can be used to extract keywords from the paraphrased training text, and the extracted keywords can be determined as the lexical control conditions for the paraphrased training text.
[0086] The keyword extraction algorithm can include: TF-IDF (Term Frequency–Inverse Document Frequency) algorithm, KeyBERT (Bidirectional Encoder Representations from Transformer) algorithm, TextRank algorithm, etc.
[0087] Taking the text for repetition training as "Is anyone home?" as an example, the lexical control condition "anyone" can be extracted from this text for repetition training.
[0088] Taking the text for repetition training as "A picture of the rotating earth showed up" as an example, the lexical control conditions "rotating" and "showed up" can be extracted from this text for repetition training.
[0089] In this specification, the syntactic control condition can represent the constraint conditions on syntactic transformation. For example, it controls the generated repetition text to meet the specified syntactic requirements. The syntactic control conditions can include: part-of-speech tagging (POS-Tagging) of the text, LCT (Linearized Constituent Tree), masked template, sentential exemplar, etc.
[0090] In this specification, part-of-speech tagging identifies the part of speech of each word in the text, which can be implemented based on part-of-speech tagging tools such as NLTK (Natural Language Toolkit) and CoreNLP (Core Natural Language Processing). For example, the text for repetition training is input into the part-of-speech tagging tool to obtain the output part-of-speech tagging result.
[0091] Text Part-of-speech tagging result Is VBZ (verb) anyone NN (common noun) home NN (common noun)
[0092] Table 1
[0093] Taking the text for repetition training as "Is anyone home?" as an example, please refer to the example in Table 1, and its part-of-speech tagging result is VBZ NN NN.
[0094] Text Part-of-speech tagging result A DT (determiner) picture NN (common noun) of IN (preposition or subordinating conjunction) the DT (determiner) rotating VBG (gerund and present participle) earth NN (common noun) showed VBD (verb past tense) up RP (particle)
[0095] Table 2
[0096] Taking the text for repetition training as "A picture of the rotating earth showed up." as an example, please refer to the example in Table 2, and its part-of-speech tagging result is DT NN IN DT VBG NN VBD RP.
[0097] In this specification, LCT is the serialized representation of a Constituent Tree, which can also be generated based on tools such as NLTK and CoreNLP. For example, by inputting the paraphrase training text into the relevant tools, the output LCT result can be obtained.
[0098] Taking the paraphrase training text "Is anyone home?" as an example, the LCT is SQ(NP)(ADVP)(?).
[0099] Among them, SQ represents the annotation at the text level, meaning that the sentence is an inverted interrogative sentence; NP corresponds to "IS" and represents a noun phrase; ADVP corresponds to "anyone home" and represents an adverb phrase.
[0100] Taking the paraphrase training text "A picture of the rotating earth showed up" as an example, the LCT is S(NP(NP(DT)(NN))(PP(IN)(NP(DT)(VBG)(NN))))(VP(VBD)(PRT(RP)))(..).
[0101] Among them, PP represents a prepositional phrase, VP represents a verb phrase, and PRT is used to indicate a relationship and also represents a verb phrase. The specific meaning can refer to the part-of-speech annotation explanation in this field.
[0102] In this specification, the grammar framework template can represent the grammar structure of the text. Words of a specified part of speech in the text can be replaced with preset markers to generate the grammar framework template. For example, after performing part-of-speech annotation on the paraphrase training text, the nouns in the paraphrase training text are replaced with the marker MASK.
[0103] Taking the paraphrase training text "Is anyone home?" as an example, after obtaining the part-of-speech annotation results VBZ NN NN, the nouns "anyone" and "home" are replaced with MASK, and the grammar framework template "Is[MASK][MASK]?" of the paraphrase training text "Is anyone home?" is obtained.
[0104] Taking the text for repetition training as "A picture of the rotating earth showed up." as an example, after obtaining the part-of-speech tagging result DT NN IN DT VBG NN VBD RP, replace "picture", "rotating", "earth", "showed" and "up" with MASK to get the grammar framework template A[MASK]of the[MASK][MASK][MASK][MASK] for "A picture of the rotating earth showed up.".
[0105] In this specification, the text sample for repetition is an example of the text obtained by repetition, and this example has the same grammatical structure as the text obtained by repetition.
[0106] Taking the text for repetition training as "Is anyone home?" as an example, its text sample for repetition can be "Is thisthe code word?".
[0107] Taking the text for repetition training as "A picture of the rotating earth showed up." as an example, its text sample for repetition can be "The job at school went well.".
[0108] Among them, the text sample for repetition can be obtained by querying the example dictionary. For example, first generate a truncated LCT for the text for repetition training, and then use the truncated LCT to search for a matching text sample for repetition in the example dictionary. The generation of the range dictionary and the search process for the text sample for repetition will be described in detail in the subsequent embodiments of this specification.
[0109] Step 106: Input the original training text, the lexical control condition, and the grammatical control condition into the text repetition model to be trained, and obtain the predicted repetition text output by the text repetition model.
[0110] Step 108: Update the parameters of the text repetition model based on the difference between the predicted repetition text and the text for repetition training, so as to train the text repetition model.
[0111] Based on the foregoing step 104, the original training text, the lexical control condition, and the grammatical control condition of the text for repetition training in the training text pair can be jointly input into the text repetition model, and the predicted repetition text output by the text repetition model can be obtained through the text repetition model.
[0112] Then, the difference between the paraphrased prediction text and the paraphrased training text in the training text pair can be calculated, and based on this difference, the model parameters of the text paraphrasing model can be updated using the backpropagation algorithm to achieve the training of the text paraphrasing model.
[0113] In this specification, the text paraphrasing model can correspond to grammar control conditions, that is, each grammar control condition can correspond to a text paraphrasing model.
[0114] Grammar control condition Text repetition model Part-of-speech tagging Text repetition model 1 LCT Text repetition model 2 Grammar framework template Text repetition model 3 Repetition example text Text repetition model 4
[0115] Table 3
[0116] Taking the above-listed 4 grammar control conditions: part-of-speech tagging, LCT, grammar framework template, and paraphrasing example text as an example, 4 text paraphrasing models can be corresponded. Referring to the example in Table 3, they can respectively correspond to Text Paraphrasing Model 1 - Text Paraphrasing Model 4. When training the text paraphrasing model, one of the grammar control conditions can be used to train the corresponding text paraphrasing model.
[0117] For example, use the lexical control condition and part-of-speech tagging to train Text Paraphrasing Model 1; use the lexical control condition and LCT to train Text Paraphrasing Model 2; use the lexical control condition and grammar framework template to train Text Paraphrasing Model 3; use the lexical control condition and paraphrasing example text to train Text Paraphrasing Model 4.
[0118] This specification divides the grammar control conditions into multiple types, sets text paraphrasing models corresponding to the grammar control condition types, and can train multiple text paraphrasing models using the same batch of training text pairs, providing more diverse choices for users subsequently.
[0119] In this specification, please refer to Figure 2 , the text paraphrasing model can be constructed based on a pre-trained language model and a decoder.
[0120] Among them, the pre-trained language model can be any currently known pre-trained language model, and the decoder can also be any currently known decoder. The pre-trained language model and the decoder can both be neural network models, and this specification does not make special restrictions on this.
[0121] When training the text paraphrasing model, the original training text, the lexical control condition, and the grammar control condition of the paraphrased training text are input into the pre-trained language model. For example, connect the original training text and the above control conditions with [SEP] to form a sequence, that is, add [SEP] after the original training text, and [SEP] can also be added between different control conditions, and then input into the pre-trained language model.
[0122] Please refer toFigure 3 Taking the original training text as "No one’s home?" and the grammar control condition as repeating the example text as an example, the input text "No one’s home? [SEP] anyone [SEP] Is this the code word?" can be input into the pre-trained language model in the text repetition model 4. Other grammar control conditions are similar and will not be elaborated one by one in this specification.
[0123] It should be noted that Figure 3 This is only an exemplary display of the vocabulary control condition and the grammar control condition in this example, and it does not mean that the four grammar control conditions are input into the pre-trained language model at the same time. Referring to the foregoing discussion, when training the text repetition model, the vocabulary control condition and one grammar control condition are input into the text repetition model corresponding to this grammar control condition for training.
[0124] The pre-trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints, and generate the semantic representation vector of the original training text. Then, this semantic representation vector is input into the decoder, and the decoder predicts the repeated text based on the semantic representation vector and outputs the repeated prediction text "Is anyone home?".
[0125] On the other hand, the formulation of the text repetition model is as follows:
[0126]
[0127] Among them, p represents probability, x represents the text to be repeated input into the text repetition model, c represents the vocabulary control condition and the grammar control condition, θ represents the model parameters, y represents the repeated text output by the text repetition model, y = (y 1 , y 2 ,..., y T ), y t represents each word in the generated repeated text, and T represents the maximum length of the generated text. The meaning expressed by this formula is that the text repetition model generates a repeated text according to the input text and the control condition, and the generation of the subsequent word in the repeated text depends on the previously generated words.
[0128] As can be seen from the above description, when training the text repetition model in this specification, the vocabulary control condition and grammar control condition for repeating the training text are used as the input of the text repetition model, so that the text repetition model can make predictions for repeating the text with the vocabulary control and grammar control conditions as constraints. By combining the vocabulary control condition and grammar control condition for model training, both vocabulary replacement and grammar transformation in the text repetition process can be taken into account, and the trained text repetition model can improve the diversity and accuracy of text repetition.
[0129] On the other hand, this specification constructs a text repetition model by using a pre-trained language model and a decoder, which can be compatible with current mainstream pre-trained language models and has better versatility.
[0130] The following separately introduces the generation of the example dictionary and the specific implementation process of generating example texts for repeating the training text.
[0131] I. Generation of the example dictionary
[0132] In this specification, an example dictionary including the mapping relationship between the truncated LCT and the example text for repetition can be pre-generated, and then the example text for repetition can be searched based on the example dictionary.
[0133] Among them, the truncated LCT refers to the serialized representation obtained after filtering the leaf nodes in the phrase structure tree, that is, filtering out the part-of-speech of the leaf nodes corresponding in the LCT to obtain the truncated LCT. When filtering, the part-of-speech located at the innermost side of the parentheses and with both left and right neighbors being parentheses can be filtered out as the leaf node.
[0134] Figure 4 It is a schematic flowchart of a method for generating an example dictionary shown in an exemplary embodiment of this specification.
[0135] Please refer to Figure 4 , and the method for generating the example dictionary may include the following steps:
[0136] Step 402, generate a truncated LCT for the text for repetition in each training text pair to obtain the mapping relationship between the truncated LCT and the text for repetition training.
[0137] In this embodiment, for each group of training text pairs, a truncated LCT can be first generated for the text for repetition in the training text pair to obtain the mapping relationship between the truncated LCT and the text for repetition training.
[0138] Taking the text for repetition training “A picture of the rotating earth showed up.” as an example, its LCT is S(NP(NP(DT)(NN))(PP(IN)(NP(DT)(VBG)(NN))))(VP(VBD)(PRT(RP)))(..). After removing the leaf node part-of-speech tags DT, NN, IN, DT, VBG, NN, VBD, and RP, the truncated LCT obtained is S(NP(NP)(PP(NP)))(VP(PRT))(..).
[0139] Taking the text for repetition training “Is this the code word?” as an example, its LCT is SQ(VBZ)(NP(DT))(NP(DT)(NN)(NN))(.?). After removing the leaf node part-of-speech tags VBZ, DT, DT, NN, and NN, the truncated LCT obtained is SQ(NP)(NP)(.?).
[0140] Taking the text for repetition training “Is anyone home?” as an example, its LCT is SQ(NP)(ADVP)(?). Since there is no leaf node in this LCT whose left and right neighbors are both parentheses, its truncated LCT is the same as the LCT, which is also SQ(NP)(ADVP)(?).
[0141] In this embodiment, each text for repetition training and its corresponding truncated LCT can be obtained.
[0142] Step 404: For each truncated LCT, in the case where the truncated LCT corresponds to multiple texts for repetition training, select one text for repetition training as the repetition example text; in the case where the truncated LCT corresponds to one text for repetition training, determine the text for repetition training as the repetition example text.
[0143] Step 406: Generate an example dictionary based on the mapping relationship between the truncated LCT and the repetition example text.
[0144] Based on the foregoing step 402, since the truncated LCT filters out the leaf node part-of-speech tags, after generating the truncated LCT, there will be a situation where one truncated LCT corresponds to multiple texts for repetition training. For this situation, one text for repetition training can be selected from the multiple texts for repetition training corresponding to the truncated LCT as the repetition example text. For example, randomly select one text for repetition training as the repetition example text, and then generate an example dictionary based on the truncated LCT and the repetition example text.
[0145] For example, assume that the first truncated LCT corresponds to three repetition training texts, namely repetition training texts A, B, and C. Randomly select repetition training text B from repetition training texts A, B, and C as the repetition example text, and a sample dictionary can be generated based on the mapping relationship between the first truncated LCT and repetition example text B.
[0146] Of course, if a truncated LCT corresponds to only one repetition training text, this repetition training text can be used as the repetition example text, and a sample dictionary can be generated based on the mapping relationship between the two.
[0147] It should be noted that to prevent the repetition text generated by the text repetition model from introducing irrelevant words in the repetition example text, the training text pair where the repetition example text is located can be filtered out, that is, the training text pair where the repetition example text is located is not used to train the text repetition model.
[0148] II. Generating Repetition Example Texts for Repetition Training Texts
[0149] Figure 5 is a schematic flowchart of a process for generating repetition example texts for repetition training texts shown in an exemplary embodiment of this specification.
[0150] Please refer to Figure 5 , and generating repetition example texts for repetition training texts may include the following steps:
[0151] Step 502, generating a truncated LCT for the repetition training text.
[0152] In this embodiment, the method for generating the truncated LCT can refer to the description in the foregoing Figure 4 illustrated embodiment and will not be elaborated here one by one.
[0153] For the convenience of subsequent distinction, the truncated LCT generated for the repetition training text during the training process of the text repetition model can be referred to as the target truncated LCT.
[0154] Step 504, searching in the sample dictionary for the repetition example text that matches the truncated LCT as the repetition example text of the repetition training text.
[0155] Based on the foregoing step 502, after generating the target truncated LCT for the repetition training text, the truncated LCT that matches the target truncated LCT can be searched in the sample dictionary, and then the repetition example text corresponding to the matching truncated LCT in the sample dictionary is determined as the repetition example text that matches the target truncated LCT, that is, the corresponding repetition example text is determined as the grammar control condition of the repetition training text.
[0156] Among them, the matching process of the truncated LCT can be determined based on the syntactic edit distance. For example, the syntactic edit distance between the target truncated LCT and each truncated LCT in the exemplar dictionary can be calculated respectively, and then the truncated LCT with the minimum syntactic edit distance is determined as the matching truncated LCT.
[0157] The calculation formula of the syntactic edit distance D is as follows:
[0158]
[0159] Among them, s represents the target truncated LCT, k represents the truncated LCT in the exemplar dictionary, LevEdit represents the character-level edit distance, and |*| represents the length, that is, the sequence length of the truncated LCT.
[0160] Truncated LCT Repetition example text S(NP)(ADVP)(VP)(.) They almost finished. SQ(NP)(NP)(?) Is this the code word? SQ(NP)(VP(NP))(?) Do you smell burning?
[0161] Table 4
[0162] Taking the exemplar dictionary shown in Table 4 as an example, assuming that the paraphrasing training text is "Is anyone home?", its target truncated LCT is SQ(NP)(ADVP)(?), and the edit distance with the truncated LCT SQ(NP)(NP)(?) in the exemplar dictionary shown in Table 4 is the smallest. Then, the paraphrasing example text "Is this the codeword?" corresponding to the truncated LCT SQ(NP)(NP)(?) in the exemplar dictionary can be determined as the paraphrasing example text of "Is anyone home?", and then the text paraphrasing model is trained.
[0163] Of course, the edit distance is only an optional algorithm for truncated LCT matching. In other examples, algorithms such as word move distance can also be used for truncated LCT matching.
[0164] It can be seen from the above description that this specification uses the paraphrasing training text in the training sample pair as the paraphrasing example text to train the text paraphrasing model. Compared with the method of extracting syntactic information, it can avoid information loss in the extraction process, improve the accuracy of the text paraphrasing model prediction, and make the generated paraphrasing text smoother and more accurate. On the other hand, using the paraphrasing example text with similar syntax to the paraphrasing training text to train the text paraphrasing model can effectively reduce the probability of introducing irrelevant words in the predicted paraphrasing text compared with using the paraphrasing training text itself as the paraphrasing example text for training, and improve the accuracy of the text paraphrasing model prediction.
[0165] In this specification, when using Figure 1After training the text paraphrasing model shown in the embodiment, the text paraphrasing model can also be tested. When testing, a test text pair for model testing can be obtained first. The test text pair includes an original test text and a paraphrased test text. Then, a vocabulary control condition and a grammar control condition are generated, and the original test text, the vocabulary control condition, and the grammar control condition are input into the trained text paraphrasing model corresponding to the grammar control condition to obtain a paraphrased prediction text output by the text paraphrasing model. Then, based on the difference between the paraphrased prediction text and the paraphrased test text, the training effect of the text paraphrasing model is evaluated. If the training effect of the text paraphrasing model meets the expectation, the training can be ended. If the training effect of the text paraphrasing model does not meet the expectation, it can continue to be trained.
[0166] Among them, the vocabulary control condition used during testing can be generated based on the original test text. For example, the original test text is input into a keyword generation model to obtain keywords output by the keyword generation model, and these keywords are determined as the vocabulary control condition. The keyword generation model can be trained using training text pairs. For example, the original training text is input into the keyword generation model to obtain the output keywords, and then the parameters of the keyword generation model are updated according to the difference between these keywords and the keywords extracted from the paraphrased training text. The paraphrased sample text used during testing can be manually written. The paraphrased test text in the test text pair can also be manually written, and this specification does not make special restrictions on this.
[0167] In this specification, a text paraphrasing method is also provided. Please refer to Figure 6 , and the text paraphrasing method may include the following steps:
[0168] Step 602, obtain the text to be paraphrased and the control condition of the text to be paraphrased.
[0169] In this embodiment, the text to be paraphrased can be input by the user.
[0170] For example, if the user wants to rewrite and polish an English text, the user can input this English text through an input box provided in the interaction interface as the text to be paraphrased.
[0171] The control condition may include a vocabulary control condition and a grammar control condition, and the user can specify the vocabulary control condition and / or the grammar control condition according to needs.
[0172] Among them, the vocabulary control condition refers to the specified words that the user wants the generated text to contain. Taking the text to be paraphrased input by the user as “There was a picture of the revolving earth that haveemerged.”, the user can specify that the generated paraphrased text must include “showed up”.
[0173] The grammar control condition may be a sample text with the same grammatical structure as the text that the user wants to generate. Still taking the aforementioned text to be retold “There was a picture of the revolving earth that have emerged.” as an example, the user can input “The job at school went well.” as the sample text. Using the sample text as the input is more user-friendly and operable for the user as it does not involve difficult-to-understand parts of speech and grammar information, and is easy to implement.
[0174] Of course, in other examples, the user can also input grammar control conditions such as part-of-speech tagging, LCT, and grammar framework templates. This specification does not impose special restrictions on this.
[0175] Step 604: Input the text to be retold and the control condition into the trained text retelling model to obtain the text retelling result output by the text retelling model.
[0176] In this embodiment, the aforementioned text to be retold, the vocabulary control condition, and the grammar control condition can be input into the trained text retelling model corresponding to the grammar control condition to obtain the text retelling result output by the text retelling model. Among them, the text retelling model can be trained by using the Figure 1 text retelling model training method shown above.
[0177] As can be seen from the above description, when using the text retelling model provided in this specification for text retelling, the user can specify the vocabulary control condition and the grammar control condition, and then use the text retelling model corresponding to the grammar control condition for text retelling to achieve more diverse and accurate text retelling.
[0178] On the other hand, using the text retelling model provided in this specification for text retelling can meet the different needs of different users. For ordinary users, inputting keywords and sample texts can achieve text retelling, which does not involve difficult-to-understand parts of speech and grammar information, is more user-friendly, and has high operability. For professional users, they can also input professional grammar information such as parts of speech, LCT, and grammar framework templates to meet the professional needs of professional users.
[0179] Corresponding to the embodiment of the training method of the aforementioned text retelling model, this specification also provides an embodiment of the training device of the text retelling model.
[0180] Embodiments of the training apparatus for the text repetition model of this specification can be applied in an electronic device. The apparatus embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful apparatus, it is formed by the processor of the electronic device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for operation. From the hardware level, as Figure 7 shown, it is a hardware structure diagram of the electronic device where the training apparatus for the text repetition model of this specification is located. In addition to Figure 7 the processor, memory, network interface, and non-volatile memory shown, the electronic device where the apparatus is located in the embodiments usually includes other hardware according to the actual functions of the electronic device, which will not be elaborated here.
[0181] Figure 8 is a block diagram of a training apparatus for a text repetition model shown in an exemplary embodiment of this specification.
[0182] Please refer to Figure 8 , the training apparatus 800 for the text repetition model can be applied to the aforementioned Figure 7 shown electronic device, and includes: a sample acquisition unit 801, a condition generation unit 802, a model input unit 803, and a parameter update unit 804.
[0183] Among them, the sample acquisition unit 801 acquires training text pairs, and the training text pairs include an original training text and a repeated training text;
[0184] The condition generation unit 802 generates a vocabulary control condition and a grammar control condition for the repeated training text;
[0185] The model input unit 803 inputs the original training text, the vocabulary control condition, and the grammar control condition into the text repetition model to be trained, and obtains the repeated prediction text output by the text repetition model;
[0186] The parameter update unit 804 updates the parameters of the text repetition model based on the difference between the repeated prediction text and the repeated training text to train the text repetition model;
[0187] Among them, the text repetition model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints, and output the semantic representation vector of the original training text. The decoder is used to predict the repeated text based on the semantic representation vector and output the repeated prediction text.
[0188] Optionally, the grammar control condition is a repeated example text;
[0189] The conditional generation unit 802:
[0190] Generate a truncated linearized constituent tree (LCT) for the paraphrase training text;
[0191] Search for a paraphrase example text that matches the truncated LCT in the example dictionary as the syntactic control condition for the paraphrase training text; wherein, the example dictionary includes the mapping relationship between the truncated LCT and the paraphrase example text.
[0192] Optionally, the conditional generation unit 802:
[0193] Calculate the syntactic edit distance between the truncated LCT of the paraphrase training text and each truncated LCT in the example dictionary;
[0194] Determine the paraphrase example text corresponding to the truncated LCT with the minimum calculated syntactic edit distance in the example dictionary as the matching paraphrase example text.
[0195] Optionally, the method for generating the example dictionary includes:
[0196] Generate a truncated LCT for the paraphrase training text in each training text pair to obtain the mapping relationship between the truncated LCT and the paraphrase training text;
[0197] For each truncated LCT, in the case where the truncated LCT corresponds to multiple paraphrase training texts, select one of the paraphrase training texts as the paraphrase example text; in the case where the truncated LCT corresponds to one paraphrase training text, determine the paraphrase training text as the paraphrase example text;
[0198] Generate an example dictionary based on the mapping relationship between the truncated LCT and the paraphrase example text.
[0199] Optionally, the conditional generation unit 802:
[0200] Generate an LCT for the paraphrase training text;
[0201] Filter out the part-of-speech of the leaf nodes in the LCT to obtain a truncated LCT.
[0202] Optionally, the conditional generation unit 802:
[0203] Adopt a keyword extraction algorithm to extract keywords from the paraphrase training text as the lexical control condition for the paraphrase training text.
[0204] Optionally, the syntax control condition includes one of the part-of-speech tagging of the repetition training text, LCT, syntax framework template, and repetition example text, and the text repetition model corresponds to the syntax control condition.
[0205] Corresponding to the embodiments of the foregoing text repetition method, this specification also provides embodiments of a text repetition device.
[0206] The embodiments of the text repetition device in this specification can be applied to an electronic device. The device embodiments can be implemented by software, or by hardware, or by a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by the processor of the electronic device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for operation. From a hardware level, the hardware structure of the electronic device where the text repetition device in this specification is located is similar to the hardware structure of the electronic device where the training device of the foregoing text repetition model is located, and may also include hardware such as a processor, a memory, a network interface, and a non-volatile memory, which will not be elaborated here.
[0207] Figure 9 It is a block diagram of a text repetition device shown in an exemplary embodiment of this specification.
[0208] Please refer to Figure 9 , the text repetition device 900 may include: a text acquisition unit 901 and a text repetition unit 902.
[0209] Among them, the text acquisition unit 901 acquires the text to be repeated and the control condition of the text to be repeated;
[0210] The text repetition unit 902 inputs the text to be repeated and the control condition into the trained text repetition model, and obtains the text repetition result output by the text repetition model;
[0211] The text repetition model is trained based on the training method of the foregoing text repetition model.
[0212] Optionally, the control condition includes a vocabulary control condition and a syntax control condition, and the trained text repetition model corresponds to the syntax control condition.
[0213] The implementation processes of the functions and roles of each unit in the above device are specifically described in detail in the implementation processes of the corresponding steps in the above method, and will not be elaborated here.
[0214] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in this specification. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0215] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any several of these devices.
[0216] Corresponding to the embodiments of the training method of the foregoing text paraphrasing model, this specification also provides a training device for a text paraphrasing model, which device includes: a processor and a memory for storing machine-executable instructions. Among them, the processor and the memory are usually interconnected by an internal bus. In other possible implementation manners, the device may further include an external interface to be able to communicate with other devices or components.
[0217] In this embodiment, by reading and executing the machine-executable instructions stored in the memory that correspond to the training logic of the text paraphrasing model, the processor is caused to:
[0218] Obtain training text pairs, where the training text pairs include original training texts and paraphrased training texts;
[0219] Generate a vocabulary control condition and a grammar control condition for the paraphrased training text;
[0220] Input the original training text, the vocabulary control condition, and the grammar control condition into the text paraphrasing model to be trained, and obtain a paraphrased prediction text output by the text paraphrasing model;
[0221] Based on the difference between the paraphrased prediction text and the paraphrased training text, update the parameters of the text paraphrasing model to train the text paraphrasing model;
[0222] Among them, the text repetition model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the lexical control condition and the syntactic control condition as constraints, and output the semantic representation vector of the original training text. The decoder is used to predict the repeated text based on the semantic representation vector and output the repeated prediction text.
[0223] Optionally, the syntactic control condition is a repeated example text;
[0224] Generating the syntactic control condition for the repeated training text includes:
[0225] Generating a truncated linearized constituent tree (LCT) for the repeated training text;
[0226] Searching in the example dictionary for the repeated example text matching the truncated LCT as the syntactic control condition for the repeated training text; where the example dictionary includes the mapping relationship between the truncated LCT and the repeated example text.
[0227] Optionally, searching in the example dictionary for the repeated example text matching the truncated LCT includes:
[0228] Calculating the syntactic edit distance between the truncated LCT of the repeated training text and each truncated LCT in the example dictionary;
[0229] Determining the repeated example text corresponding to the truncated LCT with the minimum syntactic edit distance calculated in the example dictionary as the matching repeated example text.
[0230] Optionally, the method for generating the example dictionary includes:
[0231] Generating a truncated LCT for the repeated training text in each training text pair to obtain the mapping relationship between the truncated LCT and the repeated training text;
[0232] For each truncated LCT, when there are multiple repeated training texts corresponding to the truncated LCT, selecting one of the repeated training texts as the repeated example text; when there is one repeated training text corresponding to the truncated LCT, determining the repeated training text as the repeated example text;
[0233] Generating an example dictionary based on the mapping relationship between the truncated LCT and the repeated example text.
[0234] Optionally, generating the truncated LCT for the repeated training text includes:
[0235] Generating an LCT for the repeated training text;
[0236] Filter out the part-of-speech of leaf nodes in the LCT to obtain a truncated LCT.
[0237] Optionally, generating lexical control conditions for the paraphrasing training text includes:
[0238] Using a keyword extraction algorithm to extract keywords from the paraphrasing training text as the lexical control conditions for the paraphrasing training text.
[0239] Optionally, the syntactic control conditions include one of the part-of-speech tagging of the paraphrasing training text, LCT, syntactic framework template, and paraphrasing example text, and the text paraphrasing model corresponds to the syntactic control conditions.
[0240] Corresponding to the embodiments of the foregoing text paraphrasing method, this specification also provides a text paraphrasing device, which includes: a processor and a memory for storing machine-executable instructions. Among them, the processor and the memory are usually connected to each other through an internal bus. In other possible implementation manners, the device may further include an external interface to be able to communicate with other devices or components.
[0241] In this embodiment, by reading and executing the machine-executable instructions stored in the memory corresponding to the text paraphrasing logic, the processor is caused to:
[0242] Obtain the text to be paraphrased and the control conditions of the text to be paraphrased;
[0243] Input the text to be paraphrased and the control conditions into the trained text paraphrasing model to obtain the text paraphrasing result output by the text paraphrasing model;
[0244] Among them, the text paraphrasing model is trained based on the training method of the foregoing text paraphrasing model.
[0245] Optionally, the control conditions include lexical control conditions and syntactic control conditions, and the trained text paraphrasing model corresponds to the syntactic control conditions.
[0246] Corresponding to the embodiments of the foregoing text paraphrasing model training method, this specification also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented:
[0247] Obtain training text pairs, where the training text pairs include original training texts and paraphrasing training texts;
[0248] Generate lexical control conditions and syntactic control conditions for the paraphrasing training text;
[0249] Input the original training text, the vocabulary control condition, and the grammar control condition into the text paraphrasing model to be trained, and obtain the paraphrasing prediction text output by the text paraphrasing model;
[0250] Update the parameters of the text paraphrasing model based on the difference between the paraphrasing prediction text and the paraphrasing training text to train the text paraphrasing model;
[0251] Among them, the text paraphrasing model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints, and output the semantic representation vector of the original training text. The decoder is used to predict the paraphrasing text based on the semantic representation vector and output the paraphrasing prediction text.
[0252] Optionally, the grammar control condition is a paraphrasing example text;
[0253] Generating the grammar control condition for the paraphrasing training text includes:
[0254] Generate a truncated linearized constituent tree (LCT) for the paraphrasing training text;
[0255] Search for the paraphrasing example text matching the truncated LCT in the example dictionary as the grammar control condition for the paraphrasing training text; where the example dictionary includes the mapping relationship between the truncated LCT and the paraphrasing example text.
[0256] Optionally, searching for the paraphrasing example text matching the truncated LCT in the example dictionary includes:
[0257] Calculate the grammar edit distance between the truncated LCT of the paraphrasing training text and each truncated LCT in the example dictionary;
[0258] Determine the paraphrasing example text corresponding to the truncated LCT with the minimum calculated grammar edit distance in the example dictionary as the matching paraphrasing example text.
[0259] Optionally, the method for generating the example dictionary includes:
[0260] Generate a truncated LCT for the paraphrasing training text in each training text pair to obtain the mapping relationship between the truncated LCT and the paraphrasing training text;
[0261] For each truncated LCT, when the truncated LCT corresponds to multiple paraphrasing training texts, select one of the paraphrasing training texts as the paraphrasing example text; when the truncated LCT corresponds to one paraphrasing training text, determine the paraphrasing training text as the paraphrasing example text;
[0262] Generate an example dictionary based on the mapping relationship between the truncated LCT and the paraphrased example text.
[0263] Optionally, generating a truncated LCT for the paraphrasing training text includes:
[0264] Generate an LCT for the paraphrasing training text;
[0265] Filter out the part-of-speech of the leaf nodes in the LCT to obtain a truncated LCT.
[0266] Optionally, generating a lexical control condition for the paraphrasing training text includes:
[0267] Use a keyword extraction algorithm to extract keywords from the paraphrasing training text as the lexical control condition for the paraphrasing training text.
[0268] Optionally, the syntax control condition includes one of the part-of-speech tagging, LCT, syntax framework template, and paraphrased example text of the paraphrasing training text, and the text paraphrasing model corresponds to the syntax control condition.
[0269] Corresponding to the embodiments of the foregoing text paraphrasing method, this specification also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented:
[0270] Obtain the text to be paraphrased and the control condition of the text to be paraphrased;
[0271] Input the text to be paraphrased and the control condition into the trained text paraphrasing model to obtain the text paraphrasing result output by the text paraphrasing model;
[0272] Wherein, the text paraphrasing model is trained based on the training method of the foregoing text paraphrasing model.
[0273] Optionally, the control condition includes a lexical control condition and a syntax control condition, and the trained text paraphrasing model corresponds to the syntax control condition.
[0274] The specific embodiments of this specification are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0275] The above are only the preferred embodiments of this specification and are not intended to limit this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included within the scope of protection of this specification.
Claims
1. A training method for a text paraphrasing model, comprising: obtaining training text pairs, where the training text pairs include original training texts and paraphrasing training texts; generating a vocabulary control condition and a grammar control condition for the paraphrasing training texts; inputting the original training text, the vocabulary control condition, and the grammar control condition into the text paraphrasing model to be trained, and obtaining a paraphrasing prediction text output by the text paraphrasing model; updating the parameters of the text paraphrasing model based on the difference between the paraphrasing prediction text and the paraphrasing training text to train the text paraphrasing model; wherein, the text paraphrasing model includes a pre-trained language model and a decoder. The pre-trained language model is used to perform semantic encoding on the original training text with the vocabulary control condition and the grammar control condition as constraints, and output a semantic representation vector of the original training text. The decoder is used to predict a paraphrasing text based on the semantic representation vector and output a paraphrasing prediction text; The generating a vocabulary control condition for the paraphrasing training text includes: extracting keywords from the paraphrasing training text using a keyword extraction algorithm as the vocabulary control condition for the paraphrasing training text; The grammar control condition includes one of the part-of-speech tagging of the paraphrasing training text, LCT, grammar framework template, and paraphrasing example text, and the text paraphrasing model corresponds to the grammar control condition; In the case where the grammar control condition is a paraphrasing example text, the generating a grammar control condition for the paraphrasing training text includes: generating a truncated linearized constituent tree (LCT) for the paraphrasing training text; searching in a paradigm dictionary for a paraphrasing example text that matches the truncated LCT as the grammar control condition for the paraphrasing training text; wherein, the paradigm dictionary includes a mapping relationship between the truncated LCT and the paraphrasing example text.
2. The method according to claim 1, the searching in a paradigm dictionary for a paraphrasing example text that matches the truncated LCT, comprising: calculating the grammatical edit distance between the truncated LCT of the paraphrasing training text and each truncated LCT in the paradigm dictionary; determining the paraphrasing example text corresponding to the truncated LCT with the minimum grammatical edit distance calculated in the paradigm dictionary as the matching paraphrasing example text.
3. The method according to claim 1, the generating method of the paradigm dictionary, comprising: generating a truncated LCT for the paraphrasing training text in each training text pair to obtain a mapping relationship between the truncated LCT and the paraphrasing training text; for each truncated LCT, in the case where the truncated LCT corresponds to multiple paraphrasing training texts, selecting one of the paraphrasing training texts as the paraphrasing example text; in the case where the truncated LCT corresponds to one paraphrasing training text, determining the paraphrasing training text as the paraphrasing example text; generating a paradigm dictionary based on the mapping relationship between the truncated LCT and the paraphrasing example text.
4. The method according to claim 1, the generating a truncated LCT for the paraphrasing training text, comprising: generating an LCT for the paraphrasing training text; Filter out the part-of-speech of leaf nodes in the LCT to obtain a truncated LCT.
5. A text paraphrasing method, comprising: obtaining a text to be paraphrased and control conditions for the text to be paraphrased; inputting the text to be paraphrased and the control conditions into a trained text paraphrasing model to obtain a text paraphrasing result output by the text paraphrasing model; wherein, the text paraphrasing model is trained based on the method described in any one of claims 1-4.
6. The method according to claim 5, wherein the control conditions include a vocabulary control condition and a grammar control condition, and the trained text paraphrasing model corresponds to the grammar control condition.
7. A training device for a text paraphrasing model, comprising: a sample acquisition unit that acquires a training text pair, where the training text pair includes an original training text and a paraphrasing training text; a condition generation unit that generates a vocabulary control condition and a grammar control condition for the paraphrasing training text; a model input unit that inputs the original training text, the vocabulary control condition, and the grammar control condition into a text paraphrasing model to be trained to obtain a paraphrasing prediction text output by the text paraphrasing model; a parameter update unit that updates the parameters of the text paraphrasing model based on the difference between the paraphrasing prediction text and the paraphrasing training text to train the text paraphrasing model; wherein, the text paraphrasing model includes a pre-trained language model and a decoder, the pre-trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints and output a semantic representation vector of the original training text, and the decoder is used to predict a paraphrasing text based on the semantic representation vector and output a paraphrasing prediction text; the condition generation unit uses a keyword extraction algorithm to extract keywords from the paraphrasing training text as the vocabulary control condition for the paraphrasing training text; the grammar control condition includes one of the part-of-speech tagging, LCT, grammar framework template, and paraphrasing example text of the paraphrasing training text, and the text paraphrasing model corresponds to the grammar control condition; when the grammar control condition is a paraphrasing example text, the condition generation unit: generates a truncated linearized constituent tree LCT for the paraphrasing training text; looks up in a sample dictionary a paraphrasing example text that matches the truncated LCT as the grammar control condition for the paraphrasing training text; wherein, the sample dictionary includes a mapping relationship between the truncated LCT and the paraphrasing example text.
8. A text paraphrasing device, comprising: a text acquisition unit that acquires a text to be paraphrased and control conditions for the text to be paraphrased; a text paraphrasing unit that inputs the text to be paraphrased and the control conditions into a trained text paraphrasing model to obtain a text paraphrasing result output by the text paraphrasing model; wherein, the text paraphrasing model is trained based on the method described in any one of claims 1-4.
9. A training device for a text paraphrasing model, comprising: a processor; a memory for storing machine-executable instructions; Wherein, by reading and executing machine-executable instructions stored in the memory corresponding to the training logic of the text paraphrasing model, the processor is caused to: Obtain training text pairs, where the training text pairs include original training texts and paraphrased training texts; Generate a vocabulary control condition and a grammar control condition for the paraphrased training text; Input the original training text, the vocabulary control condition, and the grammar control condition into the text paraphrasing model to be trained, and obtain a paraphrased prediction text output by the text paraphrasing model; Based on the difference between the paraphrased prediction text and the paraphrased training text, update the parameters of the text paraphrasing model to train the text paraphrasing model; Wherein, the text paraphrasing model includes a pre-trained language model and a decoder. The pre-trained language model is used to semantically encode the original training text with the vocabulary control condition and the grammar control condition as constraints, and output a semantic representation vector of the original training text. The decoder is used to predict a paraphrased text based on the semantic representation vector and output a paraphrased prediction text; The generating a vocabulary control condition for the paraphrased training text includes: Using a keyword extraction algorithm to extract keywords from the paraphrased training text as the vocabulary control condition for the paraphrased training text; The grammar control condition includes one of part-of-speech tagging of the paraphrased training text, LCT, a grammar framework template, and a paraphrased example text, and the text paraphrasing model corresponds to the grammar control condition; When the grammar control condition is a paraphrased example text, the generating a grammar control condition for the paraphrased training text includes: Generating a truncated linearized constituent tree (LCT) for the paraphrased training text; Searching in an example dictionary for a paraphrased example text matching the truncated LCT as the grammar control condition for the paraphrased training text; wherein, the example dictionary includes a mapping relationship between the truncated LCT and the paraphrased example text.
10. A text paraphrasing device comprising: A processor; A memory for storing machine-executable instructions; Wherein, by reading and executing machine-executable instructions stored in the memory corresponding to the text paraphrasing logic, the processor is caused to: Obtain a text to be paraphrased and a control condition for the text to be paraphrased; Input the text to be paraphrased and the control condition into a trained text paraphrasing model, and obtain a text paraphrasing result output by the text paraphrasing model; Wherein, the text paraphrasing model is trained based on the method according to any one of claims 1-4.
Citation Information
Patent Citations
Language model pre-training method combined with class word information
CN110489555A
Method for training statement retelling model, statement retelling method and statement retelling device.
CN112784003A