A text enhancement method and device, and a storage medium

CN116522946BActive Publication Date: 2026-10-23BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210064837.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2026-10-23
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

[0003]现有技术中,是先将原文本翻译成外文,然后再将外文翻译成中文,从而得到与原文本同一情感的新文本,在原文本中的词语较少的情况下,翻译的过程中会存在误差,导致原文本与新文本的情感不同,此时,若直接利用新文本来增强原文本,会使得增强文本中包括与原文本情感不同的杂质文本,降低了增强文本的文本质量

Benefits of technology

[0017]本申请实施例提供了一种文本增强方法及装置、存储介质,文本增强方法包括:获取样本输入文本;并利用样本输入文本和情感匹配模型调整初始文本生成模型,得到目标文本生成模型;目标文本生成模型用于输出与输入文本情感标签相同的文本;在接收到待增强文本的情况下,将待增强文本输入目标文本生成模型,得到与待增强文本的情感标签相同的目标文本,以利用目标文本增强待增强文本,得到增强文本;输入文本包括待增强文本。采用上述方法实现方案,文本增强装置通过利用样本输入文本和情感匹配模型调整初始文本生成模型,得到输出与输入文本情感标签相同目标文本生成模型,以在接收到待增强文本的情况下,直接将待增强文本输入目标文本生成模型,就可以得到与待增强文本的情感标签相同的目标文本,利用目标文本来增强待增强文本,使得增强文本中只包括与待增强文本的情感标签相同的文本,提高了增强文本的文本质量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116522946B_ABST
    Figure CN116522946B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a text enhancement method and device, a storage medium, comprising: obtaining a sample input text; and adjusting an initial text generation model by using the sample input text and an emotion matching model to obtain a target text generation model; the target text generation model is used to output a text with the same emotion label as the input text; in the case of receiving a to-be-enhanced text, inputting the to-be-enhanced text into the target text generation model to obtain a target text with the same emotion label as the to-be-enhanced text, so as to enhance the to-be-enhanced text by using the target text to obtain an enhanced text; the input text comprises the to-be-enhanced text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text enhancement technology, and in particular to a text enhancement method, apparatus, and storage medium. Background Technology

[0002] Current shopping platforms offer open feedback and reviews from existing customers. Most buyers don't write entirely negative reviews, but rather express dissatisfaction with certain aspects. Therefore, the sentiment expressed in these dissatisfaction reviews can help identify problems with the product or service. However, the number of sentiment-annotated reviews is currently limited, necessitating text enhancement to increase the number of such reviews.

[0003] In existing technology, the original text is first translated into a foreign language, and then the foreign language is translated into Chinese to obtain a new text with the same emotion as the original text. When the original text has few words, there will be errors in the translation process, resulting in the original text and the new text having different emotions. In this case, if the new text is used directly to enhance the original text, the enhanced text will include impurities with different emotions from the original text, which will reduce the text quality of the enhanced text. Summary of the Invention

[0004] To address the aforementioned technical problems, embodiments of this application aim to provide a text enhancement method, apparatus, and storage medium that can improve the text quality of enhanced text.

[0005] The technical solution of this application is implemented as follows:

[0006] This application provides a text enhancement method, including:

[0007] Obtain sample input text; and adjust the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model; the target text generation model is used to output text with the same sentiment label as the input text.

[0008] Upon receiving the text to be enhanced, the text to be enhanced is input into the target text generation model to obtain a target text with the same sentiment label as the text to be enhanced, so as to enhance the text to be enhanced using the target text to obtain the enhanced text; the input text includes the text to be enhanced.

[0009] This application provides a text enhancement device, the device comprising:

[0010] The acquisition unit is used to acquire the sample input text;

[0011] An adjustment unit is used to adjust the initial text generation model using the sample input text and the sentiment matching model to obtain a target text generation model; the target text generation model is used to output text with the same sentiment label as the input text.

[0012] An input unit is configured to input the text to be enhanced into the target text generation model upon receiving the text to be enhanced, thereby obtaining target text with the same sentiment label as the text to be enhanced, wherein the input text includes the text to be enhanced;

[0013] An enhancement unit is used to enhance the text to be enhanced using the target text to obtain enhanced text.

[0014] This application provides a text enhancement device, the device comprising:

[0015] The system includes a memory, a processor, and a communication bus. The memory communicates with the processor via the communication bus. The memory stores a text enhancement program executable by the processor. When the text enhancement program is executed, the processor performs the text enhancement method described above.

