Training text generation methods, model training methods, devices and electronic equipment

By generating output text that is semantically consistent with the target text using a guided text generation model, the problem of quickly obtaining training text is solved, and the recognition accuracy of the text recognition model is improved, especially when recognizing sensitive text.

CN115129866BActive Publication Date: 2026-01-06NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210535272.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-17
Publication Date
2026-01-06
Estimated Expiration
2042-05-17

AI Technical Summary

Technical Problem

In existing technologies, it is difficult to quickly and efficiently obtain a large amount of sensitive text for training text recognition models, resulting in low accuracy in sensitive text recognition.

Method used

By acquiring guiding text and inputting it into a guided text generation model, output text with semantic attributes consistent with the target text is generated. Training text is determined based on the output text, and rich and diverse training texts are quickly generated by utilizing the semantic consistency between the guiding text and the target text.

Benefits of technology

It improves the recognition accuracy of the text recognition model, enabling it to more accurately identify positive text and enhance the filtering effect of sensitive text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129866B_ABST
    Figure CN115129866B_ABST
Patent Text Reader

Abstract

The application discloses a training text generation method, a model training method, a text recognition method, a device and a computer readable storage medium. The training text is used for training a to-be-trained model to obtain a text recognition model. The training text generation method comprises the following steps: acquiring a guide text, the guide text being consistent with the semantic attribute of a target text, the target text being a positive example text recognized by the text recognition model; inputting the guide text into a guide-based text generation model to obtain an output text consistent with the semantic attribute of the guide text; and determining a training text according to the output text. The application automatically generates the output text based on the guide-based text generation model, thereby determining the training text, and the training text can be obtained more quickly and efficiently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a training text generation method, a model training method, an apparatus, and an electronic device. Background Technology

[0002] The internet is an essential tool for people's lives and work. However, with its increasing openness, it's also rife with sensitive text that's unsuitable for display to users. Examples include online messages, chat logs, and chatbot replies. To create a healthy chat environment, it's necessary to identify and filter this sensitive text in advance.

[0003] In related technologies, text recognition models can be used to identify sensitive text. However, text recognition models need to be trained in advance with a large number of sensitive texts with different expressions. Since it is currently difficult to collect a large amount of sensitive text on the Internet, and manually writing sensitive text is inefficient and the amount of manually written text is limited, how to quickly and efficiently obtain training text to train the text recognition model is a problem that needs to be solved. Summary of the Invention

[0004] This application provides a method for generating training text, a method for training a model, a method for recognizing text, an electronic device, and a computer-readable storage medium, which can acquire training text more quickly and efficiently to facilitate the training of a text recognition model. The specific solution is as follows:

[0005] In a first aspect, this application provides a method for generating training text, wherein the training text is used to train a model to obtain a text recognition model, the method comprising:

[0006] Obtain guiding text, wherein the guiding text has the same semantic attributes as the target text, and the target text is the positive example text identified by the text recognition model;

[0007] The guiding text is input into a guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text;

[0008] The training text is determined based on the output text.

[0009] Optionally, before inputting the guiding text into the guiding text generation model, the method further includes:

[0010] Get the question text;

[0011] The step of inputting the guiding text into a guiding text generation model to obtain output text consistent with the semantic attributes of the guiding text includes:

[0012] The question text and the guiding text are input into a guided dialogue generation model to obtain an output text that responds to the question text and whose semantic attributes are consistent with those of the guiding text.

[0013] Optionally, the output text may include multiple lines;

[0014] Determining the training text based on the output text includes:

[0015] The training text is determined from the multiple output texts.

[0016] Optionally, determining the training text from the plurality of output texts includes:

[0017] The training text is determined by a first strategy, which includes: selecting a text containing at least one preset keyword from a plurality of output texts as the training text, wherein the preset keyword is consistent with the semantic attributes of the target text;

[0018] Alternatively, the training text can be determined using a second strategy, which includes selecting a first text from a plurality of said output texts or randomly selecting a text as the training text.

[0019] Optionally, the probability of determining the training text using the first strategy is a first preset probability, and the probability of determining the training text using the second strategy is a second preset probability, wherein the first preset probability is greater than the second preset probability, and the sum of the first preset probability and the second preset probability is 1.

[0020] Optionally, the range of the first preset probability can be 0.7 to 0.9, and the range of the second preset probability can be 0.1 to 0.3.

[0021] Optionally, the guiding text includes at least one guiding word, and each guiding word is consistent with the semantic attributes of the target text;

[0022] The preset keywords include: each of the aforementioned guiding words.

[0023] Optionally, the preset keywords further include: each first target word, wherein the first target word is a word contained in any of the output texts that is consistent with the semantic attributes of the target text and is different from each of the guide words.

[0024] Optionally, the first strategy further includes: when none of the multiple output texts contain any of the preset keywords, selecting the first of the multiple output texts to determine the training text.

[0025] Optionally, the semantic attributes of the positive example text are semantically sensitive text, the semantic attributes of the target text are semantically sensitive text, and the text recognition model is used to recognize the text generated by the dialogue generation model.

[0026] Secondly, embodiments of this application also provide a method for training a text recognition model, including:

[0027] Obtain training samples, which include positive samples and negative samples, and the text corresponding to the positive samples includes: training text generated by the training text generation method described in any one of the first aspects;

[0028] The training samples are used to train the model to be trained, and a text recognition model is obtained.

[0029] Optionally, the training method further includes:

[0030] Obtain a first text, which is the text that the text recognition model misidentified, and the actual semantic attributes of the misidentified text are different from the semantic attributes that the text recognition model recognizes for the misidentified text;

[0031] The first text is annotated to obtain the first sample;

[0032] The text recognition model is optimized and trained using the first sample.

[0033] Optionally, before optimizing the text recognition model using the first sample, the training method further includes:

[0034] Obtain a second text, which contains a second target word, and the second text expresses the opposite semantic attributes to the first text. The second target word is a word contained in the first text that is consistent with the semantic attributes expressed by the target text.

[0035] The second text is annotated to obtain a second sample, the annotation information of which is opposite to that of the first sample;

[0036] The step of optimizing and training the text recognition model using the first sample includes:

[0037] The text recognition model is optimized and trained using the first sample and the second sample.

[0038] Optionally, the training samples include response samples and question-answer splicing samples;

[0039] The text corresponding to the positive sample in the response sample includes: the training text determined by inputting the question text and the guidance text into the guidance-based dialogue generation model in the first aspect;

[0040] The text corresponding to the question-and-answer splicing sample is spliced ​​text, which includes: text formed by splicing the question text with the corresponding reply text.

[0041] Thirdly, embodiments of this application also provide a text recognition method, characterized in that it includes:

[0042] Obtain the text to be recognized;

[0043] The text to be identified is input into the text recognition model to obtain the recognition result of the text to be identified, wherein the text recognition model is trained by the training method described in any one of the first aspects.

[0044] Optionally, the text to be identified is text generated by a dialogue generation model;

