A method and apparatus for text smoothing detection

By using multi-scale feature extraction and neural network optimization, the problem of insufficient word similarity capture in text smoothness detection is solved, and more efficient text smoothness and keyword recognition are achieved.

CN116894091BActive Publication Date: 2026-04-17JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
Filing Date
2023-07-24
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies struggle to capture similarities between words of different lengths in text smoothness detection, resulting in low accuracy and the potential for accidental deletion of keywords.

Method used

By using a pre-trained model to generate latent vectors, multi-scale feature extraction is performed to generate a relevance matrix and feature vectors. By combining convolution kernels and pooling operations, neural network parameters are optimized, and contrastive loss and word frequency inverse document frequency are introduced to improve keyword recognition capabilities.

Benefits of technology

It improves the accuracy and efficiency of text smoothness detection, ensures that keywords are not mistakenly deleted, and enhances the semantic consistency of the text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116894091B_ABST
    Figure CN116894091B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for text smoothness detection, relating to the field of computer technology. A specific embodiment of the text smoothness detection method includes: in response to receiving target text, encoding the target text according to a pre-set pre-trained model to generate a corresponding latent vector; performing multi-scale feature extraction on the latent vector to obtain a feature vector; combining the latent vector and the feature vector to obtain a combined vector; classifying the combined vector according to a pre-set activation function to generate a classification label corresponding to the target text. This embodiment can capture the correlation between words of different lengths, improve the detection rate of redundant colloquial words, and make the text smoother and easier to understand.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for text smoothness detection. Background Technology

[0002] Voice dialogue systems can receive users' speech, convert it into text, and perform semantic understanding. However, during dialogues, colloquial expressions often contain redundant words and excessive interjections. Therefore, it is necessary to detect the converted text to make it smoother and easier for the system to understand. Currently, the common method for text smoothness detection is to predict the label of each character individually and identify redundant words based on the similarity of each character to other characters and whether each character is repeated with its surrounding characters.

[0003] In the process of realizing this invention, the inventors discovered that the prior art has at least the following problems:

[0004] Label prediction based on a single character alone is insufficient to capture the similarity between words of different lengths, resulting in low accuracy in text smoothing detection and poor text smoothing performance. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a method and apparatus for text smoothness detection, which can capture the correlation between words of different lengths and improve the detection rate of redundant colloquial words.

[0006] To achieve the above objectives, according to a first aspect of the present invention, a method for text smoothness detection is provided, comprising:

[0007] In response to receiving target text, the target text is encoded according to a pre-set pre-trained model to generate a corresponding latent vector;

[0008] Multi-scale feature extraction is performed on the latent vectors to obtain feature vectors;

[0009] The latent vector and the feature vector are combined to obtain a combined vector. The combined vector is then classified according to a pre-set activation function to generate a classification label corresponding to the target text.

[0010] Optionally, multi-scale feature extraction is performed on the latent vector to obtain a feature vector, including:

[0011] The latent vectors are convolved using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0012] Based on the correlation between the latent vector and the multiple phrase vector representations, multiple correlation matrices are generated;

[0013] Pooling operations are performed on the multiple correlation matrices to obtain multiple pooling vectors;

[0014] The feature vector is obtained by concatenating the multiple pooling vectors.

[0015] Optionally, based on the correlation between the latent vector and the plurality of phrase vector representations, a plurality of correlation matrices are generated, including:

[0016] Based on the correlation between each phrase vector representation and the latent vector, a corresponding first correlation matrix is ​​generated;

[0017] Based on the correlation between different phrase vector representations, a corresponding second correlation matrix is ​​generated.

[0018] Optionally, the multiple pooling vectors are concatenated, including:

[0019] The concatenation order of the multiple pooling vectors is determined based on the window size of the convolution kernel;

[0020] The multiple pooling vectors are concatenated according to the concatenation order.

[0021] Optionally, before receiving the target text, the method further includes:

[0022] The pre-set neural network is iteratively trained based on a pre-set training text set to obtain the prediction results corresponding to the training text set.

[0023] The corresponding classification loss is determined based on the prediction results and the pre-set real smooth text.

[0024] The parameters of the neural network are optimized based on the classification loss.

[0025] Optionally, the method further includes:

[0026] Determine the training texts included in the training text set;

[0027] Identify the keywords included in the real smooth text, remove the keywords from the real smooth text, and obtain the post-processed text;

[0028] The contrast loss corresponding to the inference result is determined based on the similarity between the training text, the real smooth text, and the post-processed text.

[0029] The neural network is trained based on the classification loss and the contrast loss.

[0030] Optionally, removing the keywords from the real smooth text includes:

[0031] The keywords are sorted according to their term frequency and inverse document frequency to obtain the keyword ranking result.

[0032] The target keywords are determined based on the pre-set number of keywords and the keyword sorting results;

[0033] Remove the target keywords from the real, smooth text.

[0034] According to a second aspect of the present invention, an apparatus for text smoothness detection is provided, comprising:

[0035] The encoding module is used to encode the target text according to a pre-set pre-trained model in response to receiving the target text, and generate the corresponding latent vector;

[0036] The extraction module is used to perform multi-scale feature extraction on the latent vector to obtain the feature vector;

[0037] The classification module is used to combine the latent vector and the feature vector to obtain a combined vector, classify the combined vector according to a pre-set activation function, and generate a classification label corresponding to the target text.

[0038] Optionally, multi-scale feature extraction is performed on the latent vector to obtain a feature vector, including:

[0039] The latent vectors are convolved using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0040] Based on the correlation between the latent vector and the multiple phrase vector representations, multiple correlation matrices are generated;

[0041] Pooling operations are performed on the multiple correlation matrices to obtain multiple pooling vectors;

[0042] The feature vector is obtained by concatenating the multiple pooling vectors.

[0043] Optionally, based on the correlation between the latent vector and the plurality of phrase vector representations, a plurality of correlation matrices are generated, including:

[0044] Based on the correlation between each phrase vector representation and the latent vector, a corresponding first correlation matrix is ​​generated;

[0045] Based on the correlation between different phrase vector representations, a corresponding second correlation matrix is ​​generated.