[0016] This application provides a storage medium storing a computer program applied to a text enhancement device, characterized in that the computer program, when executed by a processor, implements the text enhancement method described above.

[0017] This application provides a text enhancement method, apparatus, and storage medium. The text enhancement method includes: acquiring sample input text; adjusting an initial text generation model using the sample input text and a sentiment matching model to obtain a target text generation model; the target text generation model outputting text with the same sentiment tag as the input text; and, upon receiving text to be enhanced, inputting the text to be enhanced into the target text generation model to obtain target text with the same sentiment tag as the text to be enhanced, thereby enhancing the text to be enhanced using the target text to obtain enhanced text; the input text includes the text to be enhanced. Using the above method, the text enhancement apparatus adjusts the initial text generation model using sample input text and a sentiment matching model to obtain a target text generation model that outputs text with the same sentiment tag as the input text. Upon receiving text to be enhanced, directly inputting the text to be enhanced into the target text generation model yields target text with the same sentiment tag as the text to be enhanced. Using the target text to enhance the text ensures that the enhanced text only includes text with the same sentiment tag as the text to be enhanced, thus improving the text quality of the enhanced text. Attached Figure Description

[0018] Figure 1 A flowchart of a text enhancement method provided in this application embodiment;

[0019] Figure 2 A schematic diagram of an exemplary reward function curve provided for an embodiment of this application;

[0020] Figure 3 A flowchart illustrating an exemplary text enhancement method provided in this application embodiment;

[0021] Figure 4 A schematic diagram of an exemplary reward-based sentiment short text data augmentation model provided for embodiments of this application;

[0022] Figure 5 A schematic diagram of an exemplary short text data augmentation model for purchase reviews based on reward feedback, provided for an embodiment of this application;

[0023] Figure 6 A schematic diagram of the composition structure of a text enhancement device provided in this application embodiment. Figure 1 ;

[0024] Figure 7 A schematic diagram of the composition structure of a text enhancement device provided in this application embodiment. Figure 2 . Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0026] This application provides a text enhancement method. Figure 1 A text enhancement method flow provided in the embodiments of this application Figure 1 ,like Figure 1 As shown, text enhancement methods may include:

[0027] S101. Obtain sample input text; and adjust the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model; the target text generation model is used to output text with the same sentiment label as the input text.

[0028] The text enhancement method provided in this application is applicable to scenarios where a target text generation model is used to enhance the text to be enhanced.

[0029] In the embodiments of this application, the text enhancement device can be implemented in various forms. For example, the text enhancement device described in this application may include devices such as mobile phones, cameras, tablet computers, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and devices such as digital TVs and desktop computers.

[0030] It should be noted that the target text generation model is used to output text with the same sentiment label as the input text.

[0031] In this embodiment, the sample input text can be a purchase review text after purchasing a product; the sample input text can also be marketing text; the sample input text can also be other texts; the specific sample input text can be determined according to the actual situation, and this embodiment does not limit it.

[0032] In this embodiment, the sample input text is text with sentiment tags. Specifically, the sentiment tags include positive sentiment tags and negative sentiment tags. That is, the sample input text can be text with positive sentiment tags; the sample input text can also be text with negative sentiment tags. The specific sentiment tags of the sample input text can be determined according to the actual situation, and this embodiment does not limit this.

[0033] It should be noted that if the sample input text is a purchase review text after purchasing a product, then the positive sentiment label of the sample input text can be the sentiment label that praises the product or the service purchased; the negative sentiment label is the sentiment label that indicates the shortcomings of the product or the service purchased.

[0034] In this embodiment, the sample input text can be text stored in the text library of the text enhancement device; the sample input text can also be text transmitted to the text enhancement device from other devices; the sample input text can also be text obtained by the text enhancement device in other ways; the specific way the text enhancement device obtains the sample input text can be determined according to the actual situation, and this embodiment does not limit it.

[0035] In this embodiment of the application, the process by which the text enhancement device adjusts the initial text generation model using sample input text and a sentiment matching model to obtain the target text generation model includes: the text enhancement device inputs sample input text into the initial text generation model to obtain sample output text and model loss; the text enhancement device uses the sentiment matching model to determine the sentiment matching degree between the sample input text and the sample output text; and the text enhancement device adjusts the initial text generation model based on the sentiment matching degree and the model loss to obtain the target text generation model.

