Text processing model training method and device and text processing method and device
Through the training method of text processing model, text generator and error correction twin network are used to learn text dependencies, and combined with the cluster search strategy, the problem of text error identification in search requests is solved, the Chinese error correction delay is reduced, and the search accuracy is improved. and efficiency.
Patent Information
- Application Number
- CN202310316648.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2024-09-24
AI Technical Summary
When the existing technology handles erroneous search request text, it is difficult to accurately identify user intentions, resulting in search result errors, and the Chinese error correction model inference delay is long, which increases research and development costs.
A text processing model training method is adopted, by obtaining sample text pairs, using a text generator and a text error correction twin network for feature processing, learning the mutual dependence of texts, enhancing text generation capabilities, and correcting errors through a beam search strategy , reduce model inference delay.
It improves the efficiency and accuracy of text processing, reduces model calculation complexity and error correction delay, and improves user search experience.
Smart Images

Figure CN118690188A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to the field of intelligent search technology and natural language processing technology. Background Art
[0002] Text processing technology can realize automatic checking and correction of user request statements in the mall search scenario, implicitly update and correct the user input statement, improve the correctness and accuracy of user search, and further reduce the cost of manual verification. In related technologies, incorrect request statements inevitably bring great challenges to search algorithms, such as failure to accurately identify user intentions, failure to recall the most relevant products, failure to rank the products that best meet user intentions, etc. Therefore, how to improve the efficiency and accuracy of text processing, reduce the complexity of model calculations, and reduce the delay of text error correction has become one of the important research directions. Summary of the invention
[0003] The present application aims to solve at least one of the technical problems in the related art to a certain extent.
[0004] The first embodiment of the present application proposes a training method for a text processing model, including:
[0005] Obtaining a sample text pair, and obtaining a first candidate text and a second candidate text based on the sample text pair, wherein the sample text pair includes an initial text and a reference text after error correction corresponding to the initial text;
[0006] The text generator in the text processing model performs non-autoregressive transformation and scanning sampling on the initial text to obtain a third candidate text;
[0007] The text error correction twin network in the text processing model performs feature processing on the initial text and the second candidate text respectively to obtain fused features, and obtains the target text based on the fused features;
[0008] Based on the first candidate text and the third candidate text, as well as the target text and the reference text, the text processing model is adjusted to obtain a trained text processing model, and the adjusted text processing model is continuously trained until the training is completed to obtain a target text processing model.
[0009] This application allows the model to learn the mutual dependencies of texts, enhance the text generation capabilities of the text generator, and also reduce the model inference delay, which can improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text error correction.
[0010] The second aspect of the present application provides a training device for a text processing model, including:
[0011] A first acquisition module is used to acquire a sample text pair, and acquire a first candidate text and a second candidate text based on the sample text pair, wherein the sample text pair includes an initial text and a reference text corresponding to the initial text after error correction;
[0012] A second acquisition module is used for performing non-autoregressive transformation and scanning sampling on the initial text by the text generator in the text processing model to obtain a third candidate text;
[0013] A third acquisition module is used to perform feature processing on the initial text and the second candidate text respectively by the text error correction twin network in the text processing model to obtain fusion features, and obtain the target text based on the fusion features;
[0014] The adjustment module is used to adjust the text processing model based on the first candidate text and the third candidate text, as well as the target text and the reference text, obtain the trained text processing model, and continue to train the adjusted text processing model until the training is completed to obtain the target text processing model.
[0015] The third aspect of the present application provides a text processing method, including:
[0016] Obtain the text to be corrected, and input the text to be corrected into the target text processing model;
[0017] The target text processing model processes the text to be corrected based on a beam search strategy to obtain the target text corresponding to the text to be corrected;
[0018] Among them, the target text processing model is a model trained using the training method proposed in the above-mentioned first aspect embodiment.
[0019] This application can enhance the text generation capability of the text generator, and can also reduce the model inference delay, thereby improving the efficiency and accuracy of text processing, reducing the complexity of model calculations, and reducing the delay of text error correction.
[0020] A fourth aspect of the present application provides a text processing device, including:
[0021] A first acquisition module is used to acquire the text to be corrected and input the text to be corrected into a target text processing model;
[0022] The second acquisition module is used to process the text to be corrected based on the beam search strategy by the target text processing model to obtain the target text corresponding to the text to be corrected;
[0023] Among them, the target text processing model is a model trained using the training device proposed in the above-mentioned third aspect embodiment.
[0024] A fifth aspect of the present application provides an electronic device, including:
[0025] at least one processor; and
[0026] a memory communicatively connected to at least one processor; wherein,
[0027] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the training method of the text processing model provided in the embodiment of the first aspect of the present application or execute the text processing method provided in the embodiment of the third aspect of the present application.
[0028] The sixth aspect embodiment of the present application proposes a computer-readable storage medium on which computer instructions are stored, wherein the computer instructions are used to enable a computer to execute the training method of the text processing model provided in the first aspect embodiment of the present application or to execute the text processing method provided in the third aspect embodiment of the present application.
[0029] The seventh aspect embodiment of the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements the training method of the text processing model provided in the first aspect embodiment of the present application or implements the text processing method provided in the third aspect embodiment of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flowchart of a method for training a text processing model according to an embodiment of the present application;
[0031] Figure 2 is a flowchart of a method for training a text processing model according to an embodiment of the present application;
[0032] Figure 3 is a schematic diagram of a training method for a text processing model according to an embodiment of the present application;
[0033] Figure 4 is a schematic diagram of a training method for a text processing model according to an embodiment of the present application;
[0034] Figure 5 is a flowchart of a method for training a text processing model according to an embodiment of the present application;
[0035] Figure 6 is a flowchart of a text processing method according to an embodiment of the present application;
[0036] Figure 7 is a schematic diagram of a text processing method according to an embodiment of the present application;
[0037] Figure 8It is a structural block diagram of a training device for a text processing model according to an embodiment of the present application;
[0038] Fig. 9 is a structural block diagram of a text processing device according to an embodiment of the present application;
[0039] Fig.10 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0040] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0041] In related technologies, when errors exist in the text of a user's search request, it is often impossible to establish an accurate matching relationship with the search object, resulting in errors in the search results displayed. As a result, the user is required to enter the correct request a second time to obtain the correct search object. From a product perspective, this greatly reduces the user's search experience.
[0042] In the related art, there are some requests that are easy to correct but are missed. The error detection and recall part can get the correct candidates, but the sorting module cannot rank the correct candidates higher. The reason is that the model of the sorting module only considers the context information and learns the regularity of word appearance in the data distribution. However, through the observation of missed correction requests, it is found that the correct error correction candidates often have strong morphological or phonological similarities with the wrong requests, or both. On the other hand, as time goes by, the search system stores more and more request logs. It is more advantageous to use deep learning models to process large amounts of data. Moreover, the end-to-end End2End model only needs to input one request to output multiple candidate processing results. The number of candidate processing results is controlled by the model parameters. Compared with the rule-based method with less data in the early stage, the processing results generated are more interpretable, that is, the most likely processing results. In addition, compared with foreign languages, the Chinese word list is larger, which makes the model decoding take longer. Therefore, model inference acceleration technology and hardware acceleration inference technology are needed to alleviate the problem of excessive delay, which increases the research and development cost of the algorithm.
[0043] The following describes the text processing model training method, device and text processing method and device of the embodiments of the present application in conjunction with the accompanying drawings.
[0044] Figure 1 is a flowchart of a method for training a text processing model according to an embodiment of the present application. Figure 1As shown, the method comprises the following steps:
[0045] S101, obtaining a sample text pair, and obtaining a first candidate text and a second candidate text based on the sample text pair.
[0046] In the embodiment of the present application, the sample text pair includes an initial text and a reference text after error correction corresponding to the initial text. The sample text pair can be used<source,target> Indicates, where source represents the initial text of the input text processing model, and target represents the reference text after error correction corresponding to the initial text. It should be noted that if the initial text is the correct text, the source is consistent with the target.
[0047] In an embodiment of the present application, the text processing model includes a text generator and a text correction twin network. Therefore, in order to further improve the accuracy of the text processing model, it is necessary to obtain the input data and reference data of the text generator and the text correction twin network respectively according to the sample text pairs, so as to adjust the text generator and the text correction twin network respectively.
[0048] In some embodiments, a first candidate text can be obtained based on the edit distance between the initial text and the reference text as output reference data of the text generator. In some embodiments, feature extraction is performed on the initial text and the reference text respectively, and a second candidate text is generated based on the extracted multi-dimensional features, so as to facilitate the subsequent acquisition of input data for the text error correction twin network based on the second candidate text. Optionally, the multi-dimensional features may include side information such as morphological features, semantic features, and phonological features, so that similar characters have stronger similarity representations, thereby guiding the model to have a certain robustness to unseen spelling errors.
[0049] S102, the text generator in the text processing model performs non-autoregressive transformation and scanning sampling on the initial text to obtain a third candidate text.
[0050] It should be noted that in the embodiment of the present application, the text generator is a generative model that utilizes algorithms such as non-autoregressive transformers and scanning sampling.
[0051] In an embodiment of the present application, the initial text is used as the input of the text generator in the text processing model, and the initial text is subjected to non-autoregressive transformation and scan sampling to obtain a third candidate text, so as to facilitate the subsequent reverse adjustment of the text generator in the text processing model based on the loss between the first candidate text and the third candidate text.
[0052] In the embodiment of the present application, a scanning sampling (Glancing Sample) operation is introduced in the text generator to allow the model to learn the mutual dependence of the text, so that the model can not only enhance the text generation ability of the text generator, but also reduce the model inference delay. It should be noted that allowing the model to learn the mutual dependence of the text here means that the model can learn the difference between the initial text and the reference text through scanning sampling, so as to facilitate the subsequent acquisition of the third candidate text based on the difference, and then enable the model to learn the dependency of each word segment in the text.
[0053] S103, the text error correction twin network in the text processing model performs feature processing on the initial text and the second candidate text respectively to obtain fused features, and obtains the target text based on the fused features.
[0054] In some embodiments, the text error correction twin network is a dual-tower structure, which can perform feature processing on the initial text and the second candidate text respectively, obtain the fusion features of the initial text and the second candidate text respectively, and then perform feature interaction and multi-layer perception based on the fusion features of the initial text and the second candidate text respectively to obtain the target text.
[0055] S104, based on the first candidate text and the third candidate text, as well as the target text and the reference text, the text processing model is adjusted to obtain a trained text processing model, and the adjusted text processing model is continued to be trained until the training is completed to obtain a target text processing model.
[0056] In some embodiments, the text generator of the text processing model is adjusted based on the loss function between the first candidate text and the third candidate text, and the text error correction twin network of the text processing model is adjusted based on the loss function between the target text and the reference text to obtain a trained text processing model, and the adjusted text processing model is continued to be trained until the training is completed to obtain the target text processing model.
[0057] Optionally, after reaching a preset number of training iterations, it can be determined that the training is finished and the target text processing model is obtained. Optionally, after the loss converges to a preset threshold, it can be determined that the training is finished and the target text processing model is obtained. The target text processing model can be used for text error correction.
[0058] In an embodiment of the present application, a sample text pair is obtained, and a first candidate text and a second candidate text are obtained based on the sample text pair; the text generator in the text processing model performs non-autoregressive transformation and scan sampling on the initial text to obtain a third candidate text; the text error correction twin network in the text processing model performs feature processing on the initial text and the second candidate text respectively to obtain fusion features, and obtains the target text based on the fusion features; based on the first candidate text and the third candidate text, as well as the target text and the reference text, the text processing model is adjusted to obtain a trained text processing model, and the adjusted text processing model is continued to be trained until the training is completed to obtain the target text processing model. The present application allows the model to learn the mutual dependence of texts, enhances the text generation capability of the text generator, and can also reduce the model inference delay, which can improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text error correction.
[0059] Figure 2 is a flowchart of a method for training a text processing model according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0060] S201, obtaining the edit distance between the initial text and the reference text.
[0061] In an embodiment of the present application, the initial text is segmented. For example, each character in the initial text can be used as a segmented word to further obtain the edit distance when the initial text is converted to the reference text.
[0062] How many edit operations are required for the token token in the initial text to become the reference text? Optionally, the following formula can be used to calculate the edit distance when the initial text is converted to the reference text:
[0063]
[0064] Among them, lev a,b (i, j) represents the edit distance when the i-th word in the initial text a is converted to the j-th word in the reference text b.
[0065] S202: Obtain a first candidate text according to the edit distance.
[0066] In some implementations, an edit distance matrix may be obtained based on the edit distance, and then at least one edit path with the minimum edit distance may be determined based on the edit distance matrix, a candidate duration sequence may be obtained based on the edit path, and each word segment in the initial text may be edit-aligned based on the candidate duration sequence to obtain a fourth candidate text. Figure 3As shown, for example, if the initial text is "品牌空慮清沁" and the reference text is "品牌空气滤芯", an edit distance matrix can be obtained based on the edit distance when converting the initial text to the reference text. From the edit distance matrix, three paths with the minimum edit distance can be calculated, as Figure 3 indicated by the arrows in Figure 3 , where "↖" represents character replacement, "↑" represents character deletion, and "←" represents insertion. Figure 3 The numbers in Figure 3 represent the number of edit operations required for the segmentation of the initial text at the corresponding position to become the segmentation of the reference text. For example, the element "4" in the 5th row and the 1st column of the edit matrix indicates the number of edit operations required for the first 5 segments "品牌空慮清" of the initial text to be converted into the first segment "品" of the reference text. Another example, the element "4" in the 1st row and the 5th column of the edit matrix indicates the number of edit operations required for the first segment "品" of the initial text to be converted into the first 5 segments "品牌空气滤" of the reference text, and so on.
[0067] It can be seen that Figure 3 the minimum edit distance in Figure 3 is 3. Further, Figure 3 the three edit paths with the minimum edit distance in Figure 3 are edited and aligned to obtain three edit paths as shown in Figure 4 Figure 4 , and the corresponding candidate duration sequences (the duration length of each segment, duration). Figure 4 In Figure 4 , "×" represents the deletion operation. In the candidate duration sequence, 1 represents character replacement or the character remains unchanged, 0 represents character deletion, and 2 represents character repetition or character replacement.
[0068] In some embodiments, the occurrence frequencies of each segment of the fourth candidate text in the historical text data are obtained. Based on the occurrence frequencies, the first candidate text is determined from the fourth candidate text. For example, all texts in the historical text data are segmented and counted to obtain the mapping relationship between the segments and the frequencies, and then the occurrence frequencies of each segment of the fourth candidate text in the historical text data are obtained according to the mapping relationship. Based on the occurrence frequencies, the first candidate text is determined from the fourth candidate text. Optionally, the fourth candidate text with the maximum average frequency can be determined as the first candidate text.
[0069] S203, feature extraction is respectively performed on the initial text and the reference text, and based on the extracted multi-dimensional features, a second candidate text is generated.
[0070] In the embodiments of the present application, the multi-dimensions include glyph, meaning, and rhyme, so that the model can learn the feature distinctions in multiple dimensions and improve the accuracy of the model.
[0071] In some embodiments, obtain the target glyph feature representation, target semantic feature representation, and target phonetic feature representation of each segmented word in the sample text pair, generate homophonic characters respectively based on the target glyph feature representation, target semantic feature representation, and target phonetic feature representation, and update the initial text and / or reference text based on the homophonic characters to generate a second candidate text. For example, perform character replacement / insertion on the initial text and / or reference text based on the homophonic characters to generate a second candidate text with similar glyphs, similar phonetics, or similar semantics.
[0072] Optionally, to improve the diversity of the samples, the initial text can also be processed based on an error correction algorithm to generate a second candidate text, or a second candidate text similar to the initial text and / or reference text can be selected from historical text data.
[0073] In some embodiments, multiple second candidate texts can be generated based on the multi-dimensional features of the initial text and / or reference text. For example, if the initial text is "品牌空慮清沁" and the reference text is "品牌空气滤芯", second candidate texts such as "品牌空氣濾芯", "品牌空氣濾淨", "品牌空氣濾網", etc. can be generated, where "品牌空氣濾芯" is a positive sample and the others are negative samples, so that the model can learn to give high similarity to the correct text and low similarity to the incorrect text, and further improve the accuracy of the model based on the homophonic characters.
[0074] This application enables the model to learn the mutual dependence of texts, enhances the text generation ability of the text generator, and can also reduce the inference latency of the model, improve the efficiency and accuracy of text processing, reduce the computational complexity of the model, and reduce the latency of text error correction.
[0075] Figure 5 is a flowchart of a training method for a text processing model according to an embodiment of this application, as Figure 5 shown, the method includes the following steps:
[0076] S501, obtain a sample text pair, and obtain a first candidate text and a second candidate text based on the sample text pair.
[0077] For the content of step S501, reference can be made to the relevant introduction in the above embodiments, which will not be elaborated here.
[0078] S502, perform feature extraction on each segmented word in the initial text to obtain a third feature representation.
[0079] In the embodiment of this application, each segmented word in the initial text is encoded based on the encoder Encoder in the text generator structure to obtain a third feature representation of each segmented word.
[0080] S503: predict the editing path of the initial text based on the third feature representation to obtain a predicted duration sequence.
[0081] In some embodiments, the editing path of the initial text is predicted based on the third feature representation to obtain the editing operations of each word segment in the initial text, such as word replacement, word deletion, word insertion, word unchanged and other editing operations. Among them, word replacement and word unchanged are predicted to be represented as 1, word deletion is predicted to be represented as 0, and word insertion is predicted to be represented as 2. Optionally, in an embodiment of the present application, in order to reduce the computational complexity of the duration predictor, the third feature representation can be input into a convolutional neural network (CNN), the third feature representation features of each word segment in the initial text are extracted, and then the duration of each word is predicted. Furthermore, the CNN here can be replaced by a bidirectional long short-term memory network (BiLSTM), a self-attention mechanism, and other structures, and the present application does not limit this.
[0082] S504: Based on the predicted duration sequence, edit the initial text to construct a fifth candidate text.
[0083] In the embodiment of the present application, the predicted duration sequence (the result of duration predictor) is used to edit the initial text to construct the fifth candidate text, such as: if duration is 1, it is directly copied, if duration is 2, it is copied twice, and if duration is 0, it is directly deleted.
[0084] S505, performing decoding and scanning sampling based on the fifth candidate text and the fourth candidate text to obtain a third candidate text.
[0085] Based on the decoder and glancing sample modules in the text generator structure, the fifth candidate text and the fourth candidate text are decoded and glancing sampled to obtain the third candidate text.
[0086] In the embodiment of the present application, for the text generator, when generating text at the decoder end, because all the text is generated in one step, the generation of each word lacks the dependency between words. In view of this, in the model training stage, the decoding layer (transformer decoder) of the text generator is stacked in 2 layers, and GlancingSample is added in the middle to allow the model to learn the dependency between words. In the embodiment of the present application, each word segmentation in the reference text is used to find the corresponding probability in the decoder output probability distribution, and then the following formula is used to scan and sample each word segmentation position:
[0087]
[0088] Among them, target represents the reference text, P i represents the probability distribution of the word at the i-th position output by the decoder, T is the preset probability threshold; y i Represents the word at position i in the fifth candidate text and the fourth candidate text, y′ i Represents the word at position i after the first layer decoder outputs probability decoding, y″ i Represents the word at the i-th position after the scanning sampling operation.
[0089] Furthermore, the data obtained by the above formula is re-input into the decoding layer of the text generator and decoded to obtain the third candidate text.
[0090] S506, the text error correction twin network performs multi-dimensional feature extraction on the initial text and the second candidate text respectively to obtain a first feature representation of the initial text and a second feature representation of the second candidate text.
[0091] Optionally, the morphological combination of each word segment of the initial text and the second candidate text can be obtained based on the glyph decomposition algorithm, and the phonological combination of each word segment of the initial text and the second candidate text can be obtained based on the Chinese pinyin algorithm. Furthermore, each word segment is directly searched by vector to obtain the representation of its meaning. Here, the vector search can be a pre-trained word vector, such as a word vector pre-trained based on a deep learning model (word2vec), or a randomly initialized word vector, which is trained together with the text processing model. The morphological combination of the word is encoded using a recurrent neural network encoder (RNN Encoder) to obtain morphological features. Here, the RNN Encoder can be replaced by BiLSTM or a recurrent gate unit (Gated Recurrent Unit, GRU), and this application does not limit this. Similarly, the phonological combination of the word is encoded using an RNN Encoder to obtain phonological features, and the semantic features, morphological features, and phonological features are added to finally obtain the embedded vectors of each word segment. For the embedded vector of any word segment, the text-level feature representation is obtained after encoding, which can be encoded based on BiLSTM or GTRU or seif-attention.
[0092] That is to say, the first glyph feature representation, the first word meaning feature representation and the first phonetic feature representation of each word in the initial text are obtained, and the first glyph feature representation, the first word meaning feature representation and the first phonetic feature representation are feature fused to obtain the first feature representation; the second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation of each word in the second candidate text are obtained, and the second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation are feature fused to obtain the second feature representation.
[0093] S507, performing feature interaction between the first feature representation and the second feature representation to obtain fused features, and obtaining target text based on the fused features.
[0094] Optionally, the following formula may be used to perform feature interaction between the first feature representation and the second feature representation to obtain a fusion feature:
[0095] final fea =concat(q fea -i fea ,q fea *i fea )
[0096] Among them, final fea represents the fusion feature, concat(...) represents the function used to fuse the first feature representation and the second feature representation, q fea represents the first feature representation, i fea Represents the second feature representation.
[0097] In some implementations, the fused features are subjected to a multi-layer perception (MLP) mechanism to obtain the target text.
[0098] In some implementations, the target text may be normalized (softmax calculation) to determine the category to which the target text belongs. Optionally, the probability of the target text in each category may be obtained based on the following formula:
[0099] output i =W1(Relu(W1final fea +b0))+b1
[0100]
[0101] Among them, W1, b o , b1 represents the trainable model parameters, i represents the i-th category, j represents the j-th category, k represents a total of k categories, and output i 、output j Represent the values of the i-th and j-th categories respectively, p irepresents the probability of the target text in the i-th category, and Relu(...) represents the activation function.
[0102] In some implementations, if the target text is consistent with the reference text, it is in the first category and the label is 1; otherwise, it is in the second category and the label is 0.
[0103] S508: Acquire a standard duration sequence based on the editing path when the initial text is converted into the first candidate text.
[0104] S509, adjusting the text processing model based on the first candidate text and the third candidate text, the target text and the reference text, and the standard duration sequence and the predicted duration sequence.
[0105] In an embodiment of the present application, the text generator is adjusted based on the first loss between the first candidate text and the third candidate text, the second loss between the standard duration sequence and the predicted duration sequence, and the text error correction twin network is adjusted based on the third loss between the target text and the reference text to obtain a trained text processing model. Optionally, a cross entropy loss function (Cross Entropy Loss) operation can be performed on the first candidate text and the third candidate text to obtain the first loss; a cross entropy loss function operation can be performed on the target text and the reference text to obtain the third loss.
[0106] After obtaining the adjusted text processing model, continue to train the adjusted text processing model until the training is completed to obtain the target text processing model.
[0107] This application allows the model to learn the mutual dependencies of texts, enhance the text generation capabilities of the text generator, and also reduce the model inference delay, which can improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text error correction.
[0108] Figure 6 is a flowchart of a text processing method according to an embodiment of the present application. Figure 6 As shown, the method comprises the following steps:
[0109] S601, obtaining the text to be corrected, and inputting the text to be corrected into a target text processing model.
[0110] Among them, the target text processing model is a model trained using the training method of the above-mentioned text processing model.
[0111] It should be noted that when using the target text processing model for text processing, the embodiment of the present application shields the scanning sampling Glancing Sample module of the target text processing model, and directly inputs the text to be corrected into the target text processing model, so as to facilitate the subsequent generation of multiple edited texts based on the text to be corrected, enhance the text generation capability of the text generator, and improve the accuracy of the model.
[0112] S602, the target text processing model processes the text to be corrected based on a beam search strategy to obtain a target text corresponding to the text to be corrected.
[0113] The target text processing model includes a text generator and a text error correction twin network. The text generator processes the error correction text based on the beam search strategy and outputs multiple edited texts. size is 5, and the text to be corrected is "Brand Air Filter" for explanation. After inputting the text to be corrected "Brand Air Filter", the target text processing model outputs the edited text as: <brand air filter, brand air filter, brand air filter, brand air filter, brand air filter>. Further, the edited text is input into the text correction twin network to obtain the candidate text corresponding to each edited text, and the similarity probability of each candidate text and the text to be corrected is obtained based on the normalized exponential function, for example: <brand air filter -0.95, brand air filter -0.02, brand air filter -0.01, brand air filter -0.01, brand air filter -0.01>. The candidate texts output by the text correction twin network are sorted according to the similarity probability, and the candidate text with the maximum similarity is selected as the final target text. For example, the target text can be a brand air filter.
[0114] In the embodiment of the present application, the target text processing model can implement error correction processing on the text to be corrected and obtain the target text after error correction.
[0115] In the embodiment of the present application, the text to be corrected is obtained and input into the target text processing model; the target text processing model processes the text to be corrected based on the beam search strategy to obtain the target text corresponding to the text to be corrected. The present application can enhance the text generation capability of the text generator, and can also reduce the model inference delay, improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text correction.
[0116] Figure 7 is a flowchart of a text processing method according to an embodiment of the present application. Figure 7As shown, in the embodiment of the present application, the text to be corrected is input into the target text processing model, and the encoder in the text generator extracts features from each word in the text to be corrected to obtain the feature representation of the text to be corrected; the duration prediction module is called to predict the editing path of the text to be corrected based on the feature representation of the text to be corrected, and the predicted duration sequence of the text to be corrected is obtained; the constructor Constructor edits the text to be corrected based on the predicted duration sequence of the text to be corrected, and inputs the decoding module to perform the clustering strategy to obtain multiple edited texts. The edited text and the text to be corrected are input into the text correction twin network, and the multi-dimensional feature extraction module is used to perform feature fusion of the pronunciation, shape, and meaning of the word, and then further input into the embedding mapping module and the encoder for feature extraction to obtain the feature representation of the text to be corrected and the feature representation of each edited text, and the feature representation of the text to be corrected and the feature representation of any edited text are fused based on the feature interaction module, and sent to the multi-layer perceptron to obtain the target text corresponding to any edited text, and the normalized exponential function is used for screening to obtain the similarity probability of each candidate text and the text to be corrected, and the candidate text with the largest similarity probability is determined as the target text.
[0117] It should be noted that in the embodiment of the present application, the constructor is used to edit the text to be corrected according to the predicted duration sequence, so as to construct the input text of the decoding module. For example, if the duration is 1, it is directly copied, if the duration is 2, it is copied twice, and if the duration is 0, it is directly deleted.
[0118] This application allows the model to learn the mutual dependencies of texts, enhance the text generation capabilities of the text generator, and also reduce the model inference delay, which can improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text error correction.
[0119] like Figure 8 As shown, based on the same application concept, the embodiment of the present application also provides a text processing model training device 800, including:
[0120] A first acquisition module 810 is used to acquire a sample text pair, and acquire a first candidate text and a second candidate text based on the sample text pair, wherein the sample text pair includes an initial text and a reference text corresponding to the initial text after error correction;
[0121] A second acquisition module 820 is configured to perform non-autoregressive transformation and scanning sampling on the initial text by a text generator in the text processing model to obtain a third candidate text;
[0122] The third acquisition module 830 is used to perform feature processing on the initial text and the second candidate text respectively by the text error correction twin network in the text processing model to obtain fused features, and obtain the target text based on the fused features;
[0123] The adjustment module 840 is used to adjust the text processing model based on the first candidate text and the third candidate text, as well as the target text and the reference text, obtain the trained text processing model, and continue to train the adjusted text processing model until the training is completed to obtain the target text processing model.
[0124] In some implementations, the first acquisition module 810 is further configured to:
[0125] Get the edit distance between the initial text and the reference text;
[0126] Get the first candidate text based on the edit distance.
[0127] In some implementations, the first acquisition module 810 is further configured to:
[0128] Get the edit distance matrix when converting the initial text to the reference text;
[0129] Determine at least one edit path with a minimum edit distance according to the edit distance matrix;
[0130] Obtaining a fourth candidate text of the initial text on the editing path, and obtaining the frequency of occurrence of each word segment of the fourth candidate text in the historical text data;
[0131] According to the occurrence frequency, the first candidate text is determined from the fourth candidate texts.
[0132] In some implementations, the first acquisition module 810 is further configured to:
[0133] Obtain a candidate duration sequence according to the editing path;
[0134] The word segments in the initial text are edited and aligned according to the candidate duration sequence to obtain a fourth candidate text.
[0135] In some implementations, the first acquisition module 810 is further configured to:
[0136] Feature extraction is performed on the initial text and the reference text respectively, and a second candidate text is generated based on the extracted multi-dimensional features.
[0137] In some implementations, the multiple dimensions include character shape, character meaning, and phonology. The first acquisition module 810 is further configured to:
[0138] Obtaining target glyph feature representations, target word meaning feature representations, and target phonological feature representations of each word segment in the sample text pair, and generating confusing characters based on the target glyph feature representations, target word meaning feature representations, and target phonological feature representations, respectively;
[0139] The initial text and / or the reference text is updated based on the confusing characters to generate a second candidate text.
[0140] In some implementations, the second acquisition module 820 is further configured to include:
[0141] Extract features from each word in the initial text to obtain the third feature representation;
[0142] Predicting the editing path of the initial text based on the third feature representation to obtain a predicted duration sequence;
[0143] Based on the predicted duration sequence, editing the initial text to construct a fifth candidate text;
[0144] Decoding and scanning sampling are performed based on the fifth candidate text and the fourth candidate text to obtain the third candidate text.
[0145] In some implementations, the third acquisition module 830 is further configured to include:
[0146] The text error correction twin network performs multi-dimensional feature extraction on the initial text and the second candidate text respectively to obtain a first feature representation of the initial text and a second feature representation of the second candidate text;
[0147] The first feature representation and the second feature representation are interacted to obtain fused features.
[0148] In some implementations, the third acquisition module 830 is further configured to include:
[0149] Obtaining the first glyph feature representation, the first word meaning feature representation, and the first phonological feature representation of each word segment in the initial text, and performing feature fusion on the first glyph feature representation, the first word meaning feature representation, and the first phonological feature representation to obtain a first feature representation;
[0150] The second glyph feature representation, the second word meaning feature representation and the second phonological feature representation of each word in the second candidate text are obtained, and the second glyph feature representation, the second word meaning feature representation and the second phonological feature representation are feature fused to obtain the second feature representation.
[0151] In some implementations, the adjustment module 840 is further configured to:
[0152] Acquire a standard duration sequence based on the editing path when the initial text is converted to the first candidate text;
[0153] The text processing model is adjusted based on the first candidate text and the third candidate text, the target text and the reference text, and the standard duration sequence and the predicted duration sequence.
[0154] In some implementations, the adjustment module 840 is further configured to:
[0155] The text generator is adjusted based on a first loss between the first candidate text and the third candidate text, and a second loss between the standard duration sequence and the predicted duration sequence, and the text correction twin network is adjusted based on a third loss between the target text and the reference text to obtain a trained text processing model.
[0156] This application allows the model to learn the mutual dependencies of texts, enhance the text generation capabilities of the text generator, and also reduce the model inference delay, which can improve the efficiency and accuracy of text processing, reduce the model calculation complexity, and reduce the delay of text error correction.
[0157] like Fig. 9 As shown, based on the same application concept, the embodiment of the present application further provides a text processing device 900, including:
[0158] The first acquisition module 910 is used to acquire the text to be corrected and input the text to be corrected into the target text processing model;
[0159] The second acquisition module 820 is used to process the text to be corrected by the target text processing model based on the beam search strategy to obtain the target text corresponding to the text to be corrected;
[0160] Among them, the target text processing model is a model trained using the above-mentioned training device.
[0161] This application can enhance the text generation capability of the text generator, and can also reduce the model inference delay, thereby improving the efficiency and accuracy of text processing, reducing the complexity of model calculations, and reducing the delay of text error correction.
[0162] Based on the same application concept, an embodiment of the present application also provides an electronic device.
[0163] Fig.10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 1000 includes a memory 1010, a processor 1020, and a computer program product stored in the memory 1010 and executable on the processor 1020. When the processor executes the computer program, the aforementioned text processing model training method or text processing method is implemented.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] Based on the same application concept, an embodiment of the present application further provides a computer-readable storage medium on which computer instructions are stored, wherein the computer instructions are used to enable a computer to execute the training method or text processing method of the text processing model in the above embodiment.
[0169] Based on the same application concept, an embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, is the training method or text processing method of the text processing model in the above embodiment.
[0170] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The present application may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0171] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0172] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0173] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A training method for a text processing model, characterized in that: include: Acquire a sample text pair, and acquire a first candidate text and a second candidate text based on the sample text pair, wherein the sample text pair includes an initial text and a reference text corresponding to the initial text after error correction; The text generator in the text processing model performs non-autoregressive transformation and scanning sampling on the initial text to obtain a third candidate text; The text error correction twin network in the text processing model performs feature processing on the initial text and the second candidate text respectively to obtain fused features, and obtains a target text based on the fused features; Based on the first candidate text and the third candidate text, as well as the target text and the reference text, the text processing model is adjusted to obtain a trained text processing model, and the adjusted text processing model is continuously trained until the training is completed to obtain a target text processing model.
2. The method according to claim 1, characterized in that The process of obtaining the first candidate text includes: An edit distance between the initial text and the reference text is obtained, and a first candidate text is obtained according to the edit distance.
3. The method according to claim 2, characterized in that The obtaining of the edit distance between the initial text and the reference text, and obtaining the first candidate text according to the edit distance, comprises: Obtaining an edit distance matrix when the initial text is converted to the reference text; Determine at least one edit path of minimum edit distance according to the edit distance matrix; Obtaining a fourth candidate text of the initial text on the editing path, and obtaining the frequency of occurrence of each word segment of the fourth candidate text in historical text data; The first candidate text is determined from the fourth candidate texts according to the occurrence frequency.
4. The method according to claim 3, characterized in that The obtaining a fourth candidate text of the initial text on the editing path includes: Acquire a candidate duration sequence according to the editing path; Edit and align each word in the initial text according to the candidate duration sequence to obtain the fourth candidate text.
5. The method according to claim 1, characterized in that The process of obtaining the second candidate text includes: Feature extraction is performed on the initial text and the reference text respectively, and a second candidate text is generated based on the extracted multi-dimensional features.
6. The method according to claim 5, characterized in that The multi-dimensional features include character shape, character meaning and phonology, and the feature extraction of the initial text and the reference text is performed respectively, and the second candidate text is generated based on the extracted multi-dimensional features, including: Obtaining target glyph feature representations, target word meaning feature representations, and target phonological feature representations of each word segment in the sample text pair, and generating confusing characters based on the target glyph feature representations, the target word meaning feature representations, and the target phonological feature representations, respectively; The initial text and / or the reference text is updated based on the confusing character to generate the second candidate text.
7. The method according to claim 4, characterized in that The text generator in the text processing model performs non-autoregressive transformation and scanning sampling on the initial text to obtain a third candidate text, including: Extracting features from each word in the initial text to obtain a third feature representation; Predicting the editing path of the initial text based on the third feature representation to obtain a predicted duration sequence; Based on the predicted duration sequence, editing the initial text to construct a fifth candidate text; The third candidate text is obtained by decoding and scanning sampling based on the fifth candidate text and the fourth candidate text.
8. The method according to claim 6, characterized in that The text error correction twin network of the text processing model performs feature processing on the initial text and the second candidate text respectively to obtain fusion features, including: The text error correction twin network performs multi-dimensional feature extraction on the initial text and the second candidate text respectively to obtain a first feature representation of the initial text and a second feature representation of the second candidate text; Perform feature interaction on the first feature representation and the second feature representation to obtain a fused feature.
9. The method according to claim 8, characterized in that The text error correction twin network of the text processing model performs multi-dimensional feature extraction on the initial text and the second candidate text respectively to obtain a first feature representation of the initial text and a second feature representation of the second candidate text, including: Acquire a first glyph feature representation, a first word meaning feature representation, and a first phonological feature representation of each word segment in the initial text, and perform feature fusion on the first glyph feature representation, the first word meaning feature representation, and the first phonological feature representation to acquire the first feature representation; The second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation of each word in the second candidate text are obtained, and the second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation are feature fused to obtain the second feature representation.
10. The method according to claim 7, characterized in that The method further comprises: Acquire a standard duration sequence based on an editing path when the initial text is converted into the first candidate text; The text processing model is adjusted based on the first candidate text and the third candidate text, the target text and the reference text, and the standard duration sequence and the predicted duration sequence.
11. The method according to any one of claims 1 to 9, characterized in that: The adjusting the text processing model based on the first candidate text and the third candidate text, as well as the target text and the reference text to obtain a trained text processing model includes: The text generator is adjusted based on a first loss between the first candidate text and the third candidate text, and a second loss between the standard duration sequence and the predicted duration sequence, and the text error correction twin network is adjusted based on a third loss between the target text and the reference text to obtain a trained text processing model.
12. A text processing method, characterized in that: include: Acquire the text to be corrected, and input the text to be corrected into the target text processing model; The target text processing model processes the text to be corrected based on a beam search strategy to obtain a target text corresponding to the text to be corrected; The target text processing model is a model trained using the training method described in any one of claims 1 to 11.
13. A training device for a text processing model, characterized in that: include: A first acquisition module is used to acquire a sample text pair, and acquire a first candidate text and a second candidate text based on the sample text pair, wherein the sample text pair includes an initial text and a reference text after error correction corresponding to the initial text; A second acquisition module is used for performing non-autoregressive transformation and scanning sampling on the initial text by a text generator in the text processing model to obtain a third candidate text; A third acquisition module is used to perform feature processing on the initial text and the second candidate text respectively by the text error correction twin network in the text processing model to obtain fusion features, and obtain a target text based on the fusion features; An adjustment module is used to adjust the text processing model based on the first candidate text and the third candidate text, as well as the target text and the reference text, to obtain a trained text processing model, and to continue training the adjusted text processing model until the training is completed to obtain a target text processing model.
14. The device according to claim 13, characterized in that The first acquisition module is further used for: Obtaining an edit distance between the initial text and the reference text; A first candidate text is obtained according to the edit distance.
15. The device according to claim 14, characterized in that The first acquisition module is further used for: Obtaining an edit distance matrix when the initial text is converted to the reference text; Determine at least one edit path of minimum edit distance according to the edit distance matrix; Obtaining a fourth candidate text of the initial text on the editing path, and obtaining the frequency of occurrence of each word segment of the fourth candidate text in historical text data; The first candidate text is determined from the fourth candidate texts according to the occurrence frequency.
16. The device according to claim 15, characterized in that The first acquisition module is further used for: Acquire a candidate duration sequence according to the editing path; Edit and align each word in the initial text according to the candidate duration sequence to obtain the fourth candidate text.
17. The device according to claim 13, characterized in that The first acquisition module is further used for: Feature extraction is performed on the initial text and the reference text respectively, and a second candidate text is generated based on the extracted multi-dimensional features.
18. The device according to claim 16, characterized in that The multiple dimensions include character shape, character meaning and phonology. The first acquisition module is further used for: Obtaining target glyph feature representations, target word meaning feature representations, and target phonological feature representations of each word segment in the sample text pair, and generating confusing characters based on the target glyph feature representations, the target word meaning feature representations, and the target phonological feature representations, respectively; The initial text and / or the reference text is updated based on the confusing character to generate the second candidate text.
19. The device according to claim 16, characterized in that The second acquisition module is further used to include: Extracting features from each word in the initial text to obtain a third feature representation; Predicting the editing path of the initial text based on the third feature representation to obtain a predicted duration sequence; Based on the predicted duration sequence, editing the initial text to construct a fifth candidate text; The third candidate text is obtained by decoding and scanning sampling based on the fifth candidate text and the fourth candidate text.
20. The device according to claim 18, characterized in that The third acquisition module is further used to include: The text error correction twin network performs multi-dimensional feature extraction on the initial text and the second candidate text respectively to obtain a first feature representation of the initial text and a second feature representation of the second candidate text; Perform feature interaction on the first feature representation and the second feature representation to obtain a fused feature.
21. The device according to claim 20, characterized in that The third acquisition module is further used to include: Acquire a first glyph feature representation, a first word meaning feature representation, and a first phonological feature representation of each word segment in the initial text, and perform feature fusion on the first glyph feature representation, the first word meaning feature representation, and the first phonological feature representation to acquire the first feature representation; The second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation of each word in the second candidate text are obtained, and the second glyph feature representation, the second word meaning feature representation and the second phonetic feature representation are feature fused to obtain the second feature representation.
22. The device according to claim 19, characterized in that The adjustment module is further used for: Acquire a standard duration sequence based on an editing path when the initial text is converted into the first candidate text; The text processing model is adjusted based on the first candidate text and the third candidate text, the target text and the reference text, and the standard duration sequence and the predicted duration sequence.
23. The device according to any one of claims 13 to 21, characterized in that The adjustment module is further used for: The text generator is adjusted based on a first loss between the first candidate text and the third candidate text, and a second loss between the standard duration sequence and the predicted duration sequence, and the text error correction twin network is adjusted based on a third loss between the target text and the reference text to obtain a trained text processing model.
24. A text processing device, characterized in that: include: A first acquisition module is used to acquire the text to be corrected and input the text to be corrected into a target text processing model; A second acquisition module is used to process the text to be corrected based on a beam search strategy by the target text processing model to obtain a target text corresponding to the text to be corrected; Wherein, the target text processing model is a model trained using the training device described in any one of claims 13-23.
25. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1 to 11 or the method of claim 12.
26. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 11 or to execute the method according to claim 12.
27. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11 or implements the method according to claim 12.
Citation Information
Patent Citations
Method and device for generating text
CN109829164A
Text processing method and device
CN110502754A
Text error correction method, device and system
CN111523306A
Text error correction method, system and device and readable storage medium
CN112016310A
Text error correction method and device, equipment and storage medium
CN113901797A
Cited By
Text-to-instruction system based on fuzzy pinyin matching and parameter robust analysis
CN121659895A
