CN112765954B - Method and device for identifying repair and electronic equipment - Google Patents

Method and device for identifying repair and electronic equipment Download PDF

Info

Publication number
CN112765954B
CN112765954B CN202110076417.6A CN202110076417A CN112765954B CN 112765954 B CN112765954 B CN 112765954B CN 202110076417 A CN202110076417 A CN 202110076417A CN 112765954 B CN112765954 B CN 112765954B
Authority
CN
China
Prior art keywords
repair
self
training
classifier
sentence
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
CN202110076417.6A
Other languages
Chinese (zh)
Other versions
CN112765954A (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.)
Beijing Yiyi Education Technology Co ltd
Original Assignee
Beijing Yiyi Education Technology 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 Beijing Yiyi Education Technology Co ltd filed Critical Beijing Yiyi Education Technology Co ltd
Priority to CN202110076417.6A priority Critical patent/CN112765954B/en
Publication of CN112765954A publication Critical patent/CN112765954A/en
Application granted granted Critical
Publication of CN112765954B publication Critical patent/CN112765954B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Image Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and a device for identifying a repair and electronic equipment, wherein the method comprises the following steps: presetting a repair identification model, wherein the repair identification model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier; determining a target sentence to be identified, and determining a target feature vector of the target sentence according to the repair identification model mapping layer; and circularly executing the classification process until the corresponding repair label of the target sentence is determined. According to the method, the device and the electronic equipment for the repair and identification provided by the embodiment of the invention, the repair and identification of the target sentence can be determined by sequentially identifying the repair and identification labels of the target sentence through the multiple classifiers, and the repair and identification efficiency of the target sentence can be improved when the complete repair and identification model is not run; and then determining the repair label of the target sentence when the classification confidence coefficient exceeds a preset threshold value, wherein the repair recognition result is more accurate, namely, the rapid and accurate repair recognition can be realized.

Description