[0036] In this embodiment, the initial text generation model can be a Bidirectional Encoder Representation from Transformers (BERT) model. The initial text generation model can also be other models that can generate output text information based on sample input text information. The specific initial text generation model can be determined according to the actual situation, and this embodiment does not limit it.

[0037] In this embodiment, the process by which the text enhancement device inputs sample input text into an initial text generation model to obtain sample output text can be as follows: the text enhancement device hides sample characters at preset positions in the sample input text to obtain processed sample input text; the text enhancement device inputs the processed sample input text into the initial text generation model and uses the initial text generation model to generate new sample characters corresponding to preset positions; the text enhancement device adds the new sample characters to the preset positions in the processed sample input text to obtain sample output text.

[0038] In this embodiment, the text enhancement device can determine the model loss based on the sample input text and sample output text. Specifically, if the initial text generation model is the BERT model, the model loss is as shown in formula (1):

[0039]

[0040] It should be noted that L Bert (x,θ bert ) represents the model loss; x original Input text for the sample; x mask The text obtained after hiding the sample characters at preset positions in the sample input text is the processed sample input text; t represents the set of new sample characters that are hidden, which can be regarded as selecting from a dictionary with dimension N, transforming it into a multi-classification task, finding the most suitable character to fill in, and generating a new sample output text that is similar to the sample input text.

[0041] In this embodiment of the application, the text enhancement device uses a sentiment matching model to determine the sentiment matching degree of the sample input text and the sample output text. This can be achieved by the text enhancement device inputting the sample input text and the sample output text into the sentiment matching model and then using the sentiment matching model to output the sentiment matching degree.

[0042] It should be noted that this sentiment matching score can be the probability that the sentiment of the input text and the sentiment label of the output text are the same.

[0043] In this embodiment of the application, the sentiment matching model can be an EMM (Emotion Match Model); the sentiment matching degree model can also be other models used to determine the sentiment matching degree between the sample input text and the sample output text; the specific sentiment matching model can be determined according to the actual situation, and this embodiment of the application does not limit it.

[0044] In this embodiment, the process by which the text enhancement device adjusts the initial text generation model based on sentiment matching degree and model loss to obtain the target text generation model includes: the text enhancement device determining the target reward and punishment information corresponding to the sentiment matching degree based on the correspondence between the preset matching degree and the preset reward and punishment information; the text enhancement device adjusting the model loss using the target reward and punishment information to obtain the adjusted model loss; and the text enhancement device using the initial text generation model as the target text generation model when the adjusted model loss meets the preset loss.

[0045] In this embodiment, the correspondence between the preset matching degree and the preset reward and punishment information can be the correspondence configured in the text enhancement device; the correspondence between the preset matching degree and the preset reward and punishment information can also be the correspondence transmitted from other devices to the text enhancement device; the specific way the text enhancement device obtains the correspondence between the preset matching degree and the preset reward and punishment information can be determined according to the actual situation, and this embodiment does not limit it.

[0046] In the embodiment of this application, the correspondence between the preset matching degree and the preset reward and punishment information is shown in formula (2):

[0047]

[0048] It should be noted that p is the preset matching degree, that is, the probability that the sample input text and the sample output text have the same sentiment; R(p) is the preset reward and punishment information; α is the reward parameter, which represents the degree of reward or punishment corresponding to the preset reward and punishment information. For example, the reward parameter can take values ​​in the range of [1, 1.5].

[0049] For example, the correspondence between preset matching degree and preset reward and punishment information is as follows: Figure 2As shown: when the preset matching degree is [0, 0.5], the preset reward / penalty information takes the value of [-1, 0]; when the preset matching degree is [0.5, 1], the preset reward / penalty information takes the value of [0, 1]. When the sentiment labels of the input and output texts are the same, the closer the corresponding preset matching degree value is to 1, the more positive feedback is generated, resulting in a reward; conversely, when the sentiments of the input and output texts are different, the closer the corresponding preset matching degree value is to 0, the more negative feedback is generated, resulting in a penalty; and so on. When the preset matching degree is 0.5, it can be directly discarded, the adjusted model loss is 0, meaning the current prediction result will not be backpropagated, and the model will not be trained. This effectively avoids the situation where the sentiment of the output text is inconsistent with the sentiment of the input text during the initial text generation model training process.

[0050] In this embodiment of the application, the text enhancement device adjusts the model loss using target reward and punishment information to obtain the adjusted model loss, as shown in formulas (3)-(8):

[0051] It should be noted that each action of the initial text generation model can obtain corresponding target reward and punishment information, and the overall process of obtaining the sample output text is as shown in formula (3):

