CN114861636A - Training method and device of text error correction model and text error correction method and device - Google Patents

Training method and device of text error correction model and text error correction method and device Download PDF

Info

Publication number
CN114861636A
CN114861636A CN202210506361.8A CN202210506361A CN114861636A CN 114861636 A CN114861636 A CN 114861636A CN 202210506361 A CN202210506361 A CN 202210506361A CN 114861636 A CN114861636 A CN 114861636A
Authority
CN
China
Prior art keywords
text
training
model
target
service object
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
CN202210506361.8A
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 CN202210506361.8A priority Critical patent/CN114861636A/en
Publication of CN114861636A publication Critical patent/CN114861636A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/232Orthographic correction, e.g. spell checking or vowelisation
    • 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
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • G06F40/35Discourse or dialogue representation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/088Non-supervised learning, e.g. competitive learning

Abstract

The application provides a training method and a device of a text error correction model and a text error correction method and a device, wherein the training method comprises the following steps: the method comprises the steps of firstly using general text data to carry out basic training on a language model, then using special text data in the target field to carry out fine tuning training on the language model, and then using a mature target service object in the target field to carry out interactive auxiliary training on a text error correction model in a data interaction mode with the target service object. Therefore, on the premise of not losing the generalized text error correction capability, the training model can be quickly adapted to the complex and unique language environment, and the text error correction accuracy of the model in the target field is improved. Correspondingly, the trained text error correction model can perform text error correction processing on the text data related to the target service object in the application process, and is beneficial to improving the operation efficiency of the target service object and the accuracy of the output result.

Description