[0045] Alternatively, the text to be identified may be a concatenated text formed by combining the user's question text and the text generated by the dialogue generation model. The text recognition model is trained using the model training method described in the second aspect, where the training samples include response samples and question-and-answer concatenated samples.

[0046] Fourthly, this application also provides a training text generation apparatus, wherein the training text is used to train a model to obtain a text recognition model, the apparatus comprising:

[0047] An information acquisition unit is used to acquire guiding text, wherein the guiding text has the same semantic attributes as the target text, and the target text is the positive example text recognized by the text recognition model;

[0048] The text generation unit is used to input the guiding text into the guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text;

[0049] A text determination unit is used to determine training text based on the output text.

[0050] Optionally, the device further includes:

[0051] The first text acquisition unit is used to acquire the question text;

[0052] The text generation unit is specifically used to: input the question text and the guidance text into a guidance-based dialogue generation model to obtain an output text that responds to the question text and whose semantic attributes are consistent with those of the guidance text.

[0053] Optionally, the output text may include multiple lines;

[0054] The text determination unit is specifically used to determine the training text from multiple output texts.

[0055] Optionally, the text determination unit is specifically used for:

[0056] The training text is determined by a first strategy, which includes: selecting a text containing at least one preset keyword from a plurality of output texts as the training text, wherein the preset keyword is consistent with the semantic attributes of the target text;

[0057] Alternatively, the training text can be determined using a second strategy, which includes selecting a first text from a plurality of said output texts or randomly selecting a text as the training text.

[0058] Optionally, the probability of determining the training text using the first strategy is a first preset probability, and the probability of determining the training text using the second strategy is a second preset probability, wherein the first preset probability is greater than the second preset probability, and the sum of the first preset probability and the second preset probability is 1.

[0059] Optionally, the range of the first preset probability can be 0.7 to 0.9, and the range of the second preset probability can be 0.1 to 0.3.

[0060] Optionally, the guiding text includes at least one guiding word, and each guiding word is consistent with the semantic attributes of the target text;

[0061] The preset keywords include: each of the aforementioned guiding words.

[0062] Optionally, the preset keywords further include: each first target word, wherein the first target word is a word contained in any of the output texts that is consistent with the semantic attributes of the target text and is different from each of the guide words.

[0063] Optionally, the first strategy further includes: when none of the multiple output texts contain any of the preset keywords, selecting the first of the multiple output texts to determine the training text.

[0064] Optionally, the semantic attributes of the positive example text are semantically sensitive text, the semantic attributes of the target text are semantically sensitive text, and the text recognition model is used to recognize the text generated by the dialogue generation model.

[0065] Fifthly, embodiments of this application also provide a training apparatus for a text recognition model, comprising:

[0066] A sample acquisition unit is used to acquire training samples, the training samples including positive samples and negative samples, and the text corresponding to the positive samples includes: training text generated by the training text generation device described in any of the fourth aspects;

[0067] The model training unit is used to train the model to be trained using the training samples to obtain a text recognition model.

[0068] Optionally, the training device further includes:

[0069] The second text acquisition unit is used to acquire the first text, which is the text that the text recognition model misidentified. The actual semantic attributes of the misidentified text are different from the semantic attributes that the text recognition model recognizes for the misidentified text.

[0070] A sample annotation unit is used to annotate the first text to obtain a first sample;

[0071] The model optimization unit is used to optimize and train the text recognition model using the first sample.

[0072] Optionally, the second text acquisition unit is further configured to:

[0073] Obtain a second text, which contains a second target word, and the second text expresses the opposite semantic attributes to the first text. The second target word is a word contained in the first text that is consistent with the semantic attributes expressed by the target text.

[0074] The sample annotation unit is further configured to: annotate the second text to obtain a second sample, wherein the annotation information of the second sample is opposite to that of the first sample;

[0075] The model optimization unit is specifically used to optimize and train the text recognition model using the first sample and the second sample.

[0076] Optionally, the training samples include response samples and question-answer splicing samples;

[0077] The text corresponding to the positive sample in the response sample includes: the training text determined by inputting the question text and the guidance text into the guidance-based dialogue generation model in the first aspect;

[0078] The text corresponding to the question-and-answer splicing sample is spliced ​​text, which includes: text formed by splicing the question text with the corresponding reply text.

[0079] Sixthly, embodiments of this application also provide a text recognition device, including:

[0080] The third text acquisition unit is used to acquire the text to be recognized;

[0081] A text recognition unit is used to input the text to be recognized into a text recognition model to obtain a recognition result of the text to be recognized, wherein the text recognition model is trained by the training device described in any of the fifth aspects.

[0082] Optionally, the text to be identified is text generated by a dialogue generation model;

[0083] Alternatively, the text to be identified may be a text formed by concatenating the user's question text and the text generated by the dialogue generation model, wherein the text recognition model is obtained by training using the training method described in the first aspect when the training samples include response samples and question-answer concatenation samples.

[0084] In a seventh aspect, embodiments of this application also provide an electronic device, including:

[0085] Processor; and

[0086] A memory for storing a data processing program, which, when the electronic device is powered on and runs by the processor, performs the method as described in any of the first aspects.

[0087] Eighthly, embodiments of this application also provide an electronic device, including:

[0088] Processor; and

[0089] A memory for storing a data processing program, which, when the electronic device is powered on and runs by the processor, performs the method as described in any of the second aspects.

[0090] Ninthly, embodiments of this application also provide an electronic device, including:

[0091] Processor; and

[0092] A memory for storing a data processing program, which, when the electronic device is powered on and runs by the processor, performs the method as described in any of the third aspects.

[0093] In a tenth aspect, embodiments of this application also provide a computer-readable storage medium storing a data processing program that is executed by a processor to perform the method described in any of the first aspects.

[0094] Eleventhly, embodiments of this application also provide a computer-readable storage medium storing a data processing program that is executed by a processor to perform the method described in any of the second aspects.

[0095] In a twelfth aspect, embodiments of this application also provide a computer-readable storage medium storing a data processing program that is executed by a processor to perform the method described in any of the third aspects.

[0096] Compared with the prior art, this application has the following advantages:

[0097] The training text generation method provided in this application, after inputting guiding text into a guiding text generation model, can obtain output text that is consistent with the semantic attributes of the guiding text. Since the semantic attributes of the guiding text are consistent with those of the target text, and the target text is a positive example text recognized by the text recognition model, the obtained output text is also consistent with the semantic attributes of the positive example text used by the text recognition model to recognize. In this way, the training text determined based on the obtained output text can be used as a positive example sample text for training the model to be trained.

[0098] This application uses a guided text generation model to automatically generate output text, thereby determining the training text. This allows for faster and more efficient acquisition of training text. Furthermore, since the text generation model can generate a wide variety of output texts, the training text determined based on the output texts is also more diverse, which improves the recognition accuracy of the trained text recognition model and enables the model to more accurately identify positive example texts. Attached Figure Description

[0099] Figure 1 This is a flowchart of the training text generation method provided in the embodiments of this application;