[0052] z = {τ1, a1, τ2, a2, ..., τ} n ,a n} (3)

[0053] Where z represents the entire training process, a n τ represents the training behavior at the nth prediction position. n This represents the state at the nth training position. Therefore, the determination of the entire target reward and punishment information is shown in formulas (4) and (5):

[0054]

[0055]

[0056] Where r i γ represents the target reward / penalty information at position i. i R(z) represents whether there is target reward / penalty information at position i, and R(z) represents the target reward / penalty information for the entire text generation process z.

[0057] In this embodiment, the newly constructed loss function is shown in formula (6):

[0058]

[0059] Among them, Loss r This represents the loss function that includes reward and punishment feedback, i.e., the adjusted model loss. B θ For text generation models, Y i X represents the i-th sample output text in the sample output text, and X represents the sample input text.

[0060] It should be noted that, considering that sentiment judgment is performed on the entire short text (sample input text), it is inaccurate to consider the influence of individual characters on the sentiment of the sample output text, which may lead to misjudgment of the sentence. Therefore, when considering reward and punishment information, the judgment is no longer based on a single predicted new character, but on the entire sample output text, because the target reward and punishment information also considers the sentiment of the sample output text. Therefore, formula (5) can be rewritten as formula (7).

[0061]

[0062] Among them, R all (z) represents the overall target reward and punishment information of the sample output text prediction process z.

[0063] The loss function (6) which includes feedback of target reward and punishment information can be adjusted to formula (8).

[0064]

[0065] Formula (8) can be understood as follows: if the target reward and punishment information is larger, the parameters will be adjusted more significantly. If the feedback of the target reward and punishment information is positive, multiple positive adjustments will be made. If the feedback of the target reward and punishment information is negative, multiple negative adjustments will be made. In this way, the initial text generation model will be trained in the same direction as the sentiment of the output text of the output sample and the sentiment label of the input text of the sample.

[0066] In the embodiments of this application, the adjusted model loss satisfies the preset loss in the following situations: the adjusted model loss value is less than the preset loss value; or the adjusted model loss value is less than or equal to the preset loss value.

[0067] In this embodiment, the preset loss can be information configured in the text enhancement device; the preset loss can also be information transmitted to the text enhancement device from other devices; the preset loss can also be information obtained by the text enhancement device in other ways; the specific way in which the text enhancement device obtains the preset loss can be determined according to the actual situation, and this embodiment does not limit it.

[0068] In this embodiment, the text enhancement device adjusts the model loss using target reward and punishment information. After obtaining the adjusted model loss, if the text enhancement device determines that the adjusted model loss does not meet the preset loss, the text enhancement device continues to adjust the initial text generation model using sample input text and sentiment matching model until the adjusted model correction information corresponding to the obtained adjusted text generation model meets the preset correction value. Then, the adjusted text generation model is used as the target text generation model.

[0069] In the embodiments of this application, the situation where the adjusted model loss does not meet the preset loss includes: the loss value of the adjusted model loss is greater than the loss value of the preset loss.

[0070] In this embodiment, the text enhancement device adjusts the initial text generation model using sample input text and sentiment matching model. Before obtaining the target text generation model, the text enhancement device also obtains a preset input text, a preset output text, and a preset sentiment matching degree between the preset input text and the preset output text. The text enhancement device trains the initial sentiment matching model based on the preset input text, the preset output text, and the preset sentiment matching degree to obtain the sentiment matching model.

[0071] In this embodiment, the preset input text, preset output text, and preset sentiment matching degree can be information configured in the text enhancement device; the preset input text, preset output text, and preset sentiment matching degree can also be information transmitted to the text enhancement device; the specific way the text enhancement device obtains the preset input text, preset output text, and preset sentiment matching degree can be determined according to the actual situation, and this embodiment does not limit this.

[0072] In this embodiment, the process by which the text enhancement device trains an initial sentiment matching model based on a preset input text, a preset output text, and a preset sentiment matching degree to obtain a sentiment matching model can be as follows: The text enhancement device inputs the preset input text and the preset output text into the initial sentiment matching model to obtain an output sentiment matching degree; the text enhancement device determines the sentiment matching model loss of the initial sentiment matching model based on the output sentiment matching degree and the preset sentiment matching degree; if the loss value of the sentiment matching model loss is less than or equal to the preset sentiment matching model loss value, the text enhancement device determines the initial sentiment matching model as a sentiment matching model; if the loss value of the sentiment matching model loss is greater than the preset sentiment matching model loss value, the text enhancement device continues to train the initial sentiment matching model using the preset input text, the preset output text, and the preset sentiment matching degree to obtain a trained sentiment matching model; if the text enhancement device determines that the loss value of the trained model corresponding to the trained model is less than or equal to the preset sentiment matching model loss value, the text enhancement device uses the trained model as the sentiment matching model.