[0046] Optionally, the multiple pooling vectors are concatenated, including:

[0047] The concatenation order of the multiple pooling vectors is determined based on the window size of the convolution kernel;

[0048] The multiple pooling vectors are concatenated according to the concatenation order.

[0049] Optionally, the device further includes:

[0050] The first training module is used to iteratively train a pre-set neural network based on a pre-set training text set to obtain the prediction results corresponding to the training text set.

[0051] The first determining module is used to determine the corresponding classification loss based on the prediction result and the pre-set real smooth text.

[0052] An optimization module is used to optimize the parameters of the neural network based on the classification loss.

[0053] Optionally, the device further includes:

[0054] The second determining module is used to determine the training texts included in the training text set;

[0055] The removal module is used to identify keywords included in the real smooth text, remove the keywords from the real smooth text, and obtain the post-processed text;

[0056] The comparison module is used to determine the comparison loss corresponding to the inference result based on the similarity between the training text, the real smooth text, and the post-processed text.

[0057] The second training module is used to train the neural network based on the classification loss and the contrast loss.

[0058] Optionally, removing the keywords from the real smooth text includes:

[0059] The keywords are sorted according to their term frequency and inverse document frequency to obtain the keyword ranking result.

[0060] The target keywords are determined based on the pre-set number of keywords and the keyword sorting results;

[0061] Remove the target keywords from the real, smooth text.

[0062] According to a third aspect of the present invention, an electronic device is provided, comprising:

[0063] One or more processors;

[0064] Storage device for storing one or more programs.

[0065] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.

[0066] According to a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the methods described in any of the above embodiments.

[0067] One embodiment of the above invention has the following advantages or beneficial effects: Pre-training the target text yields corresponding latent vectors; multi-scale feature extraction of these latent vectors accurately captures the correlation between words of different lengths, facilitating smooth text detection based on various correlation information; multi-scale feature extraction includes steps such as convolution operations based on kernels of different sizes, generating a correlation matrix based on correlation, max pooling, and vector concatenation, resulting in feature vectors with good feature representation; a first correlation matrix is ​​generated based on the correlation between phrase vector representations and latent vectors, and a second correlation matrix is ​​generated based on the correlation between different phrase vector representations, enabling further acquisition of text smoothness detection based on different lengths of latent vectors. The system identifies multiple correlations between words; determines the concatenation order of pooling vectors based on the window size of the convolution kernel, and concatenates the pooling vectors according to the concatenation order, which improves the flexibility of pooling vector concatenation; optimizes the parameters of the neural network based on the classification loss, which improves the optimization effect and efficiency of the neural network; determines the contrast loss corresponding to the inference result based on the similarity between multiple texts, which introduces semantic consistency constraints on the target text, improves the neural network's ability to recognize keywords, and avoids removing keywords from the target text; uses term frequency and inverse document frequency to obtain keywords, which improves the efficiency of keyword acquisition, the generation efficiency of multiple post-processed texts, and the computational efficiency of contrast loss.

[0068] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0069] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0070] Figure 1 This is a schematic diagram of the main flow of the text smoothness detection method according to an embodiment of the present invention;

[0071] Figure 2 This is a schematic diagram of the overall flow of a text smoothness detection method according to a possible embodiment of the present invention;

[0072] Figure 3 This is a schematic diagram of multi-scale feature extraction of a text smoothness detection method according to a possible embodiment of the present invention;

[0073] Figure 4 This is a schematic diagram of a neural network model framework for a text smoothness detection method according to a possible embodiment of the present invention;

[0074] Figure 5 This is a schematic diagram of the main flow of a text smoothness detection method according to a possible embodiment of the present invention;

[0075] Figure 6 This is a schematic diagram of the main flow of a text smoothness detection method according to another possible embodiment of the present invention;

[0076] Figure 7 This is a schematic diagram of the main flow of a text smoothness detection method according to another possible embodiment of the present invention;

[0077] Figure 8 This is a schematic diagram of the main modules of a text smoothness detection device according to an embodiment of the present invention;

[0078] Figure 9 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0079] Figure 10 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0080] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0081] It should be noted that the collection, use, storage, sharing and transfer of user personal information involved in the technical solution of the present invention all comply with the provisions of relevant laws and regulations, and require notification to users and obtaining their consent or authorization. When applicable, user personal information is subjected to de-identification and / or anonymization and / or encryption technical processing.

[0082] Voice dialogue systems can receive users' voice, convert it into text, and perform semantic understanding. However, during dialogues, colloquial expressions often contain redundant words and excessive interjections. Therefore, it is necessary to inspect the converted text to make it smoother and easier for the system to understand. Currently, the common method for text smoothness detection is to predict the label of each character individually, identify redundant words based on the similarity of each character to other characters and whether each character is repeated with its surrounding characters, then assign corresponding labels to the identified characters, and remove redundant words and interjections from the text based on the labels, thereby achieving text smoothness.

[0083] Predicting whether each character is redundant or an interjection in isolation ignores the similarity between words of different lengths, resulting in an inaccurate identification of word redundancy issues between words of different lengths. Furthermore, it is difficult to identify keywords in the text, which can easily lead to the removal of keywords from the text during text smoothing, changing the meaning of the text and causing inaccurate subsequent semantic understanding.

[0084] In view of this, according to a first aspect of the present invention, a method for text smoothness detection is provided.

[0085] Figure 1 This is a schematic diagram illustrating the main flow of a text smoothness detection method according to an embodiment of the present invention. Figure 1 As shown, the text smoothness detection method according to an embodiment of the present invention mainly includes the following steps S101 to S103.

[0086] Step S101: In response to receiving the target text, the target text is encoded according to the pre-set pre-trained model to generate the corresponding latent vector.

[0087] The target text is the text that needs to be smoothed. For example, after the voice dialogue system built into a smartphone, tablet or computer receives the voice sent by the user, the voice dialogue system converts the user's voice into target text and sends it to the execution subject of this embodiment of the invention, or the execution subject of this embodiment of the invention directly receives the target text input by the user.