[0100] Figure 2 This is a flowchart of another example of the training text generation method provided in the embodiments of this application;

[0101] Figure 3 This is a flowchart of the text recognition model training method provided in the embodiments of this application;

[0102] Figure 4 This is a flowchart of another example of the text recognition model training method provided in the embodiments of this application;

[0103] Figure 5It is a block diagram of a training text generation device provided by an embodiment of the present application;

[0104] Figure 6 It is a schematic structural diagram of an electronic device for implementing a training text generation method provided by an embodiment of the present application. Detailed implementation manners

[0105] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.

[0106] Intelligent chat technology can automatically reply to questions raised by users, and it is widely used in intelligent customer service, chatbots, game chatting, etc. in the fields of e-commerce or public services.

[0107] It is very widely applied in fields such as intelligent customer service, chatbots, and game chatting in the fields of e-commerce or public services.

[0108] For the questions of users, an intelligent chat device can retrieve the reply content corresponding to the user's questions from a pre-stored question-and-answer database. Since the questions stored in the question-and-answer database are limited, for questions not stored in the question-and-answer database, this method cannot give corresponding replies, resulting in not being able to have a better and more fluent question-and-answer with users, and the replied content is also relatively single, and the user experience is not good.

[0109] With the development of deep learning, intelligent chat scenarios gradually start to use dialogue generation models to reply to users' questions, which greatly improves the diversity of the replied content and also supports coherent multi-round chats, and the user experience is better.

[0110] However, dialogue generation models are usually trained based on a large amount of sample data, and some of these sample data inevitably contain sensitive texts, such as texts containing abuse, violence, etc. Therefore, the dialogue generation models will learn the expressions of these sensitive texts, resulting in the possibility that the dialogue generation models may generate sensitive texts and reply to users. In order to create a green chat environment, it is necessary to identify and filter out the generated sensitive texts in advance.

[0111] In the related art, sensitive texts can be filtered by a character- or word-based method. Since most texts containing the character "do" are not sensitive texts, such as "cooking", "doing housework", "doing exercise", etc., a whitelist table is also set up, and texts in the whitelist table are not filtered. For example, if "doing housework" is put into the whitelist table, then when the intelligent dialogue device replies "I did housework at home today", it will not be filtered.

[0112] However, since the number of sensitive words is extremely large while the number of listed sensitive words is limited, many sensitive texts will be missed, resulting in many sensitive output texts that cannot be filtered. Secondly, since the whitelist cannot be exhausted either, many normal texts will be filtered out, leading to a decline in the quality of the conversation. In addition, this method can only filter out texts that explicitly contain sensitive words and cannot filter out texts that are semantically sensitive but do not contain sensitive words.

[0113] In the related art, sensitive texts can also be filtered by means of regular expressions. For example, when the persona of the intelligent dialogue device is a child, texts replied by the intelligent dialogue device that express having or giving birth to a child are sensitive texts. In this case, the regular expressions can be "give birth to.*a.*child" or "have.*a.*child", where "." matches any character except the line break character, and "*" means matching 0 or more of the preceding characters. When the intelligent dialogue device replies with "The mother cat gave birth to 2 kittens" or "You gave birth to 1 child", they will be filtered out because they match the regular expression "give birth to.*a.*child".

[0114] However, since all sensitive regular expressions cannot be exhausted, many sensitive texts cannot be recognized. In addition, many normal texts will also be misjudged. For example, the above-mentioned "The mother cat gave birth to 2 kittens" will be misjudged. In addition, the method of regular expressions can only filter out texts that match the regular expressions and cannot filter out implicitly sensitive texts that do not match the regular expressions.

[0115] In order to improve the recognition accuracy of sensitive texts, a recognition model can be used to recognize sensitive texts, where the recognition model is a deep model. However, the recognition model needs to be pre-trained with a large number of sensitive texts with different expressions as samples. Since it is difficult to collect a large number of sensitive texts on the Internet currently, and the quantity and diversity of manually written sensitive texts are limited, how to efficiently obtain a large number of training texts (such as sensitive texts) is a problem that needs to be solved.

[0116] In order to obtain a large number of training texts more quickly and efficiently, this application provides a training text generation method, a text recognition model training method, a text recognition method, and corresponding devices, electronic devices, and computer-readable storage media. The following provides embodiments to elaborate on the above methods, devices, electronic devices, and computer-readable storage media.

[0117] The first embodiment of this application provides a method for generating training text, which is used to train a model to obtain a text recognition model. In this embodiment, the subject executing the training text generation method is an electronic device, which can be any electronic device with data processing capabilities, such as a desktop computer, laptop computer, tablet computer, server, or mobile phone.

[0118] The aforementioned training model may include at least one of the following: BERT model, convolutional neural network, logistic regression model, K-Nearest Neighbor (KNN) model, logistic regression model, binary classification model, or any other deep learning model.

[0119] The text recognition model described above can determine whether the text to be recognized is a positive or negative example. This model can also be understood as a text classification model. It can be used to recognize Chinese text, as well as foreign language texts such as English, French, and German.

[0120] Positive text refers to the text that the text recognition model needs to identify. For example, if the text recognition model is used to identify text containing place names, then text containing place names is positive text, and text not containing place names is negative text. If the text recognition model is used to identify text with sensitive semantics, then text with sensitive semantics is positive text, and text without sensitive semantics is negative text.

[0121] like Figure 1 As shown, the training text generation method provided in this application includes the following steps S110 to S130.

[0122] Step S110: Obtain the guide text.

[0123] The semantic attributes of the aforementioned guiding text are consistent with those of the target text, which is a positive example text identified by the text recognition model.

[0124] The aforementioned guiding text can be one or more paragraphs, one or more sentences, or one or more words. These words can be single-character words, two-character words, or multi-character words. The guiding text can also be other forms of text. In this embodiment, the guiding text can be manually set and then input into the electronic device, which then acquires the manually input guiding text; alternatively, the electronic device can automatically determine the guiding text based on the target text. For example, the electronic device can automatically identify the semantic attributes of the target text and determine guiding text consistent with those semantic attributes.

[0125] The aforementioned guiding text can be Chinese text or Chinese words, or it can be foreign language text or foreign language words such as English or German.

[0126] The semantic attributes of the target text can be understood as the type to which the target text belongs. Specifically, the semantic attributes of the target text can be at least one of semantically sensitive text, classified text, popular science text, academic text, and medical knowledge text. The semantic attributes of the target text can also be other specific semantic attributes. Those skilled in the art can determine the semantic attributes of the target text based on the semantic attributes of the positive example texts that the text recognition model needs to identify. This application does not limit the specific semantic attributes of the target text.

[0127] For example, if a text recognition model is used to identify semantically sensitive text, the semantic attribute of the guiding text can be sensitive text; if a trained text recognition model is used to identify classified text, the semantic attribute of the guiding text can be classified text.

[0128] Optionally, the aforementioned sensitive texts may include violent texts, pornographic texts, texts containing offensive language, or other unhealthy texts.