[0073] It should be noted that the preset sentiment matching model loss value can be the loss configured in the text enhancement device; the preset sentiment matching model loss value can also be the information received by the text enhancement device; the specific way the text enhancement device obtains the preset sentiment matching model loss value can be determined according to the actual situation, and this application embodiment does not limit it.

[0074] In this embodiment of the application, the process by which the text enhancement device determines the sentiment matching model loss of the initial sentiment matching model based on the output sentiment matching degree and the preset sentiment matching degree is as shown in formula (9):

[0075]

[0076] It should be noted that L EMM (y o ,y p |θ EMM ) represents the loss of the sentiment matching model, y o For the preset input text x original In the text vector generated by the initial sentiment matching model, y p θ is the text vector generated by the initial sentiment matching model for the preset output text. EMM This represents network parameters. Indicates y o The set of texts belonging to the sentiment category. Formula (9) represents maximizing the probability of positive samples while minimizing the probability of negative samples.

[0077] S102. Upon receiving the text to be enhanced, input the text to be enhanced into the target text generation model to obtain the target text with the same sentiment label as the text to be enhanced, so as to enhance the text to be enhanced using the target text and obtain the enhanced text; the input text includes the text to be enhanced.

[0078] In this embodiment, the text enhancement device adjusts the initial text generation model using sample input text and sentiment matching model to obtain the target text generation model. Then, when the text to be enhanced is received, the text enhancement device can input the text to be enhanced into the target text generation model to obtain the target text with the same sentiment label as the text to be enhanced. The target text is then used to enhance the text to be enhanced, thus obtaining the enhanced text.

[0079] In this embodiment, the process by which the text enhancement device enhances the text to be enhanced using the target text to obtain the enhanced text can be as follows: the text enhancement device adds the target text to the text to be enhanced to obtain the enhanced text; the process by which the text enhancement device enhances the text to be enhanced using the target text to obtain the enhanced text can also be as follows: the text enhancement device uses both the target text and the text to be enhanced as the enhanced text; the text enhancement device can also enhance the text to be enhanced using the target text in other ways to obtain the enhanced text; specifically, the method by which the text enhancement device enhances the text to be enhanced using the target text to obtain the enhanced text can be determined according to the actual situation, and this embodiment does not limit this.

[0080] It should be noted that the text to be enhanced is a portion of the input text.

[0081] In this embodiment of the application, the process by which the text enhancement device inputs the text to be enhanced into the target text generation model to obtain the target text with the same sentiment tag as the text to be enhanced includes: the text enhancement device hiding characters at preset positions in the text to be enhanced to obtain the processed text to be enhanced; the text enhancement device using the target text generation model to generate new characters corresponding to the preset positions based on the processed text to be enhanced; and the text enhancement device adding the new characters at the preset positions in the processed text to be enhanced to obtain the target text.

[0082] In this embodiment, the preset position can be the starting character position of the text to be enhanced; the preset position can also be the ending character position of the text to be enhanced; the preset position can also be the middle character position of the text to be enhanced; the specific preset position can be determined according to the actual situation, and this embodiment does not limit it.

[0083] In this embodiment, the character length at the preset position can be 20% of the character length of the text to be enhanced; the character length at the preset position can also be 5% of the character length of the text to be enhanced; the specific character length at the preset position can be determined according to the actual situation, and this embodiment does not limit it.

[0084] In this application embodiment, an exemplary text enhancement method flowchart is shown below. Figure 3 As shown:

[0085] S31. The text enhancement device acquires sample input text and inputs the sample input text into the initial text generation model to obtain sample output text and model loss.

[0086] In this embodiment, the process by which the text enhancement device inputs the sample input text into the initial text generation model to obtain the sample output text and the model loss can be described as follows: the text enhancement device first converts the sample input text into character vectors, and then the text enhancement device inputs the character vectors into the initial text generation model to obtain the sample output text and the model loss.

[0087] S32. The text enhancement device uses a sentiment matching model to determine the sentiment matching degree between the sample input text and the sample output text.