[0088] After obtaining the target text, a classification marker is added to the beginning of the target text. The classification marker can be used for subsequent classification tasks of the target text. A sentence separation marker is added to the end of the target text. The sentence separation marker is used to separate the target text. If the target text includes multiple text segments, a sentence separation marker is added to the end of each text segment. For example, the classification marker is "[CLS]" and the sentence separation marker is "[SEP]". If the target text includes three text segments: A1, A2, and A3, the result after adding the markers is "[CLS]A1[SEP]A2[SEP]A3[SEP]".

[0089] A pre-trained model is pre-configured. This pre-trained model is an encoder consisting of multiple layers, with each layer acting as a sub-encoder. Each layer includes a self-attention module and a feedforward network module. The self-attention module encodes each character, while the feedforward network module performs a non-linear transformation on the target text using fully connected layers. Specifically, the pre-trained model can be a BERT model. The labeled target text is then input into the pre-trained model, which encodes the target text to obtain latent vectors corresponding to each character. The latent vectors are vector representations of each character in the target text, and their dimensions are the same as the target text's dimensions.

[0090] Figure 2 This is a schematic diagram illustrating the overall flow of a text smoothness detection method according to a reference embodiment of the present invention. For example, as shown... Figure 2 As shown, the execution entity of this embodiment includes multiple modules such as a pre-trained model, multi-scale feature extraction, fully connected layers, and activation functions. After obtaining the target text, the target text is input into the pre-trained model, which encodes the target text to obtain latent vectors.