[0129] For example, if the positive example text identified by the text recognition model is text with sensitive attributes such as violence, pornography, or abuse, then the guiding text may include one or more single-character words or multi-character words with sensitive semantic attributes such as violence, pornography, or abuse.

[0130] The single-character or multi-character words contained in the guiding text can be called guiding words. That is, the guiding text contains one or more guiding words, and each guiding word is consistent with the semantic attributes of the target text. When the guiding text contains one or more guiding words, because the guiding words are shorter, their semantics are easier to obtain. Therefore, when the guiding text contains guiding words, it is easier for the guiding text generation model to generate text with semantic attributes consistent with the guiding words.

[0131] The number of guiding words in the guiding text can range from 5 to 15. For example, the guiding text can contain 5, 8, 10, 12, or 15 guiding words. The number of guiding words should not be too many or too few. Too many guiding words will make the computational complexity of the guided text generation model too high, thus affecting the output efficiency of the output text, or even causing computational errors and preventing the generation of output text. Too few guiding words will result in a significant difference in semantic attributes between the output text and the target text.

[0132] The guiding word can serve as a prefix text. Prefix text refers to words that remain unchanged each time the training text generation method is used. Prefix text has more stable semantics and stronger guiding properties. In other words, for training samples with the same semantic attributes, the prefix text remains unchanged each time the training text generation method provided in this application is used, so that the semantic attributes of the obtained training text are consistent with those of the prefix text each time.

[0133] Step S120: Input the guiding text into the guiding text generation model to obtain the output text that is consistent with the semantic attributes of the guiding text.

[0134] The aforementioned guided text generation model is a pre-trained model. In this embodiment, deep models such as ELMO, OpenAIGPT, BERT, or OpenAIGPT-2 neural networks can be trained based on guided samples and corresponding text samples to obtain a guided text generation model. The guided samples and text samples can be obtained and labeled from materials such as novels, scripts, articles in magazines or journals. Those skilled in the art can train a guided text generation model using conventional model training methods, which will not be detailed further in this application.

[0135] Step S130: Determine the training text based on the above output text.

[0136] In step S130, the output text can be directly determined as the training text, or the sentences can be expanded based on the output text to obtain expanded text that is consistent with the semantic attributes of the output text. The output text and the expanded text can then be determined as training samples. Alternatively, the training text can be determined based on the output text through other means.

[0137] In this embodiment of the application, since the semantic attributes of the guiding text are consistent with those of the positive example text identified by the text recognition model, when the semantic attributes of the output text are consistent with those of the guiding text, the semantic attributes of the sample text determined based on the output text are also consistent with those of the positive example text identified by the text recognition model.

[0138] For example, when the semantic attribute of the guiding text is abusive, the semantic attribute of the output text is also abusive. The semantic attribute of the training text determined based on the output text is also abusive. Therefore, the training text can be used as the text corresponding to the positive example sample to train the training model, so that the trained text recognition model can recognize the abusive text, which is the positive example text.

[0139] This application uses a guided text generation model to automatically generate output text, thereby determining the training text. This allows for faster and more efficient acquisition of training text. Furthermore, since the text generation model can generate a wide variety of output texts, the training text determined based on the output texts is also more diverse, which improves the recognition accuracy of the trained text recognition model and enables the model to more accurately identify positive example texts.

[0140] In one implementation, such as Figure 2 As shown, before step S120, the following step S140 may also be included.

[0141] Step S140: Obtain the question text.

[0142] Step S120 can be implemented by following step S121.

[0143] Step S121: Input the above question text and the above guidance text into the guidance-based dialogue generation model to obtain the output text used to reply to the above question text and whose semantic attributes are consistent with those of the above guidance text.

[0144] The aforementioned question texts were obtained from novel excerpts, scripts, social media chat logs, etc. These question texts serve as the text in which users ask questions. Question texts can be inquisitive phrases like "What time is it?" or "Where is the company address?", or casual conversational phrases like "Have a good day," "We're good friends," or "The weather is nice." Question texts can be a single sentence or multiple sentences.

[0145] The question text can be text entered by the user into the electronic device, or text selected by the electronic device from a stored text library.

[0146] In this embodiment, the text generation model in step S120 is the same as the dialogue generation model in step S121.

[0147] The aforementioned guided dialogue generation model can be trained on a deep model using question samples, guidance samples, and response samples corresponding to the guidance and question samples, thereby obtaining a guided text generation model. The question samples, guidance samples, and response samples can be obtained and labeled from materials such as novels, scripts, and social media chat data. Those skilled in the art can train a guided text dialogue model using conventional model training methods, which will not be detailed in this application.

[0148] This implementation generates output text using a guided dialogue generation model. Since this output text is a response to the question, it is more consistent with the content automatically replied by the intelligent chat device. Therefore, after determining the training text based on the output text, the text recognition model trained on this model is more suitable for recognizing chat information automatically generated by the intelligent chat device, and also more suitable for recognizing the response text generated by the intelligent chat device through the dialogue generation model. Thus, when the intelligent chat device generates unhealthy and sensitive text such as abusive or violent content through the dialogue generation model, the text recognition model can more accurately identify the sensitive text generated by the dialogue generation model.

[0149] Optionally, the output text generated by the guided dialogue generation model may include a single text, in which case the output text can be used as a training sample.

[0150] In one implementation, the output text may include multiple texts, and step S130 may be implemented by the following step S131: determining the training text from the multiple output texts.

[0151] The output text consists of multiple texts, meaning that multiple output texts are obtained through a guided text generation model.

[0152] Optionally, such as Figure 2 As shown, training text can be determined from multiple output texts by following the steps S131a.

[0153] Step S131a: Select the text containing at least one preset keyword from multiple output texts and determine it as the training text.

[0154] In this embodiment of the application, the method of determining the training text in step S131a can be determined as the first strategy.

[0155] The semantic attributes of the aforementioned preset keywords are consistent with the semantic attributes of the target text. These preset keywords can be words entered by the user, and can include one or more.

[0156] When there are more than one text containing a preset keyword among multiple output texts, each output text containing the preset keyword can be designated as a training text, or the first output text containing the preset keyword can be designated as a training text, or the output text containing the most preset keywords can be designated as a training text.

[0157] In this embodiment, since the semantic attributes of the preset keywords are consistent with those of the positive example texts identified by the text generation model, the semantic attributes of the output text containing the preset keywords are more likely to be consistent with those of the positive example texts identified by the text generation model. Thus, using the output text containing the preset keywords as the training text can make the trained text recognition model more accurate in recognizing the positive example texts.

[0158] Optionally, such as Figure 2 As shown, training texts can also be determined from multiple output texts by following steps S131b or S131c.

[0159] Step S131b: Select the first text from multiple output texts and determine it as the training text.

[0160] In this embodiment of the application, the method of determining the training text in step S131b can be used as a second strategy.