[0088] S33. The text enhancement device determines the target reward and punishment information corresponding to the emotional matching degree based on the correspondence between the preset matching degree and the preset reward and punishment information.

[0089] S34. The text enhancement device uses the target reward and punishment information to adjust the model loss, and obtains the adjusted model loss.

[0090] S35. When the adjusted model loss meets the preset loss, the text enhancement device uses the initial text generation model as the target text generation model.

[0091] It should be noted that the target text generation model is used to output text with the same sentiment label as the input text.

[0092] S36. If the adjusted model loss does not meet the preset loss, the text enhancement device continues to adjust the initial text generation model using the sample input text and the sentiment matching model until the adjusted model correction information corresponding to the obtained adjusted text generation model meets the preset correction value, and then the adjusted text generation model is used as the target text generation model.

[0093] For example, such as Figure 4As shown: The text enhancement device acquires sample input text (this headset has no noise). The text enhancement device hides the characters at preset positions in the sample input text, resulting in processed sample input text ([CLS]this headset has no [MASK][SEP]). The text enhancement device converts the processed sample input text into character vectors (E[CLS]E[this]E[headset]E[no]E[MASK]E[SEP]). The text enhancement device inputs the character vectors into the initial text generation model (BERT). The initial text generation model generates new sample characters corresponding to preset positions (including vibration, music, and sound, and selects the target new sample character with the highest probability value from multiple sample characters: sound). Based on the new sample character and the processed sample... The input text yields sample output text ([CLS] This headphone has no sound [SEP]). The text enhancement device inputs the sample output text and sample input text into the sentiment matching model (EMM), and uses the sentiment matching model to determine the sentiment matching degree (P) between the sample input text and sample output text. The text enhancement device uses the correspondence between the preset matching degree and preset reward / penalty information (Reward function) to determine the target reward / penalty information corresponding to the sentiment matching degree. The text enhancement device uses the target reward / penalty information to adjust the model loss (Loss) when the initial text generation model outputs the sample output text, obtaining the adjusted model loss (reconstructed Loss). If the adjusted model loss meets the preset loss, the initial text generation model is used as the target text generation model. If the adjusted model loss does not meet the preset loss, the initial text generation model is further adjusted using the sample input text and the sentiment matching model until the adjusted model correction information corresponding to the obtained adjusted text generation model meets the preset correction value, at which point the adjusted text generation model is used as the target text generation model.

[0094] For example, such as Figure 5As shown: The text enhancement device acquires sample input text (no sound from headphones), hides characters at preset positions in the sample input text, and obtains processed sample input text (sound from headphones [mask]); the text enhancement device inputs the processed sample input text into the initial text generation model (BERT), and obtains sample output text (sound from headphones with a different sentiment label than the sample input text, or no sound from headphones with the same sentiment label as the sample input text); the text enhancement device inputs the sample output text and the sample input text into the sentiment matching model (EMM), and uses the sentiment matching model to determine the sentiment matching degree between the sample input text and the sample output text; the text enhancement device uses the correspondence between the preset matching degree and preset reward and punishment information to determine the target reward and punishment information corresponding to the sentiment matching degree; the text enhancement device uses the target reward and punishment information to adjust the model loss when the initial text generation model outputs the sample output text, and obtains the adjusted model loss; if the adjusted model loss meets the preset loss, the initial text generation model is used as the target text generation model. If the adjusted model loss does not meet the preset loss, the initial text generation model is further adjusted using the sample input text and the sentiment matching model until the adjusted model correction information corresponding to the obtained adjusted text generation model meets the preset correction value. Then, the adjusted text generation model is used as the target text generation model. When the text enhancement device obtains the target text generation model and receives the text to be enhanced (headphones have no sound), the text enhancement device hides the characters at preset positions in the text to be enhanced, obtaining the processed text to be enhanced (headphones [mask] sound). The text enhancement device inputs the processed text to be enhanced into the target text generation model (Bert), obtaining the target text with the same sentiment label as the text to be enhanced (headphones have no sound). The text enhancement device adds the target text to the database containing the text to be enhanced, ensuring that all data in the database has the same sentiment label as the text to be enhanced (headphones with negative sentiment labels have no sound and headphones with negative sentiment labels have no sound), thus using the target text to enhance the text to obtain the enhanced text.

