[go: up one dir, main page]

CN114861636B - Text error correction model training method and device, text error correction method and device - Google Patents

Text error correction model training method and device, text error correction method and device Download PDF

Info

Publication number
CN114861636B
CN114861636B CN202210506361.8A CN202210506361A CN114861636B CN 114861636 B CN114861636 B CN 114861636B CN 202210506361 A CN202210506361 A CN 202210506361A CN 114861636 B CN114861636 B CN 114861636B
Authority
CN
China
Prior art keywords
text
training
model
target
language
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.)
Active
Application number
CN202210506361.8A
Other languages
Chinese (zh)
Other versions
CN114861636A (en
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/CN114861636B/en
Publication of CN114861636A publication Critical patent/CN114861636A/en
Application granted granted Critical
Publication of CN114861636B publication Critical patent/CN114861636B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • G06F40/35Discourse or dialogue representation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Data Mining & Analysis (AREA)
  • Biomedical Technology (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Evolutionary Computation (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Machine Translation (AREA)

Abstract

本申请提供了一种文本纠错模型的训练方法及装置、文本纠错方法及装置,所述训练方法包括:先使用通用文本数据对语言模型进行基本训练,再使用目标领域下的专有文本数据对语言模型进行微调训练,然后,通过与目标服务对象之间进行数据交互的方式,使用目标领域下较为成熟的目标服务对象,来对文本纠错模型进行交互辅助性训练。这样,本申请可以在不损失泛化文本纠错能力的前提下,训练模型快速适应复杂而独特的语言环境,从而提高模型在目标领域下的文本纠错准确率。与之相应的,本申请中训练好的文本纠错模型可以对目标服务对象应用过程中涉及的文本数据进行文本纠错处理,有利于提高目标服务对象的运行效率以及输出结果的准确程度。

The present application provides a training method and device for a text error correction model, a text error correction method and device, and the training method includes: first using general text data to perform basic training on the language model, then using proprietary text data in the target field to fine-tune the language model, and then, by means of data interaction with the target service object, using the more mature target service object in the target field to perform interactive auxiliary training on the text error correction model. In this way, the present application can train the model to quickly adapt to complex and unique language environments without losing the generalized text error correction capability, thereby improving the text error correction accuracy of the model in the target field. Correspondingly, the text error correction model trained in the present application can perform text error correction processing on the text data involved in the application process of the target service object, which is beneficial to improving the operating efficiency of the target service object and the accuracy of the output results.

Description

Training method and device for text error correction model, 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 also emerging and has achieved remarkable results in various industries. However, with the advent of cultural diversity, language expression modes with respective field features are derived in different business fields, for example, in the game field, players often use a seemingly erroneous text expression to achieve a humorous language effect without losing the game field features in a "harmonic stem" manner during the game.
In combination with the above, it can be seen that, because there is a contradiction between generalization of the language expression in the general field and pertinence in the special service field, the conventional text correction model that is originally used for correcting wrongly written characters only cannot be applied to performing text correction tasks in the special service field.
Disclosure of Invention
In view of the above, the present application aims to provide a training method and apparatus for text correction models, and a text correction method and apparatus, so that the training model can quickly adapt to a more complex and unique language environment without losing the generalized text correction capability, thereby improving the text correction accuracy of the model in the target field.
In a first aspect, an embodiment of the present application provides a training method 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, where the target service object belongs to a converged mature algorithm model in the target field, and the training method includes:
Pre-training a language model by using a first training text without semantic marks to obtain a first language characterization 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 characterization model by using a second training text with semantic marks in the target field to obtain a second language characterization model with target text feature recognition capability, wherein the target text features are used for characterizing the special semantic features and/or text expression features of the text data 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 characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text;
And 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 correction training text, acquiring positive deviation/negative deviation generated by the model output result of the target service object before and after correction, and adjusting model parameters of the second language representation model according to the positive deviation/negative deviation to obtain a text error correction model comprising the adjusted model parameters.
In an alternative embodiment, the pre-training the language model with the first training text without semantic tags to obtain a first language characterization model includes:
masking and shielding a first target number of segmented words in the first training text in a random sampling mode to obtain a first masking training text comprising the first target number of masked words, wherein the first target number is determined according to the sampling proportion of the random sampling and the number of segmented words in the first training text;
inputting the first masking training text into the language model to obtain a first masking predicted text which is output by the language model and comprises predicted results of masking words of a first target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the first masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
In an optional implementation manner, the pre-training the language model by using the first training text without semantic marks to obtain a first language characterization model, and further includes:
Masking and shielding the word segmentation of a second target number belonging to the specific text data in the first training text according to a first preset sampling proportion to obtain a second masking training text comprising the masked word of the second target number, wherein the second target number is determined according to the first preset sampling proportion and the word segmentation number belonging to the specific text data in the first training text;
Inputting the second masking training text into the language model to obtain a second masking predicted text which is output by the language model and comprises predicted results of masking words of a second target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the second masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
In an optional implementation manner, the training of the first language characterization model by using the second training text with the semantic mark in the target field at least includes performing coarse-granularity training and/or fine-granularity training on the first language characterization model by using the second training text with the semantic mark in the target field, where the coarse-granularity training is used to train the first language characterization model to classify different sentences in the second training text under the same semantic concept according to different text expression modes corresponding to the same semantic concept in the target field, and the fine-granularity training is used to train the first language characterization model to identify the text 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 an alternative embodiment, the coarse-granularity training is performed on the first language characterization model by:
inputting original version sentences of the second training text after the existing semantic marks are removed from the two sentences into the first language characterization model, and performing classification prediction on whether the two sentences correspond to the same semantic concept in the target field or not through the first language characterization model to obtain classification prediction results of the two sentences;
Determining a real classification result of any two sentences according to the semantic marks of the any two sentences in the second training text, wherein the real classification result is used for representing whether the any two sentences correspond to the same semantic concept in the target field or not;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the classification prediction result and the real classification result until the first language characterization model converges.
In an alternative embodiment, the fine-grained training of the first language characterization model is performed by:
Inputting an original version sentence of which the existing semantic mark is removed into the first language characterization model aiming at each sentence in the second training text, and analyzing sentence components of the sentence in the target field through the first language characterization model to obtain a sentence analysis result of the sentence in the target field, wherein the sentence components at least comprise first target participles which belong to entities defined in the target field and second target participles which can characterize different semantic concepts in the target field;
according to the entities defined in the target field and the semantic tags existing in the sentence, performing sequence tagging on a plurality of participles included in the sentence to obtain a participle sequence tagging result of the sentence;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the sentence analysis result and the word segmentation sequence marking result until the first language characterization model converges.
In an optional implementation manner, the inputting the third training text input or output by the target service object in the training process into the second language representation model, to obtain the corrected training text output by the second language representation model after performing text correction processing on the third training text, includes:
Inputting each sentence in the third training text into the second language characterization model to obtain a first output result of the second language characterization model for the sentence;
Under the condition that the first output result is detected to be different from the sentence, determining that the second language characterization model carries out text error correction processing on the sentence, and taking the first output result as the correction training text;
And if 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 for the sentence until the corrected training text is obtained.
In an alternative embodiment, after obtaining the corrected training text output by the second language characterization 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 the output result before correction;
And inputting the corrected training text into the target service object, and outputting the corrected training text to obtain a corrected output result.
In an alternative embodiment, the inputting the third training text into the target service object, outputting the output result before correction, includes:
The third training text is input into the target service object, and the output category of the third training text is predicted through the target service object to obtain the output result before correction, wherein 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 step of inputting the corrected training text into the target service object and outputting the corrected output result comprises the following steps:
and 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, wherein 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 implementation manner, the obtaining the positive deviation/negative deviation generated before and after correcting the model output result of the target service object includes:
Calculating a first deviation generated before and after correction of a model output result of the target service object 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, the calculating, according to a first deviation calculating policy, a first deviation generated before and after correction of the model output result of the target service object includes:
And calculating a probability deviation value of the corrected output result and the output result before correction in the same preset category, and taking the calculated result as the first deviation.
In an alternative embodiment, after obtaining the corrected training text output by the second language characterization 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, the third training text is used as the output result before correction, and the corrected training text is used as the output result after correction.
In an optional implementation manner, the obtaining the positive deviation/negative deviation generated before and after correcting the model output result of the target service object includes:
calculating a second deviation generated before and after correction of the model output result of the target service object 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 alternative embodiment, the calculating, according to a second deviation calculating policy, a second deviation generated before and after correction of the model output result of the target service object includes:
The method comprises the steps of obtaining standard text recognition results of target input data, wherein the target input data are used for representing model input data of a target service object when the target service object outputs a 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 alternative embodiment, the adjusting the model parameters of the second language characterization model according to the positive bias/negative bias to obtain a text correction model including the adjusted model parameters includes:
Acquiring target positive deviation/negative deviation obtained by a target second language characterization model trained based on the training period in each training period of the second language characterization model;
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 the training cut-off condition.
In an alternative embodiment, the target second language characterization model for each training period is determined by:
When each training period of the second language representation model is reached, acquiring the trained second language representation model in the previous training period, and generating a mirror image second language representation model which is not trained in the previous training period;
Under the training period, synchronously training the second language characterization model trained in the previous training period and the mirror image second language characterization model not trained in the previous training period to respectively obtain an optimized second language characterization model and an optimized mirror image second language characterization model trained in the training period;
The method comprises the steps of obtaining 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, wherein the first training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation obtained based on the optimized second language representation model in the training period, and the second training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation 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 by using 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, the optimized second language representation model is used as a target second language representation model of the training period; and simultaneously, 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 alternative embodiment, after the obtaining the text error correction model including the adjusted model parameters, the training method further includes:
Inputting test text input or output by the target service object in the test process into the text correction model to obtain corrected test text output by the text correction model after text correction processing is carried out on the test text;
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, obtaining test deviations generated before and after correction of the test output result of the target service object, wherein the test deviations comprise positive test deviations belonging to positive numbers and negative test deviations belonging to negative numbers;
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, the embodiment of the application further provides a text error correction method, 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 converged mature algorithm model in the target field, and the text error correction method comprises the following steps:
Inputting a text to be corrected, which is required to be subjected to text correction processing in an application process, of the target service object into a pre-trained text correction model, correcting target text errors included in the text to be corrected through the text correction model, and obtaining corrected text which is output by the text correction model and is aimed at the text to be corrected, wherein the target text errors are determined according to special semantic features and/or text expression features in the target field;
And replacing the text to be corrected, which is input or output by the target service object in the application process, with the corrected text.
In an alternative embodiment, the text error correction model is trained according to the training method of any of the alternative embodiments of the first aspect.
In a third aspect, an embodiment of the present application provides a training device 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, where the target service object belongs to a converged mature algorithm model in the target field, and the training device includes:
The first training module is used for pre-training the language model by using a first training text without semantic marks to obtain a first language characterization 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 characterization model by utilizing a second training text which is subjected to semantic marking in the target field to obtain a second language characterization model with target text feature recognition capability, wherein the target text features are used for characterizing the special semantic features and/or text expression features of the text data 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 characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text;
And the parameter adjustment module is used for acquiring positive deviation/negative deviation generated before and after correction of the model output result of the target service object according to the pre-correction output result obtained by the target service object based on the third training text and the post-correction output result obtained by the target service object based on the correction training text, and adjusting the model parameters of the second language characterization model according to the positive deviation/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 correction device, where the text correction device is applied to a pre-trained text correction model, where the text correction model is used to provide a text correction service for a target service object in a target domain, where the target service object belongs to a converged mature algorithm model in the target domain, and the text correction device includes:
The text error correction module is used for inputting a text to be corrected, which is required 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, correcting target text errors included in the text to be corrected through the text error correction model, and obtaining corrected text which is output by the text error correction model and is aimed at the text to be corrected, wherein the target text errors are determined according to special semantic features and/or text expression features in the target field;
And the text replacement module is used for replacing the text to be corrected, which is input or output by the target service object in the application process, with the corrected text.
In a fifth aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of any one of the training methods of the text error correction model described above when the processor executes the computer program.
In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, where a computer program is stored, where the computer program is executed by a processor to perform the steps of any one of the above training methods for a text error correction model.
In a seventh aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of any one of the text error correction methods described above when executing the computer program.
In an eighth aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor performs the steps of any of the text error correction methods described above.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
According to the training method and device for the text error correction model, the text error correction method and device, general text data in the open field are used for basic training of the language model, proprietary text data in the target field is used for fine tuning training of the language model, the trained language model has the capability of identifying specific text features in the target field, and then a data interaction mode is carried out between the trained language model and the converged target service object, the target service object which is mature in the target field is used as a teacher model, so that interactive auxiliary training is carried out on the text error correction model in training. On the one hand, the text correction model can be used for carrying out text correction processing on text data related in the application process of the target service object after the text correction model is trained, 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 above 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 needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a training method of a text error correction model according to an embodiment of the present application;
FIG. 2 is a flow chart of a first method of pre-training provided by an embodiment of the present application;
FIG. 3 is a flow chart of a second method of pre-training according to an embodiment of the present application;
FIG. 4 is a flow chart of a method for coarse-grained training according to an embodiment of the application;
FIG. 5 is a flow chart of a method for fine granularity training according to an embodiment of the present application;
FIG. 6 is a flowchart of a method for determining whether text error correction processing occurs according to an embodiment of the present application;
FIG. 7 is a flow chart of a method for calculating a first deviation according to an embodiment of the present application;
FIG. 8 is a flow chart of a method for calculating a second deviation according to an embodiment of the present application;
FIG. 9 is a flow chart of a method for adjusting model parameters of a second language characterization model according to an embodiment of the present application;
FIG. 10 is a flow chart of a method for determining a target second language characterization model for each training period according to an embodiment of the present application;
FIG. 11 is a flowchart of a method for testing a text error correction model according to an embodiment of the present application;
fig. 12 is a schematic flow chart of a text error correction method according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a training device for text error correction model according to an embodiment of the present application;
fig. 14 shows a schematic structural diagram of a text error correction device 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 application;
Fig. 16 is a schematic structural diagram of another electronic device 1600 according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for the purpose of illustration and description only and are not intended to limit the scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
In addition, the described embodiments are only some, but not all, embodiments of the application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the term "comprising" will be used in embodiments of the application to indicate the presence of the features stated hereafter, but not to exclude the addition of other features.
In consideration of the contradiction between generalization of the general field and pertinence of the special service field in the language expression in the prior art, the conventional text error correction model which is originally used for correcting wrongly written words only cannot be suitable for executing the text error correction task in the special service field.
Based on the above, the embodiment of the application provides a training method and device for a text error correction model, the text error correction method and device, which are characterized in that general text data in an open field is used for basic training of a language model, then proprietary text data in a target field is used for fine tuning training of the language model, so that the trained language model has the capability of identifying specific text characteristics in the target field, and then a data interaction mode is carried out between the trained language model and a converged target service object, and a more mature target service object in the target field is used as a teacher model to carry out interactive auxiliary training on the text error correction model in training. On the one hand, the text correction model can be used for carrying out text correction processing on text data related in the application process of the target service object after the text correction model is trained, and the accuracy of the output result of the target service object and the operation efficiency of the target service object are improved.
The training method and device for the text error correction model, the text error correction method and device provided by the embodiment of the application are described in detail below.
Referring to fig. 1, fig. 1 shows a flow chart of 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 a text error correction service for a target service object in a target domain, the target service object belongs to a converged mature algorithm model in the target domain, and the training method includes steps S101-S104, and specifically:
s101, pre-training the language model by using a first training text without semantic marks to obtain a first language characterization model.
S102, training the first language characterization model by using the second training text with the semantic mark in the target field to obtain a second language characterization 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 characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text.
S104, according to the pre-correction output result obtained by the target service object based on the third training text and the post-correction output result obtained by the target service object based on the correction training text, obtaining positive deviation/negative deviation generated by the model output result of the target service object before and after correction, and adjusting the model parameters of the second language characterization model according to the positive deviation/negative deviation, so as to obtain a text error correction model comprising the adjusted model parameters.
According to the training method for the text error correction model, general text data in the open field is used for basic training of the language model, proprietary text data in the target field is used for fine tuning training of the language model, the trained language model has the capability of identifying specific text features in the target field, and then a relatively mature target service object in the target field is used as a teacher model in a data interaction mode with the converged target service object to conduct interactive auxiliary training on the text error correction model in training. By the training method, the training model can be quickly adapted to more complex and unique language environment on the premise of not losing the generalized text correction capability, so that the text correction accuracy of the model in the target field is improved.
The following exemplary descriptions are respectively given to each step in the training method of the text error correction model according to the embodiment of the present application:
s101, pre-training the language model by using a first training text without semantic marks to obtain a first language characterization model.
Here, the first training text includes specific text data in a target domain and general text data outside the target domain, wherein the target domain is determined according to a specific business scenario of a 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.
The general text data is used for representing text data in other general fields except for a target field, wherein the general field is used for referring to all business scenes possibly applied by the text data when the specific business scenes applied by the text data are not limited. For example, if the target field is a game field, the general text data may be various text data that can be acquired from other fields such as an education field, a media field, a cultural sports field, and the like.
The training of the pre-training aims at using the universal text data (namely, the first training text without semantic marks) under the open field (equivalent to the field comprising the target field and the non-target field) to carry out basic training on the language model, so that the language model (namely, the first language characterization model) obtained after training can predict the occurrence probability of each word in the semantic environment characterized by different context according to different context in the text data (namely, the first language characterization model with basic context awareness capability is obtained).
Specifically, as an optional embodiment, when the first training text is obtained, text data (including the specific text data and the general text data) collected under the general field may be preprocessed (such as removing some known stop words, industry sensitive words, malicious words with abuse properties, etc.) by performing a round of sensitive word removal process on the text data collected under the general field, so as to obtain a first training text with a more standard format, reduce the difficulty of training a model for pre-training a language model, and improve the model training efficiency of the language model.
S102, training the first language characterization model by using the second training text with the semantic mark in the target field to obtain a second language characterization model with target text feature recognition capability.
In the embodiment of the application, the semantic mark in the second training text is used for representing that for each word in the second training text, if the word has specific target semantics and/or belongs to proper nouns in the target field when appearing in the target field, the target semantics and/or noun concept definition corresponding to the target field are marked.
Specifically, the training of the first language characterization model by using the second training text in step S102 is to use the proprietary text data in the target domain (i.e., the second training text that has been semantically marked in the target domain) to perform fine-tuning training on the first language characterization model after the first language characterization model has the basic context awareness capability, so that the second language characterization model obtained after the fine-tuning training can predict the relationships between sentences of different sentences in the target domain and the sentence components of the same sentence in the target domain (i.e., obtain the second language characterization model with the target text feature recognition capability).
The target text features are used for representing the special semantic features and/or text expression features of the text data in the target field, wherein the semantic features are equivalent to the fact that a second language representation model predicts the sentence relationship of different sentences in the target field (such as whether the corresponding semantics of two sentences in the target field are the same or not), and the text expression features are equivalent to the fact that the second language representation model predicts the sentence components of the same sentence in the target field (such as which word in the sentence belongs to an entity word defined in the target field and which word belongs to a proper noun interpreted by the same semantic concept in the target field).
Specifically, the above 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 a target field as an example, a "soul" is specific text data that appears only under the game field, and its semantic feature is "a kind of virtual equipment in a game".
(2) Special semantic features corresponding to the same text data when the same text data appears in the target field;
For example, still taking the game field as the target field as an example, the special semantic feature corresponding to "Sun Shangxiang" when it appears under the game field is "one game character", but when "Sun Shangxiang" appears under the general field other than the game field, the general semantic feature corresponding to "one history character" is general.
Specifically, the above text expression features may also include at least the following 2 types of features:
(1) The correct text expression of specific text data in the target field;
For example, taking the specific text data "soul" in the game field as an example, the "soul" is the correct text expression of the specific text data in the game field, and the "yul" is the incorrect text expression of the specific text data in the game field.
(2) The corresponding special text 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 under the general field belongs to the wrong text expression of a "sister", but a "sister paper" placed under the game field belongs to a characterizing name for female players/female game characters.
S103, inputting a third training text input or output by the target service object in the training process into the second language characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text.
Here, unlike the model training of the traditional language model (such as the natural language model) through the data (i.e. model training data) -algorithm (i.e. trained model), the application performs interactive auxiliary training on the text error correction model (i.e. second language characterization model) in training by using the mature target service object which has reached convergence in the target field as the teacher model, solves the reverse propagation limitation of the traditional natural language model due to discrete sampling on the interactive level, and can improve the stability of gradient optimization while helping the model to converge rapidly on the basis of not reconstructing the model training data set.
It should be noted that in step S103, the third training text essentially belongs to text type data related to the target service object in the self-training process, that is, the third training text may be input data of the target service object (for example, if the target service object is a text classification model, the third training text is input data of the target service object), or may be output data of the target service object (for example, if the target service object is a speech recognition model, the input data of the target service object is speech data, the third training text is a text recognition result of the target service object output for the input speech data), or may include both input data of the target service object and output data of the target service object (for example, if the target service object is a question-answer model, both input data and 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 corresponds to a sentence set formed by each sentence input or output by the target service object in the training process, the third training text is input into the second language characterization model one by one according to a sentence or a sentence form, and the second language characterization model may perform text error correction processing (i.e., the model output result is different from the currently input target sentence) or may not perform text error correction processing (i.e., the model output result is the same as the currently input target sentence) on the currently input target sentence.
It should be noted that, the "correction training text" in the above step S103 is a model output result obtained after the text correction processing is performed on the target sentence currently input in the third training text by the second language characterization model, that is, the "correction training text" is a model output result of the second language characterization model when the model output result is different from the target sentence currently input.
S104, according to the pre-correction output result obtained by the target service object based on the third training text and the post-correction output result obtained by the target service object based on the correction training text, obtaining positive deviation/negative deviation generated by the model output result of the target service object before and after correction, and adjusting the model parameters of the second language characterization model according to the positive deviation/negative deviation, so as to obtain a text error correction model comprising the adjusted model parameters.
In the embodiment of the application, in the actual application process of the target service object, according to whether the text data belongs to the input data of the target service object or the output data of the target service object, the service object type to which the target service object belongs can be divided into the following three cases, specifically:
1. In the first case, the service object type to which the target service object belongs is a priori type, i.e. the target service object has the task of processing the currently input text data.
For example, the text data is input to the target service object, i.e., the text correction model is used for performing text correction service on the input data of the target service object.
Specifically, when the service object type to which the target service object belongs is 'priori type', each sentence in the third training text belongs to the input data of the target service object, 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 model output result obtained by the target service object based on the sentence as input, and the output result after correction obtained by the target service object based on the corrected training text of the sentence is the model output result obtained by the target service object based on the corrected training text of the sentence as input.
2. In the second case, the service object type to which the target service object belongs is a "two-way verification type", that is, the task of the target service object may be that the data processing is performed on the currently input text data, or that the corresponding text data is predicted and generated according to the currently input target data.
In the dialogue service system, the dialogue service system is required to recognize text data/voice data input by a user and predict and generate reply text data corresponding to the input data according to a recognition result of the input data, namely, a text error correction model is used for performing text error correction service on the input data and/or output data of the target service object, and at the moment, the third training text comprises input sentences of the input data of the target service object and output sentences of the output data of the target service object.
Specifically, when the service object type to which the target service object belongs is the "two-way 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 correction and the output result after correction are the same as the first case, and the repetition is omitted here.
Specifically, when the service object type to which the target service object belongs is the "two-way 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 corrected training text output after text correction processing of the sentence by the second language characterization model.
3. In the third case, the service object type of the target service object is 'posterior type', that is, the target service object has the task of predicting and generating corresponding text data according to the currently input target data.
For example, the text data is output data of the target service object, that is, the text correction model is used to perform the text correction service for the output data of the target service object, where 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 "a posterior type", each sentence in the third training text belongs to 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 those in the case where the sentence belongs to the output data of the target service object in the second case, and the repetition is not repeated here.
As can be seen from the specific description of the three cases, the "change of the model output result of the target service object from the output result before correction to the output result after correction" corresponds to the change of the model output result of the target service object after the text correction model provides the text correction service for the target service object, the "positive deviation of the model output result of the target service object before and after correction" corresponds to the positive gain of the text correction service provided by the text correction model for the target service object (for example, the accuracy of the model output result of the target service object is improved), and the "negative deviation of the model output result of the target service object before and after correction" corresponds to the negative influence of the text correction service provided by the text correction model for the target service object (for example, the accuracy of the model output result of the target service object is reduced).
For the above-mentioned positive deviation/negative deviation obtaining manner, it should be noted that, besides the conventional manner of obtaining positive deviation/negative deviation by a difference value, different deviation obtaining manners may be selected according to specific application characteristics of the target service object, for example, taking knowledge extraction as an example of the target service object, in text error correction service in the question-answering field, the confidence level of the downstream sequence labeling model of the target service object may be used to provide a corresponding reward coefficient (i.e. positive deviation)/penalty coefficient (i.e. negative deviation) for the text error correction model in training.
Based on the method, for each text correction action (corresponding to each text correction process executed by the second language characterization model) which is simulated in the model training process, the calculated positive deviation is used as a rewarding type adjustment parameter of the model to positively adjust the model parameter of the second language characterization model when the influence of the text correction action on the model output result of the target service object is positive, and the calculated negative deviation is used as a punishment type adjustment parameter of the model to negatively adjust the model parameter of the second language characterization model when the influence of the text correction action on the model output result of the target service object is negative. Therefore, the method for controlling the learning behavior of the model by the reward and punishment adjustment mechanism with pertinence to the text error correction task in the target field is used for replacing the mode of defining the model learning direction by means of marked samples in the traditional model training mode, so that the dependence degree of the model training process on the marked samples is reduced, the training effect of the text error correction model in the application is not influenced even if the number of the marked samples is insufficient, the model is helped to be converged quickly, and the trained text error correction model is more stable.
The following details are respectively given for the specific implementation process of each step in the embodiment of the present application:
For the specific implementation process of step S101, it should be noted that there are various existing alternative ways of pre-training the language model using the text data without semantic marks in the general field, and the present application is not limited in any way for the specific pre-training way of pre-training in step S101.
Here, as an alternative example of the pretraining method in the present application, in the manner of "mask prediction" in the commonly used BERT (Bidirectional Encoder Representations from Transformers, a self-coding language model) model, for how to select the masked word to be predicted in the first training text, the following 2 different alternative embodiments are given in the present application, specifically:
In an alternative implementation, as shown in fig. 2, fig. 2 shows a schematic flow chart of a first pre-training method provided by the embodiment of the present application, where, when performing step S101, the method includes steps S201-S203, and specifically:
S201, masking and shielding the first target number of segmented words in the first training text by means of random sampling to obtain a first masking training text comprising the first target number of masking words.
In the embodiment of the application, the trained text error correction model is used for providing text error correction service for the target service object in the target field, and in consideration of the fact that different types of target service objects may have different training requirements for the text error correction model, for example, some target service objects are more prone to reduce the construction operation of training data in the training process of the text error correction model (i.e. the training requirements are biased to reduce the data processing amount/the training cost), some target service objects are more prone to improve the training effect of the text error correction model (i.e. the data processing amount/the training cost in the training process is not concerned), and in order to meet the different training requirements of different target service objects for the text error correction model, when the language model is initially pre-trained, the to-be-predicted word to be masked can be-segmented can be randomly sampled, and the professional vocabulary/the feature word in the target field can be preferentially selected as the to-be-predicted word to be masked.
It should be noted that, based on the analysis content about the word to be predicted, the embodiment of the present application does not limit whether the word to be predicted needs to be set with a selection rule/a selection standard.
Specifically, the first pre-training method described in steps S201-S203 corresponds to a preferred implementation of pre-training the language model in the case that the training requirements of the target service object for the text error correction model are biased towards reducing the data throughput/reducing the training cost.
Here, in step S201, the first target number is determined according to the sampling ratio of the random sampling and the number of the words included in the first training text, for example, if the first training text includes 100 words in total, where the sampling ratio of the random sampling is 10%, it may be determined that the first target number is 10 words, that is, 10 words are randomly extracted from 100 words included in the first training text in a random sampling manner to perform mask masking, so as to obtain a first masked training text including 10 masked words.
S202, inputting the first masking training text into the language model to obtain a first masking predicted text which is output by the language model and comprises predicted results of masking words of a first target number.
Specifically, taking the number of the blocked words (i.e., the first target number) in the first blocked prediction text as n as an example, for each blocked word I, according to the position of the blocked word I in the first blocked prediction text, the language model may determine the context of the blocked word I (such as the context may be the sentence I in which the blocked word I is located, the previous sentence H of the sentence I, and the next sentence J of the sentence I) from the first blocked prediction text, and the training language model performs word segmentation prediction on each blocked word I according to the context of the blocked word I to obtain a word segmentation prediction result p ic of each blocked word I, so that the prediction text including the word segmentation prediction result p ic of each blocked word I is used as the first blocked prediction text, where the word segmentation prediction result p ic represents the prediction probability that the blocked word I belongs to the class c word.
It should be noted that, the specific class number of c in the above c class word segmentation depends on the number of word segmentation types included in the word segmentation prediction table, and the embodiment of the present application is not limited in any way for the specific class number of c in the c class word segmentation.
S203, adjusting model parameters of the language model by utilizing cross entropy loss between the first masking predicted text and the first training text which is not masked until the language model reaches convergence, and taking the language model after the convergence as the first language characterization model.
Specifically, as can be seen from the above step S202, the first masked predicted text includes the word segmentation prediction result of each masked word, and the first training text without masking includes the real word classification result of each masked word (corresponding to the real classification result determined from the word segmentation prediction table according to the real word without masking). Therefore, for each masked word in the first masked predicted text, the word segmentation prediction result of the masked word in the first masked predicted text and the real word segmentation classification result of the masked word in the first training text are brought into the cross entropy loss function, so that the model training loss of the language model can be obtained, and the model parameters in the language model can be adjusted based on the model training loss obtained by each training, so that the converged first language characterization model can be obtained.
In the embodiment of the present application, considering that the number of word types included in the word segmentation prediction table used in the mask prediction process (i.e., the specific class number of c in the above-mentioned c-class word segmentation) 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, and is specific:
where n is the total number of masked words in the first masked predicted text, i.e., n is the first target number and i is the i-th masked word in the first masked predicted text;
n is the number of word segmentation types included in the word segmentation prediction table, and c is the c-th word segmentation included in the word segmentation prediction table;
p ic is the word segmentation prediction result of the i-th masked word;
y ic is a sign function (0 or 1), y ic takes a value of 1 if the i-th masked word is a class c word, and y ic takes a value of 0 if the i-th masked word is not a class c word;
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 shows a schematic flow chart of a second method of pre-training provided by the embodiment of the present application, where, when performing step S101, the method includes steps S301-S303, and specifically:
s301, masking and shielding the second target number of segmented words belonging to the specific text data in the first training text according to a first preset sampling proportion to obtain a second masking training text comprising the second target number of masked words.
Specifically, the second pre-training method described in steps S301-S303 corresponds to a preferred implementation of pre-training the language model in the case that the training requirement of the target service object on the text correction model is biased towards improving the training effect/improving the accuracy of the training result of the text correction model.
Here, in step S301, the second target number is determined according to the first preset sampling ratio and the number of the words belonging to the specific text data in the first training text, for example, if the first training text includes 100 words in total, where 40 words belong to the specific text data in the target field, and the first preset sampling ratio is 20%, it may be determined that the second target number is 8 words, that is, according to a random sampling manner, 8 words are randomly extracted from 40 words belonging to the specific text data in the first training text to mask, and the 8 masked words are regarded as masked words to be predicted.
S302, the second masking training text is input into the language model, and second masking predicted text which is output by the language model and comprises predicted results of masking words of a second target number is obtained.
S303, adjusting model parameters of the language model by utilizing cross entropy loss between the second masking predicted text and the first training text which is not masked until the language model reaches convergence, and taking the language model after the convergence as the first language characterization model.
Here, the embodiments of steps S302 to S303 are the same as steps S202 to 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, it is known that the training purpose of training the first language characterization model in the step S102 by using the second training text may be subdivided into the following 2 types, specifically:
training purpose 1, enabling a second language characterization model obtained after fine tuning training to predict sentence-sentence relationship of different sentences in the target field;
training purpose 2, enabling the second language representation model obtained after fine tuning training to predict sentence components of the same sentence in the target field.
Based on this, in order to accomplish the above two training purposes, in the embodiment of the present application, as an optional embodiment, the training of the first language characterization model by using the second training text in step S102 at least includes performing coarse-granularity training and/or fine-granularity training on the first language characterization model by using the second training text that has been semantically marked in the target domain, where the coarse-granularity training is used to train the first language characterization model to classify different sentences in the same semantic concept in the second training text according to different text expression modes corresponding to the same semantic concept in the target domain (i.e., coarse-granularity training is used to accomplish the training purpose 1), and the fine-granularity training is used to train the first language characterization model to identify the text expression modes in the target domain according to the word segmentation sequence marking result of each sentence in the second training text (i.e., fine-granularity training is used to accomplish the training purpose 2).
For the specific implementation of the training objective 1, in an alternative embodiment, as shown in fig. 4, fig. 4 shows a schematic flow chart of a method for coarse-granularity training provided by the embodiment of the present application, where, when executing step S102, the method includes steps S401 to S403, and specifically:
s401, inputting original version sentences of the second training text after removing the existing semantic marks into the first language characterization model aiming at any two sentences in the second training text, and carrying out classification prediction on whether the any two sentences correspond to the same semantic concept in the target field or not through the first language characterization model to obtain classification prediction results of the any two sentences.
Here, for the second training text, it should be noted that, similar to whether the selection rule/selection standard needs to be set regarding whether the word to be predicted that is masked in step S201 is required to be set, in the 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.
In particular, when the target service object is more prone to reduce the construction operation of the training data in the training process of the text error 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 word segmentation of the specific text data under the target domain, 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, or a certain amount of professional vocabularies belonging to the specific text data can be supplemented on the basis of the first training text, and the supplemented first training text is used as the second training text so as to meet the training requirement that the target service object is more prone to improving the training effect of the text error correction model by 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 the arbitrary two sentences correspond to the prediction value of the same semantic concept in the target domain, that is, the classification prediction mode in step S401 is equivalent to the classification prediction performed on whether the input two sentences correspond to the same semantic concept in the target domain.
S402, determining the real classification result of any two sentences according to the semantic tags of the any two sentences in the second training text.
Here, the true classification result is used to characterize whether the arbitrary two sentences correspond to the same semantic concept in the target domain.
In the embodiment of the application, after the second training text is obtained, as an optional embodiment, multiple semantic concept labels included in the target field can be obtained from a knowledge graph and/or an encyclopedia knowledge base in the target field, then each sentence in the second training text is marked by using the obtained multiple semantic concept labels, if a word with the semantic label conforming to the semantic concept label appears in the sentence, the semantic concept label is used as the semantic concept label of the sentence, if no word conforming to any semantic concept label exists in the sentence, the semantic concept label of the sentence can be determined to be other/no labels (which is equivalent to that the sentence is irrelevant to the target field and has smaller contribution to model training), and therefore, the true classification result of any two sentences is determined according to each sentence after the semantic concept label is carried out.
S403, adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the classification prediction result and the real classification result until the first language characterization model achieves convergence.
Here, based on the analysis content of the step S401, it is known that the classification prediction method in the step S401 is equivalent to performing classification prediction on whether the two input sentences correspond to the same semantic concept in the target domain, and therefore, the cross entropy loss function in the step S403 may be a cross entropy loss function under a classification task, specifically:
Wherein m is the total input times (also equivalent to the total prediction times of a round of two-classification prediction tasks) of the first language characterization model on any two sentences, 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 j-th input in the first language characterization model, and is the j-th prediction of the first language characterization model in a round of two-classification prediction tasks;
p j is a classification prediction result of 2 sentences in the jth prediction, wherein the numerical value of p j represents the probability that the 2 sentences in the jth prediction correspond to the same semantic concept in the target field;
y j is a sign function (0 or 1), if the true classification result of 2 sentences in the jth prediction is the same semantic concept under the corresponding target field, y j takes a value of 1, if the true classification result of 2 sentences in the jth prediction is different semantic concepts under the corresponding target field, y j takes a value of 0;
L 2 is a cross entropy loss function used in coarse-grained training of the first language characterization model according to the method described in steps S401-S403.
For the specific implementation of the training objective 2, in an alternative implementation, as shown in fig. 5, fig. 5 shows a schematic flow chart of a method for fine granularity training provided by the embodiment of the present application, where, when step S102 is performed, the method includes steps S501-S503, and specifically:
S501, inputting an original version sentence with the semantic mark removed from the sentence to the first language characterization model for each sentence in the second training text, and analyzing sentence components of the sentence in the target field through the first language characterization model to obtain a sentence analysis result of the sentence in the target field.
Here, the sentence component comprises at least a first target word segment belonging to an entity defined in the target field, and a second target word segment capable of characterizing different semantic concepts in the target field.
Specifically, on the basis that the sentence components include both entities and semantic concepts, it is necessary to explain the semantic concept labels in the step S402, so as to further improve the training effect of the second language characterization model, as an optional embodiment, for 2 sentences input in the jth prediction, when determining the real classification result y j of the 2 sentences, it may be further defined that if the 2 sentences in the jth prediction include both the word corresponding to the same semantic concept label and the word having the same entity attribute, the value of the real classification result y j is determined to be 1, and if otherwise, even if the 2 sentences include the word corresponding to the same semantic concept label, the value of the real classification result y j of the 2 sentences is still determined to be 0 when the entity attribute corresponding to the word belonging to the entity type in the 2 sentences is different, that is, the 2 sentences are not sentences under the same semantic concept at the moment.
In the embodiment of the application, the first target word and the second target word can be determined by using a knowledge graph K in the target field, for example, in the knowledge graph K, entity word types such as game roles, game types, game names and the like of commonly-made sentence subjects can appear as entity nodes S in the knowledge graph K, commonly-made sentence objects such as game equipment, game props, character skills and the like can 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, carrying out sequence marking on a plurality of participles included in the sentence according to a plurality of entities defined in the target field and the semantic marks existing in the sentence, and obtaining a participle sequence marking result of the sentence.
Specifically, when the sequence marking is performed on the sentence, as an optional embodiment, the first target word and the second target word included in the sentence may be marked according to the definitions of the first target word and the second target word, so as to obtain a word sequence marking result of the sentence.
For example, taking a game field as a target field, if the text form of the sentence a is "[ big dog ] [ how much the big dog should be ] [ what ] [ should be ]", wherein "big dog" belongs to an entity node S1 in the knowledge graph K, the "how much" belongs to a concept node G1 in the knowledge graph K, a side 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 program, and the word sequence marking result A1 of the sentence a can be determined to be "[ entity ] [0] [ category ] [0] [0]", wherein entity is an entity marking belonging to a first target word, category is a concept marking belonging to a second target word, and 0 indicates that other text which does not need to be recognized.
S503, adjusting model parameters of the first language characterization model by utilizing cross entropy loss between the sentence analysis result and the word segmentation sequence marking result until the first language characterization model achieves convergence.
Specifically, when the sentence analysis result is obtained by means of sentence component analysis, the first language representation model involves identifying and predicting a plurality of words included in the sentence, so that 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 may refer to the formula form of the cross entropy loss function L 1 in step S203, and the repetition is omitted here.
For example, taking the sentence a in the above example as an example, if the sentence analysis result A2 of the sentence a is "[ category ] [0] [ category ] [0] [0]", taking the cross entropy loss function L 1 in step S203 as an example, taking the [ big dog ] and the [ imperial ] in the sentence a as 2 masked words, taking the marking result in the sentence analysis result A2 as a first masking predicted text, taking the marking result A1 of the word sequence as a first training text which is not masked, determining the value of the symbol function y ic according to the marking result difference between the word sequence marking result A1 and the marking result in the sentence analysis result A2, and thus, fine tuning the model parameters of the first language characterization model until the first language characterization model reaches convergence.
For the specific implementation process of the step S103, based on the analysis content of the step S103, it is known that the third training text is input into the second language characterization model one by one according to a sentence or a sentence form:
As shown in fig. 6, fig. 6 is a flowchart of a method for determining whether text error correction processing occurs according to an embodiment of the present application, where, when executing step S103, the method includes steps S601-S603, and specifically:
S601, inputting each sentence in the third training text into the second language characterization model to obtain a first output result of the second language characterization model for the sentence.
S602, when detecting that the first output result is different from the sentence, determining that the second language characterization model carries out text error correction processing on the sentence, and taking the first output result as the correction training text.
S603, when 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 for the sentence until the corrected training text is obtained.
In the exemplary illustration, on the basis of the above steps S601-S603, taking the game field as the target field, if the sentence a currently input in the third training text is "the character of the game is a sister page", at this time, if the first output result a1 of the second language characterization model for the sentence a is "the character of the game is a sister page", that is, if the first output result a1 is the same as the sentence a, it is determined that the second language characterization 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 characterization model, and the judgment is continued, if the first output result a1 of the second language characterization model for the sentence a is "the character of the game is a sister page", that is, if the first output result a1 is different from the sentence a, it is determined that the second language characterization model performs text error correction processing on the sentence a, and the corrected training text a2 is "the character of the game is a sister page" the character of the game "at this time, and the step S104 is executed by using the third training text a.
For the specific implementation process of the step S104, in the embodiment of the present application, in combination with the analysis content at the step S104, it is known that the service object type to which the target service object belongs is classified into three cases of "a priori type", "bi-directional verification type", and "a posterior type", for these three specific cases, on the basis of the steps S601-S603, the third training text (corresponding to a specific sentence in the third training text) that is currently determined to be subjected to the text correction processing by the second language characterization model (i.e., the simulated text correction model actually provides the target service object with the text correction service) may be determined that the third training text (i.e., the third training text that is currently determined to be subjected to the text correction processing by the second language characterization model) in the step S104 may only be input text data/output text data of the target service object, that is the text correction model corresponds to the text correction processing performed on the input text data/output text data of the target service object.
Based on this, the following details are respectively described according to whether the text correction model performs text correction processing on the input text data of the target service object or performs text correction processing on the output text data of the target service object, and how to obtain positive deviation/negative deviation generated before and after correction of the model output result of the target service object in the above two cases:
1. when the third training text is text data input by the target service object in the training process:
At this time, the third training text is input into the target service object, and the output result before correction can be output; the corrected training text is input into the target service object, and the corrected output result can be output, namely the output result before correction is that the target service object outputs the obtained model output result based on the third training text as input, and the corrected output result is that the target service object outputs the obtained model output result based on the corrected training text as input.
It should be noted that, the third training text is input into the second language characterization model one by one according to a sentence or a sentence form, so that the text data input by the third training text in the training process is the text data of the target service object, that is, the input data of the target sentence currently input into the second language characterization model in the third training text belongs to the target service object, and the corrected training text is the corrected training sentence output by the second language characterization model after performing text correction processing on the input target sentence.
Here, as an alternative embodiment, a first deviation generated before and after correction of the model output result of the target service object may be calculated according to a first deviation calculation policy, and the first deviation may be determined to belong 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 shows a flow chart of a method for calculating the first deviation according to an embodiment of the present application, where the method includes steps S701-S703, and specifically:
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 pre-correction output result is used to characterize 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 "prior type" as an example, where the third training text that is currently determined to be subjected to text correction processing by the second language characterization model is a sentence a, and the corrected training text that is output after the sentence a is subjected to text correction processing by the second language characterization model is a corrected training sentence a2, at this time, the sentence a is input into the text classification model as the target service object, and the obtained corrected output result may have the following two types:
the text output category of the type 1 and the sentence a is obvious in the output result before correction, that is, the probability value of the sentence a belonging to a certain preset category is obviously higher than the probability value of the sentence a belonging to other preset categories, or the probability value of the sentence a belonging to a certain preset category is more than or equal to 50%.
In this case, the obtained output result R1 before correction may be 70% of the probability that the sentence a belongs to the first preset category, 5% of the probability that the sentence a belongs to the second preset category, 5% of the probability that the sentence a belongs to the third preset category, 10% of the probability that the sentence a belongs to the fourth preset category, and 10% of the probability that the sentence a belongs to the fifth preset category.
The text output category to which the type 2, sentence a belongs is not obvious in the output result before correction, i.e., the probability distribution result of sentence a belonging to each preset category is average.
In this case, the obtained output result r1 before correction may be 15% of the probability that the sentence a belongs to the first preset category, 15% of the probability that the sentence a belongs to the second preset category, 20% of the probability that the sentence a belongs to the third preset category, 25% of the probability that the sentence a belongs to the fourth preset category, and 25% of the probability that the sentence a belongs to the fifth preset category.
S702, inputting the correction training text into the target service object, and predicting the output category of the correction training text through the target service object to obtain the corrected output result.
Here, the corrected output result is used to characterize the probability that the output category of the corrected training text belongs to each preset category.
Specifically, the step S702 is the same as the embodiment of the step S701, and the possible types of the corrected output result are similar to the possible types of the output result before correction, and the repetition is omitted here.
S703, calculating a probability deviation value of the corrected output result and the output result before correction in the same preset category, and taking the calculated result as the first deviation.
Here, for the two different types of pre-correction output results shown in the above step S701, the following is exemplified respectively:
(1) When the pre-correction output result belongs to the type one:
Here, as an alternative embodiment, a target preset class corresponding to the highest probability value may be determined from the output results before correction as a specific preset class for comparing the deviation of the model output results of the target service object 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 class.
Taking the output before correction result R1 as an example, 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%, and if the output after correction result R2 is that the probability that the sentence a2 belongs to the first preset category is 90%, the probability that the sentence a belongs to the second preset category is 2%, the probability that the sentence a belongs to the third preset category is 3%, the probability that the sentence a belongs to the fourth preset category is 4% and the probability that the sentence a belongs to the fifth preset category is 1%, the numerical value change generated by the text error correction processing can be directly used as the first deviation, and the first deviation is calculated to be 90% -70% = 20%, that is, and the first deviation belongs to the numerical value of 20% forward deviation.
(2) When the output result before correction belongs to the type two:
Here, as an alternative embodiment, a plurality of probability values higher than the probability threshold in the output result before correction/the output result after correction may be selected according to a preset probability threshold (for example, 20%), and then the average value of the selected probability values may be calculated, and the difference between the average values in the output results before correction and after correction may be used as the first deviation.
Taking a preset probability threshold value as an example, taking 20% as the example, if the output result r1 before correction is that the probability of the statement a belonging to the first preset category is 15%, the probability of the statement a belonging to the second preset category is 15%, the probability of the statement a belonging to the third preset category is 20%, the probability of the statement a belonging to the fourth preset category is 25% and the probability of the statement a belonging to the fifth preset category is 25%, and the probability value higher than the probability threshold value in the output result r1 before correction is 20%, 25% and 25%;
if the corrected output result r2 is that the probability that the corrected training sentence a2 belongs to the first preset category is 5%, the probability that the corrected training sentence a2 belongs to the second preset category is 5%, the probability that the corrected training sentence a2 belongs to the third preset category is 15%, the probability that the corrected training sentence a2 belongs to the fourth preset category is 50%, and the probability that the corrected training sentence a2 belongs to the fifth preset category is 25%, the probability value that the probability value of the corrected output result r2 is higher than the probability threshold value is 50% and 25%;
at this time, according to the alternative embodiment under the above-mentioned type two, the first deviation may be calculated as:
here, for the two types described above, the difference in the calculation manner of the first deviation needs to be described as follows:
Under the condition of the type, the output type of the sentence a before correction in the third training sample is obvious in the output result before correction, namely, even if text correction processing is not carried out on the sentence a, the target service object can determine the specific text classification result of the sentence a, and at the moment, the forward deviation with the first deviation being 20% can be understood that the contribution of the text correction service provided by the text correction model to the exact text classification result obtained by the target service object is 20% (equivalent to improving the accuracy of the output result of the text classification of the sentence a by the target service object).
Under the second type, 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 text correction processing is not performed on the sentence a, the target service object cannot obtain an exact text classification result of the sentence a, and at this time, the forward bias with the first bias belonging to the value of 14.17% is obtained, which means that the contribution of the text correction service provided by the text correction model to the target service object, which can obtain an exact text classification result, is 14.17%.
Here, when the first deviation is a negative deviation, the "contribution" in the above analysis is changed into a reverse "loss", that is, the negative deviation is used to characterize the text error correction service provided by the text error correction model, which will adversely affect the model output result of the target service object, and the repetition is not repeated here.
2. When the third training text is text data output by the target service object in the training process:
At this time, the third training text is used as the output result before correction, the corrected training text is used as the output result after correction, namely, the output result before correction is the third training text, and the output result after correction is the corrected training text.
Here, as an alternative embodiment, a second deviation generated before and after correction of the model output result of the target service object may be calculated according to a second deviation calculation policy, and the second deviation is determined to belong to the positive deviation or the negative deviation based on the second deviation, where the second deviation calculation policy may be different from the first deviation calculation policy.
For the above specific calculation process of the second deviation, as shown in fig. 8, fig. 8 shows a flow chart of a method for calculating the second deviation according to an embodiment of the present application, where the method includes steps S801 to S804, and the specific steps are as follows:
S801, a standard text recognition result of target input data is obtained.
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 equivalent to being calculated in the case where the third training text is the output text data of the target service object, the target input data may be non-text type data.
Taking an example that the target service object is an image recognition model, the target input data is an image B, and the sentence B1 in the third training text is the target service object, after the image B is subjected to image text recognition, a text recognition prediction result is obtained, and 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 can 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.
In the above example, the stroke edit distance d1 (corresponding to the text difference between the sentence b1 and the standard text recognition result b) between the sentence b1 and the standard text recognition result b in the third training text is calculated, and the stroke edit distance d1 is used as the first text recognition bias value, and in this case, the smaller the stroke edit distance d1, the higher the similarity between the sentence b1 and the standard text recognition result b (corresponding to the smaller the difference), and the more accurate the model output result of the target service object.
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.
For the illustrative explanation, taking the above example as an example, if the corrected training text obtained after the text correction processing is performed on the sentence b1 by the second language characterization 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 the calculated result as the second deviation.
In the above example, the difference d between the stroke edit distance d1 and the stroke edit distance d2 is calculated, and the calculated result of the difference d is taken as the second deviation, and in this case, if the calculated result of the difference d is negative (corresponding to that the text difference between the text recognition predicted result output by the target service object and the standard text recognition result b increases after the text correction processing is performed), it means that the second deviation is negative, that is, the text correction service provided by the text correction model adversely affects the model output result of the target service object.
If the calculated result of the difference d is a positive number (which is equivalent to that the text difference degree between the text recognition predicted result output by the target service object and the standard text recognition result B is reduced after the text error correction processing is performed), the second deviation is represented as a forward 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 on the image B.
For the specific implementation process of the step S104, the following optional implementation manners are provided in the embodiments of the present application, for how to adjust the model parameters of the second language characterization model according to the positive bias/negative bias:
referring to fig. 9, fig. 9 is a flowchart of a method for adjusting model parameters of a second language characterization model according to an embodiment of the present application, where, when executing step S104, the method includes steps S901-S902, and specifically:
S901, in each training period of the second language representation model, acquiring target positive deviation/negative deviation obtained by a target second language representation model trained based on the training period.
Specifically, in the step S103, the third training text corresponds to a sentence set formed by each sentence input or output by the target service object in the training process, the third training text is input into the second language characterization model one by one according to a sentence or a sentence form, and according to this, as an alternative embodiment, the training period in the step S901 may be determined according to the data usage rate of the second language characterization model in the training for the third training text, for example, if the data usage rate of the third training text is 10% as one training period, this corresponds to a total need to go through 10 training periods if the model goes through the sentence in the third training text in the training process, and if the data usage rate of the third training text is 20% as one training period, this corresponds to a total need to go through 5 training periods if the model goes through the sentence in the third training text in the training process.
In the embodiment of the application, every other training period, the mirror image model of the second language characterization model can be stored and maintained, so that the second language characterization model trained in the previous training period and the mirror image model not trained in the previous training period are synchronously trained in each training period, the model with the highest deviation and value (equivalent to the best training effect in the current training period) is selected as the target second language characterization model needing to be subjected to model parameter adjustment in the current training period according to the deviation and value (namely the sum of positive deviation and negative deviation) accumulated by the second language characterization model in the current training period and the deviation and value accumulated by the mirror image model, and the model parameter of the target second language characterization model is adjusted according to each target positive deviation/negative deviation obtained by the target second language characterization model in the current training period.
And S902, adjusting model parameters of the target second language characterization 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 characterization model meets the training cut-off condition.
In the embodiment of the application, the target positive deviation/negative deviation can be substituted into a model loss function of the target second language representation model as a loss control variable so as 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 the form of a function as shown in the following formula:
wherein J (θ) is an original model loss function of the target second language characterization model G θ in the training process, and can be valued as a common least squares loss function;
θ denotes deriving the multiplication function;
s x~Gθ(Y1:t-1) represents the output probability that the target word s x currently corrected is located at the t-th position in the third training text, that is, the output probability that the text correction process occurs at the t-th position in the third training text;
A desired value indicating the output probability;
log G θ(Y1:T) represents the entropy of the corrected target word s x, i.e., the probability distribution of the current corrected target word s x in the third training text, calculated from the context content of each currently processed word in the third training text from 1 to T times during the training of the target second language representation model G θ;
D φ is a loss control variable, i.e., each target positive/negative bias that the target second language representation model gets based on each training sentence in the third training text in the current training period;
Epsilon is an adjustment parameter for the loss control variable used to adjust the weight of the loss control variable in the model loss function.
In an alternative implementation, as shown in fig. 10, fig. 10 shows a schematic flow chart of a method for determining a target second language representation model under each training period according to an embodiment of the present application, where before the model parameter adjustment method shown in step S901-step S902 is performed in each training period, the method includes steps S1001-S1005:
s1001, when each training period of the second language representation model is reached, acquiring the trained second language representation model in the last training period, and generating a mirror image second language representation model which is not trained in the last training period.
Here, it should be noted that, if the current training period is the first training period of the second language characterization model, only the second language characterization model in the training process may be obtained as the target second language characterization model that needs to be adjusted for model parameters in the current training period, that is, the first training period may be regarded as a mirror image model that is not trained in the previous training period.
S1002, under 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 to respectively obtain 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 manner of step S1002, in the current training period, for the target sentence currently input to the second language representation model/mirror image 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 first deviation calculation method shown in the foregoing steps S701-S703 may be referred to calculate to obtain the positive deviation/negative deviation of the second language representation model/mirror image second language representation model for the target sentence, and if the target sentence belongs to the output text data of the target service object, the second deviation calculation method shown in the foregoing steps S801-S804 may be referred to calculate to obtain the positive deviation/negative deviation of the second language representation model/mirror image second language representation model for the target sentence, which is not repeated 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.
The first training deviation is used for representing the deviation sum value of a plurality of positive deviations/negative deviations obtained based on the optimized second language representation model in the training period, and the second training deviation is used for representing the deviation sum value of a plurality of positive deviations/negative deviations obtained based on the optimized mirror image second language representation model in the training period.
And S1004, if the first training deviation is smaller than the second training deviation, replacing the optimized second language representation model by using the optimized mirror image second language representation model to serve 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 simultaneously using 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, for the above steps S1004 to S1005, according to the deviation sum value accumulated by the second language representation model in the current training period (i.e., the first training deviation) and the deviation sum value accumulated by the mirror model (i.e., the second training deviation), before executing the model parameter adjustment method shown in steps S901 to S902 in each training period, the model with the highest deviation sum value (equivalent 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 is required in the current training period.
Based on the model parameter adjustment method described in the above step S901 to step S902, the present application performs positive adjustment on the model parameter of the target second language characterization model by using the calculated positive deviation as the rewarding type adjustment parameter of the model when the influence of the occurrence of the text correction processing on the output result of the target service object is positive, and performs negative adjustment on the model parameter of the target second language characterization model by using the calculated negative deviation as the penalty type adjustment parameter of the model when the influence of the occurrence of the text correction processing on the output result of the model of the target service object is negative, for each text correction processing that occurs in the model training process.
Therefore, through the method for controlling the learning behavior of the model by the reward and punishment adjustment mechanism with pertinence to the text error correction task in the target field, the method can replace the mode of defining the model learning direction by means of marked labeling samples in the traditional model training mode, is favorable for reducing the dependence degree of the model training process on the labeling samples, is favorable for sequentially accelerating the convergence process of the model based on the target second language characterization model determining method shown in the step S1001-step S1005, and also selects the model with the largest total reward obtained in one training period (corresponding to the maximum positive number of deviation and value) as the target optimization model for actually carrying out model parameter adjustment in the current training period according to the sum of positive deviation and negative deviation of model accumulation in each training period.
In summary, even if the number of the marked samples is insufficient, the training effect of the text error correction model is not affected, which is helpful to help the model to quickly converge and make the trained text error correction model more stable.
In the embodiment of the present application, based on a test concept similar to the training concept in the above steps, through data interaction with the target service object, the text error correction model may acquire test text data related to the target service object in the test process from the target service object in the same manner except for the third training text, so as to evaluate the training effect of the text error correction model by using the test text data, and specifically:
As shown in fig. 11, fig. 11 shows a flowchart of a method for testing a text error correction model according to an embodiment of the present application, where after executing step S104, the method further includes steps S1101-S1103, and specifically:
S1101, inputting the test text input or output by the target service object in the test process into the text correction model to obtain corrected test text output by the text correction model after text correction processing is performed on the test text.
It should be noted that, the execution manner of the step S1101 is the same as that of the step S103, and the explanation of the step S103 is referred to and repeated here.
S1102, 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, obtaining test deviations generated before and after correction of the test output result of the target service object.
Here, the test deviation includes a positive test deviation belonging to a positive number and a negative test deviation belonging to a negative number.
It should be noted that, when the test deviation generated before and after correction is calculated 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 according to the method of calculating the first deviation in the previous step, if the test sentence in the current test text belongs to the output text data of the target service object, the test deviation may be calculated according to the method of calculating the second deviation in the previous step, and the repetition is omitted 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, according to the test deviation generated before and after each correction, the sum of the test deviation obtained in the test process of the text error correction model can be calculated, so that the model training effect of the text error correction model can be evaluated according to the test deviation and the value.
In the training process of the text error correction model, after calculating the positive deviation/negative deviation obtained in each training process, 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. The training method of the text error correction model is different from the training method of the text error correction model in that in the testing process of the model, the model parameters in the trained text error correction model are not required to be adjusted, namely, in the execution of the step S1103, the model optimization process in the steps S901-S902 is not involved, only the test deviation obtained each time is required to be recorded, and the training effect of the text error correction model is only required to be evaluated by utilizing the sum value of each test deviation.
According to the training method of the text error correction model, general text data in the open field is used for basic training of the language model, proprietary text data in the target field is used for fine tuning training of the language model, the trained language model has the capability of identifying specific text features in the target field, and then a data interaction mode is adopted between the trained language model and the converged target service object, the target service object which is mature in the target field is used as a teacher model, so that interactive auxiliary training is carried out on the text error correction model in training. By the training method, the training model can be quickly adapted to more complex and unique language environment on the premise of not losing the generalized text correction capability, so that the text correction accuracy of the model in the target field is improved.
In the embodiment of the application, after the text error correction model is trained, the process at the application stage of the text error correction model is as follows:
As shown in fig. 12, fig. 12 shows a flow chart of a text correction method provided by the embodiment of the present application, where the text correction method is applied to a pre-trained text correction model, where the text correction model is used to provide a text correction service for a target service object in a target domain, where the target service object belongs to a converged mature algorithm model in the target domain, and the text correction method further includes steps S1201-S1202, and specifically:
S1201, inputting a text to be corrected, which is required to be subjected to text correction processing in an application process, of the target service object into a pre-trained text correction model, correcting target text errors included in the text to be corrected through the text correction model, and obtaining corrected text, which is output by the text correction model and aims at the text to be corrected.
It should be noted that, the text error correction model is obtained after training according to the manner of the steps S101-S104 and testing according to the manner of the steps S1101-S1103, and the specific training process and the specific testing process of the text error correction model may refer to the specific implementation process of each step, and are repeated herein.
As can be seen from the analysis content of the above steps, the types of the service objects to which the target service object belongs are classified into three cases of "a priori type", "two-way verification type" and "a posteriori type", and the following optional embodiments are provided in the embodiments of the present application for how to determine the text to be corrected under these three specific types:
(1) For the case that the target service object belongs to the "a priori type":
At this time, the text correction model is used to perform text 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 "a priori type", the input text data of the target service object may be directly obtained from the target service object as the text to be corrected that needs to perform text correction processing.
(2) For the case that the target service object belongs to the "two-way authentication type":
At this time, the text correction model is used to perform text 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, in the case that the target service object belongs to the "two-way verification type", text data matching with the current specific application requirement of the target service object may be obtained from the input text data and/or the output text data of the target service object as the text to be corrected that needs to perform text correction processing.
(3) For the case that the target service object belongs to the "posterior type":
At this time, the text correction model is used to perform text 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 "a posteriori type", the output text data of the target service object may be directly obtained from the target service object as the text to be corrected that needs to perform text correction processing:
The text error correction model is used for correcting target text errors included in the text to be corrected, wherein the target text errors are determined according to special semantic features and/or text expression features in the target field. For example, if the target field is a game field, the text expression of "sister paper" belongs to a specific text expression mode in the game field, and text correction processing is not required, and if the target field is an education field, the text expression of "sister paper" belongs to text expression errors in the education field, and text correction processing is required.
S1202, replacing the text to be corrected, which is input or output by the target service object in the application process, with the corrected text.
It should be noted that, the difference exists 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 the text correction model can be divided into the following 3 understanding modes, where the following 3 understanding modes are also equivalent to the core correction concept of executing the text correction service in the target field, and in particular:
(1) Correcting conventional text errors such as basic 'semantic errors', 'text writing errors', and the like.
The exemplary description still takes the game field as an example of the target field, and when the "big dog" appears in the text data to be corrected in the form of a conventional text error of "big enough", the text error correction model belongs to the situation that the text error correction model needs to perform text error correction processing in the application.
(2) Although the text is not a conventional text error such as wrongly written characters, part of the text is more complicated and lengthy, and the characteristic text expression in the target field can be used for replacement, so that the replaced text is more concise and the text characteristics in the target field can be more represented.
For example, if the text to be corrected is a game character f in the game X, which can help a teammate player to timely supplement a character life attribute value, the game character f in the game X, which can help a teammate player to timely supplement a character life attribute value, can be corrected to a teammate type game character f in the game X according to the game character expression of game characters which are colloquially defined in the game field and have skills of "can help a teammate player to timely supplement a character life attribute value", and the text correction model also belongs to the situation that the text correction model needs text correction processing.
(3) On the basis of (2), the original characteristic text expression in the text is not subjected to error correction because of contradiction between the conventional expression of the text in the general field and the characteristic text expression.
In the exemplary description, taking the game field as an example, if the text to be corrected is "the game character f of the mother in the game X", for the existing text correction model, since "milk" and "mother" generally belong to sensitive words to be corrected when they occur at the same time, the existing text correction model performs text correction processing on the text data to be corrected, unlike the situation that the text correction model trained in the present application does not need to perform text correction processing.
According to the text error correction method provided by the embodiment of the application, after the text error correction model is trained, text error correction processing can be carried out on text data related to the application process of the target service object by using the text error correction model, so that the accuracy of the output result of the target service object model and the operation efficiency of the target service object can be improved.
Based on the same inventive concept, the embodiment of the present application further provides a training device for a text error correction model corresponding to the training method for a text error correction model in the foregoing embodiment, and since the principle of solving the problem of the training device in the embodiment of the present application is similar to that of the training method in the foregoing embodiment of the present application, implementation of the training device may refer to implementation of the foregoing training method, and repeated parts will not be repeated.
Referring to fig. 13, fig. 13 shows a schematic structural diagram of a training device 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 domain, the target service object belongs to a converged mature algorithm model in the target domain, and the training device includes:
The first training module 1301 is configured to pretrain a language model by using a first training text without semantic marks to obtain a first language characterization model, where the first training text includes specific text data in the target domain and general text data outside the target domain;
the second training module 1302 is configured to train the first language representation model by using a second training text that has been semantically marked in the target field to obtain a second language representation model with a target text feature recognition capability, where the target text feature is used to represent a semantic feature and/or a text expression feature of the text data that is 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 characterization model, and obtain a corrected training text output by the second language characterization model after performing text correction processing on the third training text;
And the parameter adjustment module 1304 is configured to obtain, 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 correction training text, a positive deviation/negative deviation generated by the model output result of the target service object before and after correction, and adjust a model parameter of the second language representation model according to the positive deviation/negative deviation, 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 and shielding a first target number of segmented words in the first training text in a random sampling mode to obtain a first masking training text comprising the first target number of masked words, wherein the first target number is determined according to the sampling proportion of the random sampling and the number of segmented words in the first training text;
inputting the first masking training text into the language model to obtain a first masking predicted text which is output by the language model and comprises predicted results of masking words of a first target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the first masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
In an alternative embodiment, the first training module 1301 is specifically configured to:
Masking and shielding the word segmentation of a second target number belonging to the specific text data in the first training text according to a first preset sampling proportion to obtain a second masking training text comprising the masked word of the second target number, wherein the second target number is determined according to the first preset sampling proportion and the word segmentation number belonging to the specific text data in the first training text;
Inputting the second masking training text into the language model to obtain a second masking predicted text which is output by the language model and comprises predicted results of masking words of a second target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the second masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
In an optional implementation manner, the training of the first language characterization model by using the second training text with the semantic mark in the target field at least includes performing coarse-granularity training and/or fine-granularity training on the first language characterization model by using the second training text with the semantic mark in the target field, where the coarse-granularity training is used to train the first language characterization model to classify different sentences in the second training text under the same semantic concept according to different text expression modes corresponding to the same semantic concept in the target field, and the fine-granularity training is used to train the first language characterization model to identify the text 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 an alternative embodiment, the second training module 1302 is configured to perform the coarse-granularity training on the first language characterization model by:
inputting original version sentences of the second training text after the existing semantic marks are removed from the two sentences into the first language characterization model, and performing classification prediction on whether the two sentences correspond to the same semantic concept in the target field or not through the first language characterization model to obtain classification prediction results of the two sentences;
Determining a real classification result of any two sentences according to the semantic marks of the any two sentences in the second training text, wherein the real classification result is used for representing whether the any two sentences correspond to the same semantic concept in the target field or not;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the classification prediction result and the real classification result until the first language characterization model converges.
In an alternative embodiment, the second training module 1302 is configured to perform the fine-granularity training on the first language characterization model by:
Inputting an original version sentence of which the existing semantic mark is removed into the first language characterization model aiming at each sentence in the second training text, and analyzing sentence components of the sentence in the target field through the first language characterization model to obtain a sentence analysis result of the sentence in the target field, wherein the sentence components at least comprise first target participles which belong to entities defined in the target field and second target participles which can characterize different semantic concepts in the target field;
according to the entities defined in the target field and the semantic tags existing in the sentence, performing sequence tagging on a plurality of participles included in the sentence to obtain a participle sequence tagging result of the sentence;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the sentence analysis result and the word segmentation sequence marking result until the first language characterization model converges.
In an alternative embodiment, the first processing module 1303 is specifically configured to:
Inputting each sentence in the third training text into the second language characterization model to obtain a first output result of the second language characterization model for the sentence;
Under the condition that the first output result is detected to be different from the sentence, determining that the second language characterization model carries out text error correction processing on the sentence, and taking the first output result as the correction training text;
And if 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 for the sentence until the corrected training text is obtained.
In an alternative embodiment, parameter adjustment 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 the output result before correction;
And inputting the corrected training text into the target service object, and outputting the corrected training text to obtain a corrected output result.
In an alternative embodiment, when the third training text is input into the target service object and the output results are obtained before correction, the parameter adjustment module 1304 is configured to:
The third training text is input into the target service object, and the output category of the third training text is predicted through the target service object to obtain the output result before correction, wherein 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 adjustment module 1304 is configured to:
and 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, wherein 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 alternative embodiment, when the model output result of the target service object is obtained and positive deviation/negative deviation generated before and after correction, the parameter adjustment module 1304 is configured to:
Calculating a first deviation generated before and after correction of a model output result of the target service object 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 the first deviation generated before and after correcting the model output result of the target service object according to the first deviation calculation policy, 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 in the same preset category, and taking the calculated result as the first deviation.
In an alternative embodiment, the parameter adjustment 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, the third training text is used as the output result before correction, and the corrected training text is used as the output result after correction.
In an alternative embodiment, when the model output result of the target service object is obtained and positive deviation/negative deviation generated before and after correction, the parameter adjustment module 1304 is further configured to:
calculating a second deviation generated before and after correction of the model output result of the target service object 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 alternative embodiment, the parameter adjustment module 1304 is specifically configured to, when calculating the second deviation generated before and after correction of the model output result of the target service object according to the second deviation calculation policy:
The method comprises the steps of obtaining standard text recognition results of target input data, wherein the target input data are used for representing model input data of a target service object when the target service object outputs a 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 alternative embodiment, when the model parameters of the second language characterization model are adjusted according to the positive bias/negative bias, the parameter adjustment module 1304 is specifically configured to:
Acquiring target positive deviation/negative deviation obtained by a target second language characterization model trained based on the training period in each training period of the second language characterization model;
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 the training cut-off condition.
In an alternative embodiment, the parameter adjustment module 1304 is further configured to determine the target second language characterization model for each training period by:
When each training period of the second language representation model is reached, acquiring the trained second language representation model in the previous training period, and generating a mirror image second language representation model which is not trained in the previous training period;
Under the training period, synchronously training the second language characterization model trained in the previous training period and the mirror image second language characterization model not trained in the previous training period to respectively obtain an optimized second language characterization model and an optimized mirror image second language characterization model trained in the training period;
The method comprises the steps of obtaining 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, wherein the first training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation obtained based on the optimized second language representation model in the training period, and the second training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation 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 by using 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, the optimized second language representation model is used as a target second language representation model of the training period; and simultaneously, 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 alternative embodiment, the training device further comprises:
The first test module is used for inputting test texts input or output by the target service object in the test process into the text correction model to obtain corrected test texts which are output by the text correction model and subjected to text correction processing;
The second test module is used for acquiring test deviation generated before and after 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, wherein the test deviation comprises positive test deviation belonging to positive numbers and negative test deviation belonging to negative numbers;
And the third test module is used for determining the model training effect of the text error correction model according to the test deviation generated before and after each correction.
According to the training device for the text error correction model, the universal text data in the open field is used for carrying out basic training on the language model, the proprietary text data in the target field is used for carrying out fine tuning training on the language model, so that the trained language model has the capability of identifying specific text characteristics in the target field, and then the target service object which is relatively mature in the target field is used as a teacher model in a data interaction mode with the converged target service object to carry out interactive auxiliary training on the text error correction model in training. By the training device, the training model can be quickly adapted to more complex and unique language environment on the premise of not losing the generalized text correction capability, so that the text correction accuracy of the model in the target field is improved.
Based on the same inventive concept, the embodiment of the present application further provides a text error correction device corresponding to the text error correction method in the foregoing embodiment, and since 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 foregoing embodiment of the present application, implementation of the text error correction device may refer to implementation of the foregoing text error correction method, and repeated parts will not be repeated.
Referring to fig. 14, fig. 14 shows a schematic structural diagram of a text correction device according to an embodiment of the present application, where the text correction device is applied to a pre-trained text correction model, the text correction model is used to provide a text correction service for a target service object in a target domain, the target service object belongs to a converged mature algorithm model in the target domain, and the text correction device includes:
A text error correction module 1401, configured to input a text 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, correct a target text error included in the text to be subjected to error correction by using the text error correction model, and obtain a corrected text output by using the text error correction model and aiming at the text to be subjected to error correction;
A text replacement module 1402, configured to replace the text to be corrected input or output by the target service object in the application process with the corrected text.
In an alternative embodiment, the text error correction model is obtained after training according to the training method in any one of the alternative embodiments described in the foregoing embodiments, and the repetition is not repeated here.
According to the text error correction device provided by the embodiment of the application, after the text error correction model is trained, text error correction processing can be carried out on text data related to the application process of the target service object by using the text error correction model, so that the accuracy of the output result of the target service object model and the operation efficiency of the target service object can be improved.
As shown in fig. 15, an embodiment of the present application provides an electronic device 1500 for executing steps of a training method of a text error correction model according to any one of the above embodiments of the present application, where 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, where the steps of the training method of a text error correction model according to any one of the above 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 herein, and when the first processor 1502 runs a computer program stored in the first memory 1501, any one of the steps of the training method of the text error correction model described above can be executed.
Corresponding to the training method of the text error correction model in the present application, the embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the training method of the text error correction model are executed.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, etc., and the computer program on the storage medium, when executed, can perform the steps of any of the above-described training methods for text error correction models.
As shown in fig. 16, an embodiment of the present application provides another electronic device 1600 for performing the steps of any one of the text error correction methods of the present application, where the device includes a second memory 1601, a second processor 1602, and a computer program stored on the second memory 1601 and executable on the second processor 1602, where the steps of any one of the text error correction methods are implemented when the second processor 1602 executes the computer program.
Specifically, the second memory 1601 and the second processor 1602 may be general-purpose memories and processors, which are not limited herein, and when the second processor 1602 runs a computer program stored in the second memory 1601, the steps of any of the text error correction methods described above can be performed.
Corresponding to the text error correction method in the present application, the embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the text error correction methods are performed.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, etc., on which a computer program is executed, capable of performing the steps of any of the text error correction methods described above.
In the embodiments provided herein, it should be understood that the disclosed systems and methods may be implemented in other ways. The system embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical functional division, and there may be additional divisions in actual implementation, and e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, system or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown 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 may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments provided in the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in 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 this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
It should be noted that like reference numerals and letters refer to like items in the following figures, and thus, once an item is defined in one figure, no further definition or explanation of that in the following figures is necessary, and furthermore, the terms "first," "second," "third," etc. are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
It should be noted that the foregoing embodiments are merely illustrative embodiments of the present application, and not restrictive, and the scope of the application is not limited to the embodiments, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any modification, variation or substitution of some of the technical features of the embodiments may be made within the technical scope of the present application disclosed in the present application, and the spirit, the scope and the scope of the technical aspects of the embodiments do not deviate from the spirit and scope of the technical aspects of the embodiments. Are intended to be encompassed within 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 (24)

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 converged mature algorithm model in the target field, and the training method comprises the following steps:
Pre-training a language model by using a first training text without semantic marks to obtain a first language characterization 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 characterization model by using a second training text with semantic marks in the target field to obtain a second language characterization model with target text feature recognition capability, wherein the target text features are used for characterizing the special semantic features and/or text expression features of the text data 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 characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text;
And 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 correction training text, acquiring positive deviation/negative deviation generated by the model output result of the target service object before and after correction, and adjusting model parameters of the second language representation model according to the positive deviation/negative deviation to obtain a text error correction model comprising the adjusted model parameters.
2. The training method of claim 1, wherein the pre-training the language model with the first training text without semantic tags to obtain a first language characterization model comprises:
masking and shielding a first target number of segmented words in the first training text in a random sampling mode to obtain a first masking training text comprising the first target number of masked words, wherein the first target number is determined according to the sampling proportion of the random sampling and the number of segmented words in the first training text;
inputting the first masking training text into the language model to obtain a first masking predicted text which is output by the language model and comprises predicted results of masking words of a first target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the first masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
3. The training method of claim 1, wherein the pre-training the language model with the first training text without semantic tags to obtain a first language characterization model, further comprises:
Masking and shielding the word segmentation of a second target number belonging to the specific text data in the first training text according to a first preset sampling proportion to obtain a second masking training text comprising the masked word of the second target number, wherein the second target number is determined according to the first preset sampling proportion and the word segmentation number belonging to the specific text data in the first training text;
Inputting the second masking training text into the language model to obtain a second masking predicted text which is output by the language model and comprises predicted results of masking words of a second target number;
And adjusting model parameters of the language model by utilizing cross entropy loss between the second masking predicted text and the first training text which is not masked until the language model is converged, and taking the language model after convergence as the first language characterization model.
4. The training method according to claim 1, wherein the training the first language characterization model by using the second training text with the semantic mark in the target domain at least comprises performing coarse-granularity training and/or fine-granularity training on the first language characterization model by using the second training text with the semantic mark in the target domain, wherein the coarse-granularity training is used for training the first language characterization model to classify different sentences in the same semantic concept in the second training text according to different word expression modes corresponding to the same semantic concept in the target domain, and the fine-granularity training is used for training the first language characterization model to recognize the word expression modes of each sentence in the target domain according to the word segmentation sequence marking result of each sentence in the second training text.
5. The training method of claim 4, wherein the coarse-grained training of the first language characterization model is performed by:
inputting original version sentences of the second training text after the existing semantic marks are removed from the two sentences into the first language characterization model, and performing classification prediction on whether the two sentences correspond to the same semantic concept in the target field or not through the first language characterization model to obtain classification prediction results of the two sentences;
Determining a real classification result of any two sentences according to the semantic marks of the any two sentences in the second training text, wherein the real classification result is used for representing whether the any two sentences correspond to the same semantic concept in the target field or not;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the classification prediction result and the real classification result until the first language characterization model converges.
6. The training method of claim 4, wherein the fine-grained training of the first language characterization model is performed by:
Inputting an original version sentence of which the existing semantic mark is removed into the first language characterization model aiming at each sentence in the second training text, and analyzing sentence components of the sentence in the target field through the first language characterization model to obtain a sentence analysis result of the sentence in the target field, wherein the sentence components at least comprise first target participles which belong to entities defined in the target field and second target participles which can characterize different semantic concepts in the target field;
according to the entities defined in the target field and the semantic tags existing in the sentence, performing sequence tagging on a plurality of participles included in the sentence to obtain a participle sequence tagging result of the sentence;
And adjusting model parameters of the first language characterization model by utilizing the cross entropy loss between the sentence analysis result and the word segmentation sequence marking result until the first language characterization model converges.
7. The training method according to claim 1, wherein the inputting the third training text input or output by the target service object in the training process into the second language characterization model, to obtain the corrected training text output by the second language characterization model after performing text correction processing on the third training text, includes:
Inputting each sentence in the third training text into the second language characterization model to obtain a first output result of the second language characterization model for the sentence;
under the condition that the first output result is detected to be different from the sentence, determining that the second language characterization model carries out text error correction processing on the sentence, and taking the first output result as the correction training text;
And if 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 for the sentence until the corrected training text is obtained.
8. The training method of claim 1, wherein after obtaining the corrected training text output by the second language characterization model after text correction processing of 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 the output result before correction;
And inputting the corrected training text into the target service object, and outputting the corrected training text to obtain a 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:
The third training text is input into the target service object, and the output category of the third training text is predicted through the target service object to obtain the output result before correction, wherein 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 step of inputting the corrected training text into the target service object and outputting the corrected output result comprises the following steps:
and 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, wherein 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 of claim 9, wherein the obtaining the positive/negative bias of the model output result of the target service object before and after the correction comprises:
Calculating a first deviation generated before and after correction of a model output result of the target service object 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 of the target service object before and after 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 in the same preset category, and taking the calculated result as the first deviation.
12. The training method of claim 1, wherein after obtaining the corrected training text output by the second language characterization model after text correction processing of 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, the third training text is used as the output result before correction, and the corrected training text is used as the output result after correction.
13. The training method of claim 12, wherein the obtaining the positive/negative bias of the model output result of the target service object before and after the correction comprises:
calculating a second deviation generated before and after correction of the model output result of the target service object 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 of the target service object before and after correction according to a second deviation calculation strategy comprises:
The method comprises the steps of obtaining standard text recognition results of target input data, wherein the target input data are used for representing model input data of a target service object when the target service object outputs a 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 of claim 1, wherein the adjusting the model parameters of the second language characterization model according to the positive bias/negative bias results in a text correction model including the adjusted model parameters, comprising:
Acquiring target positive deviation/negative deviation obtained by a target second language characterization model trained based on the training period in each training period of the second language characterization model;
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 the training cut-off condition.
16. The training method of claim 15, wherein the target second language characterization model for each training period is determined by:
When each training period of the second language representation model is reached, acquiring the trained second language representation model in the previous training period, and generating a mirror image second language representation model which is not trained in the previous training period;
Under the training period, synchronously training the second language characterization model trained in the previous training period and the mirror image second language characterization model not trained in the previous training period to respectively obtain an optimized second language characterization model and an optimized mirror image second language characterization model trained in the training period;
The method comprises the steps of obtaining 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, wherein the first training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation obtained based on the optimized second language representation model in the training period, and the second training deviation is used for representing the deviation sum value of a plurality of positive deviation/negative deviation 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 by using 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, the optimized second language representation model is used as a target second language representation model of the training period; and simultaneously, 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 a text correction model including adjusted model parameters, the training method further comprises:
Inputting test text input or output by the target service object in the test process into the text correction model to obtain corrected test text output by the text correction model after text correction processing is carried out on the test text;
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, obtaining test deviations generated before and after correction of the test output result of the target service object, wherein the test deviations comprise positive test deviations belonging to positive numbers and negative test deviations belonging to negative numbers;
and determining the model training effect of the text error correction model according to the test deviation generated before and after each correction.
18. The text error correction method is applied to a pre-trained text error correction model, wherein 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, and the text error correction method comprises the following steps:
Inputting a text to be corrected, which is required to be subjected to text correction processing in an application process, of the target service object into a pre-trained text correction model, correcting target text errors included in the text to be corrected through the text correction model, and obtaining corrected text, which is output by the text correction model and is aimed at the text to be corrected, wherein the target text errors are determined according to special semantic features and/or text expression features in the target field;
And replacing the text to be corrected, which is input or output by the target service object in the application process, with the corrected text.
19. The training device for the text error correction model is characterized by being used for providing text error correction service for a target service object in a target field, wherein the target service object belongs to a converged mature algorithm model in the target field, and comprises the following components:
The first training module is used for pre-training the language model by using a first training text without semantic marks to obtain a first language characterization 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 characterization model by utilizing a second training text which is subjected to semantic marking in the target field to obtain a second language characterization model with target text feature recognition capability, wherein the target text features are used for characterizing the special semantic features and/or text expression features of the text data 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 characterization model to obtain a corrected training text output by the second language characterization model after text correction processing is performed on the third training text;
And the parameter adjustment module is used for acquiring positive deviation/negative deviation generated before and after correction of the model output result of the target service object according to the pre-correction output result obtained by the target service object based on the third training text and the post-correction output result obtained by the target service object based on the correction training text, and adjusting the model parameters of the second language characterization model according to the positive deviation/negative deviation to obtain a text error correction model comprising the adjusted model parameters.
20. The text error correction device is applied to a pre-trained text error correction model, wherein 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, and the text error correction device comprises:
The text error correction module is used for inputting a text 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, correcting target text errors included in the text to be subjected to error correction through the text error correction model to obtain corrected text which is output by the text error correction model and is aimed at the text to be subjected to error correction, wherein the target text errors are determined according to special semantic features and/or text expression features in the target field;
And the text replacement module is used for replacing the text to be corrected, which is input or output by the target service object in the application process, with the corrected text.
21. 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 in communication via the bus when the electronic device is in operation, the machine-readable instructions when executed by the processor performing the steps of the training method of any of claims 1 to 17.
22. A computer-readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, performs the steps of the training method according to any of claims 1 to 17.
23. 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 in communication over the bus when the electronic device is in operation, the machine-readable instructions when executed by the processor performing the steps of the text error correction method of claim 18.
24. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the text error correction method of claim 18.
CN202210506361.8A 2022-05-10 2022-05-10 Text error correction model training method and device, text error correction method and device Active CN114861636B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210506361.8A CN114861636B (en) 2022-05-10 2022-05-10 Text error correction model training method and device, text error correction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210506361.8A CN114861636B (en) 2022-05-10 2022-05-10 Text error correction model training method and device, text error correction method and device

Publications (2)

Publication Number Publication Date
CN114861636A CN114861636A (en) 2022-08-05
CN114861636B true CN114861636B (en) 2024-12-03

Family

ID=82637914

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210506361.8A Active CN114861636B (en) 2022-05-10 2022-05-10 Text error correction model training method and device, text error correction method and device

Country Status (1)

Country Link
CN (1) CN114861636B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858776B (en) * 2022-10-31 2023-06-23 北京数美时代科技有限公司 Variant text classification recognition method, system, storage medium and electronic equipment
CN116306598B (en) * 2023-05-22 2023-09-08 上海蜜度信息技术有限公司 Customized error correction method, system, equipment and medium for words in different fields
CN118468061B (en) * 2024-07-15 2024-09-27 四川三合力通科技发展集团有限公司 Automatic algorithm matching and parameter optimizing method and system
CN119494000B (en) * 2025-01-16 2025-04-11 亚信科技(中国)有限公司 Training of large language model for text error correction, error correction method and related device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111460827A (en) * 2020-04-01 2020-07-28 北京爱咔咔信息技术有限公司 Text information processing method, system, equipment and computer readable storage medium
CN114444479A (en) * 2022-04-11 2022-05-06 南京云问网络技术有限公司 End-to-end Chinese speech text error correction method, device and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111460827A (en) * 2020-04-01 2020-07-28 北京爱咔咔信息技术有限公司 Text information processing method, system, equipment and computer readable storage medium
CN114444479A (en) * 2022-04-11 2022-05-06 南京云问网络技术有限公司 End-to-end Chinese speech text error correction method, device and storage medium

Also Published As

Publication number Publication date
CN114861636A (en) 2022-08-05

Similar Documents

Publication Publication Date Title
CN114861636B (en) Text error correction model training method and device, text error correction method and device
US11934781B2 (en) Systems and methods for controllable text summarization
CN112070138B (en) Construction method of multi-label mixed classification model, news classification method and system
CN116629275B (en) Intelligent decision support system and method based on big data
KR101813683B1 (en) Method for automatic correction of errors in annotated corpus using kernel Ripple-Down Rules
CN115064154B (en) Method and device for generating mixed language voice recognition model
CN111782807B (en) Self-bearing technology debt detection classification method based on multiparty integrated learning
CN112699671B (en) Language labeling method, device, computer equipment and storage medium
CN115034218A (en) Chinese grammar error diagnosis method based on multi-stage training and editing level voting
CN118312212A (en) Task testing method, code annotation method, task testing platform, equipment
CN115510841A (en) Text matching method based on data enhancement and graph matching network
CN119599137B (en) Detection and repair method and system for large language model output hallucination
CN116304061B (en) Text classification method, device and medium based on hierarchical text graph structure learning
CN115359799A (en) Speech recognition method, training method, device, electronic equipment and storage medium
CN113705207A (en) Grammar error recognition method and device
CN115757695A (en) Log language model training method and system
CN119004100A (en) Industry large model-oriented fine adjustment data generation method, computer program and terminal
CN118964641A (en) Method and system for building AI knowledge base model for enterprises
CN120373293A (en) Text error correction method, device, equipment and medium based on large model
CN116681061A (en) English grammar correction technology based on multitask learning and attention mechanism
CN112528045B (en) Method and system for judging domain map relation based on open encyclopedia map
CN118627471A (en) Automatic annotation method and system for government data based on attention-dependent graph convolution
CN117371445A (en) Information error correction method, device, computer equipment and storage medium
CN114896966B (en) A method, system, device and medium for locating grammatical errors in Chinese text
CN117217210A (en) Training method and related device for grammar error correction model

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
GR01 Patent grant
GR01 Patent grant