[0161] Since the first of multiple output texts usually matches the guiding text better, selecting the first output text as the training text for training the model can make the trained text recognition model more accurate in recognizing positive texts.

[0162] Step S131c: Randomly select one text from multiple output texts to determine as the training text.

[0163] In this embodiment, each output text can be designated as training text, or each output text can be displayed so that the user can select from it, and then the selected text can be designated as training text. This application does not specifically limit the method of determining training text from multiple output texts.

[0164] In this embodiment, since the output text derived from the semantic-based text model includes multiple texts, the output text that is more consistent with the semantic attributes of the target text can be flexibly determined from the multiple output texts as the training text. This makes the determined training text more consistent with the semantic attributes of the target text, enabling the text recognition model determined through the training text to more accurately identify positive example texts.

[0165] In one implementation, such as Figure 2 As shown, the probability of selecting the first strategy to determine the training text is the first preset probability, and the probability of selecting the second strategy to determine the training text is the second preset probability. The first preset probability is greater than the second preset probability, and the sum of the first preset probability and the second preset probability is 1.

[0166] In other words, this embodiment selects the first strategy to determine the training text with a first preset probability and selects the second strategy to determine the training text with a second preset probability.

[0167] The first preset probability is greater than the second preset probability. The first preset probability and the second preset probability can be 0.8 and 0.2 respectively, or the first preset probability and the second preset probability can be 0.9 and 0.1 respectively, or the first preset probability and the second preset probability can be 0.6 and 0.4 respectively, etc. The first preset probability is greater than the second preset probability and the sum of the two is 1. This application does not limit the specific values ​​of the two probabilities.

[0168] In one specific embodiment, the range of the first preset probability can be 0.7 to 0.9, and the range of the second preset probability can be 0.1 to 0.3. For example, the first preset probability and the second preset probability are 0.7 and 0.3, respectively; the first preset probability and the second preset probability are 0.8 and 0.2, respectively; and the first preset probability and the second preset probability are 0.9 and 0.1, respectively. That is to say, the difference between the first preset probability and the second preset probability is relatively large. Generally speaking, the probability that the output text containing the preset keyword has the same semantic attributes as the target text is much higher than the probability that the output text does not contain the preset keyword but has the same semantic attributes as the target text. Therefore, the first preset probability is much larger than the second preset probability. This not only makes the semantic attributes of the obtained training text more consistent with those of the target text, but also makes the obtained training text more diverse, so that the text recognition model trained on the training text can more accurately identify a wider variety of positive example texts.

[0169] Because the number of preset keywords is limited, it is difficult for each preset keyword to contain all words that are consistent with the semantic attributes of the target text. Therefore, even if the output text does not contain any preset keywords, it may still be consistent with the semantic attributes of the target text. Since the probability of the first output text being consistent with the semantic attributes of the target text is relatively high, regardless of whether the first output text contains preset keywords, it may still be consistent with the semantic attributes of the target text. In this embodiment, the first output text is selected as the training text with a smaller second preset probability. This can increase the training texts that do not contain preset keywords but are consistent with the semantic attributes of the target text, making the training texts more diverse. As a result, the trained text recognition model can recognize more diverse positive example texts.

[0170] When the output text contains a preset keyword, it indicates that the output text is highly likely to be consistent with the semantic attributes of the target text. Therefore, determining the output text containing at least one preset keyword as the training text with a higher first preset probability can make the semantic attributes of the determined training text more consistent with the target text, thereby enabling the text recognition model trained on the training text to more accurately identify positive example text.

[0171] The aforementioned preset keywords can include all of the aforementioned guiding words. Since the guiding words contained in the guiding text are semantically consistent with the target text, each guiding word can be directly identified as a preset keyword to quickly obtain the preset keywords.

[0172] In one specific embodiment, the aforementioned preset keywords may further include each first target word, wherein the first target word is a word contained in any output text that is consistent with the semantic attributes of the target text and is different from each of the guide words.

[0173] In this embodiment, multiple output texts can be displayed so that the user can view each output text. After viewing each output text, the user can find words from each output text that are consistent with the semantic attributes of the target text and different from each of the guiding words, and input the found words into the electronic device. In this way, the electronic device can obtain the words found and input by the user.

[0174] Since the output text is generated based on the guide text, it is highly likely that the output text has the same semantic attributes as the target text. Therefore, the output text is also highly likely to contain words with the same semantic attributes as the target text. Thus, it is very likely that words with the same semantic attributes as the target text and different from each guide word can be selected from the output text.

[0175] Because the number of guide words is limited, determining whether an output text is training text based on whether it contains guide words may filter out some texts containing words semantically consistent with the target text. In this embodiment, the first target word is determined as a preset keyword, which supplements the preset keyword list and makes the preset keywords more diverse. This makes it less likely to miss texts in the output text that are consistent with the target text, resulting in a more diverse and richer training sample.

[0176] In one specific embodiment, after step S131a, the following step S131c may also be included.

[0177] Step S131c: When none of the multiple output texts contain any preset keyword, the first of the multiple output texts is determined as the training sample.

[0178] In this embodiment of the application, the method of determining the training text in steps S131a and S131c can be jointly determined as the first strategy.

[0179] This embodiment can increase the number of texts obtained that have semantic attributes consistent with the target text.

[0180] In this embodiment, the user can perform steps S110 to S130 multiple times. Each time, the guiding text matches the semantic attributes of the positive example text identified by the text generation model, but the guiding text is not entirely the same each time. For example, the guiding text may be partially different or completely different each time. Thus, by executing the training text generation method multiple times, more diverse training texts can be obtained. The text recognition model trained using these training texts can be used to identify sensitive texts such as abusive language and pornography. Therefore, the method provided in this application can generate diverse training texts.

[0181] like Figure 3As shown, the second embodiment of this application provides a method for training a text recognition model, which includes the following steps S510 to S520.

[0182] Step S510: Obtain training samples.

[0183] The training samples mentioned above include positive samples and negative samples. The text corresponding to the positive samples includes the training text generated by the training text generation method described in any one of the first embodiments.

[0184] In this embodiment of the application, the training text generated by the training text generation method described in any one of the first embodiments can be marked as a positive example sample, thereby obtaining a positive example sample.

[0185] The text corresponding to the negative examples mentioned above can be obtained from sources such as novels, magazines, and web pages. The text corresponding to the negative examples has the opposite semantic attributes to the text corresponding to the positive examples. For example, if the text corresponding to the positive examples is semantically sensitive, then the text corresponding to the negative examples is semantically insensitive; if the text corresponding to the positive examples contains names, then the text corresponding to the negative examples does not contain names.

[0186] When a text recognition model is used to identify whether text generated by a dialogue generation model is sensitive text, the text corresponding to the aforementioned positive examples can also include: third-party text determined from sensitive text that has been filtered out from historical chat information. For example, for an intelligent chat system, it may have been running for some time, and during its operation, it has filtered a portion of the text using methods such as regular expression-based filtering and character or word-based filtering. The probability that these filtered-out texts are sensitive texts is very high. Therefore, a large amount of sensitive text can be quickly obtained from these filtered-out sensitive texts.