Method and device for identifying repair and electronic equipment
Technical Field
The present invention relates to the technical field of repair and identification, and in particular, to a method, an apparatus, an electronic device, and a computer-readable storage medium for repair and identification.
Background
In the current Chinese teaching task, students are explicitly required to master and use common techniques of tutoring. In primary school Chinese courses, common techniques for tutoring include metaphors, personification, ranking, etc. The metaphors are comparatives, that is, according to the association, grasp the similarity of different things and replace abstract and unintelligible things with shallow, concrete and vivid things. The anthropomorphic sentence is to metaphe something into a manned action, rather than a fairy tale; the written things must have the characteristics of a person, no metaphor words can appear, no words representing the person can appear. The ranking sentence refers to a sentence formed by arranging three or more phrases or sentences with related or similar meanings, same or similar structures and same mood together by using a ranking and convoying method. Sometimes two or more parallel sentences may also be referred to as a ranking sentence.
In the writing process, the method can make the article become more vivid and read to give people a beautiful feeling. The skilled use of different techniques of congratulation has become one of the important criteria for evaluating the writing level of pupils. Based on the above, finding out an automatic identification method for the method of the congratulation in the writing of students can necessarily effectively improve the richness and accuracy of the automatic evaluation of the composition. At present, a recognition technology of related congratulation mainly uses a mode based on keyword position and frequency statistics, and can solve a part of recognition problems, but the recognition is relatively dead due to the mode of rule matching, so that some special sentences are easy to miss.
At present, a scheme for identifying the method of the conquering based on the deep learning model exists, but the scheme is only applied to the deep learning model, and the conquering identification efficiency is low; in particular, the composition of a student contains a plurality of sentences, and each sentence needs to be subjected to the correction judgment, so that the efficiency of evaluating the student is seriously affected.
Disclosure of Invention
In order to solve the existing technical problems, the embodiment of the invention provides a method, a device, electronic equipment and a computer readable storage medium for identifying a repair.
In a first aspect, an embodiment of the present invention provides a method for identifying a repair, including:
presetting a correction identification model, wherein the correction identification model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier, wherein the mapping layer is connected with an input layer of a 1 st self-attention layer, and an output end of an i th self-attention layer is connected with an input end of a next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2; determining a target sentence to be identified, inputting the target sentence into the repair identification model, and determining a target feature vector of the target sentence according to the repair identification model mapping layer; the classification process is circularly executed until the corresponding repair label of the target sentence is determined;
Wherein the classification process comprises:
the current self-attention layer carries out self-attention processing on the target feature vector output by the previous layer, and generates a processed target feature vector; and the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, and otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
In a second aspect, an embodiment of the present invention further provides an apparatus for identifying a repair, including:
the model module is used for presetting a correction recognition model, wherein the correction recognition model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier, the mapping layer is connected with the input layer of the 1 st self-attention layer, and the output end of the i th self-attention layer is connected with the input end of the next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2;
The preprocessing module is used for determining a target sentence to be recognized, inputting the target sentence into the repair recognition model, and determining a target feature vector of the target sentence according to the repair recognition model mapping layer;
the circulation identification module is used for performing a classification process in a circulation manner until the corresponding repair label of the target sentence is determined;
wherein, the cycle identification module performs a classification process comprising:
the current self-attention layer carries out self-attention processing on the target feature vector output by the previous layer, and generates a processed target feature vector;
and the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, and otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
In a third aspect, an embodiment of the present invention provides an electronic device, including a bus, a transceiver, a memory, a processor, and a computer program stored on the memory and executable on the processor, where the transceiver, the memory, and the processor are connected by the bus, and where the computer program when executed by the processor implements the steps in the method for identifying a fix-up as described in any of the above.
In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs steps in a method of tutorial identification as described in any one of the preceding claims.
The method, the device, the electronic equipment and the computer readable storage medium for identifying the paraphrasing provided by the embodiment of the invention are used for identifying the paraphrasing by a paraphrasing identification model comprising a plurality of self-attentive layers and a plurality of classifiers, and when identifying the paraphrasing of the target sentence, the plurality of classifiers are used for sequentially executing classification operation until a certain classifier can accurately identify the paraphrasing label of the target sentence. According to the method, the target sentence repair labels are sequentially identified through a plurality of classifiers, and the repair labels of the target sentences can be determined even if a complete repair identification model is not run, so that the repair identification efficiency can be improved; and then determining the repair label of the target sentence when the classification confidence coefficient exceeds a preset threshold value, wherein the repair recognition result is more accurate, namely, the rapid and accurate repair recognition can be realized.
Drawings
In order to more clearly describe the embodiments of the present invention or the technical solutions in the background art, the following description will describe the drawings that are required to be used in the embodiments of the present invention or the background art.
FIG. 1 is a flow chart of a method of tutorial identification provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of a structure of a method for identifying a repair word according to an embodiment of the present invention;
FIG. 3 is a schematic diagram showing a device for identifying a repair according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device for performing a method for recognizing a fix-up language according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention describes a method, a device and electronic equipment through flowcharts and/or block diagrams.
It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions. These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
Embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
Fig. 1 is a flowchart of a method for identifying a repair according to an embodiment of the present invention. As shown in fig. 1, the method includes:
step 101: presetting a correction identification model, wherein the correction identification model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier, the mapping layer is connected with an input layer of a 1 st self-attention layer, and an output end of an i th self-attention layer is connected with an input end of a next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2.
In the embodiment of the invention, the repair identification model is provided with a plurality of self-attention layers, and the structural schematic diagram of the repair identification model can be seen in fig. 2, and the repair identification model comprises a mapping (empadd) layer, n self-attention layers, n-1 sub-classifiers and a total classifier; that is, the number of classifiers (including sub-classifiers and total classifiers) is the same as the number of self-attention layers, and is n.
In the embodiment of the invention, the mapping layer is used for mapping words into feature vectors, so that the feature vectors of sentences formed by a plurality of words can be determined; wherein the mapping layer may map the word to a low-dimensional dense semantic space to form a feature vector for the word. Optionally, the mapping layer in other recognition tasks can be directly applied by utilizing the migration learning principle so as to alleviate the problem of unexpected training.
The self-attention layer is used for performing self-attention processing on the feature vector output by the upper layer (such as a mapping layer or the upper self-attention layer) connected with the input end of the self-attention layer, and adding a self-attention mechanism to the feature vector so as to generate a processed feature vector. Meanwhile, the output end of each self-attention layer is also connected with a classifier (sub-classifier or total classifier), and the classifier can carry out classification and identification according to the feature vectors output by the connected self-attention layer so as to determine what type of the sentence to be identified belongs to; the ith sub-classifier is connected to the output end of the ith self-attention layer (i=1, 2, …, n-1), and the classifier connected to the last self-attention layer (i.e. the nth self-attention layer) is the total classifier.
In the embodiment of the present invention, the self-focusing layer does not include a conventional CNN (convolutional neural network) or RNN (recurrent neural network), and is mainly used for introducing a self-focusing mechanism, and the self-focusing layer may also include a fully-connected layer. Specifically, since the present embodiment requires multiple processing of feature vectors, and calculation of RNN or LSTM (Long Short-Term Memory network), GRU (Gated Recurrent Unit, round-robin gate unit) and the like is limited to be sequential, that is, RNN related algorithm can only be calculated sequentially from left to right or from right to left, this mechanism brings two problems: the calculation of the time slices depends on the calculation results of the time instants, so that the parallelism capability of the model is limited; information is lost in the process of sequential computation, and although the structure of gating mechanisms such as LSTM (least squares) alleviates the problem of long-term dependence to a certain extent, LSTM (least squares) still cannot be used for particularly long-term dependence phenomenon. The self-attention layer in the embodiment uses a self-attention mechanism to reduce the distance between any two positions in the sequence to a constant value; and the method is not similar to the sequential structure of RNNs, so that the self-attention layers have better parallelism, and the method can realize the multiple processing of the feature vectors by connecting a plurality of self-attention layers in series, thereby meeting the framework of the repair recognition model in the embodiment.
In addition, it should be noted that, in this embodiment, a is connected to B (or, a is connected to B), which means that a is directly connected to B, or that a and B may be indirectly connected to each other through other components. For example, the mapping layer is connected to the input layer of the 1 st self-focusing layer, and may be directly connected to the 1 st self-focusing layer (i.e., the self-focusing layer 1) as shown in fig. 2, or may be reconnected to the self-focusing layer 1 through other layers (e.g., other self-focusing layers except n self-focusing layers).
Step 102: and determining a target sentence to be identified, inputting the target sentence into the utterance recognition model, and determining a target feature vector of the target sentence according to the utterance recognition model mapping layer.
In the embodiment of the invention, when the method for remedying a certain sentence or whether the method for remedying is adopted is required to be determined, the sentence can be used as a target sentence, and the target sentence can be input into the remedying recognition model. The mapping layer of the repair recognition model can map all words in the target sentence into corresponding feature vectors, so as to determine the feature vectors of the target sentence, namely target feature vectors; the feature vectors of all words in the target sentence can be spliced to form the feature vector of the target sentence.
Step 103: and performing a classification process circularly until the corresponding repair label of the target sentence is determined.
After the target feature vector of the target sentence is determined, a self-attention mechanism is introduced to the target feature vector through the self-attention layer, and a new target feature vector is formed, so that the new target feature vector can capture the correlation of the features, learn the relation among different words, and further accurately perform the repair classification on the target sentence. Wherein, this classification process includes:
step 1031: the current self-attention layer carries out self-attention processing on the target feature vector output by the upper layer, and generates a processed target feature vector.
Step 1032: the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
In the embodiment of the invention, each classifier can execute a classification process once; wherein feature vectors first need to be processed based on the corresponding self-attention layer, i.e. the current self-attention layer. Specifically, in the classification process of the current wheel, the current self-attention layer receives the target feature vector transmitted by the previous layer; as shown in fig. 2, in the round 1 classification process, the current self-attention layer is the self-attention layer 1, which receives the target feature vector V0 of the target sentence input by the mapping layer, and then the self-attention layer 1 introduces a self-attention mechanism for the target feature vector V0, so as to generate a processed target feature vector, i.e. the target feature vector V1. At this time, the current sub-classifier is sub-classifier 1, and sub-classifier 1 performs classification processing according to the target feature vector V1 to determine the repair tag of the target sentence. If the classification confidence (i.e., the probability that the target sentence belongs to the corresponding repair label) of the sub-classifier 1 is higher than the preset threshold (e.g., 80%, 90%) during the classification, it is explained that the repair label of the target sentence can be determined relatively accurately through the classification operation, and at this time, the classification label corresponding to the target sentence can be determined directly. Conversely, if the classification confidence is not higher than the preset threshold, it indicates that the classification operation is not enough to accurately determine the label of the target sentence, and the next round of classification operation needs to be performed at this time, that is, the current self-attention layer 1 transfers the processed target feature vector V1 to the next self-attention layer, that is, the self-attention layer 2, and at this time, the self-attention layer 2 continues to perform the classification process as the current self-attention layer; for the self-attention layer 2, the target feature vector output by the previous layer is the target feature vector V1 output by the self-attention layer 1. The subsequent self-attention layer 2 performs the procedure of step 1032 as described above, and will not be described here. According to the analysis, when the repair label of the target sentence needs to be determined, if a certain sub-classifier can accurately determine the repair label of the target sentence, the corresponding repair label can be directly marked on the target sentence, and the subsequent classification process does not need to be continuously executed at the moment; if the current sub-classifier cannot accurately classify, the next sub-classifier continues to classify until a certain sub-classifier can accurately classify.
If the label of the corresponding repair of the target sentence cannot be determined after the classification process of the n-1 round, the cyclic execution of the classification process is stopped, and the current target feature vector Vn-1 is transmitted to the n-th self-attention layer n by the n-1-th self-attention layer n-1; the self-attention layer n carries out self-attention processing on the target feature vector Vn-1 again to generate a processed target feature vector Vn, and then the total classifier carries out classification processing according to the processed target feature vector Vn; at this time, whether the classification confidence coefficient exceeds a preset threshold value or not can be determined according to the classification result, and the corresponding repair label of the target sentence is determined. Alternatively, the method may determine the utterance label of the target sentence only when the classification confidence exceeds a preset threshold, otherwise, the utterance recognition model may be considered as not being able to correctly recognize the utterance manipulation of the target sentence. Wherein the repair tag may include at least two of anthropomorphic, metaphor, ranking, and no repair specifically.
According to the method for identifying the paraphrasing, provided by the embodiment of the invention, the paraphrasing identification model comprising a plurality of self-attention layers and a plurality of classifiers is used for identifying the paraphrasing of the target sentence, and the plurality of classifiers are used for sequentially executing classification operation until a certain classifier can accurately identify the paraphrasing label of the target sentence. According to the method, the target sentence repair labels are sequentially identified through a plurality of classifiers, and the repair labels of the target sentences can be determined even if a complete repair identification model is not run, so that the repair identification efficiency can be improved; and then determining the repair label of the target sentence when the classification confidence coefficient exceeds a preset threshold value, wherein the repair recognition result is more accurate, namely, the rapid and accurate repair recognition can be realized.
On the basis of the above embodiment, before the step 101 of "presetting the repair identification model", the method further includes a process of training the repair identification model, and the training process specifically includes:
step A1: training a pre-training part of the training model according to the training sample, and determining weight parameters of the pre-training part, wherein the pre-training part comprises a mapping layer, n self-attention layers and a total classifier.
In the embodiment of the invention, the total classifier and all the sub-classifiers can output the classification result, but the feature vectors input by different classifiers when performing the classification operation are different, for example, the feature vector input by the sub-classifier i in fig. 2 is Vi, so that it is difficult to directly train the repair recognition model. In this embodiment, the tutorial recognition model is divided into a pre-training part and other parts, and as shown by the dotted line in fig. 2, the pre-training part includes a mapping layer, n self-attention layers and a total classifier, and the remaining n-1 sub-classifiers are other parts. In the training process, the pre-training section is first trained. The pre-training part can also perform the training and identification of the congregation essentially, namely, the congregation label of the target sentence is determined by the total classifier after multiple times of self-attention processing, so that the pre-training part can be trained through a traditional congregation training sample; since the training method for training the pre-training part is a mature technology in the prior art, no limitation is made here. Furthermore, "pre-training" in the present embodiment means that it is not necessary for the pre-training section to use a pre-training model; of course, the mapping layer and the total classifier in the pre-training part can also adopt part of the structure in the pre-training model so as to improve training efficiency.
Optionally, the step A1 "training the pre-training portion of the tutorial recognition model according to the tutorial training sample" includes:
step A11: the probability of the corresponding repair label of the training sample sentence in the repair training sample is set as 1-epsilon, and the probability of other repair labels of the training sample sentence is set as
Figure BDA0002907636140000091
Where ε is a positive number less than 0.1 and K is the number of classifications of the repair labels.
In the embodiment of the invention, the tutorial training sample comprises a plurality of training sample sentences, each training sample sentence corresponds to a corresponding tutorial label, and a one-hot coding mode is generally adopted to describe the corresponding tutorial label at present; for example, the repair labels have four types: metaphor, anthropomorphic, ranking, no-repair, the training sample sentence is a ranking sentence, and the repair label of one-hot coding form can be [0, 1,0 ]]. However, the one-hot coding method cannot guarantee generalization capability of the repair recognition model (pre-training part), and overfitting in training is easy to cause; and the labeling result is too believed by the repair identification model, but the labeling is not always completely accurate, and the embodiment solves the problem by fine-tuning the probability of the repair label, so that the performance of the repair identification model is further improved. Specifically, the present embodiment sets the probability of the tutorial label corresponding to the training sample sentence to 1- ε, and the probabilities of the other tutorial labels to
Figure BDA0002907636140000092
So that the situation where the probability is zero can be avoided. For example, if the pedigree label is four types of metaphors, anthropomorphic, ranking, and no pedigree, k=4, and ε is a small value set in advance, for example, 0.03; if the repair tag of the training sample sentence is anthropomorphic, then the repair tag thereof can be represented as [0.01,0.97,0.01,0.01 ]]。
Optionally, after step A1 "training the pre-training portion of the tutorial recognition model based on the tutorial training sample", the training process further includes: fine tuning (finetune) the self-attention layer of the last or both of the pre-training sections enables the pre-training sections to fit better to the actual situation, e.g. to fit the scene identified by the literary composition.
Step A2: under the condition that the weight parameters of the pre-training part are kept unchanged, inputting the unlabeled sentences into the repair recognition model, determining classification probability distribution corresponding to the unlabeled sentences according to the output result of the total classifier, and determining prediction probability distribution output by each sub-classifier.
Step A3: and training the sub-classifier based on the nonstandard sentences by taking the relative entropy between the output predictive probability distribution of the sub-classifier and the classifying probability distribution of the nonstandard sentences or the sum of the relative entropy between the output predictive probability distribution of the plurality of sub-classifiers and the classifying probability distribution of the nonstandard sentences as a loss function, and finally determining the trained repair recognition model.
In the embodiment of the invention, after the training of the pre-training part is finished, the weight parameters of the pre-training part can be determined, namely the weight parameters of the mapping layer, the self-attention layer and the total classifier can be determined, and then the weight parameters of each sub-classifier are determined under the condition that the weight parameters of the pre-training part are kept unchanged, namely the weight parameters of the pre-training part are not updated in the process of training the sub-classifier. Meanwhile, in order to reduce the dependence on the training corpus and the influence of insufficient training corpus, the embodiment realizes the training of the sub-classifier through the nonstandard sentences; the unlabeled sentences refer to sentences which are not labeled with the congratulatory tags, and any correct sentences can be used as unlabeled sentences.
In the embodiment of the invention, when the sub-classifier is trained, the relative entropy between the output prediction probability distribution of the sub-classifier and the classification probability distribution of the nonstandard sentences (determined by the output of the total classifier) or the sum of the relative entropy between the output prediction probability distribution of the plurality of sub-classifiers and the classification probability distribution of the nonstandard sentences is used as a loss function for training; because each sub-classifier is mutually independent, the relative entropy between the sub-classifier output prediction probability distribution and the classification probability distribution of the nonstandard sentences can be used as a loss function, and each sub-classifier can be trained respectively. Specifically, after the nonstandard sentences are input into the repair recognition model and are processed by the mapping layer and the n self-attention layers, the probability of each repair label of the nonstandard sentences, namely probability distribution, can be determined by inputting the final feature vectors of the nonstandard sentences into the total classifier; for example, the repair tags have four types in total: metaphors, personions, ranking, no paraphrasing, if the probability distribution is [0.1,0.04,0.8,0.06], then 0.8 (80%) of the unlabeled sentence is likely to be a ranking sentence. At this time, the probability distribution generated by the overall classifier may be directly used as the probability distribution of the unlabeled sentence, i.e., the classification probability distribution. Alternatively, the classification probability distribution of the unlabeled sentence may be expressed in the form processed in the step a 11. For example, if the score classification result of the overall classifier is a ranking, the probability distribution [0.01,0.01,0.97,0.01] may be regarded as the classification probability distribution of the unlabeled sentence.
Meanwhile, each sub-classifier can determine one probability distribution of the nonstandard sentence, namely a prediction probability distribution according to the feature vector output by the corresponding self-attention layer, the relative entropy between the prediction probability distribution and the classification probability distribution is used for approximately replacing the distance between the two probability distributions in the embodiment, if the relative entropy is smaller, the two probability distributions are basically consistent, namely the classification result obtained according to the sub-classifier is basically consistent with the classification result obtained based on the total classifier. The relative entropy between two probability distributions (the predictive probability distribution and the classifying probability distribution) is calculated as the prior art, and will not be described in detail herein. The sub-classifier is trained by a plurality of unlabeled sentences so that the output of the final sub-classifier is more similar to the output of the overall classifier.
According to the embodiment of the invention, the pre-training part of the repair identification model is trained firstly, and then the sub-classifier is trained, so that the complete training of the repair identification model can be realized. Meanwhile, the relative entropy between the output prediction probability distribution of the sub-classifier and the classification probability distribution of the nonstandard sentences is used as a loss function to train the sub-classifier, other training samples are not needed at this time, the sub-classifier is directly trained through a large number of nonstandard sentences, and the problem of insufficient training samples can be relieved. In addition, although a plurality of sub-classifiers are added on the basis of the pre-training section, the throughput of the self-attentive layer is far greater than that of the classifier, even if a plurality of classification operations are added in the process of the repair recognition, the influence on the overall repair recognition efficiency is small, and the effect of improving the recognition efficiency can be still achieved by reducing the self-attentive layer once or several times.
On the basis of the above embodiment, when there are a plurality of target sentences, for example, when the sentence is subjected to the sentence repair recognition for the student, the sentence repair recognition can be sequentially performed for each target sentence, and the sentence repair tag corresponding to each target sentence can be determined. The step 102 of determining the target sentence to be identified may specifically include:
step B1: and carrying out segmentation processing on the composition to be identified, and determining the text corresponding to each segment.
Step B2: sentence terminators are used as separators to determine sentences in each text segment.
Step B3: and screening the sentences, and taking the rest sentences as target sentences to be identified. The screening process comprises one or more of removing sentences with the length smaller than a preset value, removing more than half of sentences which are personified words and removing conventions into sentences.
In the embodiment of the invention, when a certain composition is required to be subjected to the repair recognition, the composition can be used as the composition to be recognized, and then the composition to be recognized can be subjected to the segmentation processing according to the blank before a paragraph, the first line retraction and the like, so that the text of each paragraph of the composition to be recognized is determined. Then, sentence terminators such as a period, an exclamation mark, a question mark, an ellipsis and the like can be used as segmentors, and the paragraph text can be segmented into a series of sentences with different lengths, so that sentences contained in each paragraph of text can be determined. Then, sentences with lengths smaller than a preset value (for example, 5, etc.), or more than half of the content (i.e., more than 50% of the content) as the personification can be removed, in addition, colloquially called sentences such as reputation and singing in the sentence can be removed, and finally, the rest of the sentences are used as target sentences to be identified. Wherein, can self-build the colloquial sentence corpus, judge whether the sentence is colloquial sentence such as the alert sentence of the title, the adage, the post-consumer's language, the ancient poem, etc. through searching this corpus; if hit, the sentence is rejected (or the sentence is assigned a corresponding tag) and filtered out, otherwise, the sentence can be input as a target sentence to the fix recognition model for recognition.
In the embodiment of the invention, the general classifier is not generally used when the repair recognition model recognizes most of target sentences; when identifying certain specific target sentences (e.g., relatively complex sentences, etc.), it may be necessary to go to the final overall classifier to determine the fix-up tags for the target sentences, which may result in inefficient identification of the target sentences; however, when more target sentences need to be identified, the repair identification model can improve the identification efficiency as a whole. As shown in fig. 2, if three target sentences A, B, C are currently required to be identified; when the target sentence A is identified, the sub-classifier 1 cannot accurately identify the target sentence A, and the sub-classifier 2 is required to continue to identify the target sentence A at the moment, and the target sentence A can be accurately identified as a metaphor sentence; when the target sentence B is identified, the sub-classifier 1 can accurately identify the target sentence B as a rank sentence, and then the target sentence B is continuously identified without other sub-classifiers and a total classifier; the process of recognizing the target sentence C is similar to that of recognizing the target sentence a, and will not be described here. Finally, as shown in fig. 2, the target sentence a is a metaphor sentence, B is a rank sentence, C is a anthropomorphic sentence, and the repair label of the target sentence is directly determined by the sub-classifier, so that the repair recognition efficiency can be greatly improved.
Optionally, after determining the corresponding tutorial tag of the target sentence in step 103, the method further includes:
step B4: and carrying out statistical processing on the correction labels of all the target sentences to determine correction parameters of the composition to be identified, wherein the correction parameters comprise the number of each correction label and/or the ratio of each correction label to the total sentence number of the composition to be identified.
Step B5: scoring the composition to be identified according to the repair parameters, and determining the score of the composition to be identified.
In the embodiment of the invention, after the repair labels of all target sentences in the composition to be identified are determined, what repair is adopted or whether a repair method is adopted for each target sentence can be determined, and then the composition to be processed can be scored according to related repair parameters. Wherein the fix-up parameter may include the number of each fix-up label, such as how many metaphors there are, how many comparatives there are, etc.; and/or, the fix-up parameters include: the ratio of each of the repair tags to the total number of sentences of the composition to be identified, such as the ratio of metaphors to the total number of sentences, the ratio of anthropomorphic sentences to the total number of sentences, and the like. After the correction parameters are determined, the correction parameters to be identified can be scored in terms of correction use, and the score is higher as the correction parameters are larger, namely, the correction parameters and the score are in positive correlation. Optionally, the dimension analysis can be uniformly performed by combining other dimension characteristics of the composition to be processed, and finally, the comprehensive score corresponding to each scoring characteristic is obtained. Wherein a weighted average may be used to combine the plurality of features to determine a final composite score.
For example, when the composition to be identified is a composition handwritten by a student, comprehensive evaluation can be performed in combination with the cleanliness of the composition to be identified. At this time, the step of scoring the composition to be identified according to the paraphrase parameter, and determining the score of the composition to be identified includes: determining the cleanliness of the composition to be identified; and scoring the composition to be identified according to the repair parameters and the neatness, and determining the score of the composition to be identified. Wherein, the process of determining the cleanliness of the composition to be identified may include:
step C1: and acquiring a text image of the composition to be identified.
Step C2: a text box in the text image is detected and a text box confidence level for the text box is determined, the text box confidence level being used to represent a probability that the text box was correctly detected.
In the embodiment of the invention, the text in the text image is generally expressed in a form of a plurality of rows or a plurality of columns, and the text box in the text image can be detected in a detection mode; here, since text is generally represented in the form of lines, the text box in this embodiment is generally a text line box. In particular, the detection may be performed by a text box detection model, such as a CTPN (Connectionist Text Proposal Network, connected to a text pre-selection box network) model, which can accurately locate text lines in an image. In this embodiment, by performing detection processing on the text image, all text boxes in the text image can be detected, and different text boxes have different vertex coordinate information; the text box is generally in a quadrilateral shape, and has four vertices, and the vertex coordinate information includes coordinates of the four vertices. The length, width, distance from other text boxes, etc. of the corresponding text boxes can be determined according to the vertex coordinate information.
In addition, in the process of detecting the text box, the embodiment of the invention also extracts the probability that the text box can be correctly detected by characterization, and takes the probability as the confidence of the text box, namely the confidence of the text box. For example, when detecting by a text box detection model such as CTPN, the essence is that a text box with the highest probability is detected; for example, a certain line of text may correspond to a text box a or a text box B, but according to the result of the model detection, the probability that the line of text corresponds to the text box a is a%, the probability that the line corresponds to the text box B is B%, and a > B, at this time, the model is the text box a with higher output probability, and the general text box detection method also only focuses on the detected text box, that is, performs subsequent processing according to the detected text box a, but does not focus on the probability a% of the text box a. In the embodiment of the invention, when the text box detection is carried out on the handwritten text, if the text is more neat, the text box can be detected with higher probability, and the neatness at the moment is higher; therefore, the embodiment also determines the confidence of the text box of the corresponding text box while detecting the text box, and the higher the confidence of the text box is, the higher the probability of detecting the text box is, and the higher the neatness of the composition to be identified in the text image is.
Step C3: and recognizing characters in the text box, and determining the character confidence coefficient of the characters, wherein the character confidence coefficient is used for representing the probability of correctly recognizing the characters, and all the characters are used for generating the composition to be recognized.
In the embodiment of the invention, character recognition processing is also carried out on the text image so as to recognize characters contained in the text image. Specifically, the present embodiment performs character recognition processing on a text image corresponding to a text box to recognize characters (such as kanji) in each text box; wherein, a character recognition model, such as CRNN (Convolutional Recurrent Neural Network, convolutional neural network) model, can be preset, and all characters in the text box can be recognized by performing character recognition processing according to the character recognition model. In addition, in this embodiment, the probability of correctly recognizing the character is also extracted, and the probability is used as the character confidence of the corresponding character. For example, if there is a character "me" in the text box, the character recognition model determines that the character is "me" with a probability of 80%, and that the character is found with a probability of 20%, the character recognition model determines that the character is "me" and that the character confidence is 80%.
In this embodiment, the confidence level (including text box confidence level and character confidence level) is generally only used for selecting the most suitable processing result by the model, and the method provided in this embodiment characterizes the neatness of the text according to the text box confidence level and the character confidence level, so that the confidence levels determined by the detection model and the recognition model in the processing process can be more fully and effectively utilized, and the method is more suitable for machine evaluation scenes.
Step C4: determining a detection evaluation value of the text image according to the detection parameter, determining an identification evaluation value of the text image according to the identification parameter, determining a neatness evaluation value of the text image according to the detection evaluation value and the identification evaluation value, and taking the neatness evaluation value as an integral evaluation parameter; the text box confidence coefficient is a detection parameter, the text box confidence coefficient and the detection evaluation value are in positive correlation, the character confidence coefficient is an identification parameter, and the character confidence coefficient and the identification evaluation value are in positive correlation.
In the embodiment of the present invention, the method for evaluating the cleanliness is mainly divided into two processes, namely, a detection process shown in step C2 and an identification process shown in step C3. Because the detection process and the recognition process are implemented by adopting different processing modes, for example, the detection process is implemented based on a text box detection model such as CTPN and the recognition process is implemented based on a character recognition model such as CRNN, the parameters determined by the detection process are called detection parameters, such as text box confidence, the parameters determined by the recognition process are called recognition parameters, such as character confidence, and then the detection evaluation value and the recognition evaluation value of the text image are respectively determined according to the detection parameters and the recognition parameters, and then the detection evaluation value and the recognition evaluation value are combined to comprehensively determine the overall neatness evaluation value of the text image. The text box confidence coefficient is in positive correlation with the detection evaluation value, namely the larger the text box confidence coefficient is, the easier the text box is accurately detected, and the larger the detection evaluation value is, the higher the corresponding neatness evaluation value is; similarly, the character confidence and the recognition evaluation value are in positive correlation, that is, the larger the character confidence is, the more unique the description can determine which character is, the more the character is written, and the larger the recognition evaluation value is, and the higher the corresponding neatness evaluation value is.
Optionally, the step C2 "detecting a text box in the text image" includes:
step C21: and carrying out text box detection processing on the text image, and determining candidate boxes and corresponding vertex coordinate information.
Step C22: determining candidate frames which are determined to be background frames and intermediate frames according to the vertex coordinate information, removing the background frames and the intermediate frames in all the candidate frames, and taking the rest candidate frames as text frames; the background frame is a candidate frame with a distance from the text frame larger than a preset threshold value, and the intermediate frame is a candidate frame between the two text frames.
In the embodiment of the invention, the text image can be subjected to text box detection processing by adopting the existing text box detection model (such as CTPN model and the like), and all boxes (including text boxes) in the text image can be detected by adopting the existing CTPN model and the like, so that boxes which are not text boxes, such as background boxes and the like, possibly exist in the text image. In this embodiment, the boxes determined after the text box detection process are all called candidate boxes, wherein the text boxes are included, that is, the text boxes are also one type of candidate boxes, and then, determining which candidate boxes are text boxes according to vertex coordinate information of all the candidate boxes.
Specifically, the text image includes a plurality of text boxes, the text boxes are closer to each other to form a text body, and the text body occupies a large part; the background frame is a frame which is not related to the text body to be processed and is generally far away from the text frame, so that a candidate frame with a distance from the text frame larger than a preset threshold value can be used as the background frame.
Furthermore, handwritten text may have inserted words, since there is no space within the same text line where a word may be inserted, the word will typically be filled above or below the text line to indicate that a word is inserted here. In the text box detection process, the inserted word is also identified that there is a candidate box because it is not in the same line as the other text lines, and because the candidate box is still located in the text body, it is not a background box, which in this embodiment is referred to as a box, and typically the box is located between two text boxes. After identifying which candidate boxes are background boxes and which candidate boxes are intermediate boxes, the rest of the other candidate boxes can be used as text boxes to be processed subsequently.
Step C23: determining the width of the text box according to the vertex coordinate information of the text box; determining fluctuation degrees of all text boxes in the text image according to the widths of the text boxes, taking the fluctuation degrees as a detection parameter, and determining a negative correlation between the fluctuation degrees and a detection evaluation value; the degree of fluctuation std is:
Figure BDA0002907636140000161
where n is the number of text boxes, x i Representing the width of the ith text box, +.>
Figure BDA0002907636140000162
Represents the average of the widths of all text boxes, max (x i ) Representing the maximum of the width of all text boxes.
In the embodiment of the invention, the text box is generally a square-shaped box, and the size, such as the length, the width and the like, of the text box can be determined by the coordinates of four vertexes of the text box. Wherein, since the text box is generally a text line box, the width of the text box is actually a height. Specifically, one width (height) h1 may be determined by coordinates of two vertices, and then the other width h2 may be determined by coordinates of the other two vertices, and an average value of h1 and h2 may be taken as the width of the text box.
In the embodiment of the invention, the fluctuation degree of the text boxes is used for representing the variation degree of the width of the text boxes, and if the widths of the text boxes are basically the same, the fluctuation degree is smaller, and the text in the text image can be illustrated to be more neat; conversely, if the text boxes differ widely, it is indicated that the user (e.g., a student) is writing text in different lines, and the user does not ensure that the standards of each line are consistent, and the cleanliness is relatively poor. Specifically, the present embodiment comprehensively determines the detection evaluation value with the degree of fluctuation as one detection parameter, that is, based on the text box confidence and the degree of fluctuation. Wherein, the greater the fluctuation degree is, the worse the cleanliness is, so the fluctuation degree and the detection evaluation value are in a negative correlation relationship.
Step C24: determining the frame ratio, and taking the space frame ratio as a detection parameter, wherein the frame ratio is the text frame ratio or the space frame ratio; the text box ratio is the ratio of the number of the text boxes to the total number of the boxes, and the text box ratio and the detection evaluation value are in positive correlation; the space frame ratio is the ratio of the number of space frames to the total number of frames, and the space frame ratio and the detection evaluation value are in a negative correlation relationship; the total number of boxes is the sum of the number of boxes and the number of text boxes.
In the embodiment of the invention, the background frame is an interference evaluation frame and needs to be completely removed; the more the number of the space boxes is, the more the text in the text image is inserted, and the poorer the neatness is; in this embodiment, the evaluation is specifically performed by the frame ratio, that is, the detection evaluation value is determined. In this embodiment, the space ratio is the ratio of the number of space frames to the total number of frames (the sum of the number of space frames and the number of text frames), and the larger the space ratio is, the more serious the condition of inserting the word is, the worse the cleanliness is, so that when the space ratio is used as a detection parameter, the negative correlation is formed between the space ratio and the detection evaluation value.
Since the sum of the text box ratio and the box ratio is 1, the box ratio can be indirectly expressed by the text box ratio. Specifically, the larger the text box duty ratio is, the smaller the duty ratio of the text box is, and the better the neatness is, so that the text box duty ratio and the detection evaluation value are in positive correlation.
In this embodiment, the space frame ratio and the text frame ratio are both frame ratios, and since the confidence level of the text frame, the frame ratio and the determined fluctuation degree can be all used as detection parameters, the detection evaluation value can be comprehensively determined by combining the plurality of detection parameters, so that the detection evaluation value is more accurate.
In addition, the step C3 "identifying the character in the text box and determining the character confidence level" of the character includes:
step C31: and acquiring a first training sample and a second training sample, wherein the first training sample comprises common characters and corresponding character labels, the second training sample comprises uncommon characters and correction labels, and the uncommon characters and the correction labels are in a many-to-one relationship.
Step C32: training a preset character recognition model according to the first training samples and the second training samples to generate a trained character recognition model.
In the embodiment of the invention, the main frame of the character recognition model can still adopt the existing model frame, such as a CRNN model and the like, and the difference is that the traditional character recognition model can determine labels corresponding to all characters, but in the embodiment, part of rare characters are labeled with correction labels, and the rest of common characters are still labeled according to a conventional labeling mode. That is, the first training sample in this embodiment may be a conventional training sample, where each character (common character) corresponds to a determined character label; the characters (uncommon characters) in the second training sample correspond to unique altering labels, that is, a plurality of uncommon characters correspond to the same altering labels, and the altering labels can also be used as a character label, and only a plurality of uncommon characters correspond to one altering label. In the embodiment of the invention, the uncommon character can be a rarely used character, or can be a symbol without semantic meaning, such as a circle, a square, and the like. The characters in the character set may be divided into common characters and uncommon characters according to human experiences, or the characters may be divided by using frequency of each character, which is not limited in this embodiment.
When training the character recognition model, training is carried out according to a conventional training mode. The common characters of the first training sample are used as input, and the corresponding character labels are used as output, so that training is performed; similarly, training may be performed with the uncommon character of the second training sample as input and the altering label as output. The character recognition model obtained after training can normally recognize common characters, and the characters corresponding to the altering labels can be regarded as altering characters. In the embodiment, the correction character is indicated by the uncommon character, so that the character recognition model can conveniently learn the characteristics of the correction character, and further recognition of the correction character is realized.
Step C33: and carrying out recognition processing on the text image corresponding to the text box according to the trained character recognition model, recognizing normal characters and correction characters in the text box, and determining the first character confidence coefficient of the normal characters and the second character confidence coefficient of the correction characters.
Step C34: and taking the first character confidence coefficient and the second character confidence coefficient as a recognition parameter, wherein the first character confidence coefficient and the second character confidence coefficient are in positive correlation with the recognition evaluation value.
In the embodiment of the invention, the text image is identified according to a character identification model (such as a CRNN model and the like); wherein the character recognition model is used for recognizing correction characters in addition to normal characters; in this embodiment, the correction character is a character left after the user performs the correction operation, and the correction character has no specific actual meaning, but affects the cleanliness of the text. In this embodiment, the characters are divided into normal characters (characters that can be recognized normally) and altering characters, so that it is convenient to recognize which contents in the text image are altered. Meanwhile, the character recognition model also has corresponding character confidence coefficient when recognizing normal characters, namely, the first character confidence coefficient, and the confidence coefficient for recognizing correction characters is the second character confidence coefficient. The first character confidence and the second character confidence are both character confidence, and positive correlation is formed between the first character confidence and the second character confidence and between the first character confidence and the recognition evaluation value. The higher the confidence that the correction character is recognized (i.e., the confidence of the second character), the easier the character is recognized, and the higher the cleanliness is considered in this embodiment; in contrast, if the confidence of the second character is low, it is firstly explained that the character is not a normal character, and secondly, the character is difficult to be recognized, and it is extremely probable that the writing of the character is irregular and the cleanliness is poor.
Step C35: determining the character duty ratio, and taking the correction character duty ratio as an identification parameter, wherein the character duty ratio is the normal character duty ratio or the correction character duty ratio; the normal character ratio is the ratio of the number of the normal characters to the total number of the characters, and the normal character ratio and the recognition evaluation value are in positive correlation; the correction character duty ratio is the ratio of the number of correction characters to the total number of characters, and the correction character duty ratio and the recognition evaluation value are in a negative correlation; the total number of characters is the sum of the number of correction characters and the number of normal characters.
In the embodiment of the invention, as the correction characters are more, the cleanliness is poorer, so that the recognition evaluation value of the text image can be determined through the duty ratio of the correction characters, and the cleanliness can be evaluated. The correction character ratio is the ratio of the number of correction characters to the total number of characters (the sum of the number of correction characters and the number of normal characters), and the larger the correction character ratio is, the more serious the correction is, and the worse the cleanliness is, so that when the correction character ratio is used as a recognition parameter, the negative correlation relationship between the correction character ratio and the recognition evaluation value is realized.
In addition, since the sum of the normal character ratio and the correction character ratio is 1, the correction character ratio can be indirectly represented by the normal character ratio in this embodiment similarly to the above-described text box ratio representing space ratio, except that the normal character ratio and the recognition evaluation value are in a positive correlation.
On the basis of the above embodiment, the detection parameters may specifically include: the text box confidence, fluctuation degree, space frame ratio (or text box ratio) and other items, and the identification parameters specifically can include: the first character confidence, the second character confidence, the correction character ratio (or the normal character ratio) and the like, in this embodiment, the detection evaluation value and the recognition evaluation value may be calculated respectively in a weighted manner, and then the overall neatness evaluation value may be determined. Wherein, since the number of each confidence (including text box confidence, first character confidence, second character confidence) is plural, the embodiment calculates the corresponding evaluation value by the average value of the confidence. For example, when there are a plurality of text boxes in the text image, each text box corresponds to one text box confidence, and the detection evaluation value may be calculated from the average value of all the text box confidence.
Further, the cleanliness evaluation value is used for evaluating the cleanliness of a text image, and the higher the cleanliness evaluation value, the better the cleanliness thereof. Specifically, the cleanliness evaluation value may be a percent value, a ten value, or the like, or may be evaluated by further sectional quantization. For example, the confidence and the duty ratio may be values between 0 and 1, and the final determined cleanliness evaluation value may be values between 0 and 1, and the steps may be quantized as follows: a particle size of more than 0.8 is very clean, 0.5 to 0.8 is generally clean, 0.2 to 0.5 is not clean, and less than 0.2 is not clean.
The method for identifying the repair provided by the embodiment of the invention is described in detail above, and the method can also be realized by a corresponding device, and the device for identifying the repair provided by the embodiment of the invention is described in detail below.
Fig. 3 is a schematic structural diagram of a device for identifying a repair according to an embodiment of the present invention. As shown in fig. 3, the device for the repair identification includes:
the model module 31 is configured to preset a repair recognition model, where the repair recognition model includes a mapping layer, n self-attention layers, n-1 sub-classifiers, and a total classifier, the mapping layer is connected to an input layer of a 1 st self-attention layer, and an output end of an i th self-attention layer is connected to an input end of a next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2;
a preprocessing module 32, configured to determine a target sentence to be identified, input the target sentence into the repair identification model, and determine a target feature vector of the target sentence according to the repair identification model mapping layer;
a loop identifying module 33, configured to loop the classification process until determining the corresponding repair tag of the target sentence;
Wherein the loop identification module 33 performs a classification process comprising:
the current self-attention layer carries out self-attention processing on the target feature vector output by the previous layer, and generates a processed target feature vector;
and the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, and otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
On the basis of the embodiment, the device further comprises a training module;
before the model module 31 presets the tutorial recognition model, the training module is configured to:
training a pre-training part of the repair identification model according to a repair training sample, and determining weight parameters of the pre-training part, wherein the pre-training part comprises the mapping layer, n self-attention layers and a total classifier;
under the condition that the weight parameters of the pre-training part are kept unchanged, inputting an unlabeled sentence into the repair recognition model, determining a classification probability distribution corresponding to the unlabeled sentence according to the output result of the total classifier, and determining a prediction probability distribution output by each sub-classifier;
And training the sub-classifier based on the nonstandard sentences, and finally determining a trained repair recognition model by taking the relative entropy between the output prediction probability distribution of the sub-classifier and the classification probability distribution of the nonstandard sentences or the sum of the relative entropy between the output prediction probability distribution of the plurality of sub-classifiers and the classification probability distribution of the nonstandard sentences as a loss function.
On the basis of the above embodiment, the training module training the pre-training portion of the tutorial recognition model according to the tutorial training sample includes:
the probability of the corresponding repair label of the training sample sentence in the repair training sample is set to be 1-epsilon, and the probability of other repair labels of the training sample sentence is set to be 1-epsilon
Figure BDA0002907636140000221
Where ε is a positive number less than 0.1 and K is the number of classifications of the repair labels.
On the basis of the above embodiment, the training module is further configured to, after training the pre-training portion of the tutorial recognition model according to a tutorial training sample:
fine-tuning the self-attention layer of the last or both of the pre-training sections.
On the basis of the above embodiment, the preprocessing module 32 determines that the target sentence to be recognized includes:
Segmenting the composition to be identified, and determining a text corresponding to each segment;
sentence terminators are used as separators, and sentences in each text are determined;
screening the sentences, and taking the rest sentences as target sentences to be identified;
the screening processing comprises one or more of removing sentences with the length smaller than a preset value, removing more than half of sentences which are personified words and removing conventionality sentences.
On the basis of the embodiment, the system further comprises a scoring module;
after the loop identifying module 33 determines the tutorial tag corresponding to the target sentence, the scoring module is configured to:
carrying out statistical processing on the correction labels of all the target sentences to determine correction parameters of the composition to be identified, wherein the correction parameters comprise the number of each correction label and/or the ratio of each correction label to the total sentence number of the composition to be identified;
and scoring the composition to be identified according to the repair parameters, and determining the score of the composition to be identified.
In addition, the embodiment of the invention also provides an electronic device, which comprises a bus, a transceiver, a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the transceiver, the memory and the processor are respectively connected through the bus, and when the computer program is executed by the processor, the processes of the method embodiment of the above-mentioned repair and identification are realized, and the same technical effects can be achieved, so that repetition is avoided and no further description is given here.
In particular, referring to FIG. 4, an embodiment of the invention also provides an electronic device comprising a bus 1110, a processor 1120, a transceiver 1130, a bus interface 1140, a memory 1150, and a user interface 1160.
In an embodiment of the present invention, the electronic device further includes: computer programs stored on the memory 1150 and executable on the processor 1120, which when executed by the processor 1120, perform the various processes of the method embodiments of the above-described tutorial identification.
A transceiver 1130 for receiving and transmitting data under the control of the processor 1120.
In an embodiment of the invention, represented by bus 1110, bus 1110 may include any number of interconnected buses and bridges, with bus 1110 connecting various circuits, including one or more processors, represented by processor 1120, and memory, represented by memory 1150.
Bus 1110 represents one or more of any of several types of bus structures, including a memory bus and a memory controller, a peripheral bus, an accelerated graphics port (Accelerate Graphical Port, AGP), a processor, or a local bus using any of a variety of bus architectures. By way of example, and not limitation, such an architecture includes: industry standard architecture (Industry Standard Architecture, ISA) bus, micro channel architecture (Micro Channel Architecture, MCA) bus, enhanced ISA (EISA) bus, video electronics standards association (Video Electronics Standards Association, VESA) bus, peripheral component interconnect (Peripheral Component Interconnect, PCI) bus.
Processor 1120 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method embodiments may be implemented by instructions in the form of integrated logic circuits in hardware or software in a processor. The processor includes: general purpose processors, central processing units (Central Processing Unit, CPU), network processors (Network Processor, NP), digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field Programmable Gate Array, FPGA), complex programmable logic devices (Complex Programmable Logic Device, CPLD), programmable logic arrays (Programmable Logic Array, PLA), micro control units (Microcontroller Unit, MCU) or other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components. The methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. For example, the processor may be a single-core processor or a multi-core processor, and the processor may be integrated on a single chip or located on multiple different chips.
The processor 1120 may be a microprocessor or any conventional processor. The steps of the method disclosed in connection with the embodiments of the present invention may be performed directly by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software modules may be located in a random access Memory (Random Access Memory, RAM), flash Memory (Flash Memory), read-Only Memory (ROM), programmable ROM (PROM), erasable Programmable ROM (EPROM), registers, and so forth, as are known in the art. The readable storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
Bus 1110 may also connect together various other circuits such as peripheral devices, voltage regulators, or power management circuits, bus interface 1140 providing an interface between bus 1110 and transceiver 1130, all of which are well known in the art. Accordingly, the embodiments of the present invention will not be further described.
The transceiver 1130 may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. For example: the transceiver 1130 receives external data from other devices, and the transceiver 1130 is configured to transmit the data processed by the processor 1120 to the other devices. Depending on the nature of the computer system, a user interface 1160 may also be provided, for example: touch screen, physical keyboard, display, mouse, speaker, microphone, trackball, joystick, stylus.
It should be appreciated that in embodiments of the present invention, the memory 1150 may further comprise memory located remotely from the processor 1120, such remotely located memory being connectable to a server through a network. One or more portions of the above-described networks may be an ad hoc network (ad hoc network), an intranet, an extranet (extranet), a Virtual Private Network (VPN), a Local Area Network (LAN), a Wireless Local Area Network (WLAN), a Wide Area Network (WAN), a Wireless Wide Area Network (WWAN), a Metropolitan Area Network (MAN), the Internet (Internet), a Public Switched Telephone Network (PSTN), a plain old telephone service network (POTS), a cellular telephone network, a wireless fidelity (Wi-Fi) network, and a combination of two or more of the above-described networks. For example, the cellular telephone network and wireless network may be a global system for mobile communications (GSM) system, a Code Division Multiple Access (CDMA) system, a Worldwide Interoperability for Microwave Access (WiMAX) system, a General Packet Radio Service (GPRS) system, a Wideband Code Division Multiple Access (WCDMA) system, a Long Term Evolution (LTE) system, an LTE Frequency Division Duplex (FDD) system, an LTE Time Division Duplex (TDD) system, a long term evolution-advanced (LTE-a) system, a Universal Mobile Telecommunications (UMTS) system, an enhanced mobile broadband (Enhance Mobile Broadband, embbb) system, a mass machine type communication (massive Machine Type of Communication, mctc) system, an ultra reliable low latency communication (Ultra Reliable Low Latency Communications, uirllc) system, and the like.
It should be appreciated that the memory 1150 in embodiments of the present invention may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. Wherein the nonvolatile memory includes: read-Only Memory (ROM), programmable ROM (PROM), erasable Programmable EPROM (EPROM), electrically Erasable EPROM (EEPROM), or Flash Memory (Flash Memory).
The volatile memory includes: random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as: static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (ddr SDRAM), enhanced SDRAM (Enhanced SDRAM), synchronous DRAM (SLDRAM), and Direct RAM (DRAM). The memory 1150 of the electronic device described in embodiments of the present invention includes, but is not limited to, the above and any other suitable types of memory.
In an embodiment of the invention, memory 1150 stores the following elements of operating system 1151 and application programs 1152: an executable module, a data structure, or a subset thereof, or an extended set thereof.
Specifically, the operating system 1151 includes various system programs, such as: a framework layer, a core library layer, a driving layer and the like, which are used for realizing various basic services and processing tasks based on hardware. The applications 1152 include various applications such as: a Media Player (Media Player), a Browser (Browser) for implementing various application services. A program for implementing the method of the embodiment of the present invention may be included in the application 1152. The application 1152 includes: applets, objects, components, logic, data structures, and other computer system executable instructions that perform particular tasks or implement particular abstract data types.
In addition, the embodiment of the present invention further provides a computer readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements each process of the foregoing method embodiment of the repair identification, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
The computer-readable storage medium includes: persistent and non-persistent, removable and non-removable media are tangible devices that may retain and store instructions for use by an instruction execution device. The computer-readable storage medium includes: electronic storage, magnetic storage, optical storage, electromagnetic storage, semiconductor storage, and any suitable combination of the foregoing. The computer-readable storage medium includes: phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), non-volatile random access memory (NVRAM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassette storage, magnetic tape disk storage or other magnetic storage devices, memory sticks, mechanical coding (e.g., punch cards or bump structures in grooves with instructions recorded thereon), or any other non-transmission medium that may be used to store information that may be accessed by a computing device. In accordance with the definition in the present embodiments, the computer-readable storage medium does not include a transitory signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a pulse of light passing through a fiber optic cable), or an electrical signal transmitted through a wire.
In several embodiments provided herein, it should be understood that the disclosed apparatus, electronic device, and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
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 position, or may be distributed over a plurality of network units. Some or all of the units can be selected according to actual needs to solve the problem to be solved by the scheme of the embodiment of the invention.
In addition, each functional unit in the embodiments of the present invention 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 integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the embodiments of the present invention is essentially or partly contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (including: a personal computer, a server, a data center or other network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the storage medium includes various media as exemplified above that can store program codes.
The foregoing is merely a specific implementation of the embodiment of the present invention, but the protection scope of the embodiment of the present invention is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the embodiment of the present invention, and the changes or substitutions are covered by the protection scope of the embodiment of the present invention. Therefore, the protection scope of the embodiments of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method of tutorial identification comprising:
presetting a correction identification model, wherein the correction identification model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier, wherein the mapping layer is connected with an input layer of a 1 st self-attention layer, and an output end of an i th self-attention layer is connected with an input end of a next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2;
determining a target sentence to be identified, inputting the target sentence into the repair identification model, and determining a target feature vector of the target sentence according to the repair identification model mapping layer;
the classification process is circularly executed until the corresponding repair label of the target sentence is determined;
wherein the classification process comprises:
the current self-attention layer carries out self-attention processing on the target feature vector output by the previous layer, and generates a processed target feature vector;
and the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, and otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
2. The method of claim 1, comprising, prior to the preset fix identification model:
training a pre-training part of the repair identification model according to a repair training sample, and determining weight parameters of the pre-training part, wherein the pre-training part comprises the mapping layer, n self-attention layers and a total classifier;
under the condition that the weight parameters of the pre-training part are kept unchanged, inputting an unlabeled sentence into the repair recognition model, determining a classification probability distribution corresponding to the unlabeled sentence according to the output result of the total classifier, and determining a prediction probability distribution output by each sub-classifier;
and training the sub-classifier based on the nonstandard sentences, and finally determining a trained repair recognition model by taking the relative entropy between the output prediction probability distribution of the sub-classifier and the classification probability distribution of the nonstandard sentences or the sum of the relative entropy between the output prediction probability distribution of the plurality of sub-classifiers and the classification probability distribution of the nonstandard sentences as a loss function.
3. The method of claim 2, wherein training the pre-training portion of the tutorial recognition model based on the tutorial training samples comprises:
The probability of the corresponding repair label of the training sample sentence in the repair training sample is set to be 1-epsilon, and the probability of other repair labels of the training sample sentence is set to be 1-epsilon
Figure FDA0002907636130000021
Where ε is a positive number less than 0.1 and K is the number of classifications of the repair labels.
4. The method of claim 2, further comprising, after said training of the pre-trained portion of the tutorial recognition model based on the tutorial training samples:
fine-tuning the self-attention layer of the last or both of the pre-training sections.
5. The method of any one of claims 1-4, wherein the determining a target sentence to be identified comprises:
segmenting the composition to be identified, and determining a text corresponding to each segment;
sentence terminators are used as separators, and sentences in each text are determined;
screening the sentences, and taking the rest sentences as target sentences to be identified;
the screening processing comprises one or more of removing sentences with the length smaller than a preset value, removing more than half of sentences which are personified words and removing conventionality sentences.
6. The method of claim 5, further comprising, after said determining the tutorial tag corresponding to the target sentence:
Carrying out statistical processing on the correction labels of all the target sentences to determine correction parameters of the composition to be identified, wherein the correction parameters comprise the number of each correction label and/or the ratio of each correction label to the total sentence number of the composition to be identified;
and scoring the composition to be identified according to the repair parameters, and determining the score of the composition to be identified.
7. A device for identifying a repair, comprising:
the model module is used for presetting a correction recognition model, wherein the correction recognition model comprises a mapping layer, n self-attention layers, n-1 sub-classifiers and a total classifier, the mapping layer is connected with the input layer of the 1 st self-attention layer, and the output end of the i th self-attention layer is connected with the input end of the next self-attention layer; the ith sub-classifier is connected with the output end of the ith self-attention layer, and the output end of the nth self-attention layer is connected with the total classifier, wherein n is more than or equal to 2;
the preprocessing module is used for determining a target sentence to be recognized, inputting the target sentence into the repair recognition model, and determining a target feature vector of the target sentence according to the repair recognition model mapping layer;
The circulation identification module is used for performing a classification process in a circulation manner until the corresponding repair label of the target sentence is determined;
wherein, the cycle identification module performs a classification process comprising:
the current self-attention layer carries out self-attention processing on the target feature vector output by the previous layer, and generates a processed target feature vector;
and the current sub-classifier performs classification processing according to the processed target feature vector, if the classification confidence coefficient exceeds a preset threshold value, the corresponding repair label of the target sentence is determined according to the current classification result, and otherwise, the current self-attention layer transmits the processed target feature vector to the next self-attention layer.
8. The apparatus of claim 7, further comprising a training module;
before the model module presets the repair identification model, the training module is used for:
training a pre-training part of the repair identification model according to a repair training sample, and determining weight parameters of the pre-training part, wherein the pre-training part comprises the mapping layer, n self-attention layers and a total classifier;
under the condition that the weight parameters of the pre-training part are kept unchanged, inputting an unlabeled sentence into the repair recognition model, determining a classification probability distribution corresponding to the unlabeled sentence according to the output result of the total classifier, and determining a prediction probability distribution output by each sub-classifier;
And training the sub-classifier based on the nonstandard sentences, and finally determining a trained repair recognition model by taking the relative entropy between the output prediction probability distribution of the sub-classifier and the classification probability distribution of the nonstandard sentences or the sum of the relative entropy between the output prediction probability distribution of the plurality of sub-classifiers and the classification probability distribution of the nonstandard sentences as a loss function.
9. An electronic device comprising a bus, a transceiver, a memory, a processor and a computer program stored on the memory and operable on the processor, the transceiver, the memory and the processor being connected by the bus, the method of any one of claims 1 to 6, wherein the computer program when executed by the processor performs the steps of the method of the invention.
10. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor performs the steps in the method of the tutorial identification of any one of claims 1 to 6.
CN202110076417.6A 2021-01-20 2021-01-20 Method and device for identifying repair and electronic equipment Active CN112765954B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110076417.6A CN112765954B (en) 2021-01-20 2021-01-20 Method and device for identifying repair and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110076417.6A CN112765954B (en) 2021-01-20 2021-01-20 Method and device for identifying repair and electronic equipment

Publications (2)

Publication Number Publication Date
CN112765954A CN112765954A (en) 2021-05-07
CN112765954B true CN112765954B (en) 2023-06-23

Family

ID=75701761

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110076417.6A Active CN112765954B (en) 2021-01-20 2021-01-20 Method and device for identifying repair and electronic equipment

Country Status (1)

Country Link
CN (1) CN112765954B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111914544A (en) * 2020-08-18 2020-11-10 科大讯飞股份有限公司 Metaphor sentence recognition method, metaphor sentence recognition device, metaphor sentence recognition equipment and storage medium
CN111914568A (en) * 2020-07-31 2020-11-10 平安科技(深圳)有限公司 Method, device and equipment for generating text modifying sentence and readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10528669B2 (en) * 2018-03-20 2020-01-07 Wipro Limited Method and device for extracting causal from natural language sentences for intelligent systems

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111914568A (en) * 2020-07-31 2020-11-10 平安科技(深圳)有限公司 Method, device and equipment for generating text modifying sentence and readable storage medium
CN111914544A (en) * 2020-08-18 2020-11-10 科大讯飞股份有限公司 Metaphor sentence recognition method, metaphor sentence recognition device, metaphor sentence recognition equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向社交媒体的反讽识别;罗观柱;赵妍妍;秦兵;刘挺;;智能计算机与应用(02);全文 *

Also Published As

Publication number Publication date
CN112765954A (en) 2021-05-07

Similar Documents

Publication Publication Date Title
CN108829757B (en) Intelligent service method, server and storage medium for chat robot
CN108875807B (en) Image description method based on multiple attention and multiple scales
CN108984526B (en) Document theme vector extraction method based on deep learning
CN107291795B (en) Text classification method combining dynamic word embedding and part-of-speech tagging
CN107688821B (en) Cross-modal image natural language description method based on visual saliency and semantic attributes
CN112164391B (en) Statement processing method, device, electronic equipment and storage medium
CN110609897A (en) Multi-category Chinese text classification method fusing global and local features
CN111462735A (en) Voice detection method and device, electronic equipment and storage medium
CN107346340A (en) A kind of user view recognition methods and system
CN108830287A (en) The Chinese image, semantic of Inception network integration multilayer GRU based on residual error connection describes method
CN111046179B (en) Text classification method for open network question in specific field
CN111159485B (en) Tail entity linking method, device, server and storage medium
CN110597961B (en) Text category labeling method and device, electronic equipment and storage medium
CN110704601A (en) Method for solving video question-answering task requiring common knowledge by using problem-knowledge guided progressive space-time attention network
CN111598183B (en) Multi-feature fusion image description method
CN113486669B (en) Semantic recognition method for emergency rescue input voice
CN113673254B (en) Knowledge distillation position detection method based on similarity maintenance
CN103984943A (en) Scene text identification method based on Bayesian probability frame
CN111078866A (en) Chinese text abstract generation method based on sequence-to-sequence model
CN112749274B (en) Chinese text classification method based on attention mechanism and interference word deletion
CN113626589B (en) Multi-label text classification method based on mixed attention mechanism
CN112015903B (en) Question duplication judging method and device, storage medium and computer equipment
CN112765954B (en) Method and device for identifying repair and electronic equipment
CN116561592A (en) Training method of text emotion recognition model, text emotion recognition method and device
CN115934883A (en) Entity relation joint extraction method based on semantic enhancement and multi-feature fusion

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