[0095] Understandably, the text enhancement device adjusts the initial text generation model by using sample input text and a sentiment matching model to obtain a target text generation model whose output has the same sentiment label as the input text. When the text to be enhanced is received, it can be directly input into the target text generation model to obtain target text with the same sentiment label as the text to be enhanced. The target text is then used to enhance the text to be enhanced, so that the enhanced text only includes text with the same sentiment label as the text to be enhanced, thus improving the text quality of the enhanced text.

[0096] Based on the same inventive concept as the text enhancement method, this application provides a text enhancement device 1, which corresponds to a text enhancement method; Figure 6 A schematic diagram of the composition structure of a text enhancement device provided in this application embodiment. Figure 1 The text enhancement device 1 may include:

[0097] Acquisition unit 11 is used to acquire sample input text;

[0098] Adjustment unit 12 is used to adjust the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model; the target text generation model is used to output text with the same sentiment label as the input text.

[0099] Input unit 13 is used to input the text to be enhanced into the target text generation model when the text to be enhanced is received, so as to obtain target text with the same sentiment label as the text to be enhanced, wherein the input text includes the text to be enhanced;

[0100] The enhancement unit 14 is used to enhance the text to be enhanced using the target text to obtain enhanced text.

[0101] In some embodiments of this application, the apparatus further includes a determining unit;

[0102] The input unit 13 is used to input the sample input text into the initial text generation model to obtain the sample output text and the model loss;

[0103] The determining unit is used to determine the sentiment matching degree between the sample input text and the sample output text using the sentiment matching model;

[0104] The adjustment unit 12 is used to adjust the initial text generation model according to the sentiment matching degree and the model loss to obtain the target text generation model.

[0105] In some embodiments of this application, the determining unit is used to determine the target reward or punishment information corresponding to the emotional matching degree based on the correspondence between the preset emotional matching degree and the preset reward or punishment information;

[0106] The adjustment unit 12 is used to adjust the model loss using the target reward and punishment information to obtain the adjusted model loss; if the adjusted model loss meets the preset loss, the initial text generation model is used as the target text generation model.

[0107] In some embodiments of this application, the adjustment unit 12 is used to continue adjusting the initial text generation model using the sample input text and the sentiment matching model when the adjusted model loss does not meet the preset loss, until the adjusted text generation model corresponding to the obtained adjusted text generation model meets the preset correction value, and then the adjusted text generation model is used as the target text generation model.

[0108] In some embodiments of this application, the apparatus further includes a processing unit, a generating unit, and an adding unit;

[0109] The processing unit is used to hide characters at preset positions in the text to be enhanced, so as to obtain the processed text to be enhanced.

[0110] The generation unit is used to generate a new character at the preset position based on the processed text to be enhanced using the target text generation model.

[0111] The adding unit is used to add the new character at a preset position in the processed text to be enhanced, so as to obtain the target text.

[0112] In some embodiments of this application, the apparatus further includes a training unit;

[0113] The acquisition unit 11 is used to acquire a preset input text, a preset output text, and a preset sentiment matching degree between the preset input text and the preset output text;

[0114] The training unit is used to train an initial sentiment matching model based on the preset input text, the preset output text, and the preset sentiment matching degree, so as to obtain the sentiment matching model.

[0115] It should be noted that, in practical applications, the aforementioned acquisition unit 11, adjustment unit 12, input unit 13, and enhancement unit 14 can be implemented by the processor 15 on the text enhancement device 1, specifically by a CPU (Central Processing Unit), MPU (Microprocessor Unit), DSP (Digital Signal Processor), or FPGA (Field Programmable Gate Array), etc.; the aforementioned data storage can be implemented by the memory 16 on the text enhancement device 1.

[0116] This application also provides a text enhancement device 1, such as... Figure 7As shown, the text enhancement device 1 includes a processor 15, a memory 16, and a communication bus 17. The memory 16 communicates with the processor 15 through the communication bus 17. The memory 16 stores programs executable by the processor 15. When the program is executed, the processor 15 performs the text enhancement method as described above.

[0117] In practical applications, the aforementioned memory 16 can be volatile memory, such as random-access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 15.

[0118] This application provides a computer-readable storage medium having a computer program thereon, which, when executed by a processor 15, implements the text enhancement method as described above.

[0119] Understandably, the text enhancement device adjusts the initial text generation model by using sample input text and a sentiment matching model to obtain a target text generation model whose output has the same sentiment label as the input text. When the text to be enhanced is received, it can be directly input into the target text generation model to obtain target text with the same sentiment label as the text to be enhanced. The target text is then used to enhance the text to be enhanced, so that the enhanced text only includes text with the same sentiment label as the text to be enhanced, thus improving the text quality of the enhanced text.