[0187] Specifically, sensitive third texts can be manually selected from the aforementioned filtered sensitive texts. The electronic device then identifies the manually selected third text as the text corresponding to the positive sample and marks the third text as a positive sample.

[0188] The text corresponding to the aforementioned positive example sample may also include: a fourth text determined from the unfiltered text in historical chat messages. The unfiltered text in historical chat messages may also contain sensitive text. Therefore, the sensitive fourth text can be manually selected from the unfiltered text. The electronic device will then identify the manually selected fourth text as the text corresponding to the positive example sample and mark the fourth text as the positive example sample.

[0189] The above methods can be used to quickly obtain a large number of positive samples.

[0190] When a text recognition model is used to identify whether text generated by a dialogue generation model is sensitive, the text corresponding to the negative examples can include text determined from unfiltered text in historical chat messages. Since non-sensitive text constitutes a larger proportion and is more numerous in historical chat messages, the text determined from unfiltered text is essentially non-sensitive text. This allows for the easy acquisition of a large amount of non-sensitive text, i.e., the text corresponding to the negative examples. Electronic devices can then mark the text corresponding to the negative examples as negative examples.

[0191] Step S520: Use the above training samples to train the model to be trained to obtain the text recognition model.

[0192] The specific type of model to be trained can be referred to in the description of the first embodiment, and will not be repeated here.

[0193] In this embodiment, the text corresponding to positive examples and the text corresponding to negative examples can be input into the model to be trained for encoding, and a binary classifier can be used to classify the encoded text. The classification result is positive text (e.g., sensitive text, text containing names) or negative text (e.g., non-sensitive text, text not containing names). The obtained classification result is compared with the label information of the text corresponding to the positive and negative examples, thereby adjusting the various parameters of the model to be trained.

[0194] During training, the loss function can be a general binary classification cross-entropy loss function.

[0195] In this embodiment of the application, the model to be trained may include a text encoding model and a binary classification model.

[0196] The training method of the text recognition model provided in this application uses the training text generation method described in the first embodiment to generate the text corresponding to the positive sample. Therefore, it has the same beneficial effect as the first embodiment, which will not be repeated here.

[0197] In one implementation method, such as Figure 4 As shown, the training method may further include the following steps S530 to S540.

[0198] Step S530: Obtain the first text and annotate the first text to obtain the first sample.

[0199] The first text is text that the text recognition model misidentifies. The actual semantic attributes of the misidentified text are different from the semantic attributes identified by the text recognition model. For example, the actual semantic attribute of the sentence "Cao Cao was a historical figure during the Three Kingdoms period" is non-sensitive, while the text recognition model identifies the semantic attribute of this sentence as sensitive. Therefore, this sentence is text that the text recognition model misidentifies.

[0200] Step S540: Use the first sample to optimize and train the text recognition model.

[0201] Specifically, the first text is the text that the trained text recognition model misidentifies during the text recognition process. This application allows for manual inspection of the text recognized by the text recognition model to identify the misidentified text.

[0202] In this application, the first text can be manually annotated, for example, labeled as a positive sample or a negative sample.

[0203] In this embodiment, the text recognition model can be optimized and trained at preset time intervals, such as one month, two months, or other time intervals. Alternatively, the text recognition model can be optimized and trained in response to optimization commands triggered by the user.

[0204] This implementation uses text that was misidentified by the text recognition model to optimize and train the text recognition model, which can further improve the recognition accuracy of the text recognition model.

[0205] In one specific embodiment, such as Figure 4 As shown, before the above-mentioned step of optimizing and training the text recognition model using the first sample, the above training method may further include the following step S550.

[0206] Step S550: Obtain the second text and annotate the second text to obtain the second sample.

[0207] The second text contains a second target word, and the semantic attributes expressed by the second text are opposite to those expressed by the first text. The second target word is a word contained in the first text that has the same semantic attributes as the target text. The annotation information of the second sample is opposite to that of the first sample.

[0208] The above step S540 can be implemented by following step S541.

[0209] Step S541: Optimize and train the text recognition model using the first sample and the second sample.

[0210] In this embodiment, the second sample can be manually determined and input into the electronic device, thereby enabling the electronic device to obtain the second sample.

[0211] For example, in a scenario where a text recognition model is used to identify sensitive text, the first text that the text recognition model incorrectly predicts is "Cao Cao is three famous figures". The text recognition model predicts this as sensitive text, but the first text is actually non-sensitive text. Therefore, "Cao Cao is three famous figures" is marked as sensitive text, that is, marked as a positive sample.

[0212] To avoid the model overfitting to certain words, some second samples containing the target word can be added, which are opposite to the annotation information of the first sample. By using the first and second samples together to optimize and train the model, the phenomenon of the model overfitting to certain words can be better avoided, thus improving the accuracy of model recognition.

[0213] In one implementation, the training samples may include response samples and question-and-answer spliced ​​samples.

[0214] The text corresponding to the positive examples in the response samples includes: the text generated by the above-mentioned guided dialogue generation model; the text corresponding to the question-and-answer splicing samples is spliced ​​text, which includes: the text formed by splicing the question text with the response text corresponding to the question text.

[0215] In this embodiment, the text corresponding to the positive sample in the response sample may also include: response text obtained from a smart chat device, response text determined from dialogue in a novel or script, etc.

[0216] The text corresponding to negative examples in the response samples can include text determined from resources such as novels, scripts, and online articles. The text corresponding to negative examples in the response samples can also include text generated by the dialogue generation model.

[0217] Users can manually label the positive and negative samples in the response samples.

[0218] In this embodiment, the text corresponding to the response sample is used to represent the answer to the question asked by the user.

[0219] The above-mentioned concatenated text reflects the information obtained by combining the user's question with the respondent's reply.

[0220] Dialogue information can be manually obtained from resources such as novels, scripts, and online articles, and then question texts and corresponding response texts can be extracted from these dialogues.

[0221] Alternatively, a dialogue generation model can be used to generate a response text corresponding to the question text, and the question text and the text generated by the dialogue generation model can be used as the response text.

[0222] For example, if the question text is "Do you miss me?" and the reply text is "I miss you", then the combined text could be "Do you miss me? I miss you".

[0223] Since some users may intentionally discuss sensitive topics, the text of a reply from a chat device might not appear sensitive on its own. However, when the user's question and the smart reply are considered together, the text might become sensitive. This embodiment uses question-and-answer concatenation samples as training samples, enabling the trained text recognition model to recognize such concatenated text. This broadens the applicability of the text recognition model and allows it to recognize a wider variety of target text types.

[0224] In the second embodiment, the parts that are different from those in the first embodiment are explained and described, and the parts that are the same as or similar to those in the first embodiment will not be repeated.

[0225] The third embodiment of this application provides a text recognition method, including the following steps:

[0226] Obtain the text to be recognized;

[0227] The text to be recognized is input into the text recognition model to obtain the recognition result of the text to be recognized.