[0091] For another example, the target text is "{x0,x1,x2,...,x s}”, where “x0” represents a special category marker, “x s The colon ("" represents a special marker for sentence separation. After inputting the target text into the BERT model, the resulting latent vector is "{h0,h1,h2,...,h...". s}”, where “h1” is the vector representation of “x1”, “h2” is the vector representation of “x2”, and “h” is the vector representation of “x2”. s "is "x s The vector representation of "".

[0092] Inputting the target text into the preprocessing model can yield a vector representation of the target text, which facilitates multi-scale feature extraction of the latent vectors later.

[0093] Step S102: Perform multi-scale feature extraction on the latent vector to obtain the feature vector.

[0094] After obtaining the latent vectors, multiple convolution operations are performed on the latent vectors according to various pre-set convolution kernels to obtain phrase vector representations of different lengths. Then, the correlation between phrase vector representations of different lengths is calculated, the attention score between phrase vector representations of different lengths is calculated, and the correlation matrix between phrase vector representations of different lengths is obtained. The obtained correlation matrix is ​​dimensionality reduced and some correlation information in the correlation matrix is ​​retained to obtain a dimensionality reduction matrix. Each correlation matrix corresponds to a dimensionality reduction matrix. Multiple dimensionality reduction matrices are concatenated to obtain the feature vector.

[0095] For example, pre-set two-dimensional, three-dimensional, and four-dimensional convolutional kernels, and use these three kernels to perform convolution operations on the latent vectors respectively, to obtain three phrase vector representations of different lengths: phrase vector representation B2, phrase vector representation B3, and phrase vector representation B4. Here, "B2" represents the phrase vector representation corresponding to the two-dimensional convolutional kernel, "B3" represents the phrase vector representation corresponding to the three-dimensional convolutional kernel, and "B4" represents the phrase vector representation corresponding to the four-dimensional convolutional kernel. Calculate the attention scores among the multiple phrase vector representations to obtain multiple correlation matrices, including: the correlation matrix between phrase vector representations B2 and B3, the correlation matrix between phrase vector representations B2 and B4, and the correlation matrix between phrase vector representations B3 and B4. Dimensionality reduction is performed on each correlation matrix, for example, by dividing each correlation matrix into multiple regions of equal size, determining the median or mode corresponding to the data in each region, and combining the medians or modes of multiple regions according to their region positions to obtain a dimension-reduced matrix. Concatenate the multiple dimension-reduced matrices in a random order to obtain the feature matrix.

[0096] By using convolution kernels of different dimensions to perform convolution operations on latent vectors, we can obtain vector representations corresponding to words of different lengths. This allows us to calculate the correlation between words of different lengths, which is convenient for classifying and predicting words of different lengths. Dimensionality reduction of the correlation matrix can effectively control its dimension and improve the efficiency of feature extraction.

[0097] According to a possible embodiment of the present invention, multi-scale feature extraction is performed on the latent vector to obtain a feature vector, including: performing convolution operations on the latent vector using convolution kernels of different window sizes to obtain multiple phrase vector representations of different lengths; generating multiple correlation matrices based on the correlation between the latent vector and the multiple phrase vector representations of different lengths; performing pooling operations on the multiple correlation matrices to obtain multiple pooling vectors; and concatenating the multiple pooling vectors to obtain the feature vector.

[0098] A pre-configured convolutional neural network (CNN) is used, comprising multiple convolutional kernels with different window sizes. These kernels are used to perform convolution operations on the latent vectors, resulting in multiple phrase vector representations with different lengths and feature information. For example, the formula for convolution operations on the latent vectors is: H... n =Conv n (H), where Conv n H represents the convolution operation, and H represents the latent vector. n This represents a phrase vector representation of length n, where n represents the size of the convolution window (i.e., the dimension of the convolution kernel). The value of n can be 2, 3, or the length of the target text, etc.

[0099] After obtaining multiple phrase vector representations, the attention score between the latent vector and each phrase vector representation is calculated, resulting in a correlation matrix between the latent vector and each phrase vector representation. After obtaining multiple correlation matrices, a pooling operation is performed on each correlation matrix, such as average pooling; preferably, max pooling is performed on each correlation matrix. After obtaining multiple pooling vectors, the concatenation order between the pooling vectors is determined based on the window size of the convolution kernel, and the multiple pooling vectors are concatenated according to this order. For example, correlation matrix C1 is the correlation matrix between the latent vector and the phrase vector representation corresponding to the two-dimensional convolution kernel, correlation matrix C2 is the correlation matrix between the latent vector and the phrase vector representation corresponding to the three-dimensional convolution kernel, and correlation matrix C3 is the correlation matrix between the latent vector and the phrase vector representation corresponding to the four-dimensional convolution kernel. Max pooling is performed on the correlation matrices to obtain pooling vector D1 corresponding to correlation matrix C1, pooling vector D2 corresponding to correlation matrix C2, and pooling vector D3 corresponding to correlation matrix C3. The concatenation order is determined according to the ascending order of the convolution kernel dimensions to obtain "D1, D2, D3". The pooling vectors are concatenated according to the above concatenation order to obtain the feature vector "[D1:D2:D3]".

[0100] For example, such as Figure 2 As shown, after obtaining the latent vector, the latent vector is input into the multi-scale feature extraction module. Specifically, the latent vector is convolved with convolutional kernels of multiple window sizes to obtain multiple phrase vector representations. Then, correlation analysis is performed on the multiple phrase vector representations and the latent vector to obtain multiple first correlation matrices. Correlation analysis is performed on different phrase vector representations to obtain multiple second correlation matrices. Max pooling is performed on the multiple first correlation matrices and the multiple second correlation matrices to obtain pooling vectors. The multiple pooling vectors are concatenated to obtain the feature vector.

[0101] By using phrase vectors of different lengths to perform convolution operations on latent vectors, we can obtain vector representations corresponding to words of different lengths. This allows us to calculate the correlation between words of different lengths, which is convenient for classifying and predicting words of different lengths. Pooling the correlation matrix can improve the efficiency of feature extraction.

[0102] According to another possible embodiment of the present invention, generating multiple correlation matrices based on the correlation between the latent vector and the plurality of phrase vector representations includes: generating a corresponding first correlation matrix based on the correlation between each phrase vector representation and the latent vector; and generating a corresponding second correlation matrix based on the correlation between different phrase vector representations.

[0103] The attention score between each phrase vector representation and the latent vector is calculated using a pre-set activation function, resulting in the first correlation matrix between each phrase vector representation and the latent vector. The formula for calculating the attention score between each phrase vector representation and the latent vector is as follows:

[0104]

[0105] Among them, M n t=>p Let H represent the first correlation matrix between the phrase vector representation of length n and the latent vector, and let H represent the latent vector. n W represents a phrase vector representation of length n. q and W k The parameter d represents the vector dimension of the latent vector. For example, when using the BRET pre-trained model, d represents a vector dimension of 768, and the activation function used is softmax.

[0106] The attention score between different phrase vector representations is calculated using a pre-set activation function, resulting in a second correlation matrix between the different phrase vector representations. The formula for calculating the attention score between different phrase vector representations is as follows:

[0107]

[0108] Among them, M n p=>p H represents the second correlation matrix between phrase vector representations of different lengths. n W represents a phrase vector representation of length n. q and W k The parameter is d, where d represents the vector dimension of the latent vector, and the activation function used is softmax.

[0109] After obtaining the first correlation matrix between different phrase vector representations and latent vectors, and the second correlation matrix between different phrase vector representations, max pooling is performed on the first and second correlation matrices. The formula for calculating the max pooling operation on the correlation matrix is ​​as follows:

[0110]

[0111] Among them, V n t=>p This represents the pooled vector obtained by performing max pooling on the first correlation matrix between the phrase vector representations of length n and the latent vectors. `max_pooling` represents the max pooling operation. The formula for calculating the max pooling operation on the second correlation matrix is:

[0112]

[0113] Among them, V n p=>p This represents the pooling vector obtained by performing a max pooling operation on the second correlation matrix between phrase vector representations of different lengths, where max_pooling represents the max pooling operation.

[0114] Calculating the first correlation matrix between each phrase vector representation and the latent vector, and the second correlation matrix between each different phrase vector representation, allows us to obtain the correlation between words of different lengths, facilitating the extraction of multiple feature representations included in the target text. Performing max pooling on the first and second correlation matrices enables feature extraction from the target text from different perspectives, making it easier to obtain the classification labels of the target text.

[0115] According to another possible embodiment of the present invention, concatenating the plurality of pooling vectors includes: determining the concatenation order of the plurality of pooling vectors according to the window size of the convolution kernel; and concatenating the plurality of pooling vectors according to the concatenation order.

[0116] After obtaining multiple pooling vectors corresponding to multiple first correlation matrices and multiple pooling vectors corresponding to multiple second correlation matrices, the concatenation order is determined according to the dimension of the convolution kernel corresponding to the pooling vectors, and the pooling vectors are concatenated according to the concatenation order. For example, two-dimensional, three-dimensional, and four-dimensional convolution kernels are pre-set, resulting in phrase vector representations E1, E2, and E3 corresponding to the two-dimensional convolution kernels. The phrase vector representations are sorted in ascending order of convolution kernel size, resulting in "E1, E2, E3". The first correlation matrix E1-1 is obtained from phrase vector representation E1 and the latent vectors; the first correlation matrix E2-2 is obtained from phrase vector representation E2 and the latent vectors; and the first correlation matrix E3-3 is obtained from phrase vector representation E3 and the latent vectors. Similarly, the second correlation matrix E1-2 is obtained from phrase vector representation E1 and phrase vector representation E2; and the second correlation matrix E2-3 is obtained from phrase vector representation E2 and phrase vector representation E3. The second relevance matrix E1-3 is obtained by representing E1 and the phrase vector E3. Max pooling is performed on the first relevance matrix E1-1 to obtain the pooling vector F1-1, on the second relevance matrix E1-2 to obtain the pooling vector F1-2, on the first relevance matrix E2-2 to obtain the pooling vector F2-2, on the second relevance matrix E2-3 to obtain the pooling vector F2-3, on the first relevance matrix E3-3 to obtain the pooling vector F3-3, and on the second relevance matrix E1-3 to obtain the pooling vector F1-3. The pooling vectors are then sorted according to the above sorting results to obtain the feature vector "[F1-1:F1-2:F2-2:F2-3:F3-3:F1-3]".

[0117] Figure 3 This is a schematic diagram illustrating multi-scale feature extraction of a text smoothness detection method according to a reference embodiment of the present invention. For example, as shown... Figure 3 As shown, the latent vector is input into the multi-scale feature extraction module 301. The multi-scale feature extraction module 301 includes multiple convolutional kernels with different window sizes, such as 2*d convolutional kernels, 3*d convolutional kernels, etc., where d represents the vector dimension of 768. The first correlation matrix and the second correlation matrix are obtained according to each convolutional kernel. Pooling operation is performed on each first correlation matrix and the second correlation matrix to obtain the corresponding pooling vector. Multiple pooling vectors are concatenated to obtain the feature vector.

[0118] The process involves convolution operations with kernels of different sizes, generating a correlation matrix based on correlation, max pooling, and vector concatenation, resulting in a feature vector with good feature representation.

[0119] Step S103: Combine the latent vector and the feature vector to obtain a combined vector, classify the combined vector according to a pre-set activation function, and generate a classification label corresponding to the target text.

[0120] After obtaining the feature vectors, the feature vectors are passed through a fully connected layer to obtain the fully connected layer output vector of the feature vectors. The formula for calculating the fully connected layer output vector of the feature vectors is: L P =MLP(V), where L P Let V represent the feature vector, and MLP(V) represent the input of the feature vector into the fully connected layer. The latent vector is also passed through a fully connected layer to obtain the output vector of the latent vector's fully connected layer. The formula for calculating the output vector of the latent vector's fully connected layer is: L h =MLP(H), where L h The output vector of the fully connected layer represents the latent vector, H represents the feature vector, and MLP(H) means that the latent vector is input into the fully connected layer.

[0121] The latent vector and feature vector are combined, for example, by adding the latent vector and feature vector to obtain a combined vector. This combined vector is then processed using a pre-defined activation function to obtain the classification label for each character in the target sequence text. The processing formula is: P(y i |x r ) = softmax(L P +L h ), where P(y) i |x r ) indicates that the category label for the r-th character is y. i The probability of a character being retained is determined by the classification labels, which include retained labels and removed labels. Each character has a probability of being retained and a probability of being removed. For example, if the probability of retaining a character is greater than the probability of removing a character, the character is classified as a retained label; otherwise, the character is classified as a removed label. When performing text smoothing operations on the target text based on the classification labels, characters with the retained label are retained, and characters with the removed label are deleted.