[0120] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0121] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0122] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0123] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0124] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.

Claims

1. A text enhancement method, characterized in that, The method includes: Obtain sample input text; and adjust the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model; the target text generation model is used to output text with the same sentiment label as the input text. Upon receiving a text to be enhanced, the text to be enhanced is input into the target text generation model to obtain a target text with the same sentiment tag as the text to be enhanced. The target text is then used to enhance the text to be enhanced, resulting in enhanced text. The input text includes the text to be enhanced. The step of adjusting the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model includes: The sample input text is input into the initial text generation model to obtain the sample output text and the model loss; The sentiment matching model is used to determine the sentiment matching degree between the sample input text and the sample output text; Based on the correspondence between the preset matching degree and the preset reward and punishment information, the target reward and punishment information corresponding to the emotional matching degree is determined; wherein, the correspondence between the preset matching degree and the preset reward and punishment information is as follows: ,in, The preset matching degree; The preset reward and punishment information; This is a reward parameter used to indicate the degree of reward or punishment corresponding to preset reward and punishment information; The model loss is adjusted using the target reward and punishment information to obtain the adjusted model loss; If the adjusted model loss meets the preset loss, the initial text generation model is used as the target text generation model.

2. The method according to claim 1, characterized in that, After adjusting the model loss using the target reward / penalty information to obtain the adjusted model loss, the method further includes: If the adjusted model loss does not meet the preset loss, the initial text generation model is further adjusted using the sample input text and the sentiment matching model until the adjusted model correction information corresponding to the obtained adjusted text generation model meets the preset correction value. Then, the adjusted text generation model is used as the target text generation model.

3. The method according to claim 1, characterized in that, The step of inputting the text to be enhanced into the target text generation model to obtain target text with the same sentiment label as the text to be enhanced includes: The characters at preset positions in the text to be enhanced are hidden to obtain the enhanced text. The target text generation model is used to generate a new character at the preset position based on the processed text to be enhanced. The new character is added at a preset position in the processed text to be enhanced to obtain the target text.

4. The method according to claim 1, characterized in that, Before adjusting the initial text generation model using the sample input text and the sentiment matching model to obtain the target text generation model, the method further includes: Obtain a preset input text, a preset output text, and a preset sentiment matching degree between the preset input text and the preset output text; The initial sentiment matching model is trained based on the preset input text, the preset output text, and the preset sentiment matching degree to obtain the sentiment matching model.

5. A text enhancement device, characterized in that, The device includes: The acquisition unit is used to acquire the sample input text; An adjustment unit is used to adjust an initial text generation model using the sample input text and the sentiment matching model to obtain a target text generation model. The target text generation model is used to output text with the same sentiment label as the input text. The adjustment unit is also used to adjust the initial text generation model based on the sentiment matching degree and the model loss to obtain the target text generation model. The adjustment unit is also used to adjust the model loss using target reward and punishment information to obtain an adjusted model loss. If the adjusted model loss meets a preset loss, the initial text generation model is used as the target text generation model. The input unit is configured to, upon receiving a text to be enhanced, input the text to be enhanced into the target text generation model to obtain a target text with the same sentiment label as the text to be enhanced, wherein the input text includes the text to be enhanced; the input unit is also configured to input the sample input text into the initial text generation model to obtain sample output text and model loss; An enhancement unit is used to enhance the text to be enhanced using the target text, thereby obtaining enhanced text; The determining unit is configured to determine the sentiment matching degree between the sample input text and the sample output text using the sentiment matching model; the determining unit is further configured to determine the target reward / punishment information corresponding to the sentiment matching degree based on the correspondence between the preset matching degree and preset reward / punishment information; wherein, the correspondence between the preset matching degree and the preset reward / punishment information is as follows: ,in, The preset matching degree; The preset reward and punishment information; This is a reward parameter used to indicate the degree of reward or punishment corresponding to preset reward and punishment information.

6. A text enhancement device, characterized in that, The device includes: The system includes a memory, a processor, and a communication bus, wherein the memory communicates with the processor via the communication bus, and the memory stores a text enhancement program executable by the processor, wherein when the text enhancement program is executed, the method described in any one of claims 1 to 4 is performed by the processor.

7. A storage medium storing a computer program thereon for use in a text enhancement device, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Data processing method, device and apparatus and readable medium

    CN112948582A