[0228] The text recognition model described above is trained using the training method described in any one of the second embodiments.

[0229] The text to be identified can be the text generated by the dialogue generation model.

[0230] The text to be identified can also be a concatenation of the user's question and the text generated by the dialogue generation model. In this case, the training samples for training the text recognition model include the aforementioned response samples and the question-and-answer concatenation samples.

[0231] The text to be identified may also be online messages, chat messages, text in online articles, etc. This application does not limit the specific content of the text to be identified.

[0232] Existing methods include sensitive word recognition and rule-based recognition. The text recognition method provided in this application can effectively identify obscure and sensitive texts, and is less prone to misjudgment, resulting in higher accuracy in identifying sensitive texts.

[0233] The text recognition model in this third embodiment is trained using the method provided in the second embodiment. Therefore, this embodiment has similar beneficial effects to the second embodiment, which will not be repeated here.

[0234] In the third embodiment, the parts that are different from the first and second embodiments are explained and described, and the parts that are the same as or similar to the first and second embodiments are not repeated.

[0235] like Figure 5 As shown, the fourth embodiment of this application also provides a training text generation apparatus, wherein the training text is used to train a model to be trained in order to obtain a text recognition model, and the apparatus includes:

[0236] The information acquisition unit 810 is used to acquire guiding text, wherein the guiding text has the same semantic attributes as the target text, and the target text is the positive example text recognized by the text recognition model;

[0237] The text generation unit 820 is used to input the guiding text into the guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text;

[0238] The text determination unit 830 is used to determine the training text based on the output text.

[0239] Optionally, the device further includes:

[0240] The first text acquisition unit is used to acquire the question text;

[0241] The text generation unit is specifically used to: input the question text and the guidance text into a guidance-based dialogue generation model to obtain an output text that responds to the question text and whose semantic attributes are consistent with those of the guidance text.

[0242] Optionally, the output text may include multiple lines;

[0243] The text determination unit is specifically used to determine the training text from multiple output texts.

[0244] Optionally, the text determination unit is specifically used for:

[0245] The training text is determined by a first strategy, which includes: selecting a text containing at least one preset keyword from a plurality of output texts as the training text, wherein the preset keyword is consistent with the semantic attributes of the target text;

[0246] Alternatively, the training text can be determined using a second strategy, which includes selecting a first text from a plurality of said output texts or randomly selecting a text as the training text.

[0247] Optionally, the probability of determining the training text using the first strategy is a first preset probability, and the probability of determining the training text using the second strategy is a second preset probability, wherein the first preset probability is greater than the second preset probability, and the sum of the first preset probability and the second preset probability is 1.

[0248] Optionally, the range of the first preset probability can be 0.7 to 0.9, and the range of the second preset probability can be 0.1 to 0.3.

[0249] Optionally, the guiding text includes at least one guiding word, and each guiding word is consistent with the semantic attributes of the target text;

[0250] The preset keywords include: each of the aforementioned guiding words.

[0251] Optionally, the preset keywords further include: each first target word, wherein the first target word is a word contained in any of the output texts that is consistent with the semantic attributes of the target text and is different from each of the guide words.

[0252] Optionally, the first strategy further includes: when none of the multiple output texts contain any of the preset keywords, selecting the first of the multiple output texts to determine the training text.

[0253] Optionally, the semantic attributes of the positive example text are semantically sensitive text, the semantic attributes of the target text are semantically sensitive text, and the text recognition model is used to recognize the text generated by the dialogue generation model.

[0254] The fifth embodiment of this application also provides a training device for a text recognition model, comprising:

[0255] A sample acquisition unit is used to acquire training samples, the training samples including positive samples and negative samples, and the text corresponding to the positive samples includes: training text generated by the training text generation device according to any one of the fourth embodiments;

[0256] The model training unit is used to train the model to be trained using the training samples to obtain a text recognition model.

[0257] Optionally, the training device further includes:

[0258] The second text acquisition unit is used to acquire the first text, which is the text that the text recognition model misidentified. The actual semantic attributes of the misidentified text are different from the semantic attributes that the text recognition model recognizes for the misidentified text.

[0259] A sample annotation unit is used to annotate the first text to obtain a first sample;

[0260] The model optimization unit is used to optimize and train the text recognition model using the first sample.

[0261] Optionally, the second text acquisition unit is further configured to:

[0262] Obtain a second text, which contains a second target word, and the second text expresses the opposite semantic attributes to the first text. The second target word is a word contained in the first text that is consistent with the semantic attributes expressed by the target text.

[0263] The sample annotation unit is further configured to: annotate the second text to obtain a second sample, wherein the annotation information of the second sample is opposite to that of the first sample;

[0264] The model optimization unit is specifically used to optimize and train the text recognition model using the first sample and the second sample.

[0265] Optionally, the training samples include response samples and question-answer splicing samples;

[0266] The text corresponding to the positive sample in the response sample includes: the training text determined by inputting the question text and the guidance text into the guidance-based dialogue generation model in the first embodiment;

[0267] The text corresponding to the question-and-answer splicing sample is spliced ​​text, which includes: text formed by splicing the question text with the corresponding reply text.

[0268] The sixth embodiment of this application also provides a text recognition device, including:

[0269] The third text acquisition unit is used to acquire the text to be recognized;

[0270] A text recognition unit is used to input the text to be recognized into a text recognition model to obtain a recognition result of the text to be recognized, wherein the text recognition model is trained by the training device described in any one of the fifth embodiments.

[0271] Optionally, the text to be identified is text generated by a dialogue generation model;

[0272] Alternatively, the text to be identified may be the text formed by concatenating the user's question text and the text generated by the dialogue generation model, wherein the text recognition model is trained using the training method described in the first embodiment when the training samples include response samples and question-and-answer concatenation samples.

[0273] Corresponding to the training text generation method provided in the first embodiment of this application, the seventh embodiment of this application also provides an electronic device for generating training text. For example... Figure 6 As shown, the electronic device includes: a processor 901; and a memory 902 for storing a program for training the text generation method. After the device is powered on and the program for the data change response method is run through the processor, the following steps are performed:

[0274] Obtain guiding text, wherein the guiding text has the same semantic attributes as the target text, and the target text is the positive example text identified by the text recognition model;

[0275] The guiding text is input into a guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text;

[0276] The training text is determined based on the output text.

[0277] Corresponding to the text recognition model training method provided in the second embodiment of this application, the eighth embodiment of this application also provides an electronic device for training a text recognition model. The electronic device includes: a processor; and a memory for storing a program for training the text recognition model. After the device is powered on and the program for training the text recognition model is run through the processor, the following steps are executed:

[0278] Obtain training samples, which include positive samples and negative samples, and the text corresponding to the positive samples includes: training text generated by the training text generation method described in any one of the first embodiments;

[0279] The training samples are used to train the model to be trained, and a text recognition model is obtained.