Training method and device of text error correction model and text error correction method and device
Technical Field
The application relates to the technical field of deep learning, in particular to a training method and device of a text error correction model and a text error correction method and device.
Background
With the development of artificial intelligence technology, automated text error correction technology is emerging in various industries continuously and achieves remarkable results. However, with the advent of cultural diversity, language expressions with respective domain features have been derived in different business domains, for example, in the game domain, players often use "harmonic stems" to achieve a humorous language effect without losing the features of the game domain by using a character expression that looks wrong during the game.
In combination with the above, it can be seen that, because there is a contradiction between the generalization of the language expression in the general field and the pertinence in the special service field, the traditional text error correction model originally used only for correcting wrongly written words cannot be applied to the execution of the text error correction task in the special service field.
Disclosure of Invention
In view of this, an object of the present application is to provide a method and an apparatus for training a text error correction model, and a method and an apparatus for text error correction, so that on the premise of not losing the capability of generalized text error correction, the training model is quickly adapted to a more complex and unique language environment, thereby improving the accuracy of text error correction of the model in the target field.
In a first aspect, an embodiment of the present application provides a method for training a text error correction model, where the text error correction model is used to provide a text error correction service for a target service object in a target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the training method comprises the following steps:
pre-training the language model by using a first training text without semantic labels to obtain a first language representation model; wherein the first training text comprises specific text data in the target field and general text data outside the target field;
training the first language representation model by utilizing a semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability; the target text features are used for representing semantic features and/or character expression features of text data which are specific in the target field;
inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text;
and acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
In an optional implementation manner, the pre-training the language model by using the semantic tag-free first training text to obtain the first language representation model includes:
masking the participles with the first target number in the first training text in a random sampling mode to obtain a first masked training text comprising masked words with the first target number; wherein the first target number is determined according to the sampling proportion of the random sampling and the number of word segmentation included in the first training text;
inputting the first shielding training text into the language model to obtain a first shielding prediction text which is output by the language model and comprises prediction results of a first target number of shielding words;
and adjusting model parameters of the language model by using the cross entropy loss between the first occlusion prediction text and the first training text which is not subjected to mask occlusion until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
In an optional implementation manner, the pre-training the language model by using the semantic tag-free first training text to obtain the first language representation model further includes:
masking the participles belonging to the second target number of the specific text data in the first training text according to a first preset sampling proportion to obtain a second masked training text comprising masked words of the second target number; the second target quantity is determined according to the first preset sampling proportion and the number of word segments belonging to the specific text data in the first training text;
inputting the second occlusion training text into the language model to obtain a second occlusion predicted text which is output by the language model and comprises a prediction result of a second target number of occlusion words;
and adjusting model parameters of the language model by using the cross entropy loss between the second masking prediction text and the first training text which is not masked by the mask until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
In an optional embodiment, the training the first language representation model by using the semantically labeled second training text in the target domain at least comprises: performing coarse-grained training and/or fine-grained training on the first language representation model by using a semantically marked second training text in the target field; the coarse-grained training is used for training the first language representation model to classify different sentences under the same semantic concept in the second training text according to different character expression modes corresponding to the same semantic concept in the target field; and the fine-grained training is used for training the first language representation model to recognize the character expression mode of each sentence in the target field according to the word segmentation sequence marking result of each sentence in the second training text in the target field.
In an alternative embodiment, the coarse-grained training of the first language characterization model is performed by:
for any two sentences in the second training text, inputting the original version sentences of the any two sentences from which the existing semantic labels are removed into the first language representation model, and performing classification prediction on whether the any two sentences correspond to the same semantic concept in the target field through the first language representation model to obtain classification prediction results of the any two sentences;
determining real classification results of any two sentences according to the semantic labels of the any two sentences in the second training text; the real classification result is used for representing whether any two sentences correspond to the same semantic concept in the target field;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the classification prediction result and the real classification result until the first language representation model converges.
In an alternative embodiment, the fine-grained training of the first language characterization model is performed by:
for each sentence in the second training text, inputting the original version sentence of the sentence from which the semantic mark is removed into the first language representation model, and analyzing the sentence component of the sentence in the target field through the first language representation model to obtain a sentence analysis result of the sentence in the target field; wherein the sentence component comprises at least: a first target participle belonging to an entity defined in the target domain, and a second target participle capable of characterizing different semantic concepts in the target domain;
according to the multiple entities defined in the target field and the existing semantic tags in the sentence, carrying out sequence tagging on multiple participles in the sentence to obtain a participle sequence tagging result of the sentence;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the statement analysis result and the word segmentation sequence marking result until the first language representation model converges.
In an optional implementation manner, the inputting, to the second language representation model, a third training text input or output by the target service object in the training process to obtain a corrected training text output by the second language representation model after performing text error correction processing on the third training text includes:
for each sentence in the third training text, inputting the sentence into the second language representation model to obtain a first output result of the second language representation model for the sentence;
under the condition that the difference between the first output result and the sentence is detected, determining that the second language representation model carries out the text error correction processing on the sentence, and taking the first output result as the correction training text;
and under the condition that the first output result is detected to be the same as the sentence, acquiring the next sentence from the third training text, and repeating the processing steps aiming at the sentence until the corrected training text is obtained.
In an optional embodiment, after obtaining the corrected training text output by the second language representation model after performing text correction processing on the third training text, the training method further includes:
when the third training text belongs to text data input by the target service object in the training process, inputting the third training text into the target service object, and outputting to obtain an output result before correction;
and inputting the corrected training text into the target service object, and outputting to obtain the corrected output result.
In an alternative embodiment, the inputting the third training text into the target service object and outputting the output result before the correction includes:
inputting the third training text into the target service object, and predicting the output category of the third training text through the target service object to obtain the output result before correction; the output result before correction is used for representing the probability that the output category of the third training text belongs to each preset category;
the inputting the correction training text into the target service object and outputting to obtain the output result after correction includes:
inputting the corrected training text into the target service object, and predicting the output category of the corrected training text through the target service object to obtain the corrected output result; and the output result after correction is used for representing the probability that the output category of the corrected training text belongs to each preset category.
In an optional embodiment, the obtaining of the positive/negative deviations before and after the correction of the model output result of the target service object includes:
calculating a first deviation generated before and after the model output result of the target service object is corrected according to a first deviation calculation strategy;
determining whether the first deviation belongs to the positive deviation or the negative deviation based on the first deviation.
In an alternative embodiment, said calculating a first deviation of the model output result of the target service object before and after the correction according to the first deviation calculation policy includes:
and calculating a probability deviation value of the corrected output result and the output result before correction on the same preset category, and taking the calculation result as the first deviation.
In an optional embodiment, after obtaining the corrected training text output by the second language representation model after performing text correction processing on the third training text, the training method further includes:
when the third training text belongs to text data output by the target service object in the training process, taking the third training text as the output result before correction; and taking the corrected training text as the corrected output result.
In an optional embodiment, the obtaining of the positive/negative deviations before and after the correction of the model output result of the target service object includes:
calculating a second deviation generated before and after the model output result of the target service object is corrected according to a second deviation calculation strategy;
determining whether the second deviation belongs to the positive deviation or the negative deviation based on the second deviation.
In an optional embodiment, the calculating a second deviation of the model output result of the target service object before and after the correction according to the second deviation calculation strategy includes:
acquiring a standard text recognition result of target input data; wherein the target input data is used for characterizing model input data of the target service object when the target service object outputs the third training text in a training process;
calculating a text recognition deviation value between the third training text and the standard text recognition result, and taking the calculation result as a first text recognition deviation value;
calculating a text recognition deviation value between the corrected training text and the standard text recognition result, and taking the calculation result as a second text recognition deviation value;
and calculating a difference value between the first text recognition deviation value and the second text recognition deviation value, and taking a calculation result as the second deviation.
In an optional implementation manner, the adjusting the model parameters of the second language representation model according to the positive deviation/negative deviation to obtain a text error correction model including the adjusted model parameters includes:
in each training period of the second language representation model, acquiring a target positive deviation/negative deviation obtained by the target second language representation model trained based on the training period;
and adjusting the model parameters of the target second language representation model according to the target positive deviation/negative deviation, and obtaining the text error correction model comprising the adjusted model parameters when the target second language representation model meets a training cut-off condition.
In an alternative embodiment, the target second language characterization model at each training period is determined by:
when each training period of the second language representation model is reached, acquiring the second language representation model trained in the last training period, and generating a mirror image second language representation model which is not trained in the last training period;
under the training period, synchronously training the second language representation model trained in the last training period and the mirror image second language representation model which is not trained in the last training period to respectively obtain an optimized second language representation model and an optimized mirror image second language representation model trained in the training period;
acquiring a first training deviation obtained based on the optimized second language representation model and a second training deviation obtained based on the optimized mirror image second language representation model in the training period; the first training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized second language representation model in the training period; the second training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized mirror image second language representation model in the training period;
if the first training deviation is smaller than the second training deviation, replacing the optimized second language representation model with the optimized mirror image second language representation model to serve as a target second language representation model of the training period;
if the first training deviation is larger than the second training deviation, taking the optimized second language representation model as a target second language representation model of the training period; and meanwhile, taking the optimized mirror image second language representation model as a mirror image second language representation model which is not trained in the training period.
In an optional implementation manner, after obtaining the text correction model including the adjusted model parameters, the training method further includes:
inputting a test text input or output by the target service object in the test process into the text error correction model to obtain a corrected test text which is output by the text error correction model and is subjected to text error correction processing on the test text;
acquiring a test deviation generated before and after the test output result of the target service object is corrected according to a first test output result obtained by the target service object based on the test text and a second test output result obtained by the target service object based on the corrected test text; wherein the test deviations comprise positive test deviations belonging to a positive number and negative test deviations belonging to a negative number;
and determining the model training effect of the text error correction model according to the test deviation generated before and after each correction.
In a second aspect, an embodiment of the present application further provides a text error correction method, where the text error correction method is applied to a pre-trained text error correction model; the text error correction model is used for providing text error correction service for a target service object in a target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the text error correction method comprises the following steps:
inputting a text to be corrected, which needs to be subjected to text correction processing in an application process, of the target service object into a pre-trained text correction model, and correcting a target text error included in the text to be corrected through the text correction model to obtain a corrected text output by the text correction model and aiming at the text to be corrected; wherein the target text error is determined according to specific semantic features and/or character expression features in the target field;
and replacing the text to be corrected input or output by the target service object in the application process with the correction text.
In an optional implementation manner, the text correction model is obtained by training according to the training method in any one of the optional implementation manners of the first aspect.
In a third aspect, an embodiment of the present application provides a training apparatus for a text error correction model, where the text error correction model is used to provide a text error correction service for a target service object in a target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the training apparatus includes:
the first training module is used for pre-training the language model by utilizing a first training text without semantic tags to obtain a first language representation model; wherein the first training text comprises specific text data in the target field and general text data outside the target field;
the second training module is used for training the first language representation model by utilizing a semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability; the target text features are used for representing semantic features and/or character expression features of text data which are specific in the target field;
the first processing module is used for inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text;
and the parameter adjusting module is used for acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
In a fourth aspect, an embodiment of the present application provides a text error correction apparatus, where the text error correction apparatus is applied to a text error correction model trained in advance; the text error correction model is used for providing text error correction service for a target service object in the target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the text correction apparatus includes:
the text error correction module is used for inputting a text to be corrected, which needs to be subjected to text error correction processing in the application process of the target service object, into a pre-trained text error correction model, and correcting a target text error included in the text to be corrected through the text error correction model to obtain a corrected text output by the text error correction model and aiming at the text to be corrected; the target text error is determined according to specific semantic features and/or character expression features in the target field;
and the text replacement module is used for replacing the text to be corrected input or output by the target service object in the application process with the correction text.
In a fifth aspect, an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the training method for a text correction model described above when executing the computer program.
In a sixth aspect, the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the training method for text error correction model described in any one of the above.
In a seventh aspect, an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements any of the steps of the text error correction method when executing the computer program.
In an eighth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of any one of the text error correction methods described above.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
according to the training method and device for the text error correction model and the text error correction method and device provided by the embodiment of the application, the language model is basically trained by using general text data in the open field, and then the language model is finely tuned and trained by using special text data in the target field, so that the trained language model has the capability of recognizing specific text features in the target field; and then, performing interactive auxiliary training on the text error correction model in training by using a mature target service object in the target field as a teacher model in a data interaction mode with the converged target service object. Therefore, on the one hand, the training model can be quickly adapted to a more complex and unique language environment on the premise of not losing the generalized text error correction capability, so that the text error correction accuracy of the model in the target field is improved; on the other hand, correspondingly, after the text error correction model is trained, the text error correction model can be used for performing text error correction processing on the text data related in the target service object application process, and the accuracy of the output result of the target service object and the operation efficiency of the target service object are improved.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
FIG. 1 is a flowchart illustrating a training method of a text correction model according to an embodiment of the present disclosure;
FIG. 2 is a flow chart illustrating a first pre-training method provided by an embodiment of the present application;
FIG. 3 is a flow chart illustrating a second method of pre-training provided by an embodiment of the present application;
FIG. 4 is a flow chart illustrating a method of coarse grain training provided by an embodiment of the present application;
fig. 5 is a flowchart illustrating a method for fine-grained training according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for determining whether text error correction processing occurs according to an embodiment of the present disclosure;
FIG. 7 is a flow chart illustrating a method for calculating a first deviation provided by an embodiment of the present application;
FIG. 8 is a flow chart illustrating a method for calculating a second deviation according to an embodiment of the present application;
FIG. 9 is a flow chart illustrating a method for adjusting model parameters of a second language characterization model according to an embodiment of the present application;
FIG. 10 is a flowchart illustrating a method for determining a target second language representation model for each training period according to an embodiment of the present application;
FIG. 11 is a flowchart illustrating a method for testing a text error correction model according to an embodiment of the present application;
FIG. 12 is a flow chart illustrating a text error correction method provided in an embodiment of the present application;
FIG. 13 is a schematic structural diagram illustrating a training apparatus for a text error correction model according to an embodiment of the present application;
fig. 14 is a schematic structural diagram illustrating a text error correction apparatus according to an embodiment of the present application;
fig. 15 is a schematic structural diagram of an electronic device 1500 according to an embodiment of the present disclosure;
fig. 16 is a schematic structural diagram of another electronic device 1600 provided in the embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
In consideration of the contradiction between the generalization of language expression in the general field and the pertinence in the special service field in the prior art, the traditional text error correction model which is originally used for correcting wrongly written words can not be applied to executing the text error correction task in the special service field.
Based on this, the embodiment of the application provides a training method and device for a text error correction model, and a text error correction method and device, wherein a language model is basically trained by using general text data in an open field, and then a language model is finely tuned by using special text data in a target field, so that the trained language model has the capability of recognizing specific text features in the target field; and then, performing interactive auxiliary training on the text error correction model in training by using a mature target service object in the target field as a teacher model in a data interaction mode with the converged target service object. On one hand, on the premise of not losing the generalized text error correction capability, the training model can be quickly adapted to a more complex and unique language environment, so that the text error correction accuracy of the model in the target field is improved; on the other hand, correspondingly, after the text error correction model is trained, the text error correction model can be used for performing text error correction processing on the text data related in the target service object application process, and the accuracy of the output result of the target service object and the operation efficiency of the target service object are improved.
The following describes a method and an apparatus for training a text correction model, and a method and an apparatus for text correction in detail according to embodiments of the present application.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a training method of a text error correction model according to an embodiment of the present application, where the text error correction model is used to provide text error correction service for a target service object in a target field; the target service object belongs to a converged mature algorithm model in the target field; the training method comprises steps S101-S104; specifically, the method comprises the following steps:
s101, pre-training a language model by using a first training text without semantic labels to obtain a first language representation model.
S102, training the first language representation model by using the semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability.
S103, inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text.
And S104, acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
According to the training method of the text error correction model, basic training is performed on the language model by using general text data in the open field, and then fine tuning training is performed on the language model by using special text data in the target field, so that the trained language model has the capability of recognizing specific text features in the target field; and then, performing interactive auxiliary training on the text error correction model in training by using a mature target service object in the target field as a teacher model in a data interaction mode with the converged target service object. By the training method, the training model can be quickly adapted to a more complex and unique language environment on the premise of not losing the generalized text error correction capability, so that the text error correction accuracy of the model in the target field is improved.
The following describes, by way of example, each step in the training method for the text error correction model provided in the embodiment of the present application:
s101, pre-training the language model by using the first training text without the semantic mark to obtain a first language representation model.
Here, the first training text includes specific text data under the target field and general text data outside the target field; the target domain is determined according to a specific business scenario of the target service object, for example, when the target service object is a speech recognition model in a game system, the target domain is a game domain.
Specifically, the general text data is used for representing text data in other general fields except the target field; wherein the general field is used to refer to: while the specific service scenario to which the text data is applied is not limited, all service scenarios to which the text data may be applied. For example, if the target field is a game field, the general text data may be various types of text data that can be acquired from other fields such as an education field, a media field, and a cultural sports field.
Here, "semantic label free" in the first training text is used to characterize: specific text data in the first training text and other general text data are not distinguished; the pre-training aims to: the method comprises the steps of using general text data (namely a first training text without semantic tags) in an open field (equivalent to the field including a target field and a non-target field) to carry out basic training on a language model, so that the language model (namely the first language representation model) obtained after training can predict the occurrence probability of each participle in a semantic environment represented by different context contents according to the different context contents in the text data (namely the first language representation model with basic literary perception capability is obtained).
Specifically, as an optional embodiment, when the first training text is obtained, a round of text data preprocessing (for example, removing some known stop words, industry-sensitive words, malicious words with abusive properties, and the like) with sensitive word removal may be performed on text data (including the specific text data and the general text data) acquired in the general field to obtain the first training text with a more standard format, so as to reduce the difficulty in model training for the language model, and improve the efficiency of model training for the language model.
S102, training the first language representation model by using the semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability.
In the embodiment of the present application, "semantically labeled" in the second training text is used for characterizing: and for each participle in the second training text, if the participle has specific target semantics and/or a proper noun belonging to the target field when appearing in the target field, marking the target semantics of the participle and/or the corresponding noun concept definition in the target field.
Specifically, the purpose of training the first language representation model by using the second training text in step S102 is to: after the first language representation model has basic literary expression perception capability, fine tuning training is carried out on the first language representation model by using proprietary text data (namely, a second training text which is semantically marked in the target field) in the target field, so that the second language representation model obtained after the fine tuning training can predict the inter-sentence relation of different sentences in the target field and the sentence components of the same sentence in the target field (namely, the second language representation model with the target text feature recognition capability is obtained).
Here, the target text feature is used for representing a semantic feature and/or a character expression feature of the text data which is specific in the target field; the semantic features are equivalent to a second language representation model for predicting the inter-sentence relation of different sentences in the target field (for example, whether the corresponding semantics of the two sentences in the target field are the same or not); the character expression characteristic is equivalent to that the second language representation model predicts sentence components of the same sentence in the target field (for example, which participle in the sentence belongs to entity words defined in the target field, which participle belongs to proper nouns for explaining the same semantic concept in the target field, and the like).
Specifically, the semantic features may include at least the following 2 types of features:
(1) semantic features of specific text data in the target field;
for example, taking a game field as an example of a target field, "soul" is specific text data that appears only under the game field, and its semantic feature is "a kind of virtual equipment in the game".
(2) Corresponding special semantic features when the same text data appears in the target field;
for example, taking the game field as the target field as an example, if "Sunpuxiang" appears in the game field, the corresponding special semantic feature is "one game character", but if "Sunpuxiang" appears in other general fields except the game field, the corresponding general semantic feature is "one history character".
Specifically, the above-mentioned character expression features may also include at least the following 2 types of features:
(1) correct character expression of specific text data in the target field;
for example, the specific text data "win" in the game field is taken as an example, the "win" is a correct word expression of the specific text data in the game field, and the "win" is a wrong word expression of the specific text data in the game field.
(2) Corresponding special character expression when the same text data appears in the target field;
for example, still taking the game field as the target field as an example, a "sister paper" placed in the general field belongs to a wrong literal expression of a "sister", but a "sister paper" placed in the game field belongs to a distinctive designation for a female player/female game character.
S103, inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text.
Unlike the traditional language model (e.g., natural language model) that performs model training in a data (i.e., model training data) -algorithm (i.e., trained model), the present application performs interactive auxiliary training on the text error correction model (i.e., the second language representation model) during training in a manner of algorithm (i.e., target service object) -data (i.e., the third training text input or output by the target service object during training) and algorithm (i.e., the trained second language representation model) according to the actual application requirements of the trained text error correction model (i.e., providing text error correction service in the target field for the target service object), without reconstructing the model training data set, by using the mature and converged target service object in the target field as the teacher model, the method solves the backward propagation limitation of the traditional natural language model caused by discrete sampling on the interactive layer, and can promote the stability of gradient optimization while helping the model to quickly converge.
It should be noted that, in step S103, the third training text essentially belongs to the text type data related to the target service object in the self-training process, that is, the third training text may be the input data of the target service object (for example, if the target service object is a text classification model, the third training text is the input data of the target service object); or may be output data of the target service object (e.g., if the target service object is a speech recognition model, the input data of the target service object is speech data, and the third training text is a text recognition result output by the target service object for the input speech data); the method may further include both input data of the target service object and output data of the target service object (e.g., if the target service object is a question-answer type model, both the input data and the output data of the target service object belong to text type data, and at this time, the third training text is all training data occurring in the training process of the target service object).
Specifically, in step S103, the third training text is equivalent to a sentence set composed of each sentence input or output by the target service object in the training process; the third training text is input into the second language representation model one by one according to the form of one sentence and one sentence; for the currently input target sentence, the second language representation model may or may not perform text error correction processing on the currently input target sentence (i.e. the output result of the model is different from the currently input target sentence).
It should be noted that the "correction training text" in step S103 is a model output result obtained after the text error correction processing is performed on the currently input target sentence in the third training text by the second language representation model, that is, the "correction training text" is a model output result of the second language representation model when the model output result is different from the currently input target sentence.
And S104, acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
In the embodiment of the present application, in the actual application process of the target service object, the service object type to which the target service object belongs may be divided into the following three cases, specifically, according to whether the text data belongs to the input data of the target service object or belongs to the output data of the target service object:
1. in the first case: the service object type to which the target service object belongs is a prior type, that is, the work task of the target service object is as follows: and performing data processing on the currently input text data.
Exemplary illustrations, target service objects such as text classification, knowledge extraction, emotion analysis, search engines, and the like, having text data as input data for the target service objects, i.e., text error correction models for performing text error correction services for the input data for the target service objects.
Specifically, when the type of the service object to which the target service object belongs is the "prior type", each sentence in the third training text belongs to the input data of the target service object, and at this time, for each sentence in the third training text, the output result before correction obtained by the target service object based on the sentence is the output result of the model obtained by the target service object based on the sentence as input; and outputting a corrected output result of the target service object based on the corrected training text of the sentence, namely taking the corrected training text of the target service object based on the sentence as input, and outputting the obtained model output result.
2. In the second case: the service object type to which the target service object belongs is a "bidirectional authentication type", that is, the work task of the target service object may be: the data processing for the currently input text data may also be: and predicting and generating corresponding text data according to the currently input target data.
The method includes the steps that an exemplary explanation is that a target service object belonging to a bidirectional authentication type is mainly a dialogue service system in a target field, and in the dialogue service system, the dialogue service system needs to recognize text data/voice data input by a user and also needs to predict and generate reply text data corresponding to the input data according to a recognition result of the input data; that is, the text error correction model is used to perform text error correction service on the input data and/or the output data of the target service object, and at this time, the third training text includes both the input sentence of the input data belonging to the target service object and the output sentence of the output data belonging to the target service object.
Specifically, when the service object type to which the target service object belongs is the "bidirectional verification type", for each sentence in the third training text, if the sentence belongs to the input data of the target service object, the output result before the correction and the output result after the correction are the same as the first case, and the repeated points are not repeated here.
Specifically, when the service object type to which the target service object belongs is the "bidirectional verification type", for each sentence in the third training text, if the sentence belongs to the output data of the target service object, the output result before correction is the sentence in the third training text, and the output result after correction is the correction training text output after the sentence is subjected to text error correction processing by the second language representation model.
3. In the third case: the service object type to which the target service object belongs is the posterior type, that is, the work task of the target service object is as follows: and predicting and generating corresponding text data according to the currently input target data.
By way of example, a target service object with text data as output data, such as voice Character Recognition, image OCR (Optical Character Recognition), and the like, the text data is output data of the target service object, that is, the text error correction model is used for performing text error correction service on the output data of the target service object, and at this time, each sentence in the third training text belongs to the output data of the target service object.
Specifically, when the service object type to which the target service object belongs is the "posterior type", each sentence in the third training text belongs to the output data of the target service object, and at this time, the output result before correction and the output result after correction are the same as the output data of the second case to which the sentence belongs, and repeated points are not described herein again.
As can be seen from the above detailed description of the three cases, "changing the output result of the model of the target service object from the output result before correction to the output result after correction" corresponds to the change of the output result of the model of the target service object after the text error correction model provides the text error correction service for the target service object; "the forward deviation of the model output result of the target service object before and after correction" is equivalent to that the text error correction service provided by the text error correction model generates a forward gain for the target service object (for example, the accuracy of the model output result of the target service object is improved); "the negative deviation of the model output result of the target service object before and after the correction" is equivalent to that the text error correction service provided by the text error correction model has a negative effect on the target service object (for example, the accuracy of the model output result of the target service object is reduced, etc.).
For the above-mentioned positive deviation/negative deviation obtaining manner, it should be noted that, besides the conventional positive deviation/negative deviation obtaining manner through the difference, different deviation obtaining manners may also be selected according to the specific application characteristics of the target service object, for example, taking the target service object as knowledge extraction, in the text error correction service in the question and answer field, a corresponding reward coefficient (i.e. positive deviation)/penalty coefficient (i.e. negative deviation) may be provided for the text error correction model in training through the confidence of the downstream sequence labeling model of the target service object; the examples of the present application are not limited to these.
Based on the above, the method aims at each text error correction behavior (equivalent to each text error correction processing executed by the second language representation model) simulated in the model training process, and under the condition that the influence of the occurrence of the text error correction behavior on the model output result of the target service object is positive, the calculated positive deviation is used as the reward type adjustment parameter of the model, and the model parameter of the second language representation model is adjusted positively; and under the condition that the influence of the occurrence of the text error correction behavior on the model output result of the target service object is negative, taking the calculated negative deviation as a punishment type adjustment parameter of the model, and carrying out negative adjustment on the model parameter of the second language representation model. Therefore, the learning behavior of the model with the targeted reward and punishment adjustment mechanism for the text error correction task in the target field is set, the mode that the learning direction of the model is defined by 'marking samples' with marks in the traditional model training mode is replaced, the dependence degree of the model training process on the 'marking samples' is favorably reduced, even under the condition that the 'marking samples' are insufficient in quantity, the training effect of the text error correction model in the application cannot be influenced, the model can be helped to be rapidly converged, and the trained text error correction model is more stable.
The following detailed description is made for the specific implementation process of the above steps in the embodiments of the present application, respectively:
for the specific implementation process of the step S101, it should be noted that there are various existing alternative ways for pre-training the language model by using the semanteme-free labeled text data in the general field, and the application does not limit the specific pre-training way for pre-training in the step S101.
Here, a "mask prediction" mode in a conventional BERT (self-coding language model) model is used as an optional embodiment of a pre-training mode in the present application, and as to how to select a to-be-predicted participle to be masked in a first training text, the present application provides the following 2 different optional embodiments, specifically:
in an alternative embodiment, as shown in fig. 2, fig. 2 is a schematic flow chart of a first pre-training method provided in the embodiment of the present application, wherein, when step S101 is executed, the method includes steps S201 to S203; specifically, the method comprises the following steps:
s201, performing mask masking on the first target number of the participles in the first training text in a random sampling mode to obtain a first masked training text comprising the first target number of masked words.
In the embodiment of the present application, the trained text error correction model is used for providing text error correction service for target service objects in a target field, and considering that training requirements of different types of target service objects for the text error correction model may be different, for example, some target service objects are more prone to reduce construction operations of training data in a training process of the text error correction model (i.e., training requirements are biased to reduce data throughput/reduce training cost), and some target service objects are more prone to improve training effects of the text error correction model (i.e., data throughput/training cost in the training process is not concerned); at this time, in order to meet different training requirements of different target service objects for the text error correction model, when the language model is preliminarily pre-trained, the to-be-predicted participles which need to be masked by the mask may be randomly sampled, and professional vocabularies/characteristic vocabularies in the target field may be preferentially selected as the to-be-predicted participles which need to be masked by the mask.
It should be noted that, based on the analysis content related to the to-be-predicted participle, the embodiment of the present application does not set any limitation on whether the to-be-predicted participle needs to set the selection rule/selection criterion.
Specifically, the first pre-training method described in steps S201-S203 is equivalent to a preferred embodiment of pre-training the language model when the training requirement of the target service object for the text error correction model is biased to reduce the data throughput/reduce the training cost.
Here, in step S201, a first target number is determined according to the sampling ratio of the random sampling and the number of word segments included in the first training text; for example, if the first training text includes 100 segmented words in total, where the sampling proportion of the random sampling is 10%, it may be determined that the first target number is 10 segmented words, that is, according to the random sampling manner, 10 segmented words are randomly extracted from the 100 segmented words included in the first training text for mask masking, so as to obtain a first masked training text including 10 masked segmented words.
S202, inputting the first occlusion training text into the language model to obtain a first occlusion prediction text which is output by the language model and comprises a prediction result of a first target number of occlusion words.
Specifically, taking the number (i.e. the first target number) of the occluded words in the first occluded predicted text as n as an example, for each occluded word I, according to the position of the occluded word I in the first occluded predicted text, the language model may determine the context of the occluded word I from the first occluded predicted text (for example, the context may be the sentence I in which the occluded word I is located, the previous sentence H of the sentence I, and the next sentence J of the sentence I); training the language model according toThe context content of the shielding word i carries out word segmentation prediction on each shielded word i to obtain a word segmentation prediction result p of each shielded word i ic (ii) a So as to include the word segmentation prediction result p of each occluded word i ic The predicted text of (2) is used as the first masked predicted text; wherein, the word segmentation prediction result p ic Representing the predicted probability that the occluded word i belongs to the class c participle.
It should be noted that the specific number of classes c in the class c participles depends on the number of types of participles included in the participle prediction table, and the embodiment of the present application does not limit the specific number of classes c in the class c participles.
S203, adjusting model parameters of the language model by using cross entropy loss between the first occlusion prediction text and the first training text which is not subjected to mask occlusion until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
Specifically, in combination with the step S202, the first occlusion prediction text includes the segmentation prediction result of each occluded word, and the first training text without mask occlusion includes the real segmentation classification result of each occluded word (which is equivalent to the real classification result determined from the segmentation prediction table according to the real segmentation that is not occluded). Therefore, for each occluded word in the first occluded prediction text, the word segmentation prediction result of the occluded word in the first occluded prediction text and the real word segmentation classification result in the first training text of the occluded word are brought into the cross entropy loss function, so that the model training loss of the language model can be obtained, and therefore, the model parameters in the language model are adjusted based on the model training loss obtained by each training, and the converged first language representation model can be obtained.
In the embodiment of the present application, considering that the number of types of participles included in the participle prediction table used in the mask prediction process (i.e. the specific number of classes c in the above-mentioned class-c participles) is generally greater than 2 classes, the cross entropy loss function in step S203 is preferably a cross entropy loss function under a multi-classification task, specifically:
Figure BDA0003636319170000251
wherein n is the total number of the occluded words in the first occluded predicted text, that is, n is the first target number, and i is the ith occluded word in the first occluded predicted text;
n is the number of types of participles included in the participle prediction table, and c is the class-c participle included in the participle prediction table;
p ic is the word segmentation prediction result of the ith occluded word;
y ic is a sign function (0 or 1), if the ith occluded word is a class c participle, then y ic The value is 1; if the ith occluded word is not a class c participle, then y ic The value is 0;
L 1 is the cross entropy loss function used when the language model is pre-trained according to the method described in steps S201-S203.
In another alternative embodiment, as shown in fig. 3, fig. 3 is a schematic flow chart of a second pre-training method provided in the examples of the present application, wherein, when step S101 is executed, the method includes steps S301 to S303; specifically, the method comprises the following steps:
s301, according to a first preset sampling proportion, mask masking is carried out on the participles, belonging to the specific text data, of the second target number in the first training text, and a second masked training text including masked words of the second target number is obtained.
Specifically, the second pre-training method described in steps S301 to S303 is equivalent to a preferred embodiment of pre-training the language model when the training requirement of the target service object for the text correction model is biased to improve the training effect of the text correction model/improve the accuracy of the training result.
Here, in step S301, a second target number is determined according to the first preset sampling ratio and the number of word segments belonging to the specific text data in the first training text; for example, if the first training text includes 100 segmented words in total, wherein 40 segmented words belong to specific text data in the target field, and the first preset sampling proportion is 20%, it may be determined that the second target number is 8 segmented words, that is, 8 segmented words are randomly extracted from the 40 segmented words belonging to the specific text data in the first training text in a random sampling manner for mask masking, and the 8 masked segmented words are used as masked words to be predicted.
S302, inputting the second occlusion training text into the language model to obtain a second occlusion predicted text which is output by the language model and comprises a prediction result of a second target number of occlusion words.
S303, adjusting model parameters of the language model by using the cross entropy loss between the second occlusion prediction text and the first training text which is not subjected to mask occlusion until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
Here, the implementation of steps S302-S303 is the same as steps S202-S203, and the repetition is not repeated here.
For the specific implementation process of the step S102, based on the analysis content of the step S102, the training purpose of training the first language representation model by using the second training text in the step S102 can be subdivided into the following 2 types, specifically:
training the target 1, so that the second language representation model obtained after fine tuning training can predict the inter-sentence relation of different sentences in the target field;
and training the target 2, so that the second language representation model obtained after fine tuning training can predict sentence components of the same sentence in the target field.
Based on this, in order to accomplish the above two training objectives, in this embodiment of the present application, as an optional embodiment, the training the first language representation model by using the second training text in step S102 at least includes: performing coarse-grained training and/or fine-grained training on the first language representation model by using a semantically marked second training text in the target field; the coarse-grained training is used for training the first language representation model to classify different sentences under the same semantic concept in the second training text according to different character expression modes corresponding to the same semantic concept in the target field (namely, the coarse-grained training is used for completing the training purpose 1); and the fine-grained training is used for training the first language representation model to identify the character expression mode of each sentence in the target field according to the word segmentation sequence marking result of each sentence in the second training text in the target field (namely, the fine-grained training is used for completing the training purpose 2).
In an alternative implementation of the specific completion process of the training object 1, as shown in fig. 4, fig. 4 is a schematic flow chart of a coarse-grained training method provided in an embodiment of the present application, where, when step S102 is executed, the method includes steps S401 to S403; specifically, the method comprises the following steps:
s401, aiming at any two sentences in the second training text, inputting the original version sentences of which the semantic labels are removed from the any two sentences into the first language representation model, and performing classification prediction on whether the any two sentences correspond to the same semantic concept in the target field through the first language representation model to obtain classification prediction results of the any two sentences.
In this embodiment of the present application, in order to meet different training requirements of different target service objects for the text error correction model, the second training text may also be determined in different manners according to different training requirements.
Specifically, when the target service object is more inclined to reduce the construction operation of the training data in the training process of the text correction model (i.e. the training requirement is biased to reduce the data processing amount/reduce the training cost), since the first training text also includes the participle belonging to the specific text data in the target field, the first training text can be directly used as the second training text.
Correspondingly, when the target service object is more prone to improving the training effect of the text error correction model (i.e. the data processing amount/training cost in the training process is not concerned), the second training text can be directly reconstructed according to the specific text data in the target field; on the basis of the first training text, a certain amount of professional vocabularies belonging to the specific text data can be supplemented, the supplemented first training text is used as a second training text, and the training requirement that the target service object is more prone to improving the training effect of the text error correction model is met in a mode of improving the proportion of the specific text data in the second training text.
Here, in step S401, the classification prediction result is used to characterize whether any two sentences correspond to the predicted value of the same semantic concept in the target domain; that is, the classification prediction method in step S401 corresponds to two classification predictions performed on whether the two input sentences correspond to the same semantic concept in the target field.
S402, determining real classification results of any two sentences according to the semantic labels of the any two sentences in the second training text.
Here, the real classification result is used to characterize whether any two sentences correspond to the same semantic concept in the target domain.
In the embodiment of the present application, after the second training text is obtained, as an optional embodiment, multiple semantic concept labels included in the target field may be obtained from a knowledge graph and/or an encyclopedic knowledge base in the target field, then each sentence in the second training text is labeled by using the obtained multiple semantic concept labels, and if a participle whose semantic label matches the semantic concept label appears in the sentence, the semantic concept label is used as a semantic concept label of the sentence; if there is no participle in the sentence that matches any semantic concept label, it can be determined that the semantic concept label of the sentence is other/no label (corresponding to the sentence is irrelevant to the target field, and the contribution degree to model training is small), so that the real classification result of any two sentences is determined according to each sentence after the semantic concept label.
S403, adjusting model parameters of the first language representation model by using cross entropy loss between the classification prediction result and the real classification result until the first language representation model converges.
Here, based on the analysis content in step S401, the classification prediction method in step S401 corresponds to performing two-classification prediction on whether two input sentences correspond to the same semantic concept in the target domain; therefore, the cross entropy loss function in step S403 may use a cross entropy loss function under a binary task, specifically:
Figure BDA0003636319170000291
wherein m is the total input times of the first language representation model to the two arbitrary sentences (which is also equivalent to the total prediction times of a round of classification prediction task), that is, the true value of m can be determined according to the total number of sentences included in the second training text;
j is the input of the jth time in the first language representation model and is also the jth prediction of the first language representation model in a round of classification prediction tasks;
p j is the classification prediction result of 2 statements in the j prediction, wherein p j The value of (b) represents the probability that 2 sentences in the jth prediction correspond to the same semantic concept in the target field;
y j is a symbolic function (0 or 1), if the real classification results of 2 sentences in the jth prediction are the same semantic concept in the corresponding target field, y j The value is 1; if the real classification results of the 2 sentences in the jth prediction are different semantic concepts in the corresponding target field, y j The value is 0;
L 2 the first language characterization model is coarse grained according to the method described in steps S401-S403Cross entropy loss function used in the degree training.
In an alternative implementation of the specific completion process of the training object 2, as shown in fig. 5, fig. 5 is a schematic flow chart of a fine-grained training method provided in an embodiment of the present application, where, when step S102 is executed, the method includes steps S501-S503; specifically, the method comprises the following steps:
s501, aiming at each statement in the second training text, inputting the original version statement of the statement without the existing semantic mark into the first language representation model, and analyzing the sentence component of the statement in the target field through the first language representation model to obtain the statement analysis result of the statement in the target field.
Here, the sentence components include at least: the semantic concept classification method comprises a first target participle belonging to an entity defined in the target field and a second target participle capable of representing different semantic concepts in the target field.
Specifically, on the basis that the sentence component includes both the entity and the semantic concept, it needs to be explained that, in order to further improve the training effect of the second language representation model, as an optional embodiment, for 2 sentences input in the j-th prediction, the true classification result y of the 2 sentences is determined j In the case of the real classification result y, if the 2 sentences in the jth prediction include both the participles corresponding to the same semantic concept mark and the participles with the same entity attribute, the method can be further limited to determine the real classification result y j The value is 1; otherwise, even if the 2 sentences include the participles corresponding to the same semantic concept mark, the real classification result y of the 2 sentences is still determined when the entity attributes corresponding to the participles belonging to the entity type in the 2 sentences are different j The value is 0, that is, it is determined that the 2 sentences are not sentences under the same semantic concept at this time.
In the embodiment of the present application, the first target participle and the second target participle may be determined by using a knowledge graph in a target domain; for example, taking a knowledge graph K in the game field as an example, in the knowledge graph K, entity class participles such as game characters, game types, game names and the like which are frequently used as subject sentences appear as entity nodes S in the knowledge graph K, concept class participles which are frequently used as object sentences such as game equipment, game props, character skills and the like and belong to the game field and have special definitions appear as concept nodes G in the knowledge graph K, and edges between each entity node S and the concept nodes G in the knowledge graph K are used for representing the association relationship between the entity nodes S and the concept nodes G.
S502, according to the multiple entities defined in the target field and the existing semantic tags in the sentence, sequence tagging is carried out on the multiple participles in the sentence, and a participle sequence tagging result of the sentence is obtained.
Specifically, when a sentence is subjected to sequence marking, as an optional embodiment, the first target participle and the second target participle included in the sentence may be respectively marked according to the definitions of the first target participle and the second target participle, so as to obtain a participle sequence marking result of the sentence.
For example, taking the game field as the target field as an example, if the text form of the sentence a is "[ the ] [ the ] should ] [ the ] be ] [ what ]", where "the" big dog "belongs to the entity node S1 in the knowledge graph K and" the "belongs to the concept node G1 in the knowledge graph K, and the edge between the entity node S1 and the concept node G1 indicates that the concept node G1 and the entity node S1 belong to the same game application; it may be determined that the participle sequence tagging result a1 of statement a is "[ entity ] [0] [0 ]", where entity is an entity tag belonging to the first target participle, category is a concept tag belonging to the second target participle, and 0 represents belonging to other text that does not need to be recognized.
S503, adjusting the model parameters of the first language representation model by using the cross entropy loss between the statement analysis result and the word segmentation sequence marking result until the first language representation model converges.
Specifically, in the TongWhen the sentence analysis result is obtained by way of sentence component analysis, the first language representation model relates to recognition and prediction of a plurality of participles included in the sentence, so the cross entropy loss calculation method in step S503 is similar to the cross entropy loss calculation method under the multi-classification task in step S203, and the cross entropy loss function form in step S503 can refer to the cross entropy loss function L in step S203 1 The repetition of the formula form is not repeated herein.
Illustratively, still taking statement A in the above example as an example, if statement A's statement analysis result A2 is "[ category][0][category][0][0][0]", then with the cross entropy loss function L in step S203 1 For example, let [ big Tian dog ] in statement A]And [ Yu Chun]Respectively as 2 shielded words, taking the marked result in the sentence analysis result A2 as a first shielded prediction text, taking the word segmentation sequence marked result A1 as a first training text which is not subjected to mask shielding, and determining a symbolic function y according to the marked result difference in the word segmentation sequence marked result A1 and the sentence analysis result A2 ic So as to calculate the cross entropy loss between the word segmentation sequence marking result A1 and the sentence analysis result A2, and then finely adjust the model parameters of the first language representation model until the first language representation model converges.
For the specific implementation process of the step S103, based on the analysis content of the step S103, the third training texts are input into the second language representation model one by one in the form of one sentence and one sentence; for a currently input target sentence, as to how to determine whether the second language representation model performs text error correction processing on the target sentence, the embodiment of the present application provides the following optional implementation schemes, specifically:
as shown in fig. 6, fig. 6 is a flowchart illustrating a method for determining whether text error correction processing occurs according to an embodiment of the present application, where, when step S103 is executed, the method includes steps S601-S603; specifically, the method comprises the following steps:
s601, aiming at each sentence in the third training text, inputting the sentence into the second language representation model to obtain a first output result of the second language representation model aiming at the sentence.
S602, when the difference between the first output result and the sentence is detected, determining that the second language representation model carries out the text error correction processing on the sentence, and taking the first output result as the correction training text.
S603, when it is detected that the first output result is the same as the sentence, obtaining a next sentence from the third training text, and repeating the processing steps for the sentence until the corrected training text is obtained.
For example, on the basis of the above steps S601-S603, taking the game field as the target field as an example, if the currently input sentence a in the third training text is "the image of the character of the game is a young sister paper", at this time, if the first output result a1 of the second language representation model for the sentence a is "the image of the character of the game is a young sister paper", that is, the first output result a1 is the same as the sentence a, it is determined that the second language representation model does not perform text error correction processing on the sentence a, at this time, the next sentence b is obtained from the third training text as the input of the second language representation model, and the judgment is continued; if the first output result a1 of the second language representation model for the sentence a is "the image of the game character has been a sister", that is, the first output result a1 is different from the sentence a, it is determined that the second language representation model performs the text error correction processing on the sentence a, at this time, the obtained corrected training text a2 is "the image of the game character has been a sister", and step S104 is executed by using the corrected training text a2 and the sentence a in the third training text.
For the specific implementation process of the above step S104, in the embodiment of the present application, in combination with the analysis content at the above step S104, the service object type to which the target service object belongs is classified into three cases of "a priori type", "two-way verification type", and "a posteriori type", and for these three specific cases, on the basis of the above steps S601-S603, for the third training text (corresponding to one specific sentence in the third training text) currently determined to have been subjected to the text error correction processing by the second language representation model (i.e. simulating that the text error correction model really provides the text error correction service for the target service object), it can be determined that the third training text in step S104 (i.e. the third training text currently determined to have been subjected to the text error correction processing by the second language representation model) may only be the input text data/output text data of the target service object, that is, the text error correction model is equivalent to performing text error correction processing on input text data/output text data of a target service object.
Based on this, the following detailed description is respectively made on how to obtain the positive deviation/negative deviation generated before and after the correction of the model output result of the target service object in the above two cases according to whether the text error correction model performs the text error correction processing on the input text data of the target service object or performs the text error correction processing on the output text data of the target service object:
1. when the third training text is the text data input by the target service object in the training process:
at this time, inputting a third training text into the target service object, and outputting to obtain the output result before correction; inputting the corrected training text into a target service object, and outputting to obtain a corrected output result; that is, the output result before correction is: the target service object takes the third training text as input and outputs the obtained model output result; the output result after correction is: and the target service object takes the corrected training text as input and outputs the obtained model output result.
It should be noted that the third training text is input into the second language representation model one by one in the form of a sentence and a sentence, and therefore, the text data input by the target service object in the training process in the third training text is the input data of the target service object to which the target sentence currently input into the second language representation model belongs; the corrected training text is the corrected training sentence which is output after the second language representation model carries out text error correction processing on the input target sentence.
Here, as an alternative embodiment, a first deviation generated before and after the correction of the model output result of the target service object may be calculated according to a first deviation calculation policy; determining whether the first deviation belongs to the positive deviation or the negative deviation based on the first deviation.
For the specific calculation process of the first deviation, as shown in fig. 7, fig. 7 is a schematic flow chart of a method for calculating the first deviation provided in the embodiment of the present application, where the method includes steps S701 to S703; specifically, the method comprises the following steps:
s701, inputting the third training text into the target service object, and predicting the output category of the third training text through the target service object to obtain the output result before correction.
Here, the output result before correction is used to represent the probability that the output category of the third training text belongs to each preset category.
Specifically, in the embodiment of the present application, taking a text classification model in a "priori type" as an example of a target service object, where a third training text currently determined to be subjected to text error correction processing by the second language representation model is a sentence a, and a correction training text output after the sentence a is subjected to text error correction processing by the second language representation model is a correction training sentence a 2; at this time, the sentence a is input into the text classification model as the target service object, and the obtained output result before correction may have the following two types:
the type 1 and the text output category to which the sentence a belongs are obvious in the output result before correction, that is, the probability value that the sentence a belongs to a certain preset category is obviously higher than the probability value that the sentence a belongs to other preset categories, or the probability value that the sentence a belongs to a certain preset category is greater than or equal to 50%.
By way of example, at this time, the output result R1 before correction may be: the probability that the sentence a belongs to the first preset category is 70%, the probability that the sentence a belongs to the second preset category is 5%, the probability that the sentence a belongs to the third preset category is 5%, the probability that the sentence a belongs to the fourth preset category is 10%, and the probability that the sentence a belongs to the fifth preset category is 10%.
The type 2, the text output category to which the sentence a belongs is not obvious in the output result before correction, that is, the probability distribution result of the sentence a belonging to each preset category is average.
Illustratively, at this time, the obtained output result r1 before correction may be: the probability that the sentence a belongs to the first preset category is 15%, the probability that the sentence a belongs to the second preset category is 15%, the probability that the sentence a belongs to the third preset category is 20%, the probability that the sentence a belongs to the fourth preset category is 25%, and the probability that the sentence a belongs to the fifth preset category is 25%.
S702, inputting the corrected training text into the target service object, and predicting the output category of the corrected training text through the target service object to obtain the corrected output result.
Here, the corrected output result is used to represent the probability that the output category of the corrected training text belongs to each preset category.
Specifically, step S702 is the same as the step S701, and the possible types of the output result after the correction are similar to the possible types of the output result before the correction, and the repetition points are not repeated herein.
And S703, calculating a probability deviation value of the corrected output result and the output result before correction on the same preset category, and taking the calculation result as the first deviation.
Here, two different types of output results before correction shown in the above step S701 are exemplarily illustrated as follows:
(1) and when the output result before correction belongs to type one:
here, as an alternative embodiment, the target preset category corresponding to the highest probability value from the output results before correction may be determined as the specific preset category of the model output results of the comparison target service objects, which has a deviation before and after correction, and then the first deviation between the output results after correction and the output results before correction may be calculated under the target preset category.
For example, taking the output result before correction R1 as an example, the output result before correction R1 is: the probability that the sentence a belongs to the first preset category is 70%, the probability that the sentence a belongs to the second preset category is 5%, the probability that the sentence a belongs to the third preset category is 5%, the probability that the sentence a belongs to the fourth preset category is 10%, and the probability that the sentence a belongs to the fifth preset category is 10%; if the corrected output result R2 is: the probability of correcting the training sentence a2 to belong to the first preset category is 90%, the probability of belonging to the second preset category is 2%, the probability of belonging to the third preset category is 3%, the probability of belonging to the fourth preset category is 4%, and the probability of belonging to the fifth preset category is 1%; the numerical value change of the highest probability value of the preset category to which the output result R1 belongs before correction due to the occurrence of text error correction processing can be directly used as a first deviation; the first deviation is calculated here as: from 90% to 70% 20%, that is to say that the first deviation belongs to a forward deviation of the value 20%.
(2) And when the output result before correction belongs to the type two:
here, as another alternative embodiment, a plurality of probability values higher than a predetermined probability threshold in the pre-correction output result/the post-correction output result may be selected according to the predetermined probability threshold (for example, 20%), an average value of the selected probability values is calculated, and a difference value between the average values in the two output results before and after the correction is used as the first deviation.
For example, if a predetermined probability threshold is 20%, the output r1 before correction is: the probability that the sentence a belongs to the first preset category is 15%, the probability that the sentence a belongs to the second preset category is 15%, the probability that the sentence a belongs to the third preset category is 20%, the probability that the sentence a belongs to the fourth preset category is 25%, and the probability that the sentence a belongs to the fifth preset category is 25%; the probability value above the probability threshold in the output result r1 before correction is: 20%, 25%;
if the corrected output r2 is: the probability of correcting the training sentence a2 to belong to the first preset category is 5%, the probability of belonging to the second preset category is 5%, the probability of belonging to the third preset category is 15%, the probability of belonging to the fourth preset category is 50%, and the probability of belonging to the fifth preset category is 25%; the probability value in the corrected output result r2 for which the probability value is above the probability threshold is: 50 percent and 25 percent;
at this time, according to the alternative embodiment under type two above, the first deviation can be calculated as:
Figure BDA0003636319170000371
here, for the difference in the calculation method of the first deviation between the two types, it is to be noted that:
in the type, the output category of the sentence a before correction in the third training sample is obvious in the output result before correction, that is, even if the sentence a is not subjected to text error correction, the target service object can determine the specific text classification result of the sentence a, and at this time, obtaining that the first deviation belongs to a forward deviation with a value of 20% can be understood as: the contribution of the text correction service provided by the text correction model to the target service object for obtaining the exact text classification result is 20% (which is equivalent to improving the accuracy of the output result of text classification of the target service object for the sentence a).
Under type two, the output category of the sentence a before correction in the third training sample is not obvious in the output result before correction, that is, if the sentence a is not subjected to text error correction processing, the target service object cannot obtain an exact text classification result of the sentence a, and at this time, obtaining the first deviation belonging to a forward deviation with a value of 14.17% can be understood as: the contribution of the text correction service provided by the text correction model to the ability of the target service object to obtain an exact text classification result is 14.17%.
Here, when the first deviation is a negative deviation, it is equivalent to change the "contribution" in the analysis into a reverse "loss", that is, the negative deviation is used to represent the text error correction service provided by the text error correction model and may adversely affect the model output result of the target service object, and the repeated parts are not described herein again.
2. When the third training text is the text data output by the target service object in the training process:
at the moment, the third training text is used as the output result before correction; taking the corrected training text as the result output after correction, namely, outputting the result before correction, namely the third training text; and outputting a result after correction, namely the corrected training text.
Here, as an alternative embodiment, a second deviation generated before and after the correction of the model output result of the target service object may be calculated according to a second deviation calculation policy; determining whether the second deviation belongs to the positive deviation or the negative deviation based on the second deviation; wherein the second deviation calculation strategy may be different from the first deviation calculation strategy described above.
For the specific calculation process of the second deviation, as shown in fig. 8, fig. 8 is a schematic flowchart illustrating a method for calculating the second deviation according to an embodiment of the present application, where the method includes steps S801-S804; specifically, the method comprises the following steps:
s801, acquiring a standard text recognition result of target input data.
Here, the target input data is used to characterize model input data of the target service object when the target service object outputs the third training text in the training process.
It should be noted that, since the second deviation is calculated in a case where the third training text is the output text data of the target service object, the target input data may be a non-text type data.
For an exemplary illustration, taking the target service object as an image recognition model as an example, the target input data is an image B, and a sentence B1 in the third training text is that the target service object performs image text recognition on the image B, so as to obtain a text recognition prediction result; at this time, according to the reference sample data used by the target service object in the training process, the standard text recognition result B of the image B may be obtained from the reference sample data.
S802, calculating a text recognition deviation value between the third training text and the standard text recognition result, and taking the calculation result as a first text recognition deviation value.
Illustratively, still taking the above example as an example, the stroke edit distance d1 (equivalent to the text difference between the sentence b1 and the standard text recognition result b) between the sentence b1 in the third training text and the standard text recognition result b is calculated, and the stroke edit distance d1 is taken as the first text recognition deviation value, in this case, the smaller the stroke edit distance d1, the higher the similarity (equivalent to the smaller the difference) between the sentence b1 and the standard text recognition result b, the more accurate the model output result of the target service object.
And S803, calculating a text recognition deviation value between the corrected training text and the standard text recognition result, and taking the calculation result as a second text recognition deviation.
Illustratively, still taking the above example as an example, if the corrected training text obtained after the sentence b1 is subjected to the text correction processing by the second language representation model is the corrected training sentence b2, the stroke edit distance d2 between the corrected training sentence b2 and the standard text recognition result b is calculated, and the stroke edit distance d2 is used as the second text recognition bias value.
S804, calculating a difference value between the first text recognition deviation value and the second text recognition deviation value, and taking a calculation result as the second deviation.
Illustratively, still taking the above example as an example, the difference d between the stroke edit distance d1 and the stroke edit distance d2 is calculated, and the calculation result of the difference d is taken as the second deviation; at this time, if the calculation result of the difference d is a negative number (which is equivalent to that the text difference between the text recognition prediction result output by the target service object and the standard text recognition result b is increased after the text error correction processing is performed), it indicates that the second deviation is a negative deviation, that is, the text error correction service provided by the text error correction model adversely affects the model output result of the target service object.
If the calculation result of the difference d is a positive number (which is equivalent to that the text difference between the text recognition prediction result output by the target service object and the standard text recognition result B is reduced after the text error correction processing is performed), it indicates that the second deviation is a positive deviation, that is, the text error correction service provided by the text error correction model is beneficial to improving the image text recognition accuracy of the target service object for the image B.
For the specific implementation process of the step S104, as to how to adjust the model parameters of the second language representation model according to the positive deviation/negative deviation, the following optional implementation schemes are provided in the examples of the present application, specifically:
as shown in fig. 9, fig. 9 is a flowchart illustrating a method for adjusting model parameters of a second language representation model according to an embodiment of the present application, wherein the method includes steps S901 to S902 when step S104 is executed; specifically, the method comprises the following steps:
s901, in each training period of the second language representation model, acquiring a target positive deviation/negative deviation obtained by the target second language representation model trained based on the training period.
Specifically, in step S103, the third training text is equivalent to a sentence set composed of sentences input or output by the target service object in the training process; the third training text is input into the second language representation model one by one according to the form of one sentence and one sentence; based on this, as an optional embodiment, the training period in step S901 may be determined according to the data usage rate of the second language representation model in training for the third training text; for example, if the data usage rate of the third training text is 10% as a training period, at this time, it is equivalent to that 10 training periods are required in total if the model traverses the sentences in the third training text for one round in the training process; if the data usage rate of the third training text is 20% as a training period, this is equivalent to that if the model traverses the sentences in the third training text for one round in the training process, a total of 5 training periods are required.
In the embodiment of the present application, a mirror model of the second language characterization model may be stored and maintained every other training period, synchronously training the second language representation model trained in the last training period and the mirror image model not trained in the last training period in each training period, therefore, according to the accumulated deviation sum value (namely the sum value of the positive deviation and the negative deviation) of the second language representation model in the current training period and the accumulated deviation sum value of the mirror image model, the model with the highest deviation sum value (which is equivalent to the model with the best training effect in the current training period) is selected as the target second language representation model which needs to be subjected to model parameter adjustment in the current training period, and adjusting the model parameters of the target second language representation model according to the positive deviation/negative deviation of each target obtained by the target second language representation model in the current training period.
And S902, adjusting the model parameters of the target second language representation model according to the target positive deviation/negative deviation, and obtaining the text error correction model comprising the adjusted model parameters when the target second language representation model meets the training cutoff condition.
In this embodiment of the application, the target positive deviation/negative deviation may be substituted as a loss control variable into a model loss function of the target second language representation model to adjust model parameters of the target second language representation model.
Specifically, as an alternative embodiment, the model loss function of the target second language characterization model may be in a functional form as shown in the following formula:
Figure BDA0003636319170000411
wherein J (θ) is the target second language representation model G θ The loss function of the original model in the training process can be taken as a common least square loss function;
θ means to derive a multiplication function;
s x ~G θ (Y 1:t-1 ) Representing the currently corrected target participle s x The output probability at the t-th position in the third training text, i.e. the text error correction processing occurs in the third training textThe output probability of the t-th position in the text;
Figure BDA0003636319170000421
an expected value representing the output probability;
logG θ (Y 1:T ) Second language representation model G representing a target θ In the training process, aiming at each currently processed participle in the third training text, the error-corrected target participle s is calculated through the context content of the participle from 1 to T time x I.e. the currently corrected target participle s x A probability distribution in the third training text;
D φ the second language representation model is a loss control variable, namely, each target positive deviation/negative deviation obtained by the target second language representation model based on each training statement in the third training text in the current training period;
ε is the tuning parameter of the loss control variable used to tune the weight of the loss control variable in the model loss function.
In an alternative embodiment, as shown in fig. 10, fig. 10 is a flowchart illustrating a method for determining a target second language representation model in each training period according to an embodiment of the present application, wherein the method includes steps S1001 to S1005 before the model parameter adjustment method shown in steps S901 to S902 is performed in each training period; specifically, the method comprises the following steps:
s1001, when each training period of the second language representation model is reached, the second language representation model trained in the last training period is obtained, and a mirror image second language representation model which is not trained in the last training period is generated.
Here, it should be noted that, if the current training period is the first training period of the second language representation model, only the second language representation model in the training process may be obtained as the target second language representation model for which the current training period needs to be subjected to model parameter adjustment, that is, in the first training period, it may be regarded that there is no mirror image model which has not been trained in the previous training period.
S1002, in the training period, synchronously training the second language representation model trained in the previous training period and the mirror image second language representation model not trained in the previous training period, and respectively obtaining an optimized second language representation model and an optimized mirror image second language representation model trained in the training period.
Here, for the specific implementation of step S1002, in the current training period, for a target sentence currently input into the second language representation model/mirror second language representation model in the third training text, if the target sentence belongs to the input text data of the target service object, the positive deviation/negative deviation of the second language representation model/mirror second language representation model for the target sentence may be calculated with reference to the first deviation calculation method shown in the foregoing steps S701-S703; if the target sentence belongs to the output text data of the target service object, the positive deviation/negative deviation of the second language representation model/mirror image second language representation model for the target sentence can be calculated by referring to the second deviation calculation method shown in the foregoing steps S801-S804; the repetition is not described in detail herein.
S1003, acquiring a first training deviation obtained based on the optimized second language representation model and a second training deviation obtained based on the optimized mirror image second language representation model in the training period.
Here, the first training bias is used to characterize a bias sum of a plurality of positive biases/negative biases obtained based on the optimized second language characterization model in the training period; the second training bias is used for representing the bias sum value of a plurality of positive biases/negative biases obtained based on the optimized mirror image second language representation model in the training period.
S1004, if the first training deviation is smaller than the second training deviation, replacing the optimized second language representation model with the optimized mirror image second language representation model to be used as a target second language representation model of the training period.
S1005, if the first training deviation is larger than the second training deviation, using the optimized second language representation model as a target second language representation model of the training period; and meanwhile, taking the optimized mirror image second language representation model as a mirror image second language representation model which is not trained in the training period.
Specifically, with respect to the above-mentioned steps S1004 to S1005, in the embodiment of the present application, according to the accumulated deviation sum value of the second language representation model (i.e. the first training deviation) and the accumulated deviation sum value of the mirror image model (i.e. the second training deviation) in the current training period, before the model parameter adjustment method shown in steps S901 to S902 is executed in each training period, the model with the highest deviation sum value (corresponding to the best training effect in the current training period) is selected as the target second language representation model for which the model parameter adjustment needs to be performed in the current training period.
Based on the model parameter adjustment method described in the above steps S901 to S902, in the present application, for each text error correction process that occurs in the simulation during the model training process, in the case that the influence of the occurrence of the text error correction process on the output result of the target service object is positive, the calculated positive deviation is used as the reward-type adjustment parameter of the model to perform positive adjustment on the model parameters of the target second language representation model; and under the condition that the influence of the text error correction processing on the model output result of the target service object is negative, taking the calculated negative deviation as a punishment type adjustment parameter of the model, and carrying out negative adjustment on the model parameter of the target second language representation model.
Therefore, the learning behavior of the model is controlled by the reward and punishment adjusting mechanism with pertinence on the text error correction task in the target field, the method can replace the mode of defining the learning direction of the model by relying on the marked sample in the traditional model training mode, and is favorable for reducing the dependence degree of the model training process on the marked sample; on this basis, based on the target second language representation model determination method shown in the above steps S1001 to S1005, the present application further selects, according to the sum of the positive deviation and the negative deviation accumulated by the model in each training period, the model with the largest total reward obtained in one training period (which is equivalent to the deviation sum being the largest positive value) as the target optimization model for actually performing model parameter adjustment in the current training period, which is beneficial to sequentially accelerating the convergence process of the model.
In summary, even if the number of the "labeled samples" is insufficient, the training effect of the text correction model in the application is not affected, which helps the model to converge quickly, and makes the trained text correction model more stable.
In this embodiment of the present application, based on a testing concept similar to the training concept in the above steps, through data interaction with the target service object, in addition to the third training text, the text error correction model may also obtain, in the same manner, test text data related to the target service object in the testing process from the target service object, so as to evaluate, by using the test text data, a training effect of the text error correction model, specifically:
as shown in fig. 11, fig. 11 is a flowchart illustrating a method for testing a text error correction model according to an embodiment of the present application, where after step S104 is executed, the method further includes steps S1101-S1103; specifically, the method comprises the following steps:
s1101, inputting the test text input or output by the target service object in the test process into the text error correction model to obtain a corrected test text output by the text error correction model and subjected to text error correction processing on the test text.
It should be noted that the execution manner of step S1101 is the same as that of step S103, and reference may be made to the related explanation content of step S103, and repeated parts are not repeated herein.
And S1102, acquiring a test deviation generated before and after the correction of the test output result of the target service object according to a first test output result obtained by the target service object based on the test text and a second test output result obtained by the target service object based on the correction test text.
Here, the test deviations include positive test deviations belonging to a positive number and negative test deviations belonging to a negative number.
It should be noted that, when calculating the test deviation generated before and after the correction in step S1102, if the test sentence in the current test text belongs to the input text data of the target service object, the test deviation may be calculated in a manner of calculating the first deviation in the foregoing step; if the test statement in the current test text belongs to the output text data of the target service object, calculating the test deviation according to the mode of calculating the second deviation in the previous step; the repetition is not described in detail herein.
S1103, determining the model training effect of the text error correction model according to the test deviation generated before and after each correction.
Specifically, the sum of the test deviations obtained by the text error correction model in the test process can be calculated according to the test deviations generated before and after each correction, so that the model training effect of the text error correction model can be evaluated according to the test deviations and the test values.
It should be noted that, in the training process of the text error correction model, after the positive deviation/negative deviation obtained in each training process is calculated, the model parameters in the text error correction model need to be adjusted and optimized based on the calculated positive deviation/negative deviation according to the method shown in steps S901-S902. Different from the training method of the text error correction model, in the test process of the model, the model parameters in the trained text error correction model do not need to be adjusted, that is, when step S1103 is executed, the model optimization process in the above steps S901-S902 is not involved, only the test deviation obtained each time needs to be recorded, and the training effect of the text error correction model is evaluated by using the sum of each test deviation.
According to the training method of the text error correction model, the language model is basically trained by using the general text data in the open field, and then the language model is subjected to fine tuning training by using the special text data in the target field, so that the trained language model has the capability of recognizing the specific text characteristics in the target field; and then, performing interactive auxiliary training on the text error correction model in training by using a mature target service object in the target field as a teacher model in a data interaction mode with the converged target service object. By the training method, the training model can be quickly adapted to a more complex and unique language environment on the premise of not losing the generalized text error correction capability, so that the text error correction accuracy of the model in the target field is improved.
In the embodiment of the present application, after the text error correction model is trained, the process in the application stage of the text error correction model is as follows:
as shown in fig. 12, fig. 12 is a schematic flowchart illustrating a text error correction method provided in an embodiment of the present application, where the text error correction method is applied to a pre-trained text error correction model; the text error correction model is used for providing text error correction service for a target service object in the target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the text error correction method further includes steps S1201-S1202; specifically, the method comprises the following steps:
s1201, inputting the text to be corrected, which needs to be subjected to text correction processing in the application process of the target service object, into a pre-trained text correction model, and correcting the target text errors included in the text to be corrected through the text correction model to obtain a corrected text output by the text correction model and aiming at the text to be corrected.
The text error correction model is obtained by training according to the manner of the steps S101 to S104 and testing according to the manner of the steps S1101 to S1103; for the specific training process and the specific testing process of the text error correction model, reference may be made to the specific implementation processes of the foregoing steps, and the repetition parts are not described herein again.
As can be known by combining the analysis content of the above steps, the service object type to which the target service object belongs is classified into three cases, namely, a priori type, a bidirectional verification type, and a posterior type, and for the following three specific types, how to determine the text to be corrected, the embodiment of the present application further provides the following optional implementation schemes, specifically:
(1) for the case that the target service object belongs to the prior type:
at this time, the text error correction model is used for performing text error correction service on the input text data of the target service object, and based on this, as an optional embodiment, in the case that the target service object belongs to the "prior type", the input text data of the target service object can be directly obtained from the target service object as the text to be error corrected, which needs to be subjected to the text error correction processing.
(2) For the case that the target service object belongs to the bidirectional authentication type:
at this time, the text error correction model is used for performing text error correction service on the input text data and/or the output text data of the target service object, and based on this, as an optional embodiment, under the condition that the target service object belongs to the "bidirectional verification type", the text data matched with the current specific application requirement of the target service object can be acquired from the input text data and/or the output text data of the target service object according to the current specific application requirement of the target service object, and is used as the text to be error corrected, which needs to be subjected to the text error correction processing.
(3) And for the case that the target service object belongs to the posterior type:
at this time, the text error correction model is used to perform text error correction service on the output text data of the target service object, and based on this, as an optional embodiment, in the case that the target service object belongs to the "posterior type", the output text data of the target service object can be directly obtained from the target service object as the text to be error corrected that needs to be subjected to the text error correction processing:
specifically, the text error correction model is used for correcting a target text error included in a text to be corrected; the target text error is determined according to specific semantic features and/or character expression features in the target field. For example, if the target field is a game field, the character expression of "sister paper" in the game field belongs to a specific character expression mode, and text error correction processing is not required; if the target field is the education field, the word expression of 'sister paper' in the education field is a word expression error, and text error correction processing is required.
S1202, replacing the text to be corrected input or output by the target service object in the application process with the correction text.
It should be noted that, there is a difference between the corrected text and the text to be corrected, that is, the text correction model performs text correction processing on the text to be corrected, and may be divided into the following 3 understanding manners, where the following 3 understanding manners are also equivalent to a core error correction concept for executing a text correction service in a target field, and specifically:
(1) and correcting the conventional text errors such as basic semantic errors, character writing errors and the like.
By way of example, still taking the target field as the game field as an example, if the "big day dog" occurs in the text data to be corrected in the form of a conventional text error, such as "big day enough", it is the case that the text correction model needs to perform the text correction process in this application.
(2) Although the text is not a conventional text error such as wrongly written characters, part of character expressions in the text are complex and long, and the characteristic text expression in the target field can be used for replacement, so that the replaced text is simpler and can embody the text characteristics of the target field.
For example, still taking the target field as the game field as an example, if the text to be corrected is "a game character f in the game X capable of helping the teammate player to supplement the character life attribute value in time", according to the characteristic text expression that game characters having skills "capable of helping the teammate player to supplement the character life attribute value in time" are collectively called "mama type" game characters in the game field, the game character f in the text to be corrected "in the game X capable of helping the teammate player to supplement the character life attribute value in time" can be corrected to "mama type game character f in the game X", which also belongs to the situation that the text correction model needs to perform text correction processing in the present application.
(3) And on the basis of the step (2), the original characteristic word expression in the text is not subjected to error correction due to the contradiction between the conventional expression of the words in the general field and the characteristic text expression.
For an exemplary explanation, still taking the target field as the game field as an example, if the text to be corrected is "mama type game role f in game X", then for the existing text correction model, since "mama" and "mam" generally belong to sensitive words that need to be corrected when appearing at the same time, the existing text correction model will perform text correction processing on the text data to be corrected; in contrast, this is the case where the trained text correction model in the present application does not require text correction processing.
By the text error correction method provided by the embodiment of the application, after the text error correction model is trained, the text error correction model can be used for performing text error correction processing on text data related to the target service object in the application process, so that the accuracy of the output result of the target service object model and the operating efficiency of the target service object are improved.
Based on the same inventive concept, the embodiment of the present application further provides a training apparatus for a text error correction model corresponding to the training method for the text error correction model in the embodiment of the present application, and as the principle of solving the problem of the training apparatus in the embodiment of the present application is similar to the training method in the embodiment of the present application, the implementation of the training apparatus may refer to the implementation of the training method, and repeated parts are not described again.
Referring to fig. 13, fig. 13 is a schematic structural diagram illustrating a training apparatus for a text correction model according to an embodiment of the present application; the text error correction model is used for providing text error correction service for a target service object in a target field; the target service object belongs to a converged mature algorithm model in the target field; the training apparatus includes:
the first training module 1301 is configured to pre-train the language model by using a first training text without semantic tags to obtain a first language representation model; wherein the first training text comprises specific text data in the target field and general text data outside the target field;
a second training module 1302, configured to train the first language representation model by using a semantically labeled second training text in the target field, so as to obtain a second language representation model with a target text feature recognition capability; the target text features are used for representing semantic features and/or character expression features of text data which are specific in the target field;
the first processing module 1303 is configured to input a third training text input or output by the target service object in the training process into the second language representation model, so as to obtain a corrected training text output by the second language representation model and obtained by performing text error correction processing on the third training text;
a parameter adjusting module 1304, configured to obtain a positive deviation/a negative deviation generated before and after the correction of the model output result of the target service object according to the output result of the target service object before the correction obtained based on the third training text and the output result of the target service object after the correction obtained based on the correction training text, and adjust the model parameter of the second language representation model according to the positive deviation/the negative deviation, so as to obtain a text error correction model including the adjusted model parameter.
In an alternative embodiment, the first training module 1301 is specifically configured to:
masking the participles with the first target number in the first training text in a random sampling mode to obtain a first masked training text comprising masked words with the first target number; wherein the first target number is determined according to the sampling proportion of the random sampling and the number of word segmentation included in the first training text;
inputting the first occlusion training text into the language model to obtain a first occlusion prediction text which is output by the language model and comprises prediction results of first target number of occlusion words;
and adjusting model parameters of the language model by using the cross entropy loss between the first occlusion prediction text and the first training text which is not subjected to mask occlusion until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
In an alternative embodiment, the first training module 1301 is specifically configured to:
masking the participles belonging to the second target number of the specific text data in the first training text according to a first preset sampling proportion to obtain a second masked training text comprising masked words of the second target number; the second target quantity is determined according to the first preset sampling proportion and the number of word segments belonging to the specific text data in the first training text;
inputting the second occlusion training text into the language model to obtain a second occlusion predicted text which is output by the language model and comprises a prediction result of a second target number of occlusion words;
and adjusting model parameters of the language model by using the cross entropy loss between the second masking prediction text and the first training text which is not masked by the mask until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
In an optional embodiment, the training the first language representation model by using the semantically labeled second training text in the target domain at least comprises: performing coarse-grained training and/or fine-grained training on the first language representation model by using a semantically marked second training text in the target field; the coarse-grained training is used for training the first language representation model to classify different sentences under the same semantic concept in the second training text according to different character expression modes corresponding to the same semantic concept in the target field; and the fine-grained training is used for training the first language representation model to identify the character expression mode of each sentence in the target field according to the word segmentation sequence marking result of each sentence in the second training text in the target field.
In an alternative embodiment, the second training module 1302 is configured to perform the coarse-grained training on the first language characterization model by:
for any two sentences in the second training text, inputting the original version sentences of the any two sentences from which the existing semantic labels are removed into the first language representation model, and performing classification prediction on whether the any two sentences correspond to the same semantic concept in the target field through the first language representation model to obtain classification prediction results of the any two sentences;
determining real classification results of any two sentences according to the semantic marks of the any two sentences in the second training text; the real classification result is used for representing whether any two sentences correspond to the same semantic concept in the target field;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the classification prediction result and the real classification result until the first language representation model converges.
In an alternative embodiment, the second training module 1302 is configured to perform the fine-grained training on the first language characterization model by:
for each sentence in the second training text, inputting the original version sentence of the sentence from which the semantic mark is removed into the first language representation model, and analyzing the sentence component of the sentence in the target field through the first language representation model to obtain a sentence analysis result of the sentence in the target field; wherein the sentence components include at least: a first target participle belonging to an entity defined in the target domain, and a second target participle capable of characterizing different semantic concepts in the target domain;
according to the multiple entities defined in the target field and the existing semantic tags in the sentence, carrying out sequence tagging on multiple participles in the sentence to obtain a participle sequence tagging result of the sentence;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the statement analysis result and the word segmentation sequence marking result until the first language representation model converges.
In an optional implementation manner, the first processing module 1303 is specifically configured to:
for each sentence in the third training text, inputting the sentence into the second language representation model to obtain a first output result of the second language representation model for the sentence;
under the condition that the difference between the first output result and the sentence is detected, determining that the second language representation model carries out the text error correction processing on the sentence, and taking the first output result as the correction training text;
and under the condition that the first output result is detected to be the same as the sentence, acquiring the next sentence from the third training text, and repeating the processing steps aiming at the sentence until the corrected training text is obtained.
In an alternative embodiment, the parameter adjusting module 1304 is configured to:
when the third training text belongs to text data input by the target service object in the training process, inputting the third training text into the target service object, and outputting to obtain an output result before correction;
and inputting the corrected training text into the target service object, and outputting to obtain the corrected output result.
In an optional embodiment, when the third training text is input into the target service object and the output result before the correction is obtained, the parameter adjusting module 1304 is configured to:
inputting the third training text into the target service object, and predicting the output category of the third training text through the target service object to obtain the output result before correction; the output result before correction is used for representing the probability that the output category of the third training text belongs to each preset category;
when the corrected training text is input into the target service object and the corrected output result is output, the parameter adjusting module 1304 is configured to:
inputting the corrected training text into the target service object, and predicting the output category of the corrected training text through the target service object to obtain the corrected output result; and the corrected output result is used for representing the probability that the output category of the corrected training text belongs to each preset category.
In an optional embodiment, in the case of positive/negative deviations generated before and after the correction of the model output result of the target service object, the parameter adjusting module 1304 is configured to:
calculating a first deviation generated before and after the model output result of the target service object is corrected according to a first deviation calculation strategy;
determining whether the first deviation belongs to the positive deviation or the negative deviation based on the first deviation.
In an alternative embodiment, when calculating a first deviation of the model output result of the target service object before and after the correction according to the first deviation calculation strategy, the parameter adjustment module 1304 is configured to:
and calculating a probability deviation value of the corrected output result and the output result before correction on the same preset category, and taking the calculation result as the first deviation.
In an alternative embodiment, the parameter adjusting module 1304 is further configured to:
when the third training text belongs to text data output by the target service object in the training process, taking the third training text as the output result before correction; and taking the corrected training text as the corrected output result.
In an optional embodiment, when the model output result of the target service object is obtained as a positive deviation/a negative deviation before and after the correction, the parameter adjusting module 1304 is further configured to:
calculating a second deviation generated before and after the model output result of the target service object is corrected according to a second deviation calculation strategy;
determining whether the second deviation belongs to the positive deviation or the negative deviation based on the second deviation.
In an optional implementation manner, when the second deviation generated before and after the second deviation calculation policy is calculated according to the model output result of the target service object, the parameter adjusting module 1304 is specifically configured to:
acquiring a standard text recognition result of target input data; wherein the target input data is used for representing model input data of the target service object when the target service object outputs the third training text in a training process;
calculating a text recognition deviation value between the third training text and the standard text recognition result, and taking the calculation result as a first text recognition deviation value;
calculating a text recognition deviation value between the corrected training text and the standard text recognition result, and taking the calculation result as a second text recognition deviation value;
and calculating a difference value between the first text recognition deviation value and the second text recognition deviation value, and taking a calculation result as the second deviation.
In an optional implementation manner, when the model parameters of the second language representation model are adjusted according to the positive deviation/negative deviation to obtain a text error correction model including the adjusted model parameters, the parameter adjusting module 1304 is specifically configured to:
in each training period of the second language representation model, acquiring a target positive deviation/negative deviation obtained by the target second language representation model trained based on the training period;
and adjusting the model parameters of the target second language representation model according to the target positive deviation/negative deviation, and obtaining the text error correction model comprising the adjusted model parameters when the target second language representation model meets a training cut-off condition.
In an alternative embodiment, the parameter adjustment module 1304 is further configured to determine the target second language characterization model at each training period by:
when each training period of the second language representation model is reached, acquiring the second language representation model trained in the last training period, and generating a mirror image second language representation model which is not trained in the last training period;
under the training period, synchronously training the second language representation model trained in the last training period and the mirror image second language representation model which is not trained in the last training period to respectively obtain an optimized second language representation model and an optimized mirror image second language representation model trained in the training period;
acquiring a first training deviation obtained based on the optimized second language representation model and a second training deviation obtained based on the optimized mirror image second language representation model in the training period; the first training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized second language representation model in the training period; the second training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized mirror image second language representation model in the training period;
if the first training deviation is smaller than the second training deviation, replacing the optimized second language representation model with the optimized mirror image second language representation model to serve as a target second language representation model of the training period;
if the first training deviation is larger than the second training deviation, taking the optimized second language representation model as a target second language representation model of the training period; and meanwhile, taking the optimized mirror image second language representation model as a mirror image second language representation model which is not trained in the training period.
In an optional embodiment, the training apparatus further includes:
the first test module is used for inputting a test text input or output by the target service object in the test process into the text error correction model to obtain a corrected test text output by the text error correction model and subjected to text error correction processing on the test text;
the second testing module is used for acquiring a testing deviation generated before and after the testing output result of the target service object is corrected according to a first testing output result obtained by the target service object based on the testing text and a second testing output result obtained by the target service object based on the correcting testing text; wherein the test deviations comprise positive test deviations belonging to a positive number and negative test deviations belonging to a negative number;
and the third testing module is used for determining the model training effect of the text error correction model according to the testing deviation generated before and after each correction.
According to the training device for the text error correction model, provided by the embodiment of the application, the language model is basically trained by using the general text data in the open field, and then the language model is subjected to fine tuning training by using the special text data in the target field, so that the trained language model has the capability of recognizing the specific text characteristics in the target field; and then, performing interactive auxiliary training on the text error correction model in training by using a mature target service object in the target field as a teacher model in a data interaction mode with the converged target service object. Through the training device, the training model can be quickly adapted to a more complex and unique language environment on the premise of not losing the generalized text error correction capability, so that the text error correction accuracy of the model in the target field is improved.
Based on the same inventive concept, a text error correction device corresponding to the text error correction method in the above embodiment is also provided in the embodiment of the present application, and because the principle of solving the problem of the text error correction device in the embodiment of the present application is similar to that of the text error correction method in the above embodiment of the present application, the implementation of the text error correction device may refer to the implementation of the text error correction method, and repeated details are not repeated.
Referring to fig. 14, fig. 14 is a schematic structural diagram illustrating a text error correction apparatus according to an embodiment of the present application; the text error correction device is applied to a pre-trained text error correction model; the text error correction model is used for providing text error correction service for a target service object in the target field; the target service object belongs to a converged mature algorithm model in the target field; the text correction apparatus includes:
a text error correction module 1401, configured to input a text to be corrected, which needs to be subjected to text error correction processing in an application process of the target service object, into a pre-trained text error correction model, and correct a target text error included in the text to be corrected through the text error correction model, so as to obtain a corrected text output by the text error correction model and specific to the text to be corrected; wherein the target text error is determined according to specific semantic features and/or character expression features in the target field;
a text replacing module 1402, configured to replace the text to be corrected, input or output by the target service object in the application process, with the correction text.
In an optional implementation manner, the text correction model is obtained by training according to the training method in any of the optional implementation manners in the foregoing embodiment; the repetition is not described in detail herein.
By the text error correction device provided by the embodiment of the application, after the text error correction model is trained, the text error correction model can be used for performing text error correction processing on text data related to the target service object in the application process, so that the accuracy of the output result of the target service object model and the operating efficiency of the target service object are improved.
As shown in fig. 15, an electronic device 1500 according to an embodiment of the present application is provided, which is configured to execute the steps of the method for training the text error correction model according to any one of the above-mentioned embodiments of the present application, and the device includes a first memory 1501, a first processor 1502, and a computer program stored in the first memory 1501 and executable on the first processor 1502, wherein the steps of the method for training the text error correction model according to any one of the above-mentioned embodiments are implemented when the first processor 1502 executes the computer program.
Specifically, the first memory 1501 and the first processor 1502 may be general-purpose memories and processors, which are not limited in particular, and when the first processor 1502 runs a computer program stored in the first memory 1501, any of the steps of the method for training a text error correction model described above can be executed.
Corresponding to the training method of the text correction model in the present application, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform any of the steps of the training method of the text correction model described above.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, or the like, and when executed, the computer program on the storage medium can perform any of the steps of the training method for the text error correction model described above.
As shown in fig. 16, another electronic device 1600 for executing the steps of the text error correction method according to any of the above-mentioned embodiments of the present application is provided, which includes a second memory 1601, a second processor 1602 and a computer program stored in the second memory 1601 and operable on the second processor 1602, wherein the second processor 1602 executes the computer program to implement any of the steps of the text error correction method according to any of the above-mentioned embodiments.
Specifically, the second memory 1601 and the second processor 1602 may be general-purpose memories and processors, and are not limited herein, and when the second processor 1602 runs the computer program stored in the second memory 1601, the steps of any of the text error correction methods described above can be executed.
Corresponding to the text error correction method in the present application, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform any of the steps of the text error correction method.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, or the like, and when executed, the computer program on the storage medium can perform any of the steps of the text error correction method described above.
In the embodiments provided in the present application, it should be understood that the disclosed system and method may be implemented in other ways. The above-described system embodiments are merely illustrative, and for example, the division of the units is only one logical functional division, and there may be other divisions in actual implementation, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of systems or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is defined in one figure, it need not be further defined and explained in subsequent figures, and moreover, the terms "first", "second", "third", etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the present disclosure, which should be construed in light of the above teachings. Are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (25)

