CN115129866A - Training text generation method, model training device and electronic equipment - Google Patents

Training text generation method, model training device and electronic equipment Download PDF

Info

Publication number
CN115129866A
CN115129866A CN202210535272.6A CN202210535272A CN115129866A CN 115129866 A CN115129866 A CN 115129866A CN 202210535272 A CN202210535272 A CN 202210535272A CN 115129866 A CN115129866 A CN 115129866A
Authority
CN
China
Prior art keywords
text
training
guide
model
output
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210535272.6A
Other languages
Chinese (zh)
Inventor
王丽
宋有伟
张林箭
张聪
范长杰
胡志鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202210535272.6A priority Critical patent/CN115129866A/en
Publication of CN115129866A publication Critical patent/CN115129866A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Human Computer Interaction (AREA)
  • Machine Translation (AREA)

Abstract

The application discloses a training text generation method, a model training method, a text recognition method, device electronic equipment and a computer readable storage medium, wherein a training text is used for training a model to be trained to obtain a text recognition model, and the training text generation method comprises the following steps: acquiring a guide text, wherein the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text identified by the text identification 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. According to the method and the device, the output text is automatically generated through the text generation model based on guidance, so that the training text is determined, and the training text can be obtained more quickly and efficiently.

Description

Training text generation method, model training device and electronic equipment
Technical Field
The application relates to the technical field of computers, in particular to a training text generation method, a model training method, a training device and electronic equipment.
Background
The internet is an important tool for people to live and work, and as the openness of the internet is increased, the internet is flooded with a large amount of sensitive texts which are not suitable for being displayed to users, such as network messages of the users, conversation information of the users on chat software, information replied by conversation robots, and the like. To create a green chat environment, these sensitive texts need to be identified and filtered out in advance.
In the related art, sensitive text may be recognized using a text recognition model. However, the text recognition model needs to be trained through a large number of sensitive texts with different expressions in advance, and because a large number of sensitive texts are difficult to collect on the internet at present, the efficiency of manually writing the sensitive texts is low, and the number of manually writing the sensitive texts is limited, how to quickly and efficiently acquire the training texts to train the text recognition model is a problem to be solved.
Disclosure of Invention
The application provides a training text generation method, a model training method, a text recognition method, device electronic equipment and a computer readable storage medium, which can acquire a training text more quickly and efficiently so as to facilitate the training of a text recognition model. The specific scheme is as follows:
in a first aspect, the present application provides a method for generating a training text, where the training text is used to train a model to be trained to obtain a text recognition model, and the method includes:
acquiring a guide text, wherein the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text identified by the text identification 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.
Optionally, before the entering the guide text into the guide-based text generation model, the method further comprises:
obtaining a question 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, wherein the method comprises the following steps:
and inputting the question text and the guide text into a guide-based dialog generation model to obtain an output text which is used for replying the question text and is consistent with the semantic attribute of the guide text.
Optionally, the output text comprises a plurality of pieces;
the determining a training text according to the output text includes:
a training text is determined from a plurality of the output texts.
Optionally, the determining a training text from a plurality of the output texts includes:
determining a training text by a first strategy, the first strategy comprising: selecting a text containing at least one preset keyword from the output texts as a training text, wherein the preset keyword is consistent with the semantic attribute of the target text;
or determining the training text through a second strategy, wherein the second strategy comprises the following steps: and selecting a first text from the output texts or randomly selecting a text as a training text.
Optionally, the first strategy is selected to determine that the probability of the training text is a first preset probability, the second strategy is selected to determine that the probability of the training text 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.
Optionally, the first preset probability may range from 0.7 to 0.9, and the second preset probability may range from 0.1 to 0.3.
Optionally, the guide text comprises at least one guide word, and each guide word is consistent with the semantic attribute of the target text;
the preset keywords include: each of the lead words.
Optionally, the preset keywords further include: and each first target word is a word which is contained in any one of the output texts, has the semantic attribute consistent with that of the target text and is different from each guide word.
Optionally, the first policy further includes: and when the output texts do not contain any preset keyword, selecting a first output text of the output texts to determine a training text.
Optionally, the semantic attribute of the regular text is a semantically sensitive text, the semantic attribute of the target text is a semantically sensitive text, and the text recognition model is used for recognizing a text generated by the dialogue generation model.
In a second aspect, an embodiment of the present application further provides a method for training a text recognition model, including:
obtaining training samples, wherein the training samples comprise positive example samples and negative example samples, and texts corresponding to the positive example samples comprise: a training text generated by the training text generation method of any one of the first aspect;
and training the model to be trained by using the training sample to obtain a text recognition model.
Optionally, the training method further comprises:
acquiring a first text, wherein the first text is a text which is recognized by the text recognition model by errors, and the actual semantic attribute of the text which is recognized by the error recognition model is different from the semantic attribute recognized by the text recognition model for the text which is recognized by the error recognition model;
labeling the first text to obtain a first sample;
and performing optimization training on the text recognition model by using the first sample.
Optionally, before the optimally training the text recognition model by using the first sample, the training method further includes:
acquiring a second text, wherein the second text comprises a second target word, the semantic attribute of the second text is opposite to that of the first text, and the second target word is a word contained in the first text and consistent with the semantic attribute expressed by the target text;
labeling the second text to obtain a second sample, wherein the labeling information of the second sample is opposite to that of the first sample;
the optimally training the text recognition model using the first sample comprises:
optimally training the text recognition model using the first and second samples.
Optionally, the training samples include reply samples and question-answer splice samples;
the text corresponding to the normal sample in the reply sample comprises: a training text determined by the way in the first aspect in which the question text and the guide text are entered into a guide-based dialog generation model;
the text corresponding to the question-answer stitching sample is a stitching text, and the stitching text comprises: and splicing the question text and the reply text corresponding to the question text to form a text.
In a third aspect, an embodiment of the present application further provides a text recognition method, including:
acquiring a text to be recognized;
and inputting 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 obtained by training through the training method of any one of the first aspect.
Optionally, the text to be recognized is a text generated by a dialog generation model;
or the text to be recognized is formed by splicing a question text of a user and a text generated by a dialogue generating model, wherein the text recognition model is obtained by training through a model training method in the model training method of the second aspect when the training samples include a reply sample and a question-answer splicing sample.
In a fourth aspect, the present application further provides a training text generation apparatus, where the training text is used to train a model to be trained to obtain a text recognition model, and the apparatus includes:
the information acquisition unit is used for acquiring a guide text, the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text recognized by the text recognition model;
the text generation unit is used for 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 the text determining unit is used for determining a training text according to the output text.
Optionally, the apparatus further comprises:
the first text acquisition unit is used for acquiring a question text;
the text generation unit is specifically configured to: and inputting the question text and the guide text into a guide-based dialog generation model to obtain an output text which is used for replying the question text and is consistent with the semantic attribute of the guide text.
Optionally, the output text comprises a plurality of pieces;
the text determination unit is specifically configured to: a training text is determined from a plurality of the output texts.
Optionally, the text determining unit is specifically configured to:
determining a training text by a first strategy, the first strategy comprising: selecting a text containing at least one preset keyword from the output texts as a training text, wherein the preset keyword is consistent with the semantic attribute of the target text;
or determining the training text through a second strategy, wherein the second strategy comprises the following steps: and selecting a first text from the output texts or randomly selecting a text as a training text.
Optionally, the first strategy is selected to determine that the probability of the training text is a first preset probability, the second strategy is selected to determine that the probability of the training text 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.
Optionally, the first preset probability may range from 0.7 to 0.9, and the second preset probability may range from 0.1 to 0.3.
Optionally, the guide text comprises at least one guide word, and each guide word is consistent with the semantic attribute of the target text;
the preset keywords include: each of the lead words.
Optionally, the preset keywords further include: and each first target word is a word which is contained in any one of the output texts, has the semantic attribute consistent with that of the target text and is different from each guide word.
Optionally, the first policy further includes: and when the output texts do not contain any preset keyword, selecting a first output text of the output texts to determine a training text.
Optionally, the semantic attribute of the regular text is a semantically sensitive text, the semantic attribute of the target text is a semantically sensitive text, and the text recognition model is used for recognizing the text generated by the dialogue generation model.
In a fifth aspect, an embodiment of the present application further provides a training apparatus for a text recognition model, including:
the sample acquisition unit is used for acquiring training samples, the training samples comprise positive example samples and negative example samples, and texts corresponding to the positive example samples comprise: training texts generated by the training text generation device according to any one of the fourth aspect;
and the model training unit is used for training the model to be trained by using the training sample to obtain a text recognition model.
Optionally, the training device further comprises:
a second text acquisition unit, configured to acquire a first text, where the first text is a text recognized by the text recognition model as being incorrect, and an actual semantic attribute of the text recognized by the text recognition model is different from a semantic attribute recognized by the text recognition model for the text recognized as being incorrect;
the sample labeling unit is used for labeling the first text to obtain a first sample;
and the model optimization unit is used for performing optimization training on the text recognition model by using the first sample.
Optionally, the second text obtaining unit is further configured to:
acquiring a second text, wherein the second text comprises a second target word, the semantic attribute of the second text is opposite to that of the first text, and the second target word is a word contained in the first text and consistent with the semantic attribute expressed by the target text;
the sample labeling unit is further configured to: labeling the second text to obtain a second sample, wherein the labeling information of the second sample is opposite to that of the first sample;
the model optimization unit is specifically configured to: optimally training the text recognition model using the first and second samples.
Optionally, the training samples include reply samples and question-answer splice samples;
the text corresponding to the normal sample in the reply sample comprises: a training text determined by the way in the first aspect in which the question text and the guide text are entered into a guide-based dialog generation model;
the text corresponding to the question-answer stitching sample is a stitching text, and the stitching text comprises: and splicing the question text and the reply text corresponding to the question text to form a text.
In a sixth aspect, an embodiment of the present application further provides a text recognition apparatus, including:
the third text acquisition unit is used for acquiring a text to be recognized;
a text recognition unit, configured to input the text to be recognized into a text recognition model, so as to obtain a recognition result of the text to be recognized, where the text recognition model is obtained by training through the training apparatus according to any one of the fifth aspects.
Optionally, the text to be recognized is a text generated by a dialog generation model;
or the text to be recognized is formed by splicing a question text of a user and a text generated by a dialogue generating model, wherein the text recognition model is obtained by training when a training sample comprises a reply sample and a question-answer splicing sample by the training method of the first aspect.
In a seventh aspect, an embodiment of the present application further provides an electronic device, including:
a processor; and
a memory for storing a data processing program, the electronic device being adapted to perform the method according to any of the first aspect when powered on and run by said processor.
In an eighth aspect, an embodiment of the present application further provides an electronic device, including:
a processor; and
a memory for storing a data processing program, the electronic device being adapted to perform the method according to any of the second aspects after being powered on and running the program via the processor.
In a ninth aspect, an embodiment of the present application further provides an electronic device, including:
a processor; and
a memory for storing a data processing program, the electronic device performing the method according to any of the third aspects after being powered on and running the program via the processor.
In a tenth aspect, embodiments of the present application further provide a computer-readable storage medium, which stores a data processing program, where the program is executed by a processor to perform the method according to any one of the first aspect.
In an eleventh aspect, the present application further provides a computer-readable storage medium, which stores a data processing program, where the program is executed by a processor to perform the method according to any one of the second aspects.
In a twelfth aspect, embodiments of the present application further provide a computer-readable storage medium, which stores a data processing program, where the program is executed by a processor to perform the method according to any one of the third aspects.
Compared with the prior art, the method has the following advantages:
according to the method for generating the training text, after the guide text is input into the guide-based text generation model, the output text which is consistent with the semantic attribute of the guide text can be obtained, the semantic attribute of the guide text is consistent with that of the target text, and the target text is the regular example text recognized by the text recognition model, so that the obtained output text is also consistent with the semantic attribute of the regular example text recognized by the text recognition model, and the training text determined according to the obtained output text can be used as the regular example sample text to train the model to be trained.
According to the method and the device, the output text is automatically generated through the text generation model based on the guidance, so that the training text is determined, the training text can be obtained more quickly and efficiently, and the text generation model can generate abundant and various output texts, so that the diversity of the training text determined according to the output text is better, the recognition accuracy of the text recognition model obtained through training can be improved, and the text recognition model can recognize the regular text more accurately.
Drawings
Fig. 1 is a flowchart of a training text generation method provided in an embodiment of the present application;
fig. 2 is a flowchart of another example of a training text generation method according to an embodiment of the present application;
FIG. 3 is a flowchart of a text recognition model training method provided in an embodiment of the present application;
FIG. 4 is a flowchart illustrating another example of a text recognition model training method according to an embodiment of the present disclosure;
FIG. 5 is a block diagram of elements of a training text generation apparatus provided in an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device for implementing a training text generation method according to an embodiment of the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The intelligent chatting technology can automatically reply to the questions posed by the users, and the intelligent customer service and chatting machine thereof in the fields of e-commerce, public service and the like
The application is very wide in the fields of human and game chatting and the like.
For the user's question, the intelligent chat device may retrieve reply content corresponding to the user's question from a pre-stored question-and-answer database. Because the questions stored in the question-answer database are limited, for the questions not stored in the question-answer database, the method cannot give corresponding responses, so that the questions and answers cannot be smoothly performed with the user, the content of the responses is single, and the user experience is poor.
With the development of deep learning, the intelligent chat scene gradually starts to reply the problem of the user by using the dialogue generation model, so that the diversity of reply contents is greatly improved, continuous multiple rounds of chatting are supported, and the use experience of the user is better.
However, the dialog generation model is usually trained based on a large amount of sample data, which inevitably contains some sensitive texts, such as, for example, 35881, and the sensitive texts such as curse, violence, etc., so that the dialog generation model learns the expressions of the sensitive texts, which may result in the dialog generation model generating the sensitive texts and replying to the user. In order to create a green chat environment, the generated sensitive text needs to be identified and filtered out in advance.
In the related art, sensitive text may be filtered in a word or word-based manner. For example, text containing sensitive words such as "do", "you are you", "your" and the like is directly filtered out, and text such as "i want to do" and "you do" replied by the intelligent dialogue device is directly filtered out. Because most of texts containing the word 'do' are not sensitive texts, such as 'cook', 'do housework', 'do sports', and the like, a whitelist table is also established, and the texts in the whitelist table are not filtered. For example, putting "do housework" into the white list table, the intelligent dialogue device replies that "i do housework at home today" will not be filtered.
However, since the number of sensitive words is very large and the number of listed sensitive words is limited, many sensitive texts are omitted, so that many sensitive output texts cannot be filtered. Secondly, since the white list is also inexhaustible, many normal texts are filtered out, resulting in a degradation of the quality of the dialog. Furthermore, this approach can only filter out text showing the presence of sensitive words, and cannot filter out text that does not contain sensitive words but is semantically sensitive, such as "i want you".
In the related art, sensitive text can also be filtered in a regular expression-based manner. For example, when the person of the intelligent dialogue device is a child, the text replied by the intelligent dialogue device expresses that the child is about to be generated or that the child is sensitive text. In this case, the regular expression may be "raw. or" having. children ", where". matches any character except for the line break, ". indicates that 0 or more characters ahead are matched. When the intelligent dialogue device replies "cat mom has 2 children" and "you have 1 child", it is filtered out because the regular expression "live.
However, many sensitive texts cannot be identified because all sensitive regular expressions cannot be exhausted. In addition, many normal texts can be killed by mistake, for example, the above-mentioned "cat mother has 2 children". In addition, the regular expression mode can only filter out the text matched with the regular expression, and cannot filter out the implicit sensitive text unmatched with the regular expression.
In order to improve the recognition accuracy of the sensitive text, the sensitive text can be recognized by using a recognition model, wherein the recognition model is a depth model. However, the recognition model needs to be trained by taking a large number of sensitive texts with different expressions as samples in advance, and since a large number of sensitive texts are difficult to collect on the internet at present, and the number and diversity of manually written sensitive texts are limited, how to efficiently acquire a large number of training texts (such as sensitive texts) is a problem to be solved.
In order to acquire a large amount of training texts more quickly and efficiently, the present application provides a training text generation method, a text recognition model training method, a text recognition method, and apparatuses, electronic devices, and computer-readable storage media corresponding to the methods.
The first embodiment of the present application provides a method for generating a training text, where the training text is used to train a model to be trained, so as to obtain a text recognition model. In the embodiment of the application, the main execution body of the training text generation method is an electronic device, and the electronic device can be any electronic device with data processing capability, such as a desktop computer, a notebook computer, a tablet computer, a server, a mobile phone, and the like.
The model to be trained may include at least one of a bert model, a convolutional neural network, a logistic regression model, a K-nearest neighbor (KNN) model, a logistic regression model, and a binary model, or may be any other deep learning model.
The text recognition model can determine whether the text to be recognized is a positive case text or a negative case text, and can also be understood as a text classification model. The text recognition model can be used for recognizing Chinese texts and can also be used for recognizing foreign texts such as English, French and German.
The positive example text refers to text which the text recognition model needs to recognize, for example, the text recognition model is used for recognizing text containing a place name, then the text containing the place name is the positive example text, the text not containing the place name is the negative example text, and the text recognition model is used for recognizing text with sensitive semantics, then the text with sensitive semantics is the positive example text, and the text with non-sensitive semantics is the negative example text.
As shown in fig. 1, the training text generation method provided in the embodiment of the present application includes the following steps S110 to S130.
Step S110: and acquiring a guide text.
The semantic attributes of the guide text and the target text are consistent, and the target text is a regular text recognized by the text recognition model.
The guide text can be one or more sections of text, one or more sentences of text, one or more words, which can be single words, double words or multiple words, and the guide text can also be other forms of text. In the embodiment of the application, the guidance text can be manually set and then input into the electronic equipment, and the electronic equipment acquires the manually input guidance text; alternatively, the electronic device may automatically determine the guide text according to the target text, for example, the electronic device may automatically recognize a semantic attribute of the target text, and determine the guide text consistent with the semantic attribute according to the semantic attribute of the target text.
The guide text can be a Chinese text or a Chinese word, and can also be a foreign text or a foreign word such as English, German and the like.
The semantic attribute of the target text can be understood as the type of the target text to which the semantics belong. Specifically, the semantic attribute of the target text may be at least one of a semantic sensitive text, a classified text, a popular science text, an academic text and a medical knowledge text, and the semantic attribute of the target text may also be other specific semantic attributes.
For example, if the text recognition model is used to recognize a semantic sensitive text, the semantic attribute of the guide text may be the sensitive text, and if the trained text recognition model is used to recognize a confidential text, the semantic attribute of the guide text may be the confidential text.
Alternatively, the sensitive text may include violent text, yellow-related text, language attack text, or other unhealthy text.
For example, if the proper example text identified by the text recognition model is text with sensitive properties such as violence, yellow-related, or < 35881 >, or curse, the guide text may include one or more single-word or multi-word words with sensitive semantic properties such as violence, yellow-related, or < 35881 >, or curse.
The individual single word or multiple words contained in the guide text may be referred to as guide words, that is, the guide text contains one or more guide words, and each guide word is consistent with the semantic attributes of the target text. When the guide text contains one or more guide words, the semantics of the guide words are easier to acquire because the guide words are shorter, so that when the guide text contains the guide words, the generation of the text consistent with the semantic attributes of the guide words based on the guide text generation model is more convenient.
The number of the guide words contained in the guide text can range from 5 to 15, for example, the number of the guide words contained in the guide text is 5, 8, 10, 12, 15, and the like. The number of the guide words is not too large or too small, too large can cause the operation complexity of the guide-based text generation model to be too high, thereby affecting the output efficiency of the output text, even the output text cannot be obtained due to wrong operation, and too small can cause the semantic attribute difference between the output text and the target text to be larger.
The guide word can be used as a prefix text, the prefix text refers to a word which is not changed when the training text generation method is carried out each time, the semantic meaning of the prefix text is more stable, and the guide performance is stronger. That is to say, for training samples generating the same semantic attribute, when a text is generated by the training text generation method provided by the present application each time, the prefix text is not changed, so that the training text obtained each time is consistent with the semantic attribute of the prefix text.
Step S120: and inputting the guide text into a guide-based text generation model to obtain an output text consistent with the semantic attributes of the guide text.
The above-mentioned guidance-based text generation model is a pre-trained model. In the embodiment of the application, the depth models such as neural network models such as the ELMO, OpenAIGPT, BERT, OpenAIGPT-2 and the like can be trained based on the guide sample and the text sample corresponding to the guide sample, so that a text generation model based on the guide can be obtained. The guide samples and the text samples can be obtained and labeled from the data such as the articles on the novel, the script, the magazine or the journal, and the like, and a person skilled in the art can train according to a conventional model training method to obtain a text generation model based on the guide, which is not described in detail in the application.
Step S130: and determining a training text according to the output text.
In step S130, the output text may be directly determined as a training text, or a sentence may be expanded according to the output text to obtain an expanded text having a semantic attribute consistent with that of the output text, and the output text and the expanded text may be determined as training samples, or a training text may be determined in other manners according to the output text.
In the embodiment of the application, because the semantic attributes of the guide text are consistent with those of the regular text recognized by the text recognition model, when the semantic attributes of the obtained output text are consistent with those of the guide text, the semantic attributes of the regular text recognized by the text recognition model are also consistent with those of the sample text determined according to the output text.
For example, when the semantic attribute of the guide text is \35881;, the semantic attribute of the output text is also \35881;, the text of the cursive attribute, the semantic attribute of the training text determined from the output text is also \35881;, the text of the cursive attribute, therefore, the training text can be used as the text corresponding to the normal case sample to train the model to be trained, thereby enabling the trained text recognition model to recognize the text of the cursive attribute \\35881;, the text of the cursive attribute, i.e., the normal case text.
According to the method and the device, the output text is automatically generated through the text generation model based on the guidance, so that the training text is determined, the training text can be obtained more quickly and efficiently, and the text generation model can generate abundant and various output texts, so that the diversity of the training text determined according to the output text is better, the recognition accuracy of the text recognition model obtained through training can be improved, and the text recognition model can recognize the regular text more accurately.
In one embodiment, as shown in fig. 2, before step S120, the following step S140 may be further included.
Step S140: and obtaining the question text.
Step S120 may be implemented as following step S121.
Step S121: and inputting the question text and the guide text into a dialogue generating model based on guide to obtain an output text which is used for replying the question text and is consistent with the semantic attributes of the guide text.
The question text is obtained through novel segments, line script, social media chat records and the like. The question text serves as text for the user to ask a question. The questioning text can be questioning text such as ' asking for a few points ', ' where the company address is ', etc., and the questioning text can also be chatty text such as ' congratulating you, ' we are good friends ' and ' good weather '. The question text can be a sentence text or a multi-sentence text.
The questioning text may be text entered into the electronic device by the user or may be text selected by the electronic device from a stored text library.
In the present embodiment, the text generation model in step S120 is the dialogue generation model in step S121.
The guidance-based dialog generation model may train a depth model based on the question sample, the guide sample, and the reply sample corresponding to the guide sample and the question sample, thereby obtaining a guidance-based text generation model. The questioning sample, the guidance sample and the reply sample can be obtained and labeled from the data such as novel, lines script, chat data of social media and the like, and a person skilled in the art can train according to a conventional model training method to obtain a text conversation model based on guidance, and the detailed description is omitted in the application.
In the embodiment, the output text is generated through the guided dialog generation model, and the output text is the reply to the question text, so that the output text is more consistent with the contents automatically replied by the intelligent chat device, and thus after the training text is determined according to the output text, the text recognition model trained on the training text is more suitable for recognizing the chat information automatically generated by the intelligent chat device and is also more suitable for recognizing the reply text generated by the intelligent chat device through the dialog generation model. Thus, when the intelligent chat device generates unhealthy sensitive text, such as, for example, \35881, expletions, violence, etc., via the conversation generation model, the text recognition model can more accurately recognize the sensitive text generated by the conversation generation model.
Alternatively, the output text derived based on the guided dialog generation model may include a piece of text, in which case the piece of output text may be determined as a training sample.
In one embodiment, the output text may include a plurality of pieces, and step S130 may be implemented as the following step S131: a training text is determined from the plurality of output texts.
The output text comprises a plurality of pieces, i.e. a plurality of pieces of output text is derived by the guidance-based text generation model.
Alternatively, as shown in fig. 2, the training text may be determined from the plurality of output texts as the following step S131 a.
Step S131 a: and selecting a text containing at least one preset keyword from the output texts to determine the text as a training text.
In this embodiment of the application, the manner of determining the training text in step S131a may be determined as the first policy.
And the semantic attributes of the preset keywords are consistent with those of the target text. The preset keyword may be a word input by a user, and the preset keyword may include one or more words. For example, when the regular text recognized by the text recognition model is semantically sensitive text, the preset keywords may include: groaning, beating, handing over, fulling, etc. semantically sensitive words.
When more than one text containing the preset keywords exists in the output texts, the output texts each containing the preset keywords can be determined as the training texts, the first one of the output texts each containing the preset keywords can be determined as the training texts, or the output text containing the largest number of the preset keywords can be determined as the training text.
In this embodiment, because the preset keywords are consistent with the semantic attributes of the regular example text recognized by the text generation model, the output text containing the preset keywords is more easily consistent with the semantic attributes of the regular example text recognized by the text generation model, and thus, the accuracy of recognizing the regular example text by the text recognition model obtained through training is higher by taking the output text containing the preset keywords as the training text.
Alternatively, as shown in fig. 2, the training text may also be determined from the plurality of output texts in the following step S131b or step S131 c.
Step S131 b: a first piece of text selected from the plurality of pieces of output text is determined as a training text.
In this embodiment, the manner of determining the training text in step S131b may be used as the second policy.
Because the matching degree of the first output text in the output texts and the guide text is higher, the accuracy of recognizing the regular example text by the trained text recognition model can be higher by selecting the first output text as the training text to train the model to be trained.
Step S131 c: randomly selecting one text from the output texts to determine the selected text as the training text.
In this embodiment, each output text may be determined as a training text, or each output text may be displayed so that the user can select from the output texts, and then the text selected by the user is determined as the training text. The manner in which the training text is determined from the plurality of output texts is not specifically limited by the present application.
In the embodiment, the output text obtained by the text model based on the semantics comprises a plurality of output texts, so that the output text which is more consistent with the semantic attribute of the target text can be flexibly determined from the plurality of output texts as the training text, the determined training text is more consistent with the semantic attribute of the target text, and the text recognition model determined by the training text can more accurately recognize the text of the positive case.
In an embodiment, as shown in fig. 2, the first policy is selected to determine that the probability of the training text is a first preset probability, the second policy is selected to determine that the probability of the training text is a second preset probability, the first preset probability is greater than the second preset probability, and a sum of the first preset probability and the second preset probability is 1.
That is, in the present embodiment, the first policy determination training text is selected with a first preset probability, and the second policy determination training text is selected with a second preset probability.
The first preset probability is greater than the second preset probability, the first preset probability and the second preset probability are respectively 0.8 and 0.2, the first preset probability and the second preset probability are respectively 0.9 and 0.1, the first preset probability and the second preset probability are respectively 0.6 and 0.4, and 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.
In one embodiment, the first predetermined probability may range from 0.7 to 0.9, and the second predetermined probability may range from 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, the difference between the first predetermined probability and the second predetermined probability is relatively large. Generally speaking, the probability that the semantic attributes of the output text containing the preset keywords are consistent with the semantic attributes of the target text is higher than the probability that the semantic attributes of the output text containing no preset keywords are consistent with the semantic attributes of the target text, so that the first preset probability is higher than the second preset probability, the semantic attributes of the obtained training text can be made to be consistent with the semantic attributes of the target text to a greater extent, the diversity of the obtained training text can be better, and the text recognition model trained through the training text can accurately recognize more various formal texts.
Because the number of the preset keywords is limited, each preset keyword hardly contains all words consistent with the semantic attributes of the target text, and therefore, even if the output text does not contain any preset keywords, the output text is also possibly consistent with the semantic attributes of the target text. Because the probability that the semantic attributes of the first output text are consistent with the semantic attributes of the target text is relatively high, no matter whether the first output text contains preset keywords, the first output text is also possibly consistent with the semantic attributes of the target text, in this embodiment, the first output text is selected as the training text with a second relatively low preset probability, so that training texts which do not contain the preset keywords but are consistent with the semantic attributes of the target text can be added, the diversity of the training texts is better, and the trained text recognition model can recognize more diversified regular texts.
When the output text contains the preset keywords, the probability that the semantic attributes of the output text are consistent with those of the target text is high, so that the output text containing at least one preset keyword is determined as the training text with a high first preset probability, the semantic attributes of the determined training text and the target text can be more consistent, and the text recognition model obtained through training of the training text can more accurately recognize the regular text.
The preset keyword may include each of the guide words. Because the semantics of the guide words contained in the guide text are consistent with those of the target text, the guide words are directly determined as the preset keywords, and the preset keywords are quickly obtained.
In a specific embodiment, the preset keywords may further include first target words, where the first target words are words included in any output text, are consistent with semantic attributes of the target text, and are different from the guide words.
In this embodiment, a plurality of output texts may be displayed, so that a user can view each output text. After the user views each output text, words which are consistent with the semantic attributes of the target text and different from each lead word can be found out from each output text, and the found words are input into the electronic equipment, so that the electronic equipment can obtain the words which are found out and input by the user.
Because the output text is generated based on the guide text, the output text has a high probability of being consistent with the semantic attribute of the target text, and therefore, the output text has a high probability of containing words with the semantic attribute consistent with the semantic attribute of the target text, so that words which are consistent with the semantic attribute of the target text and different from all the guide words are probably screened out from the output text.
Because the number of leading words is limited, determining whether the output text is training text based on whether the output text contains leading words may filter out some text that contains other words that are semantically consistent with the target text. The first target word is determined as the preset keyword in the embodiment, the preset keyword is supplemented, the preset keyword is richer and more diverse, and therefore the text consistent with the target text in the output text is not easy to miss, and the training sample is more abundant.
In a specific embodiment, after the step S131a, the following step S131c may be further included.
Step S131 c: and when each of the output texts does not contain any preset keyword, determining a first output text in the output texts as a training sample.
In the embodiment of the present application, the manner in which the training texts are determined in steps S131a and S131c may be jointly determined as the first policy.
According to the embodiment, the number of the acquired texts with the semantic attributes consistent with those of the target text can be increased.
In the embodiment of the present application, the user may perform steps S110 to S130 multiple times, where the guidance text in each time of performing is consistent with the semantic attribute of the regular text recognized by the text generation model, but the guidance text in each time of performing is not completely the same, for example, the guidance text in each time of performing may be partially different or completely different, so that more different training texts may be obtained by performing the multiple training text generation method. The text recognition model trained by the training text can be used for recognizing \35881, cursory, yellow and other sensitive texts. Therefore, various training texts can be generated by the method provided by the application.
As shown in fig. 3, a second embodiment of the present application provides a method for training a text recognition model, which includes the following steps S510 to S520.
Step S510: training samples are obtained.
The training samples comprise positive samples and negative samples, and the texts corresponding to the positive samples comprise: a training text generated by the training text generation method described in any one of the first embodiments.
In this embodiment of the application, the training text generated by the training text generation method described in any one of the first embodiments may be marked as a positive example sample, so as to obtain the positive example sample.
The text corresponding to the negative example sample can be obtained from the materials such as novel, magazine, web page and the like. The text corresponding to the negative examples has the opposite semantic property from the text corresponding to the positive examples. For example, if the text corresponding to the positive example is a text with sensitive semantics, the text corresponding to the negative example is a text with insensitive semantics, and if the text corresponding to the positive example is a text containing a name of a person, the text corresponding to the negative example is a text without the name of the person.
When the text recognition model is used to recognize whether the text generated by the dialog generation model is sensitive text, the text corresponding to the normal sample may further include: third text determined from the sensitive text filtered out of the historical chat information. For example, for an intelligent chat system, the intelligent chat system may have been operated for a period of time, a part of texts have been filtered in the operation process through a regular expression-based filtering manner, a word or word-based filtering manner, and the like, and the probability that the filtered texts are sensitive texts is very high, so that a large amount of sensitive texts can be quickly obtained from the filtered sensitive texts.
Specifically, a sensitive third text may be manually selected from the filtered sensitive texts, and the electronic device determines the manually selected third text as a text corresponding to the text sample, and marks the text sample with the third text.
The text corresponding to the positive example sample may further include: and fourth text determined from the text not filtered out from the historical chat information. The text which is not filtered in the historical chat information may also contain sensitive text, so that a sensitive fourth text can be manually selected from the text which is not filtered, the electronic device determines the manually selected fourth text as the text corresponding to the text sample, and marks the text sample with the fourth text.
A large number of sample samples can be obtained quickly through the method.
When the text recognition model is used to recognize whether the text generated by the dialog generation model is sensitive text, the text corresponding to the negative example may include: text determined from text not filtered from the historical chat information. Because the proportion of the non-sensitive texts in the historical chat information is larger and the number of the non-sensitive texts is larger, the texts determined from the text which is not filtered are basically the non-sensitive texts, so that a large number of non-sensitive texts, namely the texts corresponding to the negative examples, can be conveniently obtained. The electronic device can mark text corresponding to the negative examples as negative examples.
Step S520: and training the model to be trained by using the training sample to obtain a text recognition model.
The specific type of the model to be trained may refer to the description of the first embodiment, and is not described herein again.
In the embodiment of the application, the text corresponding to the positive example sample and the text corresponding to the negative example sample may be input into the model to be trained and encoded, the encoded texts are classified by using a two-classifier, the classification result is the positive example text (for example, a sensitive text and a text containing a name of a person) or the negative example text (for example, a non-sensitive text and a text not containing a name of a person), and the obtained classification result is compared with the labeling information of the texts corresponding to the positive example sample and the negative example sample, so as to adjust each parameter of the model to be trained.
During the training process, the loss function can be a general two-class cross entropy loss function.
In the embodiment of the application, the model to be trained may include a text coding model and a classification model.
The training method for the text recognition model provided by the application adopts the training text generation method described in the first embodiment to generate the text corresponding to the normal example sample, so that the method has the beneficial effects corresponding to the first embodiment, and the details are not repeated here.
In an embodiment, as shown in fig. 4, the training method may further include the following steps S530 to S540.
Step S530: and acquiring a first text, and labeling the first text to obtain a first sample.
The first text is a text which is recognized by a text recognition model to be wrong, and the actual semantic attribute of the text which is recognized by the wrong recognition model is different from the semantic attribute recognized by the text recognition model for the text which is recognized by the wrong recognition model. For example, the actual semantic attribute of the word "cao is a history character of three kingdoms" is a non-sensitive semantic, and the text recognition model recognizes an incorrect text if the semantic attribute recognized by the text recognition model is a sensitive semantic.
Step S540: and optimally training the text recognition model by using the first sample.
Specifically, the first text is a text which is recognized by the trained text recognition model in error in the process of executing text recognition, and the text recognized by the text recognition model can be manually checked to find the text which is recognized by error.
In the present application, the first text may be labeled manually, for example, as a positive example or a negative example.
In this embodiment, the text recognition model may be optimally trained at a preset time interval, where the preset time interval may be one month, two months, or other time intervals. Alternatively, the text recognition model may be optimally trained in response to user-triggered optimization instructions.
The text recognition model is optimally trained by the text which is recognized wrongly by the text recognition model, so that the recognition accuracy of the text recognition model can be further improved.
In a specific embodiment, as shown in fig. 4, before the step of optimally training the text recognition model by using the first sample, the training method may further include the following step S550.
Step S550: and acquiring a second text, and labeling the second text to obtain a second sample.
The second text comprises a second target word, the semantic attributes of the second text are opposite to those of the first text, and the second target word is a word contained in the first text and consistent with the semantic attributes of the target text. The second sample is the inverse of the label information of the first sample.
The above step S540 may be implemented as the following step S541.
Step S541: the text recognition model is optimally trained using the first and second samples.
In this embodiment, the second sample may be determined manually, and the second sample may be input to the electronic device, so that the electronic device obtains the second sample.
For example, for a scenario where a text recognition model is used to recognize sensitive text, the first text that the text recognition model predicts incorrectly is "canada is three famous characters", the text recognition model predicts it as sensitive text, but the first text is actually non-sensitive text, so "canadum three famous characters" is marked as sensitive text, i.e., marked as a positive example, the word contained in the first text that is consistent with the semantic attribute expressed by the target text is "operation", that is, "gyo" is the second target word, the second text containing "gyo" and having semantic attributes opposite to those of the non-sensitive text "caocho is three famous characters" may be "how do you want", the second text is the sensitive text, which is opposite to the semantic property of the first text, then mark "how you want to do" as non-sensitive text, i.e. as a negative example sample.
Since "caochao" is a semantically sensitive word "cao" contained in three famous characters ", the text recognition model recognizes the sentence as a sensitive text. In the embodiment, when the 'cao is three famous characters' and is marked as the non-sensitive text for the model optimization training, the model is easy to consider the text containing the 'jo' as the non-sensitive text, in this case, in order to avoid overfitting the model to certain words, some second samples which are opposite to the labeling information of the first sample and contain the second target word 'jo' can be added, the model is optimized and trained through the first sample and the second sample, the phenomenon that the model is overfitting to certain words is better avoided, and the accuracy of model identification is improved.
In one embodiment, the training samples may include reply samples and question and answer splice samples.
The text corresponding to the normal sample in the reply sample comprises: generating a text through the guidance-based dialog generation model; the text corresponding to the question-answer splicing sample is a spliced text, and the spliced text comprises the following steps: and splicing the question text and the reply text corresponding to the question text to form a text.
In this embodiment, the text corresponding to the positive example in the reply sample may further include: reply text obtained from the intelligent chat device, reply text determined from the dialog of a novel or script, and the like.
The text corresponding to the negative examples in the reply sample may include: the text determined from the resources such as novel, script, web article, etc., the text corresponding to the negative example sample in the reply sample may further include: text generated by a dialog generation model.
The user can manually label the positive examples and the negative examples in the reply examples.
In this embodiment, the text corresponding to the reply sample is used to represent a reply to a question asked by the user.
The spliced text can reflect information obtained by splicing the problem of the user and the reply of the replier.
The dialogue information can be manually obtained from resources such as novel, script, network articles and the like, and the question text and the reply text corresponding to the question text are obtained from the dialogue information.
Alternatively, a reply text corresponding to the question text may be generated by the dialogue generating model, and the question text and the text generated by the dialogue generating model may be determined as the reply text.
For example, if the question text is "do you want me", and the reply text is "i want you", then the concatenation text may be "do you want me, i want you".
Since some users may be deliberately chatting about some sensitive topics, this time the text replied by the chat device may not be sensitive text if it is recognized separately, but it may appear to be sensitive text to connect the user's question with the reply of the smart reply device. If the user asks for a question of ' do you want me ', the chatting device replies with ' kah-me ', the reply text ' kah-me ', which is not sensitive text, but ' do you want me, kah-me ', which is sensitive text '. In the embodiment, the question-answer splicing sample is used as the training sample, so that the text recognition model obtained by training can be used for recognizing the question-answer splicing text, the application range of the text recognition model is wider, and more types of the recognized target text are provided.
In the second embodiment, the explanation mainly deals with the parts different from the first embodiment, and the content of the parts same as or similar to the first embodiment is not repeated.
A third embodiment of the present application provides a text recognition method, including the steps of:
acquiring a text to be recognized;
and inputting the text to be recognized into a text recognition model to obtain a recognition result of the text to be recognized.
The text recognition model is obtained by training through the training method in any one of the second embodiment.
The text to be recognized may be a text generated by a dialog generation model.
The text to be recognized may also be formed by splicing a question text of the user and a text generated by the dialog generation model. In this case, the training samples for training the text recognition model include the reply sample and the question-answer concatenation sample.
The text to be recognized may also be a network message, dialog information on a chat tool, a text in a network article, or the like, and the specific content of the text to be recognized is not limited in the present application.
The method in the prior art comprises a sensitive word recognition method and a rule-based recognition method, and the text recognition method provided by the application can be used for well recognizing the obscure sensitive text, is not easy to cause misjudgment, and has higher recognition accuracy of the sensitive text.
The text recognition model in the text recognition method of the third embodiment is obtained by training with the method provided by the second embodiment, so that the embodiment has similar beneficial effects to the second embodiment, and details are not repeated here.
In the third embodiment, the parts different from the first embodiment and the second embodiment are mainly explained, and the content of the parts same as or similar to the first embodiment and the second embodiment is not repeated.
As shown in fig. 5, a fourth embodiment of the present application further provides a training text generation apparatus, where the training text is used to train a model to be trained to obtain a text recognition model, and the apparatus includes:
an information obtaining unit 810, configured to obtain a guide text, where the guide text is consistent with a semantic attribute of a target text, and the target text is a regular text recognized by the text recognition model;
a text generating unit 820, configured to input the guidance text into a guidance-based text generating model, and obtain an output text that is consistent with semantic attributes of the guidance text;
a text determining unit 830, configured to determine a training text according to the output text.
Optionally, the apparatus further comprises:
the first text acquisition unit is used for acquiring a question text;
the text generation unit is specifically configured to: and inputting the question text and the guide text into a guide-based dialog generation model to obtain an output text which is used for replying the question text and is consistent with the semantic attribute of the guide text.
Optionally, the output text comprises a plurality of pieces;
the text determination unit is specifically configured to: training text is determined from a plurality of the output texts.
Optionally, the text determining unit is specifically configured to:
determining training text through a first strategy, wherein the first strategy comprises the following steps: selecting a text containing at least one preset keyword from the output texts as a training text, wherein the preset keyword is consistent with the semantic attribute of the target text;
or determining the training text through a second strategy, wherein the second strategy comprises the following steps: and selecting a first text from the output texts or randomly selecting a text as a training text.
Optionally, the first strategy is selected to determine that the probability of the training text is a first preset probability, the second strategy is selected to determine that the probability of the training text 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.
Optionally, the first preset probability may range from 0.7 to 0.9, and the second preset probability may range from 0.1 to 0.3.
Optionally, the guide text comprises at least one guide word, and each guide word is consistent with the semantic attribute of the target text;
the preset keywords comprise: each of the guidance words.
Optionally, the preset keyword further includes: and each first target word is a word which is contained in any one of the output texts, has the semantic attribute consistent with that of the target text and is different from each guide word.
Optionally, the first policy further includes: and when the output texts do not contain any preset keyword, selecting a first output text of the output texts to determine a training text.
Optionally, the semantic attribute of the regular text is a semantically sensitive text, the semantic attribute of the target text is a semantically sensitive text, and the text recognition model is used for recognizing the text generated by the dialogue generation model.
The fifth embodiment of the present application further provides a training apparatus for a text recognition model, including:
the system comprises a sample obtaining unit, a training sample obtaining unit and a text matching unit, wherein the training sample obtaining unit is used for obtaining a training sample, the training sample comprises a positive sample and a negative sample, and a text corresponding to the positive sample comprises: a training text generated by the training text generation apparatus according to any one of the fourth embodiments;
and the model training unit is used for training the model to be trained by using the training sample to obtain a text recognition model.
Optionally, the training device further comprises:
a second text acquisition unit, configured to acquire a first text, where the first text is a text recognized by the text recognition model as being incorrect, and an actual semantic attribute of the text recognized by the text recognition model is different from a semantic attribute recognized by the text recognition model for the text recognized as being incorrect;
the sample labeling unit is used for labeling the first text to obtain a first sample;
and the model optimization unit is used for performing optimization training on the text recognition model by using the first sample.
Optionally, the second text obtaining unit is further configured to:
acquiring a second text, wherein the second text comprises a second target word, the semantic attribute of the second text is opposite to that of the first text, and the second target word is a word contained in the first text and consistent with the semantic attribute of the target text;
the sample labeling unit is further configured to: labeling the second text to obtain a second sample, wherein the labeling information of the second sample is opposite to that of the first sample;
the model optimization unit is specifically configured to: optimally training the text recognition model using the first and second samples.
Optionally, the training samples include a reply sample and a question-answer concatenation sample;
the text corresponding to the normal sample in the reply sample comprises: training texts determined in a manner that the questioning texts and the guide texts are input into a guide-based dialogue generating model in the first embodiment;
the text corresponding to the question-answer stitching sample is a stitching text, and the stitching text comprises: and splicing the question text and the reply text corresponding to the question text to form a text.
The sixth embodiment of the present application further provides a text recognition apparatus, including:
the third text acquisition unit is used for acquiring a text to be recognized;
a text recognition unit, configured to input the text to be recognized into a text recognition model, so as to obtain a recognition result of the text to be recognized, where the text recognition model is obtained by training through the training apparatus according to any one of the fifth embodiments.
Optionally, the text to be recognized is a text generated by a dialog generation model;
or the text to be recognized is a text formed by splicing a question text of the user and a text generated by a dialogue generating model, wherein the text recognition model is obtained by training through the training method in the first embodiment when the training samples comprise a reply sample and a question-answer splicing sample.
Corresponding to the training text generation method provided in the first embodiment of the present application, a seventh embodiment of the present application further provides an electronic device for generating a training text. As shown in fig. 6, the electronic apparatus includes: a processor 901; and a memory 902 for storing a program of a training text generation method, wherein the apparatus executes the following steps after being powered on and the program of the data change response method is executed by the processor:
acquiring a guide text, wherein the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text identified by the text identification 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.
Corresponding to the training method of the text recognition model provided in the second embodiment of the present application, an eighth embodiment of the present application further provides an electronic device for training a text recognition model. The electronic device includes: a processor; and a memory for storing a program of a training method of a text recognition model, the apparatus performing the following steps after being powered on and running the program of the training method of the text recognition model by the processor:
obtaining training samples, wherein the training samples comprise positive example samples and negative example samples, and texts corresponding to the positive example samples comprise: a training text generated by the training text generation method described in any one of the first embodiments;
and training the model to be trained by using the training sample to obtain a text recognition model.
Corresponding to the text recognition method provided in the third embodiment of the present application, a ninth embodiment of the present application further provides an electronic device for recognizing a text. The electronic device includes: a processor; and a memory for storing a program of a text recognition method, the apparatus performing the following steps after being powered on and running the program of the text recognition method by the processor:
acquiring a text to be identified;
and inputting 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 obtained by training through the training method in any one of the second embodiments.
A tenth embodiment of the present application provides, in correspondence with the training text generation method provided in the first embodiment of the present application, a computer-readable storage medium storing a program of the training text generation method, the program being executed by a processor to perform the steps of:
acquiring a guide text, wherein the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text identified by the text identification 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.
It should be noted that for the embodiments of the apparatus, the electronic device, and the computer-readable storage medium provided in the fourth embodiment to the tenth embodiment of the present application, reference may be made to the relevant descriptions of the first embodiment to the third embodiment of the present application for detailed description, and details are not repeated here.
Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application, and those skilled in the art can make variations and modifications without departing from the spirit and scope of the present application, therefore, the scope of the present application should be determined by the claims that follow.
In a typical configuration, an electronic device includes one or more processors (CPUs), input/output interfaces, a network interface, and a memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
1. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, 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), random access memory of other nature (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage media, or any other non-transmission medium which can be used to store information which can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
2. As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application, and those skilled in the art can make variations and modifications without departing from the spirit and scope of the present application, therefore, the scope of the present application should be determined by the appended claims.

Claims (18)

1. A method for generating a training text is characterized in that the training text is used for training a model to be trained to obtain a text recognition model, and the method comprises the following steps:
acquiring a guide text, wherein the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text identified by the text identification 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.
2. The method of claim 1, wherein prior to the entering the guide text into a guide-based text generation model, the method further comprises:
obtaining a question 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, wherein the method comprises the following steps:
and inputting the question text and the guide text into a guide-based dialog generation model to obtain an output text which is used for replying the question text and is consistent with the semantic attribute of the guide text.
3. The method of claim 2, wherein the output text comprises a plurality of pieces;
the determining a training text according to the output text includes:
a training text is determined from a plurality of the output texts.
4. The method of claim 3, wherein determining a training text from the plurality of output texts comprises:
determining a training text by a first strategy, the first strategy comprising: selecting a text containing at least one preset keyword from the output texts as a training text, wherein the preset keyword is consistent with the semantic attribute of the target text;
or determining the training text through a second strategy, wherein the second strategy comprises the following steps: and selecting a first text from the output texts or randomly selecting a text as a training text.
5. The method according to claim 4, wherein selecting the first strategy determines the probability of the training text to be a first preset probability, selecting the second strategy determines the probability of the training text to be 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.
6. The method of claim 4, wherein the guide text comprises at least one guide word, each guide word being consistent with a semantic attribute of the target text;
the preset keywords include: each of the guidance words.
7. The method of claim 6, wherein the preset keywords further comprise: and each first target word is a word which is consistent with the semantic attribute of the target text and is different from each leading word.
8. The method of claim 4, wherein the first policy further comprises: and when the output texts do not contain any preset keyword, selecting a first output text of the output texts to determine a training text.
9. The method according to any one of claims 1 to 8, wherein the semantic attribute of the regular text is a semantically sensitive text, the semantic attribute of the target text is a semantically sensitive text, and the text recognition model is used for recognizing the text generated by the dialogue generation model.
10. A training method of a text recognition model is characterized by comprising the following steps:
obtaining training samples, wherein the training samples comprise positive example samples and negative example samples, and texts corresponding to the positive example samples comprise: a training text generated by the training text generation method of any one of claims 1 to 9;
and training the model to be trained by using the training sample to obtain a text recognition model.
11. The training method of claim 10, further comprising:
acquiring a first text, wherein the first text is a text which is recognized by the text recognition model and has an error, and the actual semantic attribute of the text which is recognized by the error is different from the semantic attribute recognized by the text recognition model for the text which is recognized by the error;
labeling the first text to obtain a first sample;
and performing optimization training on the text recognition model by using the first sample.
12. A training method as defined in claim 11, wherein prior to the optimally training the text recognition model using the first sample, the training method further comprises:
acquiring a second text, wherein the second text comprises a second target word, the semantic attribute of the second text is opposite to that of the first text, and the second target word is a word contained in the first text and consistent with the semantic attribute expressed by the target text;
labeling the second text to obtain a second sample, wherein the labeling information of the second sample is opposite to that of the first sample;
the optimally training the text recognition model using the first sample comprises:
optimally training the text recognition model using the first and second samples.
13. Training method according to any of claims 10 to 12, wherein the training samples comprise reply samples and question-answer splice samples;
the text corresponding to the normal sample in the reply sample comprises: a text generated by the training text generation method of any one of claims 2 to 8;
the text corresponding to the question-answer stitching sample is a stitching text, and the stitching text comprises: and splicing the question text and the reply text corresponding to the question text to form a text.
14. A text recognition method, comprising:
acquiring a text to be identified;
inputting 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 obtained by training through the training method of any one of claims 10 to 13.
15. The text recognition method according to claim 14, wherein the text to be recognized is a text generated by a dialogue generating model;
or, the text to be recognized is a text formed by splicing a question text of a user and a text generated by a dialogue generating model, where the text recognition model is obtained by training through the training method of claim 13.
16. A training text generation apparatus, wherein the training text is used for training a model to be trained to obtain a text recognition model, the apparatus comprising:
the information acquisition unit is used for acquiring a guide text, the semantic attributes of the guide text are consistent with those of a target text, and the target text is a regular text recognized by the text recognition model;
the text generation unit is used for 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 the text determining unit is used for determining a training text according to the output text.
17. An electronic device, comprising:
a processor; and
a memory for storing a data processing program which, when powered on and executed by said processor, performs the method of any one of claims 1 to 15.
18. A computer-readable storage medium, in which a data processing program is stored, which program, when executed by a processor, performs the method according to any one of claims 1-15.
CN202210535272.6A 2022-05-17 2022-05-17 Training text generation method, model training device and electronic equipment Pending CN115129866A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210535272.6A CN115129866A (en) 2022-05-17 2022-05-17 Training text generation method, model training device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210535272.6A CN115129866A (en) 2022-05-17 2022-05-17 Training text generation method, model training device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115129866A true CN115129866A (en) 2022-09-30

Family

ID=83376082

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210535272.6A Pending CN115129866A (en) 2022-05-17 2022-05-17 Training text generation method, model training device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115129866A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116542297A (en) * 2023-07-03 2023-08-04 深圳须弥云图空间科技有限公司 Method and device for generating countermeasure network based on text data training

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116542297A (en) * 2023-07-03 2023-08-04 深圳须弥云图空间科技有限公司 Method and device for generating countermeasure network based on text data training

Similar Documents

Publication Publication Date Title
US20200301954A1 (en) Reply information obtaining method and apparatus
CN110727779A (en) Question-answering method and system based on multi-model fusion
US20220343082A1 (en) System and method for ensemble question answering
Dong et al. A natural language question answering system as a participant in human Q&A portals
CN106649739B (en) Multi-round interactive information inheritance identification method and device and interactive system
CN110188189B (en) Knowledge-based method for extracting document abstract by adaptive event index cognitive model
CN112686051B (en) Semantic recognition model training method, recognition method, electronic device and storage medium
CN112632242A (en) Intelligent conversation method and device and electronic equipment
CN112287100A (en) Text recognition method, spelling error correction method and voice recognition method
CN116541504B (en) Dialog generation method, device, medium and computing equipment
CN114625858A (en) Intelligent government affair question-answer replying method and device based on neural network
CN112506945A (en) Self-adaptive learning guiding method and system based on knowledge graph
CN111639187B (en) Knowledge graph-based knowledge question and answer verification code generation system and method
CN112667796A (en) Dialog reply method and device, electronic equipment and readable storage medium
CN115714030A (en) Medical question-answering system and method based on pain perception and active interaction
CN111708870A (en) Deep neural network-based question answering method and device and storage medium
CN116821290A (en) Multitasking dialogue-oriented large language model training method and interaction method
CN115129866A (en) Training text generation method, model training device and electronic equipment
Sarmah et al. Survey on word sense disambiguation: an initiative towards an Indo-Aryan language
CN114004283A (en) Text anti-attack method, device, equipment and storage medium
CN113505786A (en) Test question photographing and judging method and device and electronic equipment
CN114372454A (en) Text information extraction method, model training method, device and storage medium
Liao et al. Status, identity, and language: A study of issue discussions in GitHub
CN115658845A (en) Intelligent question-answering method and device suitable for open-source software supply chain
CN113392196A (en) Topic retrieval method and system based on multi-mode cross comparison

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination