A translation-based synonymous rewriting method for professional vertical field texts
By determining the proper noun in vertical domain text synonyms and using the English-turn-Chinese model, the problems of limited rewriting range and proper noun maintenance are solved, and high-quality rewriting results and diversity are achieved, suitable for different scenarios and fields.
Patent Information
- Application Number
- CN202011449188.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-09
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2040-12-09
AI Technical Summary
In the synonymous rewriting of vertical fields, the rewriting range is limited, and the proper noun cannot be kept unchanged, and different rewriting ranges and diversity cannot be provided according to the needs of the scene.
Using a professional translation-based synonymous rewriting method for text in vertical fields, by determining the vertical fields, translating Chinese into English using the English-translation model, and circumventing specific vocabulary during the generation process, ensuring that the proper noun is not rewritten, providing Different rewrite ranges and diversity.
It improves the quality of text rewriting, meets the rewriting range of different scenarios, provides randomness and diversity, and can quickly migrate to different vertical fields.
Smart Images

Figure CN112560509B_ABST
Abstract
Description
Technical Field
[0001] The present invention specifically relates to a translation-based synonymous rewriting method for professional vertical field texts. Background Art
[0002] There are currently two main solutions to the problem of rewriting Chinese text in vertical fields:
[0003] 1. Segment the text to be rewritten, and replace it with synonyms or near-synonyms based on the segmentation to achieve the purpose of synonym rewriting.
[0004] 2. Use general translation software to first translate the text that needs to be rewritten into the medium language, and then translate the medium language back into Chinese text to achieve the purpose of synonymous rewriting.
[0005] In the prior art, the text synonym rewriting method has the following disadvantages:
[0006] (1) The rewriting method based on synonym replacement has a limited scope for rewriting texts and basically cannot change the sentence structure.
[0007] (2) For proper nouns that appear in vertical fields, they should generally not be changed when rewriting text. However, in existing translation-based text rewriting methods, proper nouns are often translated incorrectly, resulting in poor rewriting results.
[0008] (3) Existing translation-based text rewriting methods are unable to provide results with different rewriting ranges according to different scenario requirements.
[0009] (4) For the same sentence, existing translation-based text rewriting methods cannot provide multiple rewriting results with randomness. Summary of the invention
[0010] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a translation-based professional vertical field text synonym rewriting method.
[0011] In order to achieve the above object, the present invention provides the following technical solutions:
[0012] The translation-based synonymous rewriting method for professional vertical field texts includes the following steps:
[0013] (1) Input the text to be rewritten;
[0014] (2) Identify the specific nouns in the vertical field and choose avoidable words;
[0015] (3) translating the Chinese version of the text to be rewritten into English and adding the proper nouns in step (2);
[0016] (4) Translate English into Chinese so that no avoided words appear in the translation results;
[0017] (5) Output the rewriting result.
[0018] Furthermore, in step (2), a proper word list corresponding to the vertical field is used to find the proper nouns in the text, thereby determining the proper nouns in the vertical field.
[0019] Furthermore, step (4) is specifically as follows: using an English-to-Chinese model to translate English into Chinese, and avoiding words in the generated rewritten text to complete the rewriting of the text.
[0020] Furthermore, the construction of the English-Chinese translation model includes data set establishment and model training, and the data set establishment and model training include the following steps:
[0021] (1.1) Collect common Chinese-English parallel corpora, as well as Chinese monolingual data in vertical fields;
[0022] (1.2) Collect the proper nouns in the vertical field and build a vocabulary of proper nouns for the field;
[0023] (1.3) Use TensorFlow or PyTorch framework to build network architecture and model training and testing code;
[0024] (1.4) Using the common Chinese-English parallel corpus in step (1.1), train a common Chinese-English translation model and a common English-Chinese translation model respectively;
[0025] (1.5) Use the general Chinese-English translation model trained in step (1.4) to translate the Chinese monolingual data in the vertical field in step (1.1) into English, and use the proper noun vocabulary in step (1.2) to extract the proper nouns in each Chinese corpus and add them to the generated corresponding English corpus to construct a Chinese-English pseudo-parallel corpus in the vertical field;
[0026] (1.6) Using the vertical Chinese-English pseudo-parallel corpus in step (1.5) and the general Chinese-English parallel corpus in step (1.1), continue training on the basis of the general English-to-Chinese model trained in step (1.4) to obtain the final English-to-Chinese model.
[0027] Furthermore, in step (4), the generation probability of the avoidance words in the model decoding process of the English translation is set to 0, so that the avoidance words do not appear in the translation result.
[0028] Furthermore, in step (2), the rule for selecting avoidance words is: only words of certain parts of speech are selected, and proper nouns are not selected. For the text to be rewritten, the LTP tool is first used to perform word segmentation and part of speech judgment, and some avoidance words that meet the part of speech requirements (such as adjectives) are selected. Then, the avoidance words are compared with the proper nouns in the text. If the avoidance words contain any character of the proper noun, the word will be removed from the avoidance word list of this rewriting and cannot be used as an avoidance word.
[0029] Furthermore, in step (4), during the model training process, for a single training sample (i.e., a Chinese-English parallel corpus), assuming that the input text is X, with a length of m, and the output text is Y, with a length of n, the probability of the sample in the model can be expressed as:
[0030]
[0031] Among them, P θ (Y|X) represents the probability of the sample in the model, θ represents the parameters of the model; x represents the specific word in the text X, y represents the specific word in the text Y, x t represents the tth word in the text X, y t Represents the tth word in the text Y.
[0032] Assuming there are N training samples in the training set, the objective function optimized during training is:
[0033]
[0034] Here, θ represents the parameters of the model, i represents the i-th training sample in the training set, and the training goal is to find a suitable θ so that the objective function L(θ) above reaches its minimum value.
[0035] The formula for updating model parameters is:
[0036]
[0037] in, is the gradient operator, t' represents the t'th update of the parameters, θ t' represents the model parameters after t' updates, θ t'+1 represents the model parameters after t'+1 updates, and α represents the learning rate, which is used to control the amplitude of each parameter update.
[0038] In some preferred embodiments, a threshold ε is set in advance. After the parameters are updated, if the change amplitude of the objective function L(θ) (for example, defined as the absolute value of the difference between the objective function before and after the parameter update) is less than the threshold, it is considered that a model that meets the requirements has been obtained.
[0039] In some other preferred embodiments, the number of parameter updates M is predefined. When the number of parameter updates reaches the set value M, the parameter updates are stopped, and it is considered that a model that meets the requirements has been obtained.
[0040] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor can implement the steps in the synonymous rewriting method as described above when executing the computer program.
[0041] A computer-readable storage medium stores a computer program, which can implement the steps in the synonymous rewriting method described above when executed by a processor.
[0042] The beneficial effects of the present invention are:
[0043] (1) The rewriting method of the present invention is based on deep learning and provides proper noun information in vertical fields at the input end, thereby optimizing the ability to retain proper nouns during the text rewriting process, thereby improving the quality of the relevant text rewriting results in the vertical field.
[0044] (2) When generating text, the present invention adopts a specific decoding strategy, so that the present invention can provide results with different rewriting ranges, meet the rewriting range requirements in different scenarios, and improve flexibility. At the same time, the decoding strategy adopted by the present invention can also provide a variety of rewriting results with randomness, with stronger diversity.
[0045] (3) The process adopted by the present invention can be easily and quickly migrated to different vertical fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of the synonymous rewriting method of the present invention.
[0047] Figure 2 It is a schematic diagram of a computer device. DETAILED DESCRIPTION
[0048] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings. It should be pointed out that the specific implementation methods are only detailed descriptions of the present invention and should not be regarded as limitations of the present invention.
[0049] Example 1
[0050] like Figure 1 As shown, the translation-based synonymous rewriting method for professional vertical field text includes the following steps:
[0051] (1) Input the text to be rewritten;
[0052] In this embodiment, the selected vertical field is the automobile field, and the input automobile field text is: In terms of appearance, the Beijing BJ 40PLUS City Hunter Edition will not have obvious changes.
[0053] (2) Identify the specific nouns in the vertical field and choose avoidable words;
[0054] In the text of step (1), find the proper noun: Beijing BJ 40, PLUS; here, the avoidance words refer to: Chinese words that do not appear in the translation result, that is, words to be rewritten; in this embodiment, the avoidance words selected are "obvious" and "change".
[0055] In some preferred methods, appropriate avoidance words are selected from the Chinese text that needs to be rewritten according to the needs of the usage scenario, and a proper noun vocabulary is used to ensure that the proper noun is not in the avoidance word list (the avoidance word list includes at least one avoidance word). The more avoidance words selected, the greater the extent of the rewriting. For the same input text that needs to be rewritten, different avoidance words can be (randomly) selected. Selecting different avoidance words can control the final extent of the rewriting and provide randomness and diversity of the rewriting.
[0056] The rules for selecting avoidance words are determined by specific scenario requirements. For example, if numbers are required to be very precise, when specifying the rules for selecting avoidance words, it is necessary to ensure that the avoidance words do not contain numbers, that is, the numbers will not be rewritten.
[0057] (3) translating the Chinese version of the text to be rewritten into English and adding the proper nouns found in step (2);
[0058] Translate the Chinese in the text to be rewritten into English: In terms of appearance, Beijing BJ40plus urban Hunter version will not be significantly changed. Add the automobile proper noun information after the English as follows (after word segmentation, it is easy to input into the model):
[0059] In terms of appearance, Beijing BJ 40 plus urban Hunter version will not be significantly changed. <sep>PLUS <sep>Beijing BJ 40;
[0060] (4) Translate English into Chinese so that no avoidance words appear in the translation result; in this embodiment, the avoidance words selected are "obvious" and "change", and these two words will not appear in the translation result, so significantly changed is translated as "significant change" instead of "obvious change".
[0061] Translating English into Chinese means rewriting the result as follows:
[0062] In terms of appearance, the Beijing BJ 40PLUS City Hunter Edition will not have significant changes.
[0063] (5) Output the rewriting result.
[0064] In some preferred embodiments, in step (2), a proper noun vocabulary corresponding to a vertical field is used to find proper nouns present in the text.
[0065] In some preferred embodiments, in step (3), Chinese is translated into English using a Chinese-to-English translation model.
[0066] In some preferred embodiments, in step (4), an English-to-Chinese translation model is used to translate English into Chinese.
[0067] In some preferred embodiments, data set establishment and model training include the following steps:
[0068] (1.1) Collect common Chinese-English parallel corpora and Chinese monolingual data in vertical fields. The present invention is not limited to a specific vertical field, and any vertical field can be selected, such as the automotive field, financial field, sports field, entertainment field, etc. The text rewriting method of the present invention has been successfully applied in the automotive field, entertainment field, etc. In the present invention, "general" refers to "general field", which is opposite to "vertical field".
[0069] (1.2) Collect the proper nouns in the vertical field and build a vocabulary of proper nouns for the field.
[0070] Specifically, proper nouns are determined and collected by people familiar with the vertical field. For example, proper nouns in the sports field can be collected by editors who write sports news (editors may have a certain amount of proper noun data, such as the names of teams in major football leagues, etc.). They can also be collected through some automated means, such as crawling some relevant proper nouns from mainstream sports websites, and then manually reviewing and determining them.
[0071] The proper noun vocabulary refers to organizing words into an ordered list. In the present invention, as long as the proper nouns are put together, there is no need to arrange the order or perform other editing. Constructing a proper noun vocabulary is just one implementation method.
[0072] (1.3) Use the TensorFlow framework to build network architecture and model training and testing code;
[0073] The present invention only uses the TensorFlow framework and does not improve the TensorFlow framework itself. The present invention can also be implemented using other frameworks, such as PyTorch.
[0074] (1.4) Use the general Chinese-English parallel corpus in step (1.1) to train a general Chinese-English translation model and a general English-Chinese translation model. In the present invention, "general" refers to "general field", as opposed to "vertical field". Moreover, the "general English-Chinese translation" model here serves to continue to build the model in (1.6).
[0075] During the training process, for a single training sample (i.e. a Chinese-English parallel corpus), let the input text be X, with a length of m, and the output text be Y, with a length of n. The probability of this sample in the model can be expressed as:
[0076] Among them, P θ (Y|X) represents the probability of the sample in the model, θ represents the parameters of the model; x represents the specific word in the text X, y represents the specific word in the text Y, x t represents the tth word in the text X, y t Represents the tth word in the text Y.
[0077] Assuming there are N training samples in the training set, the objective function optimized during training is:
[0078]
[0079] Here, θ represents the parameters of the model, i represents the i-th training sample in the training set, and the training goal is to find a suitable θ so that the objective function L(θ) above reaches its minimum value.
[0080] The formula for updating model parameters is:
[0081]
[0082] in, is the gradient operator, t' represents the t'th update of the parameters, θ t' represents the model parameters after t' updates, θ t'+1 represents the model parameters after t'+1 updates, and α represents the learning rate, which is used to control the amplitude of each parameter update.
[0083] Generally, it is difficult to find the model parameter θ corresponding to the exact minimum value of the objective function, so we only need to find the approximate value of the minimum value of the objective function L(θ).
[0084] In actual operation, a threshold ε can be set in advance. After the parameters are updated, if the change range of the objective function L(θ) (for example, defined as the absolute value of the difference between the objective function before and after the parameter update) is less than the threshold, it is considered that a model that meets the requirements has been obtained. The number of parameter updates M can also be predefined. When the number of parameter updates reaches the set value M, the parameter update is stopped, and it is considered that a model that meets the requirements has been obtained. In this embodiment, the threshold ε can be set to 0.01-0.1, and the set value M can be 400000-600000.
[0085] (1.5) Use the general Chinese-to-English translation model trained in step (1.4) to translate the Chinese monolingual data in the vertical field in step (1.1) into English, and use the proper noun vocabulary in step (1.2) to extract the proper nouns existing in each Chinese corpus in the vertical field in step (1.1), add them to the generated corresponding English corpus, and construct a Chinese-English pseudo-parallel corpus in the vertical field.
[0086] The Chinese-English pseudo-parallel corpus includes
[0087] (1) Chinese monolingual data in vertical fields, examples:
[0088] In terms of appearance, the Beijing BJ 40 PL US City Hunter Edition will not have any obvious changes.
[0089] (2) Translated English corpus and proper nouns in vertical fields, examples (after word segmentation for easy input into the model):
[0090] In terms of appearance, Beijing BJ 40 plus urban Hunter version will not be significantly changed. <sep>PLUS <sep>Beijing BJ 40
[0091] (1.6) Using the vertical Chinese-English pseudo-parallel corpus in step (1.5) and the general Chinese-English parallel corpus in step (1.1), continue training on the basis of the English-Chinese translation model trained in step (1.4) to obtain the final English-Chinese translation model.
[0092] The English-to-Chinese model trained in step (1.4) is a general English-to-Chinese model, which is not optimized for specific vertical fields, so the translation effect for vertical field sentences may not be good. Continuing to train the model here means optimizing the vertical field based on the general English-to-Chinese model (with the help of the vertical field Chinese-English pseudo-parallel corpus built previously), so that the final model can better handle vertical field sentences.
[0093] Here, during the training process, the input to the model is: the English corpus after adding proper nouns, that is, (2) in the Chinese-English pseudo-parallel corpus in step (1.5); the output is: the Chinese monolingual corpus in the vertical field, that is, (1) in the Chinese-English pseudo-parallel corpus in step (1.5).
[0094] The input and output data in step (1.6) are different from those in step (1.4), but the training process of the two is similar, which will not be described here. Through training, an English-Chinese translation model that meets the requirements is finally obtained. Similarly, in this embodiment, the threshold ε can be set to 0.01-0.1, and the set value M can be 400000-600000.
[0095] The present invention adopts a specific decoding strategy:
[0096] In the decoding process of the English-to-Chinese model, the model compares the words to be generated with the words in the original sentence to be rewritten, avoids some words that have appeared in the original sentence, and generates some other synonymous or near-synonymous words and expressions. In this way, the rewriting range of the generated sentence will be improved.
[0097] In the specific implementation, some words in the original sentence (i.e. the avoidance words mentioned above) are selected to reduce the generation probability of these words during the decoding process. For example, if the number requirements are very precise, it is necessary to ensure that the avoidance words do not contain numbers, and the generation probability of the avoidance words can be directly set to 0.
[0098] In some preferred ways, avoid the choice of words:
[0099] The rule for selecting avoidance words: only select words of certain parts of speech, and ensure that proper nouns are not selected. For the text to be rewritten, first use some common tools in the field of natural language processing, such as LTP tools, to perform word segmentation and part of speech judgment, select some avoidance words that meet the part of speech requirements (such as adjectives), and then compare the avoidance words with the proper nouns in the text. If the avoidance words contain any character of the proper noun, the word will be removed from the avoidance word list of this rewriting and cannot be used as an avoidance word.
[0100] Example 2, refer to the attached Figure 2 .
[0101] In this embodiment, a computer device 100 is provided, including a memory 102, a processor 101, and a computer program 103 stored in the memory 102 and executable on the processor 101. When the processor 101 executes the computer program 103, the steps in the synonymous rewriting method provided in the above embodiment 1 can be implemented.
[0102] Example 3
[0103] In this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the synonymous rewriting method provided in the above embodiments can be implemented.
[0104] In this embodiment, the computer program may be the computer program in Embodiment 2.
[0105] In this embodiment, the computer-readable storage medium can be executed by the computer device in Embodiment 2.
[0106] Those skilled in the art will appreciate that all or part of the processes in the above embodiments can be implemented by instructing the relevant hardware through a computer program, which can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0107] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0108] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of protection. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the scope of protection of the present invention.
[0109] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.< / sep> < / sep> < / sep> < / sep>
Claims
1. Synonymous rewriting method for professional vertical field text based on translation, Its characteristics are: The following steps are involved: (1) Input the text to be rewritten; (2) Identify the specific nouns in the vertical field and choose avoidable words; (3) translating the Chinese version of the text to be rewritten into English and adding the proper nouns in step (2); (4) Translate English into Chinese so that no avoidance words appear in the translation result; specifically: use the English-to-Chinese model to translate English into Chinese so that no avoidance words appear in the generated rewritten text, thus completing the rewriting of the text; The construction of the English-Chinese translation model includes data set establishment and model training, which includes the following steps: (1.1) Collect common Chinese-English parallel corpora, as well as Chinese monolingual data in vertical fields; (1.2) Collect the proper nouns in the vertical field and build a vocabulary of proper nouns for the field; (1.3) Use TensorFlow or PyTorch framework to build network architecture and model training and testing code; (1.4) Using the common Chinese-English parallel corpus in step (1.1), train a common Chinese-English translation model and a common English-Chinese translation model respectively; (1.5) Use the general Chinese-English translation model trained in step (1.4) to translate the Chinese monolingual data in the vertical field in step (1.1) into English, and use the proper noun vocabulary in step (1.2) to extract the proper nouns in each Chinese corpus and add them to the generated corresponding English corpus to construct a Chinese-English pseudo-parallel corpus in the vertical field; (1.6) Using the vertical domain Chinese-English pseudo-parallel corpus in step (1.5) and the general Chinese-English parallel corpus in step (1.1), continue training on the basis of the general English-Chinese translation model trained in step (1.4) to obtain the final English-Chinese translation model; (5) Output the rewriting result.
2. According to the translation-based professional vertical field text synonym rewriting method according to claim 1, Its characteristics are: In step (2), the proper nouns in the text are found using the proper word list of the corresponding vertical field, thereby determining the proper nouns in the vertical field.
3. The method for synonymous rewriting of professional vertical field text based on translation according to claim 1, Its characteristics are: In step (4), the generation probability of the avoidance words in the model decoding process of the English translation is set to 0, so that the avoidance words do not appear in the translation result.
4. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When executing the computer program, the processor can implement the steps in the synonymous rewriting method according to any one of claims 1 to 3.
5. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps in the synonymous rewriting method according to any one of claims 1 to 3 can be implemented.