[0280] Corresponding to the text recognition method provided in the third embodiment of this application, the ninth embodiment of this application also provides an electronic device for recognizing text. The electronic device includes: a processor; and a memory for storing a program for the text recognition method. After the device is powered on and the program for the text recognition method is run through the processor, the following steps are performed:

[0281] Obtain the text to be recognized;

[0282] The text to be recognized is input into the text recognition model to obtain the recognition result of the text to be recognized, wherein the text recognition model is trained by the training method described in any one of the second embodiments.

[0283] Corresponding to the training text generation method provided in the first embodiment of this application, the tenth embodiment of this application provides a computer-readable storage medium storing a program for a training text generation method. This program is executed by a processor to perform the following steps:

[0284] Obtain guiding text, wherein the guiding text has the same semantic attributes as the target text, and the target text is the positive example text identified by the text recognition model;

[0285] The guiding text is input into a guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text;

[0286] The training text is determined based on the output text.

[0287] It should be noted that for the detailed description of the apparatus, electronic device and computer-readable storage medium embodiments provided in the fourth to tenth embodiments of this application, please refer to the relevant descriptions of the first to third embodiments of this application, which will not be repeated here.

[0288] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

[0289] In a typical configuration, an electronic device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0290] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0291] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage media, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.

[0292] 2. 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 a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0293] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

Claims

1. A training text generation method, characterized by, The training text is used for training a to-be-trained model to obtain a text recognition model, and the method comprises: obtaining a guide text, the guide text being consistent with a semantic attribute of a target text, the target text being a positive example text recognized by the text recognition model, the guide text comprising at least one guide word, each guide word being consistent with the semantic attribute of the target text, the semantic attribute of the positive example text being a semantic sensitive text, the semantic attribute of the target text being a semantic sensitive text; inputting the guide text into a guide-based text generation model to obtain an output text consistent with the semantic attribute of the guide text; determining a training text according to the output text, comprising: determining a training text by a first strategy, the first strategy comprising: selecting a text containing at least one preset keyword from a plurality of the output texts as the training text, the preset keyword being consistent with the semantic attribute of the target text, the preset keyword comprising: each guide word; or determining a training text by a second strategy, the second strategy comprising: selecting a first text or a text at random from a plurality of the output texts as the training text; the probability of selecting the first strategy to determine the training text being a first preset probability, the probability of selecting the second strategy to determine the training text being a second preset probability, the first preset probability being greater than the second preset probability, and the sum of the first preset probability and the second preset probability being 1.

2. The method of claim 1, wherein, Before the guide text is input into the guide-based text generation model, the method further comprises: obtaining a question text; the guide text is input into the guide-based text generation model to obtain an output text consistent with the semantic attribute of the guide text, comprising: inputting the question text and the guide text into a guide-based dialogue generation model to obtain an output text for replying to the question text and consistent with the semantic attribute of the guide text.

3. The method of claim 2, wherein, The output text comprises a plurality of texts; determining a training text according to the output text, comprising: determining a training text from a plurality of the output texts.

4. The method of claim 1, wherein, The preset keyword further comprises: each first target word, the first target word being a word consistent with the semantic attribute of the target text and different from each guide word.

5. The method of claim 1, wherein, The first strategy further comprises: when none of the plurality of the output texts contains any of the preset keywords, selecting a first text in the plurality of the output texts to determine a training text.

6. The method according to any one of claims 1 to 5, characterized in that, The text recognition model is used for recognizing a text generated by a dialogue generation model. 7.A method for training a text recognition model, the method comprising: comprising: obtaining a training sample, the training sample comprising a positive example sample and a negative example sample, the text corresponding to the positive example sample comprising: a training text generated by the training text generation method in claim 6; training a to-be-trained model using the training sample to obtain a text recognition model.

8. The training method of claim 7, wherein, The training method further comprises: Obtain a first text, which is the text that the text recognition model misidentified, and the actual semantic attributes of the misidentified text are different from the semantic attributes that the text recognition model recognizes for the misidentified text; The first text is annotated to obtain the first sample; The text recognition model is optimized and trained using the first sample.

9. The training method of claim 8, wherein, Before optimizing the text recognition model using the first sample, the training method further includes: Obtain a second text, which contains a second target word, and the semantic attributes of the second text are opposite to those of the first text. The second target word is a word contained in the first text that is consistent with the semantic attributes expressed by the target text. The second text is annotated to obtain a second sample, the annotation information of which is opposite to that of the first sample; The step of optimizing and training the text recognition model using the first sample includes: The text recognition model is optimized and trained using the first sample and the second sample.

10. Training method according to any one of claims 7 to 9, characterized in that, The training samples include response samples and question-and-answer spliced ​​samples; The text corresponding to the positive sample in the response sample includes: text generated by the training text generation method described in claim 6; The text corresponding to the question-and-answer splicing sample is spliced ​​text, which includes: text formed by splicing the question text with the corresponding reply text.

11. A text recognition method characterized by, include: Obtain the text to be recognized; The text to be identified is input into the text recognition model to obtain the recognition result of the text to be identified, wherein the text recognition model is trained by the training method of any one of claims 7 to 10.

12. The text recognition method of claim 11, wherein, The text to be identified is the text generated by the dialogue generation model; Alternatively, the text to be identified may be the text formed by concatenating the user's question text with the text generated by the dialogue generation model.

13. A training text generation apparatus, characterized by comprising: The training text is used to train the model to obtain a text recognition model, and the apparatus includes: An information acquisition unit is used to acquire guiding text, wherein the guiding text has the same semantic attributes as the target text, the target text is a positive example text identified by the text recognition model, the guiding text includes at least one guiding word, each guiding word has the same semantic attributes as the target text, the positive example text has semantically sensitive text, and the target text has semantically sensitive text. The text generation unit is used to input the guiding text into the guiding text generation model to obtain output text that is consistent with the semantic attributes of the guiding text; A text determination unit is configured to determine training text based on the output text, comprising: determining training text using a first strategy, the first strategy comprising: selecting a text containing at least one preset keyword from a plurality of output texts as training text, the preset keyword being consistent with the semantic attributes of the target text, the preset keyword comprising: each of the lead words; or, determining training text using a second strategy, the second strategy comprising: selecting a first text from a plurality of output texts or randomly selecting a text as training text; the probability of determining the training text using the first strategy is a first preset probability, the probability of determining the training text using the second strategy is a second preset probability, the first preset probability is greater than the second preset probability, and the sum of the first preset probability and the second preset probability is 1.

14. An electronic device, comprising: include: processor; as well as A memory for storing a data processing program, which, when the electronic device is powered on and runs through the processor, executes the method as described in any one of claims 1-12.

15. A computer readable storage medium, characterized in that, The system contains a data processing program that is executed by a processor to perform the method as described in any one of claims 1-12.

Citation Information

Patent Citations

  • Text generation model training method and device and text generation method and device

    CN111783455A

  • Text classification model training method, device and equipment and storage medium

    CN111897964A

  • Controllable grounded text generation

    WO2021126388A1