[0122] For example, such as Figure 2 As shown, after obtaining the feature vector, the feature vector and the latent vector are input into the fully connected layer respectively, and then the output vectors of the two fully connected layers are input into the activation function to obtain the classification labels of each character in the target text.

[0123] Using activation functions to process the combined vectors yields classification labels for each character in the target text, which improves the accuracy of classification labels and optimizes text smoothness.

[0124] According to a possible embodiment of the present invention, before receiving the target text, the method further includes: iteratively training a pre-set neural network based on a pre-set training text set to obtain a prediction result corresponding to the training text set; determining a corresponding classification loss based on the prediction result and pre-set real smooth text; and optimizing the parameters of the neural network based on the classification loss.

[0125] A pre-set training text set is a collection of training texts. The pre-set neural network is iteratively trained using this training text set. Each training iteration yields a prediction result corresponding to the training text set, representing the probability of the predicted label for each character in the text. A pre-set ground truth text set is then used, containing the true labels corresponding to each character in the training text. A pre-set loss function is used to calculate the loss difference between the predicted result and the true labels contained in the ground truth text. This loss difference is the sum of the loss differences at each time step of the neural network. Preferably, the cross-entropy loss function is used to calculate the loss difference, and this loss difference is used as the classification loss.

[0126] Figure 4 This is a schematic diagram of a neural network model framework for a text smoothness detection method according to a reference embodiment of the present invention. Exemplarily, as shown... Figure 4 As shown, the training text is first input into the BERT pre-trained model to obtain latent vectors. These latent vectors are then input into the multi-scale feature extraction module to obtain feature vectors. Figure 4 The rectangle with horizontal lines within 401 is based on feature vectors and latent vectors. Figure 4 The rectangle within 401 (without horizontal lines) is used to predict the label for each character in the training text vector, yielding the inference result. The label "O" indicates the character is to be retained, and the label "D" indicates the character is to be removed. Keywords are identified in the real smooth text and removed to obtain the post-processed text. Both the real and post-processed texts are encoded to obtain corresponding latent vectors. Multiple latent vectors are compared and learned to narrow the gap between the training text and the real smooth text, and widen the gap between the training text and the post-processed text, thereby improving the accuracy of labeling and text smoothness detection.

[0127] Optimizing the parameters of a neural network based on the classification loss can improve the optimization effect and efficiency of the neural network.

[0128] According to another possible embodiment of the present invention, the method further includes: determining the training texts included in the training text set; identifying keywords included in the real smooth text, removing the keywords from the real smooth text to obtain post-processed text; determining the contrast loss corresponding to the inference result based on the similarity between the training text, the real smooth text and the post-processed text; and training the neural network based on the classification loss and the contrast loss.

[0129] The text input into the neural network from the training text set is used as the training text. Based on the pre-set keyword template, the keywords included in the real smooth text are determined. The keywords are then removed from the real smooth text to obtain the post-processed text.

[0130] Contrastive learning is performed on real smooth text, training text, and post-processed text. The contrastive loss among real smooth text, training text, and post-processed text is calculated using the following formula:

[0131]

[0132] Among them, L cl Let x represent the contrast loss, and let x represent the training text. + To represent truly smooth text, x - Let represent the post-processed text, sim represent the similarity function, and τ be the temperature coefficient. By calculating the contrast loss, the distance between the training text and the real smooth text can be reduced, while the distance between the training text and the post-processed text can be increased.

[0133] After obtaining the classification loss and contrastive loss, the joint loss of the neural network is calculated based on these two losses. The formula for calculating the joint loss is: Loss = λL ce +(1-λ)L cl Where Loss is the joint loss, L ce L represents the classification loss. cl The loss function represents the contrastive loss, where λ is the coefficient. The coefficients of the two loss functions are different. The neural network is trained based on the joint loss. It should be noted that the parameter-optimized neural network can be used for text smoothness detection methods, specifically for outputting classification labels for the target text.

[0134] The contrast loss corresponding to the inference result is determined by the similarity between multiple texts. The classification loss and contrast loss are used as the total loss function to train the neural network. This can introduce semantic consistency constraints on the target text, improve the neural network's ability to recognize keywords, and avoid removing keywords from the target text.

