Text clustering method and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2023-04-28
- Publication Date
- 2026-08-07
AI Technical Summary
[0003]现有技术中,往往是获取大量不同类别的文本,基于该大量不同类别的文本训练获得分类模型,但是不同类别的文本数量之间可能差别很大,导致不同类别训练样本数不平衡,且由于文本的稀疏性,噪声对聚类结果的影响也较大,缺少可靠的监督信号,严重影响分类模型的鲁棒性,从而严重影响文本聚类结果的准确性
[0020]这种情况下,先获取至少两个待聚类文本的类别标签,基于该类别标签迭代训练设定次数获得文本分类模型,通过文本分类模型获得至少两个待聚类文本对应的预测类别分布,通过最优传输求解算法,求解预测类别分布对应的最优类别分布,以对初始确定出的类别标签进行更新,然后基于更新后的类别标签继续对文本分类模型进行训练,直至文本分类模型收敛,可以获得至少两个待聚类文本对应的聚类结果。如此,通过最优传输求解算法,对初始的类别标签不断进行迭代更新,使得至少两个待聚类文本的类别标签逐渐靠近真实类别分布,生成可靠的类别标签,将该可靠的类别标签作为监督信号,对文本分类模型进行训练直至收敛,基于最优传输求解算法不断更新类别标签,提高了待聚类文本对文本类别不平衡的鲁棒性,且通过可靠的类别标签作为监督信号可以提高文本分类模型对数据噪声的鲁棒性,从而提高了文本分类模型的识别准确性,进而保证了文本聚类结果的准确性。
Smart Images