1. The training method of the text error correction model is characterized in that the text error correction model is used for providing text error correction service for a target service object in a target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the training method comprises the following steps:
pre-training a language model by using a first training text without semantic labels to obtain a first language representation model; wherein the first training text comprises specific text data in the target field and general text data outside the target field;
training the first language representation model by utilizing a semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability; the target text features are used for representing semantic features and/or character expression features of text data which are specific in the target field;
inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text;
and acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
2. The training method according to claim 1, wherein the pre-training the language model with the semantic-tag-free first training text to obtain the first language representation model comprises:
masking the participles with the first target number in the first training text in a random sampling mode to obtain a first masked training text comprising masked words with the first target number; wherein the first target number is determined according to the sampling proportion of the random sampling and the number of word segmentation included in the first training text;
inputting the first occlusion training text into the language model to obtain a first occlusion prediction text which is output by the language model and comprises prediction results of first target number of occlusion words;
and adjusting model parameters of the language model by using the cross entropy loss between the first occlusion prediction text and the first training text which is not subjected to mask occlusion until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
3. The training method according to claim 1, wherein the pre-training the language model with the semantic-tag-free first training text to obtain a first language representation model, further comprises:
masking the participles belonging to the second target number of the specific text data in the first training text according to a first preset sampling proportion to obtain a second masked training text comprising masked words of the second target number; the second target quantity is determined according to the first preset sampling proportion and the number of word segments belonging to the specific text data in the first training text;
inputting the second occlusion training text into the language model to obtain a second occlusion predicted text which is output by the language model and comprises a prediction result of a second target number of occlusion words;
and adjusting model parameters of the language model by using the cross entropy loss between the second masking prediction text and the first training text which is not masked by the mask until the language model converges, and taking the language model which reaches the convergence as the first language representation model.
4. The training method according to claim 1, wherein the training the first language characterization model using the semantically labeled second training text in the target domain comprises at least: performing coarse-grained training and/or fine-grained training on the first language representation model by using a semantically marked second training text in the target field; the coarse-grained training is used for training the first language representation model to classify different sentences under the same semantic concept in the second training text according to different character expression modes corresponding to the same semantic concept in the target field; and the fine-grained training is used for training the first language representation model to recognize the character expression mode of each sentence in the target field according to the word segmentation sequence marking result of each sentence in the second training text in the target field.
5. The training method of claim 4, wherein the coarse-grained training of the first language characterization model is performed by:
for any two sentences in the second training text, inputting the original version sentences of the any two sentences from which the existing semantic labels are removed into the first language representation model, and performing classification prediction on whether the any two sentences correspond to the same semantic concept in the target field through the first language representation model to obtain classification prediction results of the any two sentences;
determining real classification results of any two sentences according to the semantic labels of the any two sentences in the second training text; the real classification result is used for representing whether any two sentences correspond to the same semantic concept in the target field;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the classification prediction result and the real classification result until the first language representation model converges.
6. The training method of claim 4, wherein the fine-grained training of the first language characterization model is performed by:
for each sentence in the second training text, inputting the original version sentence of the sentence from which the semantic mark is removed into the first language representation model, and analyzing the sentence component of the sentence in the target field through the first language representation model to obtain a sentence analysis result of the sentence in the target field; wherein the sentence component comprises at least: a first target participle belonging to an entity defined in the target domain, and a second target participle capable of characterizing different semantic concepts in the target domain;
according to the multiple entities defined in the target field and the existing semantic tags in the sentence, carrying out sequence tagging on multiple participles in the sentence to obtain a participle sequence tagging result of the sentence;
and adjusting the model parameters of the first language representation model by using the cross entropy loss between the statement analysis result and the word segmentation sequence marking result until the first language representation model converges.
7. The training method according to claim 1, wherein the inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model after performing text error correction processing on the third training text comprises:
for each sentence in the third training text, inputting the sentence into the second language representation model to obtain a first output result of the second language representation model for the sentence;
under the condition that the difference between the first output result and the sentence is detected, determining that the second language representation model carries out the text error correction processing on the sentence, and taking the first output result as the correction training text;
and under the condition that the first output result is detected to be the same as the sentence, acquiring the next sentence from the third training text, and repeating the processing steps aiming at the sentence until the corrected training text is obtained.
8. The training method according to claim 1, wherein after obtaining the corrected training text output by the second language representation model after text error correction processing on the third training text, the training method further comprises:
when the third training text belongs to text data input by the target service object in the training process, inputting the third training text into the target service object, and outputting to obtain an output result before correction;
and inputting the corrected training text into the target service object, and outputting to obtain the corrected output result.
9. The training method of claim 8, wherein the inputting the third training text into the target service object and outputting the pre-correction output result comprises:
inputting the third training text into the target service object, and predicting the output category of the third training text through the target service object to obtain the output result before correction; the output result before correction is used for representing the probability that the output category of the third training text belongs to each preset category;
the inputting the correction training text into the target service object and outputting to obtain the output result after correction includes:
inputting the corrected training text into the target service object, and predicting the output category of the corrected training text through the target service object to obtain the corrected output result; and the corrected output result is used for representing the probability that the output category of the corrected training text belongs to each preset category.
10. The training method according to claim 9, wherein the obtaining of the positive/negative bias before/after correction of the model output result of the target service object comprises:
calculating a first deviation generated before and after the model output result of the target service object is corrected according to a first deviation calculation strategy;
determining whether the first deviation belongs to the positive deviation or the negative deviation based on the first deviation.
11. The training method of claim 10, wherein calculating a first deviation of the model output result of the target service object before and after the correction according to a first deviation calculation strategy comprises:
and calculating a probability deviation value of the corrected output result and the output result before correction on the same preset category, and taking the calculation result as the first deviation.
12. The training method according to claim 1, wherein after obtaining the corrected training text output by the second language representation model and obtained by text correction processing on the third training text, the training method further comprises:
when the third training text belongs to text data output by the target service object in the training process, taking the third training text as the output result before correction; and taking the corrected training text as the corrected output result.
13. The training method according to claim 12, wherein the obtaining of the positive/negative bias before/after the correction of the model output result of the target service object comprises:
calculating a second deviation generated before and after the model output result of the target service object is corrected according to a second deviation calculation strategy;
determining whether the second deviation belongs to the positive deviation or the negative deviation based on the second deviation.
14. The training method of claim 13, wherein calculating a second deviation of the model output result of the target service object before and after the correction according to a second deviation calculation strategy comprises:
acquiring a standard text recognition result of target input data; wherein the target input data is used for characterizing model input data of the target service object when the target service object outputs the third training text in a training process;
calculating a text recognition deviation value between the third training text and the standard text recognition result, and taking the calculation result as a first text recognition deviation value;
calculating a text recognition deviation value between the corrected training text and the standard text recognition result, and taking the calculation result as a second text recognition deviation value;
and calculating a difference value between the first text recognition deviation value and the second text recognition deviation value, and taking a calculation result as the second deviation.
15. The training method according to claim 1, wherein the adjusting the model parameters of the second language representation model according to the positive/negative deviation to obtain a text error correction model including the adjusted model parameters comprises:
in each training period of the second language representation model, acquiring a target positive deviation/negative deviation obtained by the target second language representation model trained based on the training period;
and adjusting the model parameters of the target second language representation model according to the target positive deviation/negative deviation, and obtaining the text error correction model comprising the adjusted model parameters when the target second language representation model meets a training cut-off condition.
16. A training method according to claim 15, characterized in that the target second language representation model at each training period is determined by:
when each training period of the second language representation model is reached, acquiring the second language representation model trained in the last training period, and generating a mirror image second language representation model which is not trained in the last training period;
under the training period, synchronously training the second language representation model trained in the last training period and the mirror image second language representation model which is not trained in the last training period to respectively obtain an optimized second language representation model and an optimized mirror image second language representation model trained in the training period;
acquiring a first training deviation obtained based on the optimized second language representation model and a second training deviation obtained based on the optimized mirror image second language representation model in the training period; the first training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized second language representation model in the training period; the second training deviation is used for representing deviation sum values of a plurality of positive deviations/negative deviations obtained based on the optimized mirror image second language representation model in the training period;
if the first training deviation is smaller than the second training deviation, replacing the optimized second language representation model with the optimized mirror image second language representation model to serve as a target second language representation model of the training period;
if the first training deviation is larger than the second training deviation, taking the optimized second language representation model as a target second language representation model of the training period; and meanwhile, taking the optimized mirror image second language representation model as a mirror image second language representation model which is not trained in the training period.
17. The training method of claim 1, wherein after the obtaining of the text correction model including the adjusted model parameters, the training method further comprises:
inputting the test text input or output by the target service object in the test process into the text error correction model to obtain a corrected test text output by the text error correction model and subjected to text error correction processing on the test text;
acquiring a test deviation generated before and after the test output result of the target service object is corrected according to a first test output result obtained by the target service object based on the test text and a second test output result obtained by the target service object based on the corrected test text; wherein the test deviations comprise positive test deviations belonging to a positive number and negative test deviations belonging to a negative number;
and determining the model training effect of the text error correction model according to the test deviation generated before and after each correction.
18. A text error correction method is characterized in that the text error correction method is applied to a pre-trained text error correction model; the text error correction model is used for providing text error correction service for a target service object in the target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the text error correction method comprises the following steps:
inputting a text to be corrected, which needs to be subjected to text correction processing in an application process, of the target service object into a pre-trained text correction model, and correcting a target text error included in the text to be corrected through the text correction model to obtain a corrected text output by the text correction model and aiming at the text to be corrected; wherein the target text error is determined according to specific semantic features and/or character expression features in the target field;
and replacing the text to be corrected input or output by the target service object in the application process with the correction text.
19. The method of claim 18, wherein the text correction model is obtained by training according to the training method of any one of claims 1 to 17.
20. The training device of the text error correction model is characterized in that the text error correction model is used for providing text error correction service for a target service object in a target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the training apparatus includes:
the first training module is used for pre-training the language model by utilizing a first training text without semantic tags to obtain a first language representation model; wherein the first training text comprises specific text data in the target field and general text data outside the target field;
the second training module is used for training the first language representation model by utilizing a semantically marked second training text in the target field to obtain a second language representation model with target text feature recognition capability; the target text features are used for representing semantic features and/or character expression features of text data which are specific in the target field;
the first processing module is used for inputting a third training text input or output by the target service object in the training process into the second language representation model to obtain a corrected training text output by the second language representation model and subjected to text error correction processing on the third training text;
and the parameter adjusting module is used for acquiring a positive deviation/a negative deviation generated before and after the model output result of the target service object is corrected according to a pre-correction output result obtained by the target service object based on the third training text and a post-correction output result obtained by the target service object based on the corrected training text, and adjusting the model parameters of the second language representation model according to the positive deviation/the negative deviation to obtain a text error correction model comprising the adjusted model parameters.
21. The text error correction device is characterized in that the text error correction device is applied to a pre-trained text error correction model; the text error correction model is used for providing text error correction service for a target service object in the target field; wherein the target service object belongs to a mature algorithm model converged under the target domain; the text correction apparatus includes:
the text error correction module is used for inputting a text to be corrected, which needs to be subjected to text error correction processing in the application process of the target service object, into a pre-trained text error correction model, and correcting a target text error included in the text to be corrected through the text error correction model to obtain a corrected text output by the text error correction model and aiming at the text to be corrected; wherein the target text error is determined according to specific semantic features and/or character expression features in the target field;
and the text replacement module is used for replacing the text to be corrected input or output by the target service object in the application process with the correction text.
22. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the training method of any of claims 1 to 17.
23. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, performs the steps of the training method as claimed in any one of the claims 1 to 17.
24. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the text correction method of any of claims 18 to 19.
25. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the text correction method according to one of claims 18 to 19.
CN202210506361.8A 2022-05-10 2022-05-10 Training method and device of text error correction model and text error correction method and device Pending CN114861636A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210506361.8A CN114861636A (en) 2022-05-10 2022-05-10 Training method and device of text error correction model and text error correction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210506361.8A CN114861636A (en) 2022-05-10 2022-05-10 Training method and device of text error correction model and text error correction method and device