[0135] According to another possible embodiment of the present invention, removing the keywords from the real smooth text includes: sorting the keywords according to the word frequency and the inverse document frequency of the keywords to obtain a keyword sorting result; determining a target keyword according to a preset number of keywords and the keyword sorting result; and removing the target keyword from the real smooth text.

[0136] After identifying the keywords included in the real smooth text, the term frequency (TNF) and inverse document frequency (IVF) of each keyword are calculated. The TNF represents the frequency with which the keyword appears in the real smooth text, i.e., TNF = g1 / g2, where g1 represents the number of times the keyword appears in the real smooth text, and g2 represents the total number of words in the real smooth text. The IVF represents the ratio of the total number of texts to the number of texts containing the keyword, for example, IVF = log(g3 / (g4+1)), where g3 represents the total number of texts, and g4 represents the number of texts containing the keyword. The TNF and IVF of each keyword are multiplied to obtain a ranking value, which is then sorted in descending order. A pre-set number of keywords is obtained, representing the number of keywords to be deleted from the real smooth text. For example, if the number of keywords is 's', the keywords corresponding to the first 'ranking values' are used as target keywords, which are then removed from the real smooth text to obtain the post-processed text.

[0137] For example, keyword J1 has a term frequency of 0.4, an inverse document frequency of 4, and a ranking value of 1.6; keyword J2 has a term frequency of 0.5, an inverse document frequency of 3, and a ranking value of 1.5; keyword J3 has a term frequency of 0.6, an inverse document frequency of 3, and a ranking value of 1.8; the preset number of keywords is 2, so they are sorted from largest to smallest according to their ranking values, and the target keywords to be removed are keyword J3 and keyword J1.

[0138] Using term frequency and inverse document frequency to obtain keywords can improve the efficiency of keyword acquisition, the efficiency of generating various types of text, and the computational efficiency of contrast loss.

[0139] Figure 5 This is a schematic diagram illustrating the main flow of a text smoothness detection method according to a possible embodiment of the present invention. Figure 5 As shown, the method for text smoothness detection may include:

[0140] Step S501: In response to receiving the target text, the target text is encoded according to the pre-set pre-trained model to generate the corresponding latent vector;

[0141] Step S502: Convolve the latent vectors using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0142] Step S503: Generate multiple correlation matrices based on the correlation between the latent vector and multiple phrase vector representations;

[0143] Step S504: Perform pooling operations on multiple correlation matrices to obtain multiple pooling vectors;

[0144] Step S505: Concatenate multiple pooling vectors to obtain a feature vector;

[0145] Step S506: Input the feature vector and the latent vector into the fully connected layer respectively;

[0146] Step S507: Based on the pre-set activation function, perform label prediction on the output of the fully connected layer to generate the classification label corresponding to the target text.

[0147] The specific implementation details of the text smoothness detection method of the present invention described above have been explained in detail in the text smoothness detection method described above, so the content will not be repeated here.

[0148] Figure 6 This is a schematic diagram of the main flow of a text smoothness detection method according to another possible embodiment of the present invention. Figure 6 As shown, the method for text smoothness detection may include:

[0149] Step S601: Iteratively train the pre-set neural network based on the pre-set training text set to obtain the prediction result;

[0150] Step S602: Determine the corresponding classification loss based on the prediction results;

[0151] Step S603: Optimize the parameters of the neural network based on the classification loss;

[0152] Step S604: In response to receiving the target text, the target text is encoded according to the pre-set pre-trained model to generate the corresponding latent vector;

[0153] Step S605: Convolve the latent vectors using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0154] Step S606: Generate a first correlation matrix between each phrase vector representation and the latent vector based on the correlation between each phrase vector representation and the latent vector;

[0155] Step S607: Generate the corresponding second correlation matrix based on the correlation between different phrase vector representations;

[0156] Step S608: Perform pooling operations on multiple correlation matrices to obtain multiple pooling vectors;

[0157] Step S609: Concatenate multiple pooling vectors to obtain a feature vector;

[0158] Step S610: Input the feature vector and the latent vector into the fully connected layer respectively;

[0159] Step S611: Predict the label of the output of the fully connected layer according to the pre-set activation function to generate the corresponding classification label.

[0160] The specific implementation details of the text smoothness detection method of another applicable embodiment of the present invention have been described in detail in the text smoothness detection method described above, so the content will not be repeated here.

[0161] Figure 7 This is a schematic diagram of the main flow of a text smoothness detection method according to another possible embodiment of the present invention. Figure 7 As shown, the method for text smoothness detection may include:

[0162] Step S701: Iteratively train the pre-set neural network based on the pre-set training text set to obtain the prediction result;

[0163] Step S702: Determine the corresponding cross-entropy loss based on the prediction results;

[0164] Step S703: Determine the training texts included in the training text set;

[0165] Step S704: Identify the keywords included in the real smooth text, remove the keywords from the real smooth text, and obtain the post-processed text;

[0166] Step S705: Determine the corresponding contrast loss based on the similarity between the training text, the real smooth text, and the post-processed text;

[0167] Step S706: Train the neural network based on the contrastive loss;

[0168] Step S707: In response to receiving the target text, the target text is encoded according to the pre-set pre-trained model to generate the corresponding latent vector;

[0169] Step S708: Convolve the latent vectors using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0170] Step S709: Generate a first correlation matrix between each phrase vector representation and the latent vector based on the correlation between each phrase vector representation and the latent vector.

[0171] Step S710: Generate the corresponding second correlation matrix based on the correlation between different phrase vector representations;

[0172] Step S711: Determine the splicing order based on the window size of the convolution kernel;

[0173] Step S712: Concatenate the multiple pooling vectors obtained according to the concatenation order to obtain the feature vector;

[0174] Step S713: Input the feature vector and the latent vector into the fully connected layer respectively;

[0175] Step S714: Predict the label of the output of the fully connected layer according to the pre-set activation function to generate the corresponding classification label.

[0176] The specific implementation details of the text smoothness detection method of another reference embodiment of the present invention have been described in detail in the text smoothness detection method described above, so the content will not be repeated here.

[0177] According to a second aspect of the present invention, an apparatus for detecting text smoothness is provided.

[0178] Figure 8 This is a schematic diagram of the main modules of a text smoothness detection device according to an embodiment of the present invention, as shown below. Figure 8 As shown, the text smoothness detection device 800 mainly includes:

[0179] The encoding module 801 is used to encode the target text according to a pre-set pre-trained model in response to receiving the target text, and generate the corresponding latent vector.

[0180] Extraction module 802 is used to perform multi-scale feature extraction on the latent vector to obtain feature vector;

[0181] The classification module 803 is used to combine the latent vector and the feature vector to obtain a combined vector, classify the combined vector according to a pre-set activation function, and generate a classification label corresponding to the target text.

[0182] According to a possible embodiment of the present invention, multi-scale feature extraction is performed on the latent vector to obtain a feature vector, including:

[0183] The latent vectors are convolved using convolution kernels with different window sizes to obtain multiple phrase vector representations;

[0184] Based on the correlation between the latent vector and the multiple phrase vector representations, multiple correlation matrices are generated;

[0185] Pooling operations are performed on the multiple correlation matrices to obtain multiple pooling vectors;

[0186] The feature vector is obtained by concatenating the multiple pooling vectors.

[0187] According to another possible embodiment of the present invention, a plurality of correlation matrices are generated based on the correlation between the latent vectors and the plurality of phrase vector representations, including:

[0188] Based on the correlation between each phrase vector representation and the latent vector, a corresponding first correlation matrix is ​​generated;

[0189] Based on the correlation between different convolution vectors, a corresponding second correlation matrix is ​​generated.

[0190] According to another possible embodiment of the present invention, concatenating the plurality of pooling vectors includes:

[0191] The concatenation order of the multiple pooling vectors is determined based on the window size of the convolution kernel;

[0192] The multiple pooling vectors are concatenated according to the concatenation order.

[0193] According to another possible embodiment of the present invention, the text smoothness detection device 800 further includes:

[0194] The first training module is used to iteratively train a pre-set neural network based on a pre-set training text set to obtain the prediction results corresponding to the training text set.

[0195] The first determining module is used to determine the corresponding classification loss based on the prediction result and the pre-set real smooth text.

[0196] An optimization module is used to optimize the parameters of the neural network based on the classification loss.

[0197] According to another possible embodiment of the present invention, the text smoothness detection device 800 further includes:

[0198] The second determining module is used to determine the training texts included in the training text set;

[0199] The removal module is used to identify keywords included in the real smooth text, remove the keywords from the real smooth text, and obtain the post-processed text;

[0200] The comparison module is used to determine the comparison loss corresponding to the inference result based on the similarity between the training text, the real smooth text, and the post-processed text.

[0201] The second training module is used to train the neural network based on the classification loss and the contrast loss.

[0202] According to a possible embodiment of the present invention, removing the keywords from the real smooth text includes:

[0203] The keywords are sorted according to their term frequency and inverse document frequency to obtain the keyword ranking result.

[0204] The target keywords are determined based on the pre-set number of keywords and the keyword sorting results;

[0205] Remove the target keywords from the real, smooth text.

[0206] It should be noted that the specific implementation details of the text smoothness detection device described in the embodiments of the present invention have been described in detail in the text smoothness detection method described above, so the details will not be repeated here.

[0207] According to the technical solution of this invention, the target text is pre-trained to obtain corresponding latent vectors. Multi-scale feature extraction is then performed on the latent vectors to accurately obtain the correlation between words of different lengths, facilitating text smoothness detection based on multiple correlation information. Multi-scale feature extraction includes steps such as convolution operations based on kernels of different sizes, generating a correlation matrix based on correlation, max pooling, and vector concatenation, resulting in feature vectors with good feature representation. A first correlation matrix is ​​generated based on the correlation between phrase vector representations and latent vectors, and a second correlation matrix is ​​generated based on the correlation between different phrase vector representations, enabling further acquisition of features between words of different lengths. Multiple correlations between words; determining the concatenation order based on the window size of the convolution kernel, and concatenating multiple pooling vectors according to the concatenation order, can improve the flexibility of pooling vector concatenation; optimizing the parameters of the neural network based on the classification loss can improve the optimization effect and efficiency of the neural network; determining the contrastive loss corresponding to the inference result based on the similarity between multiple texts can introduce semantic consistency constraints on the target text, improve the neural network's ability to recognize keywords, and avoid removing keywords from the target text; using term frequency and inverse document frequency to obtain keywords can improve the efficiency of keyword acquisition, the efficiency of post-processing text generation, and the computational efficiency of contrastive loss.

[0208] According to a third aspect of the present invention, an electronic device for text smoothness detection is provided, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the present invention.

[0209] According to a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect of the present invention.

[0210] Figure 9 An exemplary system architecture 900 is shown, in which the text smoothness detection method or apparatus of embodiments of the present invention can be applied.

[0211] like Figure 9 As shown, system architecture 900 may include terminal devices 901, 902, and 903, network 904, and server 905. Network 904 is used as a medium to provide a communication link between terminal devices 901, 902, and 903 and server 905. Network 904 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0212] Users can use terminal devices 901, 902, and 903 to interact with server 905 via network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, and 903, such as text smoothing detection applications, text recognition applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0213] Terminal devices 901, 902, and 903 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0214] Server 905 can be a server providing various services, such as a backend management server supporting text smoothness detection requests sent by upstream terminal devices 901, 902, and 903 (for example only). Upon receiving target text, the backend management server can encode the target text according to a pre-set pre-trained model to generate corresponding latent vectors; perform multi-scale feature extraction on the latent vectors to obtain feature vectors; combine the latent vectors and the feature vectors to obtain combined vectors; classify the combined vectors according to a pre-set activation function to generate classification labels corresponding to the target text; and feed back the text smoothness detection results (for example only) to the terminal devices.

[0215] It should be noted that the text smoothness detection method provided in this embodiment of the invention is generally executed by server 905, and correspondingly, the text smoothness detection device is generally installed in server 905. The text smoothness detection method provided in this embodiment of the invention can also be executed by terminal devices 901, 902, and 903, and correspondingly, the text smoothness detection device can be installed in terminal devices 901, 902, and 903.