Figure CN116257633B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a text clustering method. This specification also relates to a text clustering apparatus, a computing device, and a computer-readable storage medium. Background Technology
[0002] With the rapid development of computer and internet technologies, more and more information can be stored and managed through online text. More and more fields are beginning to use computers for text matching and clustering to facilitate quick retrieval and understanding of relevant content. As the amount of text grows rapidly, there are more and more text clustering algorithms.
[0003] Current technologies often involve acquiring a large amount of text from different categories and training a classification model based on this large amount of text from different categories. However, the number of texts in different categories can vary greatly, leading to an imbalance in the number of training samples for each category. Furthermore, due to the sparsity of text, noise has a significant impact on the clustering results. The lack of reliable supervision signals severely affects the robustness of the classification model, thereby seriously impacting the accuracy of text clustering results. Therefore, more accurate and reliable methods are needed for text clustering operations or processing. Summary of the Invention
[0004] In view of this, embodiments of this specification provide a text clustering method. This specification also relates to a text clustering apparatus, a computing device, and a computer-readable storage medium to address the technical deficiencies existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, a text clustering method is provided, comprising:
[0006] Obtain the category labels of at least two texts to be clustered, and determine the predicted category distribution of at least two texts to be clustered based on the text classification model. The text classification model is obtained by iteratively training the category labels a set number of times.
[0007] Based on the optimal transport algorithm, determine the optimal class distribution corresponding to the predicted class distribution;
[0008] Update the category labels according to the optimal category distribution, and continue to train the text classification model based on the updated category labels until the text classification model converges;
[0009] By using a convergent text classification model, the clustering results corresponding to at least two texts to be clustered are determined.
[0010] According to a second aspect of the embodiments of this specification, a text clustering apparatus is provided, comprising:
[0011] The first determining module is configured to obtain the category labels of at least two texts to be clustered, and determine the predicted category distribution corresponding to at least two texts to be clustered based on the text classification model, wherein the text classification model is obtained by iteratively training the category labels a set number of times;
[0012] The second determining module is configured to determine the optimal class distribution corresponding to the predicted class distribution based on the optimal transmission solution algorithm;
[0013] The update module is configured to update the category labels according to the optimal category distribution and continue training the text classification model based on the updated category labels until the text classification model converges.
[0014] The third determination module is configured to determine the clustering results corresponding to at least two texts to be clustered by using a converged text classification model.
[0015] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising:
[0016] Memory and processor;
[0017] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the text clustering method described above.
[0018] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions that, when executed by a processor, implement the steps of the text clustering method described above.
[0019] The text clustering method provided in this specification involves obtaining category labels for at least two texts to be clustered, and determining the predicted category distribution corresponding to the at least two texts to be clustered based on a text classification model. The text classification model is obtained by iteratively training the category labels a set number of times. An optimal category distribution corresponding to the predicted category distribution is determined using an optimal transfer algorithm. The category labels are updated based on the optimal category distribution, and the text classification model is trained again based on the updated category labels until the text classification model converges. The clustering result corresponding to the at least two texts to be clustered is determined using the converged text classification model.
[0020] In this scenario, the class labels of at least two texts to be clustered are first obtained. Based on these class labels, a text classification model is iteratively trained a set number of times. The text classification model then yields the predicted class distributions for at least two texts. An optimal transfer algorithm is used to solve for the optimal class distribution corresponding to the predicted class distribution, updating the initially determined class labels. The text classification model is then trained again based on the updated class labels until convergence, yielding clustering results for at least two texts. Thus, by iteratively updating the initial class labels using the optimal transfer algorithm, the class labels of at least two texts gradually approach the true class distribution, generating reliable class labels. These reliable class labels are used as monitoring signals to train the text classification model until convergence. Continuously updating the class labels based on the optimal transfer algorithm improves the robustness of the texts to class imbalance, and using reliable class labels as monitoring signals enhances the robustness of the text classification model to data noise, thereby improving the recognition accuracy of the text classification model and ensuring the accuracy of the text clustering results. Attached Figure Description
[0021] Figure 1 This is a flowchart of a text clustering method provided in one embodiment of this specification;
[0022] Figure 2 This is a schematic diagram of the algorithm architecture of a text clustering method provided in one embodiment of this specification;
[0023] Figure 3 This is a flowchart illustrating a text clustering method applied to short text scenarios, provided in one embodiment of this specification.
[0024] Figure 4 This is a schematic diagram of the structure of a text clustering device provided in one embodiment of this specification;
[0025] Figure 5 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0026] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0027] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0028] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0029] It's important to note that a significant amount of data is presented in the form of short texts, and short text clustering can extract valuable information from large datasets, making it one of the most fundamental text mining tasks. However, short texts are often imbalanced and noisy, and short text clustering methods struggle to handle this problem effectively. In other words, short texts have many categories with varying distributions; different short text datasets often have different category distributions, ranging from roughly equal (almost balanced) to significantly different (severely imbalanced). Current short text clustering methods do not consider class imbalance, leading to poor solutions and a significant drop in clustering accuracy when the data is severely imbalanced. Furthermore, the short length of short text data results in a relatively small amount of information, and due to its sparsity, noise has a significant impact on the clustering results. Current short text clustering methods, lacking supervised information, suffer from insufficiently robust text representations, thus affecting the overall clustering outcome.
[0030] Therefore, this specification provides a robust text clustering method in its embodiments, which guides robust short text representation learning by providing reliable pseudo-labels, thereby obtaining robust short text clustering results. Specifically, this method mainly includes two parts: (1) generating reliable pseudo-labels: by evaluating the actual class distribution and restricting the pseudo-label distribution to conform to the evaluated class distribution; (2) robust representation learning: using the generated pseudo-labels as supervision signals, combined with contrastive learning to train robust short text representations. These two parts promote each other and iteratively optimize, providing both robustness of the model to data imbalance (restricting the pseudo-label distribution to conform to the evaluated class distribution) and robustness of the model to data noise (using pseudo-label supervision and combining contrastive learning).
[0031] This specification provides a text clustering method, and also relates to a text clustering apparatus, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments.
[0032] Figure 1 A flowchart of a text clustering method according to an embodiment of this specification is shown, specifically including the following steps 102-108:
[0033] Step 102: Obtain the category labels of at least two texts to be clustered, and determine the predicted category distribution corresponding to at least two texts to be clustered based on the text classification model. The text classification model is obtained by iteratively training the category labels a set number of times.
[0034] In this document, the text to be clustered refers to the text content that needs to be classified. This text can be long or short. Long text refers to text whose content exceeds a set threshold, while short text refers to text whose content is less than the set threshold. Short text contains less content, resulting in sparse features for learning and training. Due to the sparsity of short text, noise has a greater impact on the clustering results. The text clustering method provided in this specification is mainly applicable to the clustering of short text, but it can also be applied to the clustering of long text to improve the robustness of the model and thus improve the accuracy of the recognition results.
[0035] Additionally, the category label refers to the initially determined category to which the text to be clustered belongs. This category label is a pseudo-label, not the true category, and needs to be continuously updated iteratively to gradually approach the true category. The predicted category distribution refers to the probability predicted by the text classification model that each text to be clustered belongs to each category. That is, the predicted category distribution can be viewed as a probability distribution matrix, where the element in the i-th row and j-th element represents the probability that the i-th text to be clustered belongs to the j-th category.
[0036] In practical applications, the set number of times is a pre-set value that indicates that after a certain number of iterations of training, the supervision signal is updated, that is, the category label is updated. For example, the set number of times can be 5 times, 10 times, 50 times, 300 times, etc.
[0037] It should be noted that at least two texts to be clustered can be subjected to initial simple clustering to obtain the category of each text to be clustered, which serves as the initial category label. This initial category label can be used as a supervision signal to iterate the text classification model for a set number of times. Then, based on the text classification model after iterating for a set number of times, the predicted category distribution corresponding to at least two texts to be clustered can be predicted.
[0038] In one optional implementation of this embodiment, at least two texts to be clustered can be clustered using a set clustering algorithm, that is, the category labels of at least two texts to be clustered can be obtained. The specific implementation process is as follows:
[0039] The k-means clustering algorithm is used to cluster at least two texts to be clustered, thereby obtaining the category labels of at least two texts to be clustered.
[0040] The k-means clustering algorithm is an iterative clustering analysis algorithm. Its steps are as follows: First, the data is pre-divided into K groups. Then, K objects are randomly selected as initial cluster centers. Next, the distance between each object and each seed cluster center is calculated, and each object is assigned to the nearest cluster center. The cluster centers and the objects assigned to them represent a cluster. Each time a sample is assigned, the cluster centers are recalculated based on the existing objects in the cluster. This process is repeated until a termination condition is met. The termination condition may be that no (or a minimum number) objects are reassigned to different clusters, no (or a minimum number) cluster centers change, or the sum of squared errors reaches a local minimum.
[0041] It should be noted that at least two texts to be clustered can be input into the k-means clustering algorithm to obtain k clusters. All texts to be clustered in each cluster belong to the same category, and the category label is the category of that cluster. Thus, the k-means clustering algorithm obtains category labels for at least two texts to be clustered. These category labels are not the final true category labels, but initial pseudo-labels. These initial pseudo-labels can be used as supervision signals to train the text classification model. After a certain number of training iterations, the initial pseudo-labels are updated to continuously make the pseudo-labels gradually approach the true category distribution, thereby improving the robustness of the text classification model and ensuring the accuracy of text clustering.
[0042] Of course, in practical applications, other clustering algorithms can also be used to obtain at least two category labels for the texts to be clustered, such as fuzzy c-means clustering algorithm, etc. The embodiments in this specification do not limit this.
[0043] In an optional implementation of this embodiment, after obtaining the category labels of at least two texts to be clustered through a set clustering algorithm, the category labels can be used as supervision signals to iteratively train the text classification model a set number of times. Then, the text classification model after iterative training a set number of times predicts the predicted category distribution corresponding to at least two texts to be clustered. That is, before determining the predicted category distribution corresponding to at least two texts to be clustered based on the text classification model, the following may also be included:
[0044] Select the target text from at least two texts to be clustered;
[0045] Text enhancement is performed on the target text to obtain the corresponding first enhanced text and second enhanced text;
[0046] Input the first enhanced text and the second enhanced text into the initial classification model to obtain the first prediction distribution corresponding to the first enhanced text and the second prediction distribution corresponding to the second enhanced text;
[0047] Based on the category labels, the first prediction distribution, and the second prediction distribution, calculate the first loss value of the initial classification model, and adjust the model parameters of the initial classification model in reverse according to the first loss value. Then, return to the step of selecting the target text from at least two texts to be clustered, until the number of iterations reaches the set number, and obtain the text classification model.
[0048] It should be noted that you can arbitrarily select one of at least two texts to be clustered as the target text, perform text augmentation on the target text to obtain the corresponding first augmented text and second augmented text. Subsequently, you can use the initially obtained category labels to compare and learn through the first augmented text and the second augmented text to train the text classification model.
[0049] In practical applications, context-based enhancement can be used to augment target text, yielding corresponding first and second enhanced texts. Specifically, by using a bidirectional language model, a wider range of alternative words are provided based on the words predicted from the context. This context prediction method provides various alternative words with aggregation relationships with the original words to enhance the original text and obtain the corresponding enhanced text.
[0050] In practice, contrastive learning typically requires at least two inputs to compare and analyze the model's performance. Therefore, text augmentation can be applied to the target text to obtain a first augmented text and a second augmented text. These two augmented texts are then input into an initial classification model. The initial classification model can classify and identify the first and second augmented texts respectively, outputting a first prediction distribution and a second prediction distribution. The first prediction distribution represents the probability of each augmented text belonging to each category, and the second prediction distribution represents the probability of the second augmented text belonging to each category.
[0051] Then, based on the category labels obtained from the initial clustering, the first prediction distribution, and the second prediction distribution, the first loss value of the initial classification model can be calculated. The model parameters of the initial classification model can be adjusted in reverse based on the first loss value to train the initial classification model. Then, the step of selecting the target text from at least two texts to be clustered can be performed to continue training the model until the set number of times is reached. Training is paused to obtain the text classification model. Subsequently, the category labels can be updated, and then training can continue based on the updated category labels to improve the robustness of the text classification model.
[0052] In practice, the first loss value of the initial classification model can be calculated using the following formula (1):
[0053]
[0054] in, The first loss value of the initial classification model is represented by N, which is also the class-level loss value; N represents the number of classes in the text to be clustered; Q represents the class label; P represents the class label. (1) P represents the first prediction distribution; (2) This represents the second predicted distribution.
[0055] In the embodiments of this specification, the first loss value is calculated based on the category labels obtained from the initial clustering. The optimization goal is to make the first and second predicted distributions closer to the category labels. This provides class-level contrastive learning, bringing texts of the same category closer together and texts of different categories further apart. By using category labels as supervision information, smaller intra-class distances are achieved, thereby improving the robustness of the trained text classification model.
[0056] In an optional implementation of this embodiment, the initial classification model includes an encoding layer and a classification layer. In this case, the first enhanced text and the second enhanced text are input into the initial classification model to obtain a first prediction distribution corresponding to the first enhanced text and a second prediction distribution corresponding to the second enhanced text. The specific implementation process can be as follows:
[0057] The first and second augmented texts are input into the encoding layer of the initial classification model to obtain the first vector representation of the first augmented text and the second vector representation of the second augmented text.
[0058] By inputting the first vector representation and the second vector representation into the classification layer of the initial classification model, a first prediction distribution corresponding to the first enhanced text and a second prediction distribution corresponding to the second enhanced text are obtained.
[0059] It should be noted that the encoding layer of the initial classification model is used to encode the input text and generate the corresponding feature vector. This encoding layer can be an SBERT (Distilbert) model structure. SBERT is a pre-trained semantic similarity model that can generate relatively accurate sentence vectors. Through the SBERT model, the first vector representation corresponding to the first augmented text and the second vector representation corresponding to the second augmented text can be obtained.
[0060] In addition, the classification layer of the initial classification model can be a neural network structure, and the number of nodes in the last layer of the neural network is equal to the number of categories. This classification layer can identify the encoded first vector representation and the second vector representation, and determine the corresponding first prediction distribution and second prediction distribution.
[0061] In the embodiments of this specification, the initial classification model can be divided into a semantic similarity model and a neural network model. The semantic similarity model is used to encode the input augmented text to obtain the corresponding vector representation. The neural network model is used to classify and recognize the encoded vector representation to obtain the corresponding prediction distribution. By combining the semantic similarity model and the neural network model, the prediction distributions corresponding to the two augmented texts are determined so that the model can be trained based on the prediction distributions corresponding to the two augmented texts. Through class-level comparative learning, the distance between texts of the same category is reduced, and the distance between texts of different categories is increased. The category labels are used as supervision information to achieve smaller intra-class distances, thereby improving the robustness of the trained text classification model.
[0062] In an optional implementation of this embodiment, in addition to class-level contrastive learning, instance-level contrastive learning can also be introduced. That is, after inputting the first enhanced text and the second enhanced text into the encoding layer of the initial classification model to obtain the first vector representation corresponding to the first enhanced text and the second vector representation corresponding to the second enhanced text, the implementation may further include:
[0063] By inputting the first vector representation and the second vector representation into the mapping model, a first mapping representation of the first vector representation in the comparison space and a second mapping representation of the second vector representation in the comparison space are obtained.
[0064] The second loss value of the initial classification model is calculated based on the first and second mapping representations.
[0065] The mapping model is used to map the enhanced representation of the input to another contrast space. The mapping model can also be a neural network structure, specifically a two-layer neural network.
[0066] It should be noted that the first and second vector representations can be input into the mapping model to obtain the first mapping representation of the first vector representation in the contrast space, and the second mapping representation of the second vector representation in the contrast space. Then, based on the first and second mapping representations, the second loss value of the initial classification model can be calculated. This second loss value is obtained from the two mapping representations in the contrast mapping space and is an instance-level loss value, that is, it provides instance-level contrastive learning, which promotes the separation of texts from different sources so that overlapping classes can be correctly separated, obtaining a larger inter-class distance. This is beneficial for the former to obtain more accurate clustering results, and further improves the robustness of the trained text classification model to noise.
[0067] In practical applications, the second loss value of the initial classification model can be calculated using the following formulas (2) and (3):
[0068]
[0069]
[0070] in, represents the second loss value of the initial classification model, i.e., the instance-level loss value; N represents the number of texts to be clustered; i represents the i-th augmented text. The first vector representation of the first augmented text and the second vector representation of the second augmented text are concatenated together. Then the i-th augmented text and the 2i-th augmented text are a pair of augmented texts from the same original text. The vector representations of the i-th augmented text and the 2i-th augmented text are a pair of positive samples. The vector representations of augmented text i and the other 2N-2 augmented texts constitute negative samples; the formula (3) corresponding to l(i,j) is the loss of the positive sample pair (i,j). l(i,2i) and l(2i,i) in formula (2) are actually using formula (3). Here, (i,2i) and (2i,i) are also positive sample pairs; Z i Z represents the first mapping representation; j τ represents the second mapping representation; k represents the temperature hyperparameter of the contrastive learning; k represents the k-th augmented text, and the sample pair (i,k) is the negative sample pair composed of the vector representations of the i-th augmented text and the k-th augmented text, that is, the i-th augmented text and the k-th augmented text do not come from the same original text; j represents the j-th augmented text.
[0071] In one optional implementation of this embodiment, the initial classification model can be trained by combining the first loss value and the second loss value. That is, the model parameters of the initial classification model can be adjusted in reverse according to the first loss value. The specific implementation process can be as follows:
[0072] Based on the first loss value and the second loss value, determine the total loss value of the initial classification model;
[0073] The model parameters of the initial classification model are adjusted in reverse based on the total loss value.
[0074] It should be noted that the first and second loss values can be summed to determine the total loss value of the initial classification model, and the model parameters of the initial classification model can be adjusted in reverse based on the total loss value. In specific implementation, the total loss value of the initial classification model can be determined by the following formula (4):
[0075]
[0076] in, This represents the total loss value of the initial classification model; This represents the first loss value of the initial classification model, also known as the class-level loss value. λ represents the second loss value of the initial classification model, also known as the instance-level loss value; λ represents the weight coefficient of the instance-level loss value, which can be pre-configured.
[0077] In the embodiments of this specification, the classification model can be trained by combining class-level loss values and instance-level loss values. Through class-level contrastive learning, the distance between texts of the same category is reduced, while the distance between texts of different categories is increased. Class labels are used as supervision information to achieve smaller intra-class distances. Through instance-level contrastive learning, texts from different sources are separated so that overlapping classes can be correctly separated, resulting in larger inter-class distances. This is beneficial for obtaining more accurate clustering results at the class level and improves the robustness of the trained text classification model to noise.
[0078] Step 104: Determine the optimal class distribution corresponding to the predicted class distribution based on the optimal transport solution algorithm.
[0079] It should be noted that by using the initially obtained category labels as supervision signals to perform comparative learning on the classification model and iterating the training a certain number of times, it indicates that the recognition accuracy of the text category model has reached a certain level. At this point, the text to be clustered can be input into the text classification model obtained by the set number of iterations to obtain the predicted category distribution of the text to be clustered. This predicted category distribution is relatively accurate, but it is not the true category distribution. The optimal category distribution corresponding to the predicted category distribution can be determined further according to the optimal transfer solution algorithm, so that the category labels can be updated based on the optimal category distribution, and the text classification model can be trained again.
[0080] In an optional implementation of this embodiment, the optimal class distribution to be solved can be regarded as the optimal transfer matrix in the optimal transfer problem. The optimal transfer matrix is solved by the optimal transfer algorithm to obtain the optimal class distribution. That is, the optimal class distribution corresponding to the predicted class distribution is determined according to the optimal transfer algorithm. The specific implementation process can be as follows:
[0081] The cost matrix in the optimal transport solution algorithm is determined based on the predicted category distribution.
[0082] Solve for the optimal transmission matrix based on the cost matrix;
[0083] The optimal transfer matrix is used as the optimal class distribution.
[0084] In practical applications, the optimization objective is normally the cross-entropy loss function, as shown in formula (5) below:
[0085]
[0086] Where L represents the cross-entropy loss function, N represents the number of texts to be clustered, K represents the number of categories, and Q represents the number of categories. ij Let P represent the optimal class distribution to be solved, which refers to the probability that the i-th text to be clustered belongs to the j-th class; ij This represents the distribution of predicted categories obtained by a text classification model trained a specified number of times. In other words, given P... ij In the case of Q, solve ij .
[0087] Furthermore, the objective function in the optimal transport solution algorithm is shown in the following formula (6):
[0088]
[0089] Where π represents the optimal transmission matrix to be solved; M represents the cost matrix in the optimal transmission solution algorithm.
[0090] It should be noted that, for clustering tasks, the optimal class distribution Q...ij It is unknown. Comparing the above formulas (5) and (6), it can be seen that if the optimal class distribution Q is... ij Consider it as the optimal transfer matrix in the optimal transfer solution algorithm, and use -logP ij Considered as the cost matrix in the optimal transport solution algorithm, the optimal class distribution Q ij It can be obtained by solving an optimal transmission problem.
[0091] It should be noted that when solving for the optimal transfer matrix, the class distribution needs to be known to limit the range of solutions and avoid degenerate solutions (where the number of samples assigned to a certain class is 0). Without knowing the actual class distribution, the class distribution is often set to a balanced distribution. When the optimal class distribution is restricted to a balanced distribution, unreliable pseudo-labels will be obtained for imbalanced data. Therefore, an adaptive optimal transfer method is proposed, which does not fix the class distribution to a balanced distribution, but evaluates the class distribution simultaneously during the calculation of the optimal transfer matrix (optimal class distribution). The evaluated class distribution gradually approaches the actual data class distribution. Specifically, the solution objective is as follows (7):
[0092]
[0093] stπ1=a,π T 1 = b, πr > 0, b T 1 = 1 (7)
[0094] Where π represents the optimal transmission matrix to be solved; M represents the cost matrix in the optimal transmission solution algorithm; b represents the category distribution, which is a range constraint on the optimal transmission matrix π to be solved. It is the category distribution of the total text to be clustered. Specifically, each column of π can be summed to obtain a 1*K vector, where K represents the number of categories. b can also be solved at the same time as π, thus achieving adaptive optimal transmission. Each row of π represents the category distribution of a text to be clustered; ∈1 and ∈2 represent hyperparameters, which are manually adjusted; H(π) is the entropy regularization term, H(π) = <π, log π-1>, which can speed up the solution process of optimal transmission; T represents ...; "st" represents the constraint condition; a represents the category distribution of the text to be clustered. It is assumed that the text to be clustered is uniformly distributed, that is, the number of texts in each category is the same, and the probability of each category of texts is 1 / N, where N is the number of texts to be clustered.
[0095] Where Ψ(b)-logb-log(1-b) represents the penalty function of b.
[0096] In practice, the Lagrange multiplier algorithm can be used to optimize the above formula (7) to obtain the following formula (8):
[0097] -fT (π1-a)-g T (π T 1-b)-h(b T 1-1) (8)
[0098] Where f, g, and h are all Lagrange multipliers.
[0099] Then, by taking the derivative of the above formula (8) with respect to the variable π, we can obtain the following formula (9):
[0100]
[0101] Since π1=a and π T 1 = b, we first correct b to obtain the following formulas (10) and (11):
[0102]
[0103]
[0104] Where C represents the number of categories of the text to be clustered.
[0105] Then, we can correct f and g, and update b, to obtain the following formula (12):
[0106]
[0107] Taking the derivative of the above formula (12) with respect to variable b, we can obtain the following formula (13):
[0108]
[0109] The judgment formula of formula (13) can be easily derived from the above, as shown in formula (14):
[0110]
[0111]
[0112] Please note the following formula (15):
[0113]
[0114] Therefore, choose b below. j Formula (16) corresponding to (h):
[0115]
[0116] Returning the above formula (16) to the initial constraint b T 1 = 1, the formula is defined as follows (17):
[0117] (b(h)) T 1-1=0 (17)
[0118] h is the root of the above formula (17), which can be solved by Newton's algorithm. Specifically, we first define the following formula (18):
[0119] f(h)=(b(h)) T 1-1 (18)
[0120] Then, h can be updated to the following formula (19):
[0121]
[0122] In the embodiments of this specification, an adaptive optimal transfer method is used to simultaneously evaluate the actual class distribution and restrict the class label distribution to conform to the evaluated class distribution, thereby generating a reliable optimal class distribution. This allows for subsequent updates to the predicted class distribution, iteratively updating the class labels so that they gradually approach the true class distribution. These labels then serve as a supervisory signal to train the text classification model until convergence. The optimal transfer solution algorithm continuously updates the class labels, improving the robustness of the text to be clustered to class imbalance.
[0123] Step 106: Update the category labels according to the optimal category distribution, and continue to train the text classification model based on the updated category labels until the text classification model converges.
[0124] In practical applications, the category labels can be updated based on the optimal category distribution. The updated category labels are then used as the learning target to continue training the text classification model until it converges. Specifically, a target text can be selected from at least two texts to be clustered. Text augmentation is performed on the target text to obtain a first augmented text and a second augmented text. These are then input into the initial classification model to obtain a first prediction distribution for the first augmented text and a second prediction distribution for the second augmented text. Next, based on the updated category labels, the first prediction distribution, and the second prediction distribution, a first loss value is calculated for the initial classification model. The model parameters of the initial classification model are then adjusted in reverse based on the first loss value. The process of selecting the target text from at least two texts to be clustered is repeated until the set number of iterations is reached, resulting in a text classification model.
[0125] It should be noted that the specific implementation process of continuing to train the text classification model based on the updated category labels is similar to the implementation process of iterative training based on the initial category labels in step 102 above. The only difference is that the learning target is replaced by the initial category labels obtained based on the k-means clustering algorithm, which are updated based on the optimal transfer solution algorithm. This manual will not elaborate further here.
[0126] In one optional implementation of this embodiment, the category labels are updated according to the optimal category distribution. The specific implementation process can be as follows:
[0127] The category with the highest probability value in each row of the optimal category distribution is used as the updated category;
[0128] Replace the category corresponding to each text to be clustered in the category label with the updated category.
[0129] It's important to note that the optimal category distribution refers to the probability distribution of each text to be clustered belonging to each category; it's essentially a probability distribution matrix. The element in the i-th row and j-th column of this optimal category distribution represents the probability that the i-th text to be clustered belongs to the j-th category. Since the target of training the text classification model during contrastive learning should not be the category distribution itself, but rather a specific category, the category with the largest value in the i-th row can be used as the updated category for the i-th text to be clustered. Then, the old category corresponding to the i-th text in the category labels is replaced with this updated category. After updating the category labels for all texts to be clustered, the updated category labels are obtained.
[0130] In the embodiments of this specification, the initial category labels are iteratively updated through the optimal transfer solution algorithm, so that the category labels of at least two texts to be clustered gradually approach the true category distribution, generating more reliable category labels, which facilitates the subsequent supervised training of the text classification model. The continuous updating of category labels based on the optimal transfer solution algorithm improves the robustness of the texts to be clustered to text category imbalance.
[0131] Step 108: Using a converged text classification model, determine the clustering results for at least two texts to be clustered.
[0132] It should be noted that once the text classification model converges, it means that the text classification model has been trained. The trained text classification model is highly robust to problems such as imbalanced text category distribution and text noise caused by text sparsity. At this point, the clustering results corresponding to at least two texts to be clustered can be determined through the converged text classification model to obtain accurate clustering results.
[0133] In one optional implementation of this embodiment, a converged text classification model is used to determine the clustering results corresponding to at least two texts to be clustered. The specific implementation process can be as follows:
[0134] Input at least two texts to be clustered into a converged text classification model to obtain the corresponding target category distribution;
[0135] Determine the category with the highest probability value in each row of the target category distribution;
[0136] The category with the highest probability value in each row is taken as the clustering result corresponding to at least two texts to be clustered.
[0137] It should be noted that the target category distribution refers to the probability distribution of each text to be clustered belonging to each category; that is, it is a probability distribution matrix. The element in the i-th row and j-th column of this target category distribution represents the probability that the i-th text to be clustered belongs to the j-th category. The category with the highest probability value in the i-th row is the category corresponding to the i-th text to be clustered. For each row of the target category distribution, the category with the highest probability value can be determined, which is the category of the corresponding text to be clustered, thus obtaining the clustering results for each text to be clustered.
[0138] Example, Figure 2 This is a schematic diagram of the algorithm architecture of a text clustering method provided in one embodiment of this specification, as shown below. Figure 2 As shown, text augmentation is performed on the text X to be clustered, resulting in augmented text X1 and augmented text X2. Augmented text X1 and augmented text X2 are then input into the encoding layer of the text classification model to obtain the corresponding first vector representation E1 and second vector representation E2. The first vector representation E1 and second vector representation E2 are then input into the clustering layer of the text classification model to obtain the corresponding first prediction distribution P1 and second prediction distribution P2. Based on the first prediction distribution P1, the second prediction distribution P2, and the initial class label Q, the loss value L is calculated. C The initial category label Q is the category determined based on the k-means clustering algorithm. The loss value L... C It can bring text within the same category closer together and push text between different categories further apart.
[0139] Input the first vector representation E1 and the second vector representation E2 into the mapping model (Projecting) to obtain the corresponding first mapping representation Z1 and second mapping representation Z2. Calculate the loss value L based on the first mapping representation Z1 and the second mapping representation Z2. I Through the loss value L I It can bring text from the same instance (i.e., the same source) closer together and push text from different instances (i.e., different sources) further apart.
[0140] Based on the loss value L C and L I The model is trained iteratively. After a set number of iterations, the text X to be clustered is input into the encoding layer of the text classification model. That is, the encoding layer of the text classification model shares the model parameters with the encoding layer after a set number of iterations to obtain the corresponding vector representation E. The vector representation E is then input into the classification layer of the text classification model. The classification layer shares the model parameters with the classification layer after a set number of iterations to obtain the predicted class distribution P.
[0141] The optimal transfer algorithm is used to solve the reference class distribution P' corresponding to the predicted distribution class P. The update module (argmax) updates the initial class label Q based on the solved reference class distribution P' to obtain the updated class label Q.
[0142] The updated category label Q can continue to serve as a supervisory signal and participate in the loss value L. C The calculation continues, and the training is iterated a set number of times until the text classification model converges.
[0143] The text clustering method provided in this specification first obtains the category labels of at least two texts to be clustered. Based on these category labels, a text classification model is iteratively trained a set number of times to obtain a text classification model. The text classification model then obtains the predicted category distributions corresponding to the at least two texts to be clustered. An optimal transfer algorithm is used to solve for the optimal category distribution corresponding to the predicted category distribution, updating the initially determined category labels. The text classification model is then trained again based on the updated category labels until it converges, yielding clustering results for the at least two texts to be clustered. In this way, by iteratively updating the initial category labels using the optimal transfer algorithm, the category labels of the at least two texts to be clustered gradually approach the true category distribution, generating reliable category labels. These reliable category labels are used as monitoring signals to train the text classification model until convergence. Continuously updating the category labels based on the optimal transfer algorithm improves the robustness of the texts to class imbalance, and using reliable category labels as monitoring signals improves the robustness of the text classification model to data noise, thereby improving the recognition accuracy of the text classification model and ensuring the accuracy of the text clustering results.
[0144] It should be noted that a large amount of data is presented in the form of short texts, and short text clustering can extract valuable information from a large amount of short text data, making it one of the most basic text mining tasks. However, short texts are often class-imbalanced and sparse. Therefore, the text clustering method provided in the embodiments of this specification is mainly applied to short text clustering scenarios to solve the problem of data imbalance in short texts and the problem that noise caused by the sparsity of short text content has a significant impact on the clustering results.
[0145] The following is in conjunction with the appendix Figure 3 Taking the text clustering method provided in this manual as an example in the application of short text scenarios, this paper further explains the text clustering method. Figure 3 This specification illustrates a flowchart of a text clustering method for short text scenarios, provided by an embodiment of this specification. The method specifically includes the following steps:
[0146] Step 302: Determine the category labels Q of multiple short texts using the k-means clustering algorithm.
[0147] Step 304: Enhance the short text X to obtain X1 and X2.
[0148] Step 306: Input X1 and X2 into the encoding layer of the text classification model to obtain the corresponding vector representations E1 and E2.
[0149] Step 308: Input E1 and E2 into the classification layer of the text classification model to obtain the corresponding prediction distributions P1 and P2. Calculate the class-level loss value L based on P1, P2, and the class label Q. C .
[0150] Step 310: Input E1 and E2 into the mapping model to obtain the corresponding mapping representations Z1 and Z2, and calculate the instance-level loss value L based on Z1 and Z2. I .
[0151] Step 312: Based on the class-level loss value L C and instance-level loss value L I Train the text classification model.
[0152] Step 314: Input the short text X into the text classification model after iterative training for a set number of times to obtain the predicted distribution P.
[0153] Step 316: Based on the optimal transfer solution algorithm, determine the optimal distribution P' corresponding to the predicted distribution P, update the category label Q according to the optimal distribution P', obtain the updated category label Q, and return to execute the above step 304 until the text classification model converges.
[0154] Step 318: Input multiple short texts into the converged text classification model to obtain the target category distribution of the short texts, and determine the clustering result of the short texts based on the target category distribution.
[0155] The text clustering method provided in this specification first obtains initial category labels for multiple short texts. Based on these category labels, a text classification model is iteratively trained a set number of times to obtain a text classification model. The text classification model then obtains the predicted category distribution for the multiple short texts. An optimal transfer algorithm is used to solve for the optimal category distribution corresponding to the predicted category distribution, updating the initially determined category labels. The text classification model is then trained again based on the updated category labels until it converges, yielding the clustering results for the multiple short texts. In this way, by iteratively updating the initial category labels using the optimal transfer algorithm, the category labels of the multiple short texts gradually approach the true category distribution, generating reliable category labels. These reliable category labels are used as supervision signals to train the text classification model until convergence. Continuously updating the category labels based on the optimal transfer algorithm improves the robustness of short texts to text category imbalance, and using reliable category labels as supervision signals improves the robustness of the text classification model to data noise, thereby improving the recognition accuracy of the text classification model and ensuring the accuracy of the short text clustering results.
[0156] Corresponding to the above method embodiments, this specification also provides embodiments of a text clustering device. Figure 4 A schematic diagram of a text clustering device according to an embodiment of this specification is shown. Figure 4 As shown, the device includes:
[0157] The first determining module 402 is configured to obtain the category labels of at least two texts to be clustered, and determine the predicted category distribution corresponding to at least two texts to be clustered according to the text classification model, wherein the text classification model is obtained by iterative training based on the category labels for a set number of times;
[0158] The second determining module 404 is configured to determine the optimal category distribution corresponding to the predicted category distribution based on the optimal transmission solution algorithm;
[0159] The update module 406 is configured to update the category labels according to the optimal category distribution and continue training the text classification model based on the updated category labels until the text classification model converges.
[0160] The third determination module 408 is configured to determine the clustering results corresponding to at least two texts to be clustered by using a converged text classification model.
[0161] Optionally, the first determining module 402 is further configured as follows:
[0162] The k-means clustering algorithm is used to cluster at least two texts to be clustered, thereby obtaining the category labels of at least two texts to be clustered.
[0163] Optionally, the device also includes a training module configured to:
[0164] Select the target text from at least two texts to be clustered;
[0165] Text enhancement is performed on the target text to obtain the corresponding first enhanced text and second enhanced text;
[0166] Input the first enhanced text and the second enhanced text into the initial classification model to obtain the first prediction distribution corresponding to the first enhanced text and the second prediction distribution corresponding to the second enhanced text;
[0167] Based on the category labels, the first prediction distribution, and the second prediction distribution, calculate the first loss value of the initial classification model, and adjust the model parameters of the initial classification model in reverse according to the first loss value. Then, return to the step of selecting the target text from at least two texts to be clustered, until the number of iterations reaches the set number, and obtain the text classification model.
[0168] Optionally, the initial classification model includes an encoding layer and a classification layer; the training module is further configured as follows:
[0169] The first and second augmented texts are input into the encoding layer of the initial classification model to obtain the first vector representation of the first augmented text and the second vector representation of the second augmented text.
[0170] By inputting the first vector representation and the second vector representation into the classification layer of the initial classification model, a first prediction distribution corresponding to the first enhanced text and a second prediction distribution corresponding to the second enhanced text are obtained.
[0171] Optionally, the training module is further configured as follows:
[0172] By inputting the first vector representation and the second vector representation into the mapping model, a first mapping representation of the first vector representation in the comparison space and a second mapping representation of the second vector representation in the comparison space are obtained.
[0173] The second loss value of the initial classification model is calculated based on the first and second mapping representations.
[0174] Optionally, the training module is further configured as follows:
[0175] Based on the first loss value and the second loss value, determine the total loss value of the initial classification model;
[0176] The model parameters of the initial classification model are adjusted in reverse based on the total loss value.
[0177] Optionally, the second determining module 404 is further configured to:
[0178] The cost matrix in the optimal transport solution algorithm is determined based on the predicted category distribution.
[0179] Solve for the optimal transmission matrix based on the cost matrix;
[0180] The optimal transfer matrix is used as the optimal class distribution.
[0181] Optionally, update module 406 is further configured as follows:
[0182] The category with the highest probability value in each row of the optimal category distribution is used as the updated category;
[0183] Replace the category corresponding to each text to be clustered in the category label with the updated category.
[0184] Optionally, the third determining module 408 is further configured as follows:
[0185] Input at least two texts to be clustered into a converged text classification model to obtain the corresponding target category distribution;
[0186] Determine the category with the highest probability value in each row of the target category distribution;
[0187] The category with the highest probability value in each row is taken as the clustering result corresponding to at least two texts to be clustered.
[0188] The text clustering apparatus provided in this specification first acquires the category labels of at least two texts to be clustered. Based on these category labels, iterative training is performed a set number of times to obtain a text classification model. The text classification model then obtains the predicted category distributions corresponding to the at least two texts to be clustered. An optimal transfer algorithm is used to solve for the optimal category distribution corresponding to the predicted category distribution, updating the initially determined category labels. The text classification model is then trained again based on the updated category labels until it converges, yielding clustering results for the at least two texts to be clustered. In this way, by iteratively updating the initial category labels using the optimal transfer algorithm, the category labels of the at least two texts to be clustered gradually approach the true category distribution, generating reliable category labels. These reliable category labels are used as monitoring signals to train the text classification model until convergence. Continuously updating the category labels based on the optimal transfer algorithm improves the robustness of the texts to class imbalance, and using reliable category labels as monitoring signals improves the robustness of the text classification model to data noise, thereby improving the recognition accuracy of the text classification model and ensuring the accuracy of the text clustering results.
[0189] The above is an illustrative scheme of a text clustering device according to this embodiment. It should be noted that the technical solution of this text clustering device and the technical solution of the text clustering method described above belong to the same concept. For details not described in detail in the technical solution of the text clustering device, please refer to the description of the technical solution of the text clustering method described above.
[0190] Figure 5 A structural block diagram of a computing device according to an embodiment of this specification is shown. The components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and a database 550 is used to store data.
[0191] The computing device 500 also includes an access device 540, which enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 540 may include one or more of any type of wired or wireless network interface (e.g., Network Interface Controller (NIC)), such as an IEEE 802.11 Wireless Local Area Networks (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0192] In one embodiment of this specification, the above-described components of the computing device 500 and Figure 5 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 5 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0193] The computing device 500 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 500 can also be a mobile or stationary server.
[0194] The processor 520 is configured to execute the following computer-executable instructions to implement the steps of the text clustering method described above.
[0195] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the above-described text clustering method belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-described text clustering method.
[0196] An embodiment of this specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, are used to implement the steps of the text clustering method described above.
[0197] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the text clustering method described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the text clustering method described above.
[0198] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0199] Computer instructions include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0200] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this specification is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this specification. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this specification.
[0201] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0202] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. These embodiments have been selected and specifically described in this specification to better explain the principles and practical applications of this specification, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A text clustering method, characterized in that, The method includes: Select the target text from at least two texts to be clustered; The target text is enhanced to obtain the corresponding first enhanced text and second enhanced text; Input the first enhanced text and the second enhanced text into the initial classification model to obtain the first prediction distribution corresponding to the first enhanced text and the second prediction distribution corresponding to the second enhanced text; Based on the category label, the first prediction distribution, and the second prediction distribution, calculate the first loss value of the initial classification model, and adjust the model parameters of the initial classification model in reverse according to the first loss value. Then, return to the step of selecting the target text from at least two texts to be clustered, until the number of iterations reaches the set number, and obtain the text classification model. Obtain the category labels of at least two texts to be clustered, and determine the predicted category distribution corresponding to the at least two texts to be clustered according to the text classification model, wherein the text classification model is obtained by iteratively training a set number of times based on the category labels; The optimal class distribution corresponding to the predicted class distribution is determined based on the optimal transport algorithm. The category labels are updated according to the optimal category distribution, and the text classification model is trained again based on the updated category labels until the text classification model converges. By using a convergent text classification model, the clustering results corresponding to the at least two texts to be clustered are determined.
2. The text clustering method according to claim 1, characterized in that, The process of obtaining category labels for at least two texts to be clustered includes: The at least two texts to be clustered are clustered using the k-means clustering algorithm to obtain the category labels of the at least two texts to be clustered.
3. The text clustering method according to claim 1, characterized in that, The initial classification model includes an encoding layer and a classification layer; the step of inputting the first enhanced text and the second enhanced text into the initial classification model to obtain a first prediction distribution corresponding to the first enhanced text and a second prediction distribution corresponding to the second enhanced text includes: The first and second enhanced texts are input into the encoding layer of the initial classification model to obtain the first vector representation corresponding to the first enhanced text and the second vector representation corresponding to the second enhanced text. The first vector representation and the second vector representation are input into the classification layer of the initial classification model to obtain the first prediction distribution corresponding to the first enhanced text and the second prediction distribution corresponding to the second enhanced text.
4. The text clustering method according to claim 3, characterized in that, After inputting the first enhanced text and the second enhanced text into the encoding layer of the initial classification model to obtain the first vector representation corresponding to the first enhanced text and the second vector representation corresponding to the second enhanced text, the method further includes: The first vector representation and the second vector representation are input into the mapping model to obtain a first mapping representation of the first vector representation in the comparison space and a second mapping representation of the second vector representation in the comparison space; The second loss value of the initial classification model is calculated based on the first mapping representation and the second mapping representation.
5. The text clustering method according to claim 4, characterized in that, The step of adjusting the model parameters of the initial classification model in reverse according to the first loss value includes: Based on the first loss value and the second loss value, determine the total loss value of the initial classification model; The model parameters of the initial classification model are adjusted in reverse based on the total loss value.
6. The text clustering method according to any one of claims 1-5, characterized in that, Determining the optimal class distribution corresponding to the predicted class distribution based on the optimal transport algorithm includes: The cost matrix in the optimal transport solution algorithm is determined based on the predicted category distribution; Based on the cost matrix, solve for the optimal transmission matrix; The optimal transfer matrix is used as the optimal class distribution.
7. The text clustering method according to any one of claims 1-5, characterized in that, Updating the category label according to the optimal category distribution includes: The category with the highest probability value in each row of the optimal category distribution is used as the updated category; Replace the category corresponding to each text to be clustered in the category label with the updated category.
8. The text clustering method according to any one of claims 1-5, characterized in that, The process of determining the clustering results corresponding to the at least two texts to be clustered using a converged text classification model includes: Input the at least two texts to be clustered into a converged text classification model to obtain the corresponding target category distribution; Determine the category with the highest probability value in each row of the target category distribution; The category with the highest probability value in each row is taken as the clustering result corresponding to the at least two texts to be clustered.
9. A text clustering device, characterized in that, The device includes: The training module is configured to select a target text from at least two texts to be clustered; perform text augmentation on the target text to obtain corresponding first augmented text and second augmented text; input the first augmented text and second augmented text into an initial classification model to obtain a first prediction distribution corresponding to the first augmented text and a second prediction distribution corresponding to the second augmented text; calculate a first loss value of the initial classification model based on the category label, the first prediction distribution, and the second prediction distribution, and adjust the model parameters of the initial classification model in reverse based on the first loss value, and return to execute the step of selecting a target text from at least two texts to be clustered until the number of iterations reaches a set number to obtain the text classification model; The first determining module is configured to acquire the category labels of at least two texts to be clustered, and determine the predicted category distribution corresponding to the at least two texts to be clustered according to the text classification model, wherein the text classification model is obtained by iteratively training a set number of times based on the category labels; The second determining module is configured to determine the optimal category distribution corresponding to the predicted category distribution based on the optimal transmission solution algorithm; The update module is configured to update the category labels according to the optimal category distribution, and continue training the text classification model based on the updated category labels until the text classification model converges. The third determining module is configured to determine the clustering results corresponding to the at least two texts to be clustered by using a converged text classification model.
10. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the text clustering method according to any one of claims 1-8.
11. A computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the text clustering method according to any one of claims 1-8.
12. A computer program product, characterized in that, Includes computer instructions that, when executed by a processor, implement the steps of the text clustering method according to any one of claims 1-8.
Citation Information
Patent Citations
Weakly supervised text classification method, system and device based on self-supervised training
CN115080749A
Self-supervised bearing fault diagnosis method based on clustering algorithm
CN115791179A