Publications (1)

Publication Number Publication Date
CN114861636A true CN114861636A (en) 2022-08-05

Family

ID=82637914

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210506361.8A Pending CN114861636A (en) 2022-05-10 2022-05-10 Training method and device of text error correction model and text error correction method and device

Country Status (1)

Country Link
CN (1) CN114861636A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858776A (en) * 2022-10-31 2023-03-28 北京数美时代科技有限公司 Variant text classification recognition method, system, storage medium and electronic equipment
CN116306598A (en) * 2023-05-22 2023-06-23 上海蜜度信息技术有限公司 Customized error correction method, system, equipment and medium for words in different fields

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858776A (en) * 2022-10-31 2023-03-28 北京数美时代科技有限公司 Variant text classification recognition method, system, storage medium and electronic equipment
CN116306598A (en) * 2023-05-22 2023-06-23 上海蜜度信息技术有限公司 Customized error correction method, system, equipment and medium for words in different fields
CN116306598B (en) * 2023-05-22 2023-09-08 上海蜜度信息技术有限公司 Customized error correction method, system, equipment and medium for words in different fields

Similar Documents

Publication Publication Date Title
CN112070138B (en) Construction method of multi-label mixed classification model, news classification method and system
KR101813683B1 (en) Method for automatic correction of errors in annotated corpus using kernel Ripple-Down Rules
CN112270379A (en) Training method of classification model, sample classification method, device and equipment
CN111966812B (en) Automatic question answering method based on dynamic word vector and storage medium
CN114861636A (en) Training method and device of text error correction model and text error correction method and device
CN103678271B (en) A kind of text correction method and subscriber equipment
CN109033085B (en) Chinese word segmentation system and Chinese text word segmentation method
CN112905795A (en) Text intention classification method, device and readable medium
CN111159412A (en) Classification method and device, electronic equipment and readable storage medium
CN112860896A (en) Corpus generalization method and man-machine conversation emotion analysis method for industrial field
CN111507093A (en) Text attack method and device based on similar dictionary and storage medium
CN114218379A (en) Intelligent question-answering system-oriented method for attributing questions which cannot be answered
CN110991193A (en) Translation matrix model selection system based on OpenKiwi
CN113806489A (en) Method, electronic device and computer program product for dataset creation
CN113705207A (en) Grammar error recognition method and device
CN112613293A (en) Abstract generation method and device, electronic equipment and storage medium
US20230004581A1 (en) Computer-Implemented Method for Improving Classification of Labels and Categories of a Database
CN110929532A (en) Data processing method, device, equipment and storage medium
CN116028608A (en) Question-answer interaction method, question-answer interaction device, computer equipment and readable storage medium
CN115496630A (en) Patent writing quality checking method and system based on natural language algorithm
CN116151220A (en) Word segmentation model training method, word segmentation processing method and device
CN114330350A (en) Named entity identification method and device, electronic equipment and storage medium
CN113505589A (en) BERT model-based MOOC learner cognitive behavior identification method
CN112528045B (en) Method and system for judging domain map relation based on open encyclopedia map
CN110008307B (en) Method and device for identifying deformed entity based on rules and statistical learning

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