[0216] It should be understood that Figure 9 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0217] The following is for reference. Figure 10 It shows a schematic diagram of the structure of a computer system 1000 suitable for implementing a terminal device of the present invention. Figure 10 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0218] like Figure 10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage section 908 into a random access memory (RAM) 1003. The RAM 1003 also stores various programs and data required for the operation of the system 1000. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0219] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to I / O interface 1005 as needed. A removable medium 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 1010 as needed so that computer programs read from it can be installed into storage section 1008 as needed.

[0220] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1009, and / or installed from removable medium 1011. When the computer program is executed by central processing unit (CPU) 1001, it performs the functions defined in the system of the embodiments of this invention.

[0221] It should be noted that the computer-readable medium shown in the embodiments of the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the embodiments of the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0222] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer programs according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0223] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor may be described as including an encoding module, an extraction module, and a classification module. The names of these modules do not necessarily limit the module itself; for example, the encoding module may also be described as "a module for encoding target text."

[0224] In another aspect, embodiments of the present invention also provide a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: in response to receiving target text, encoding the target text according to a pre-set pre-trained model to generate a corresponding latent vector; performing multi-scale feature extraction on the latent vector to obtain a feature vector; combining the latent vector and the feature vector to obtain a combined vector; classifying the combined vector according to a pre-set activation function to generate a classification label corresponding to the target text.

[0225] According to the technical solution of this invention, the target text is pre-trained to obtain corresponding latent vectors. Multi-scale feature extraction is then performed on the latent vectors to accurately obtain the correlation between words of different lengths, facilitating text smoothness detection based on multiple correlation information. Multi-scale feature extraction includes steps such as convolution operations based on convolution kernels of different sizes, generating a correlation matrix based on correlation, max pooling, and vector concatenation, resulting in feature vectors with good feature representation. A first correlation matrix is ​​generated based on the correlation between phrase vector representations and latent vectors, and a second correlation matrix is ​​generated based on the correlation between different phrase vector representations, enabling further acquisition of word-related information of different lengths. Multiple correlations between texts; determining the concatenation order based on the window size of the convolution kernel, and concatenating multiple pooling vectors according to the concatenation order, can improve the flexibility of pooling vector concatenation; optimizing the parameters of the neural network based on the classification loss can improve the optimization effect and efficiency of the neural network; determining the contrastive loss corresponding to the inference result based on the similarity between multiple texts can introduce semantic consistency constraints on the target text, improve the neural network's ability to recognize keywords, and avoid removing keywords from the target text; using term frequency and inverse document frequency to obtain keywords can improve the efficiency of keyword acquisition, the efficiency of post-processed text generation, and the computational efficiency of contrastive loss.

[0226] The specific embodiments described above do not constitute a limitation on the scope of protection of the embodiments of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the embodiments of the present invention should be included within the scope of protection of the embodiments of the present invention.

Claims

1. A method for text smoothness detection, characterized in that, include: In response to receiving target text, the target text is encoded according to a pre-set pre-trained model to generate a corresponding latent vector; Multi-scale feature extraction is performed on the latent vectors to obtain feature vectors; The latent vector and the feature vector are combined to obtain a combined vector. The combined vector is then classified according to a pre-set activation function to generate a classification label corresponding to the target text. The classification label includes a retained label and a removed label. When performing text smoothing operation on the target text according to the classification label, characters with the retained label are retained, and characters with the removed label are deleted.

2. The method according to claim 1, characterized in that, Multi-scale feature extraction is performed on the latent vector to obtain a feature vector, including: The latent vectors are convolved using convolution kernels with different window sizes to obtain multiple phrase vector representations; Based on the correlation between the latent vector and the multiple phrase vector representations, multiple correlation matrices are generated; Pooling operations are performed on the multiple correlation matrices to obtain multiple pooling vectors; The feature vector is obtained by concatenating the multiple pooling vectors.

3. The method according to claim 2, characterized in that, Based on the correlation between the latent vector and the multiple phrase vector representations, multiple correlation matrices are generated, including: Based on the correlation between each phrase vector representation and the latent vector, a corresponding first correlation matrix is ​​generated; Based on the correlation between different phrase vector representations, a corresponding second correlation matrix is ​​generated.

4. The method according to claim 3, characterized in that, Concatenating the multiple pooling vectors includes: The concatenation order of the multiple pooling vectors is determined based on the window size of the convolution kernel; The multiple pooling vectors are concatenated according to the concatenation order.

5. The method according to claim 1, characterized in that, Before receiving the target text, the method further includes: The pre-set neural network is iteratively trained based on a pre-set training text set to obtain the prediction results corresponding to the training text set. The corresponding classification loss is determined based on the prediction results and the pre-set real smooth text. The parameters of the neural network are optimized based on the classification loss.

6. The method according to claim 5, characterized in that, The method further includes: Determine the training texts included in the training text set; Identify the keywords included in the real smooth text, remove the keywords from the real smooth text, and obtain the post-processed text; The contrast loss corresponding to the prediction result is determined based on the similarity between the training text, the real smooth text, and the post-processed text. The neural network is trained based on the classification loss and the contrast loss.

7. The method according to claim 6, characterized in that, Removing the keywords from the real, smooth text includes: The keywords are sorted according to their term frequency and inverse document frequency to obtain the keyword ranking result. The target keywords are determined based on the pre-set number of keywords and the keyword sorting results; Remove the target keywords from the real, smooth text.

8. A device for detecting text smoothness, characterized in that, include: The encoding module is used to encode the target text according to a pre-set pre-trained model in response to receiving the target text, and generate the corresponding latent vector; The extraction module is used to perform multi-scale feature extraction on the latent vector to obtain the feature vector; The classification module is used to combine the latent vector and the feature vector to obtain a combined vector, classify the combined vector according to a pre-set activation function, and generate a classification label corresponding to the target text. The classification label includes a retained label and a removed label. When performing text smoothing operation on the target text according to the classification label, characters with the classification label of retained label are retained, and characters with the classification label of removed label are deleted.

9. An electronic device, characterized in that, include: One or more processors; Storage device, used to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.

10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Multi-label classification method for robot to collect and obtain client intention labels

    CN112818086A

  • Method and device for processing text, electronic equipment and medium

    CN114764565A