Training text generation method and related equipment
By calculating the correlation coefficients of semantic similarity between historical training texts and text category labels, the new training text set is determined, which solves the problem of poor training text selection in the existing technology and achieves more efficient training text selection.
Patent Information
- Application Number
- CN202311352239.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-18
- Publication Date
- 2025-04-22
AI Technical Summary
When selecting training texts, the prior art mainly relies on the similarity between single text attribute features, resulting in poor training text selection effect.
By obtaining the historical training text set and the new text set, we calculate the semantic similarity between historical training texts and the correlation coefficient between text category labels, and then determine the new training text set to improve the selection effect of training text.
By considering the semantic similarity between historical training texts and the correlation between text category labels, the information basis for training text selection is enriched and the effect of training text selection is improved.
Smart Images

Figure CN119862415A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a training text generation method and related equipment. Background Art
[0002] Text classification can be understood as a classification system or standard for classifying and labeling text. Currently, a commonly used text method is to classify text through a text classification model. In order to improve the classification accuracy of the model, the text classification model needs to be trained, that is, the model needs to be trained based on a training text set with already labeled categories, and the relationship model between text features and text categories needs to be found. Then, the model learned through training is used to classify the text that needs to be classified.
[0003] Therefore, in the training process of text classification models, the training text set plays an important role. However, in the process of selecting training texts (i.e. selecting samples / generating samples / generating training texts), the commonly used method is to select training texts based on the similarity between single text attribute features, which easily leads to poor training text selection effects. Summary of the invention
[0004] The embodiments of the present application provide a training text generation method and related equipment, which are beneficial to improving the training text selection effect.
[0005] In order to solve the above technical problems, this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for generating a training text, the method comprising:
[0007] Acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts;
[0008] Determining the semantic similarity between the historical training texts and the correlation coefficient between the text category labels;
[0009] Determining a second text set according to the semantic similarity, the correlation coefficient, and the first historical training text set;
[0010] A target training text set is obtained according to the second text set and the first text set.
[0011] In a second aspect, an embodiment of the present application further provides a training text generation device, the device comprising:
[0012] A first acquisition module, used to acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts;
[0013] A first determination module is used to determine the semantic similarity between the historical training texts and the correlation coefficient between the text category labels;
[0014] A second determination module, configured to determine a second text set according to the semantic similarity, the correlation coefficient and the first historical training text set;
[0015] The text set acquisition module is used to obtain a target training text set according to the second text set and the first text set.
[0016] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned training text generation method when executing the computer program.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned training text generation method are implemented.
[0018] It can be seen that in the process of selecting the second text set based on the first historical training text set, it is no longer based on a single piece of information, but enriched with the information on which the second text set is selected. The second text set is selected based on the semantic similarity between the historical training texts in the first historical training text set and the correlation coefficient between the text category labels of the historical training texts. That is, in the process of selecting the second text set, the similarity between the historical training texts in the first historical training text set is used, and the semantic similarity is used, that is, the similarity between the semantic information of the texts is considered. At the same time, the correlation coefficient between the text category labels of the historical training texts in the first historical training text set is also used, that is, the correlation between text categories is also considered. After that, the target training text set is obtained according to the determined second text set and the first text set, and the selection of training samples is completed, thereby improving the selection effect of training texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 This is one of the flow charts of a training text generation method provided in an embodiment of the present application;
[0021] Figure 2 This is the second flowchart of a training text generation method provided in an embodiment of the present application;
[0022] Figure 3 This is a flow chart of a model training using a target training text set generated by a training text generation method provided in an embodiment of the present application;
[0023] Figure 4 It is a structural schematic diagram of a training text generation device provided in an embodiment of the present application;
[0024] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] In the process of text classification model training, a training text set, that is, a training sample set, is needed. The training text set plays an important role in model training. However, in the process of selecting training texts, the commonly used method is to select training texts based on the similarity between a single text attribute feature, which easily leads to poor training text selection results. Based on this, an embodiment of the present application provides a text classification method, which can determine the semantic similarity between historical training texts and the correlation coefficient between text category labels, determine the second text set from the first historical training text set according to the semantic similarity and the correlation coefficient, and obtain the target training text set according to the second text set and the first text set, that is, in the process of selecting the second text set according to the first historical training text set, the embodiment of the present application no longer relies on a single information, and enriches the information based on which the second text set is selected. The second text set is selected based on the semantic similarity between the historical training texts in the first historical training text set and the correlation coefficient between the text category labels of the historical training texts. That is, in the process of selecting the second text set, the similarity between the historical training texts in the first historical training text set is used, and the semantic similarity is used, that is, the similarity between the semantic information of the text is considered, and the correlation coefficient between the text category labels of the historical training texts in the first historical training text set is also used, that is, the correlation between the text categories is also considered, and then the target training text set is obtained according to the determined second text set and the first text set, and the selection of training samples is completed, thereby improving the selection effect of training texts.
[0027] See also Figure 1 , Figure 1 is a flow chart of a training text generation method provided in an embodiment of the present application. The training text generation method of this embodiment can be applied to an electronic device, which can be a mobile device or a non-mobile device. The method can be applied to the first scenario, such as Figure 1 As shown, the method comprises the following steps:
[0028] Step 101: Obtain a first historical training text set and a first text set.
[0029] The first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts. That is, in this embodiment, the historical training texts are taken into consideration in the text selection process. It should be noted that, illustratively, the historical training text set can be understood as a text set for which the text classification model is trained in advance, that is, a text set for which the model has been trained.
[0030] In addition, the text in the first text set can be understood as the text generated in actual applications. For example, illustratively, the first text set can be the text actually generated in the first scenario. The first scenario can be any specific application field scenario, which is not limited to a specific scenario. According to the needs, it can be a specific scenario. For example, as an example, the above method can be applied to the financial industry scenario, then the text in the first text set can be the customer complaint text (i.e., public opinion and customer complaint text data) actually generated in the financial industry scenario. For another example, as an example, the above method can be applied to the live broadcast scenario, then the text in the first text set can be the call text actually generated in the live broadcast scenario, etc.
[0031] That is, in this embodiment, it is necessary to obtain the first text set, and in addition, the historical training text set of the text classification model that needs to be retrained is also considered, that is, the first historical training text set also needs to be obtained.
[0032] Step 102: Determine the semantic similarity between historical training texts and the correlation coefficient between text category labels.
[0033] The similarity between texts refers to the degree of similarity between two texts, and can also be understood as the commonality or difference between texts. The greater the commonality and the smaller the difference, the higher the similarity. When two texts are exactly the same, the similarity is the highest. In this embodiment, semantic similarity is used. There are many ways to calculate semantic similarity, which are not specifically limited. For example, as an example, it can be but not limited to a cosine similarity calculation method, a Jaccard similarity calculation method, or a Dice similarity calculation method, and the obtained semantic similarity can be cosine similarity, Jaccard similarity, or Dice similarity.
[0034] Exemplarily, the semantic feature vector of each historical training text in the first historical training text set can be extracted, and the semantic feature vectors of the historical training texts in the first historical training text set can be used to calculate the semantic similarity between every two historical training texts in the first historical training text set, that is, the similarity between the semantic feature vectors of the two historical training texts. Exemplarily, before extracting the semantic feature vector of each historical training text in the first historical training text set, stop word filtering and word segmentation processing can be performed on each historical training text in the first historical training text set to update the historical training texts in the first historical training text set. Then, the semantic feature vector of each historical training text in the first historical training text set is extracted; for example, as an example, the word2vec algorithm, doc2vec algorithm, bert algorithm, etc. can be used for vectorization to obtain the semantic feature vector of each historical training text.
[0035] It should be understood that if the first historical training sample set includes N (an integer greater than 1) historical training texts, then there are S types of combinations of any two texts (pairwise combinations) in the first historical training text set, where S=N(N-1) / 2. For example, if the first historical training text set includes text A, text B, text C, and text D, then there are 6 types of combinations of any two texts, namely, A and B, A and C, A and D, B and C, B and D, and C and D. For every two historical training texts in the first historical training text set, it refers to the two texts in each combination (pairwise combination) in the first historical training text set. For the semantic similarity between every two historical training texts in the first historical training text set, it refers to the semantic similarity between the two texts in each combination in the first historical training text set. In this way, the semantic similarity between the above historical training texts may include S semantic similarities. As exemplified above, the semantic similarity between historical training texts may include the semantic similarity between A and B, the semantic similarity between A and C, the semantic similarity between A and D, the semantic similarity between B and C, the semantic similarity between B and D, and the semantic similarity between C and D. For the correlation parameter between the text category labels corresponding to every two historical training texts in the first historical training text set, it refers to the correlation parameter between the text category labels corresponding to the two texts in each combination in the first historical training text set, and the correlation coefficient between the text category labels may include S correlation coefficients. As exemplified above, the correlation coefficient between historical training texts may include the correlation coefficient between the text category labels corresponding to A and B, the correlation coefficient between the text category labels corresponding to A and C, the correlation coefficient between the text category labels corresponding to A and D, the correlation coefficient between the text category labels corresponding to B and C, the correlation coefficient between the text category labels corresponding to B and D, and the correlation coefficient between the text category labels corresponding to C and D.
[0036] In addition, it should be understood that the correlation coefficient between the text category labels corresponding to two historical training texts can represent the degree of match (or correlation) between the text category labels corresponding to the two historical training texts. The larger the correlation coefficient value between the text category labels corresponding to the two historical training texts, the greater the degree of match or correlation between the text category labels of the two historical training texts.
[0037] It should be understood that there are various ways to calculate the correlation parameter. For example, in one example, the feature similarity between the text category labels corresponding to the two historical training texts can be calculated to obtain the correlation parameter. In another example, it can also be determined whether the text category labels corresponding to the two historical training texts belong to the same category label set (the category labels can be divided, and similar category labels are in the same category label set). If they do, the correlation parameter between the text category labels corresponding to the two historical training texts can be set to a first value, otherwise, it can be set to a second value, and the second value is less than the first value. In another example, the corresponding correlation parameter can be determined by determining whether the text label categories corresponding to the two historical training texts are the same. When the text label categories corresponding to the two historical training texts are the same, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined according to the total number of category labels corresponding to the training texts in the first historical training text set. The correlation coefficient between the text label categories corresponding to the two historical training texts is inversely proportional to the total number of category labels in the historical training sample set; when the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined to be a preset value. It should be noted that this preset value is smaller than the correlation coefficient between text label categories corresponding to any two historical training texts determined according to the total number of category labels corresponding to the training texts in the first historical training text set.
[0038] Step 103: Determine a second text set according to the semantic similarity, the correlation coefficient and the first historical training text set.
[0039] Through the semantic similarity between every two historical training texts in the first historical training text set and the correlation parameters between the corresponding text category labels, training texts can be selected from the first historical training text set to form a second text set, that is, the second text set includes training texts selected from the first historical training text set based on the semantic similarity and correlation parameters.
[0040] Step 104: Obtain a target training text set according to the second text set and the first text set.
[0041] It should be noted that the target training text set is used to train the text classification model, and the text classification model can be applied to the first scenario. After obtaining the second text set, the second text set can be merged with the first text set in the first scenario applied by this scheme to generate the target training text set. In addition, it should be noted that before this, the text classification model has been trained according to the first historical training text set, that is, the first historical training text set is a text set for pre-training the text classification model. In this embodiment, the first historical training text set of the text classification model and the first text set are considered. The second text set and the first text set selected from the first historical training text set are used to obtain the target training text set that can be used to train the text classification model again, that is, the target training text set can be used to train the text classification model, and the selected target training text set can be used to train the text classification model later. In one example, the second text set and the first text set can be merged to obtain the target training text set, and the obtained target training text set includes the text in the second text set and the text in the first text set.
[0042] It can be seen that in the process of selecting the second text set based on the first historical training text set, it is no longer based on a single piece of information, but enriched with the information on which the second text set is selected. The second text set is selected based on the semantic similarity between the historical training texts in the first historical training text set and the correlation coefficient between the text category labels of the historical training texts. That is, in the process of selecting the second text set, the similarity between the historical training texts in the first historical training text set is used, and the semantic similarity is used, that is, the similarity between the semantic information of the texts is considered. At the same time, the correlation coefficient between the text category labels of the historical training texts in the first historical training text set is also used, that is, the correlation between text categories is also considered. After that, the target training text set is obtained according to the determined second text set and the first text set, and the selection of training samples is completed, thereby improving the selection effect of training texts.
[0043] In one embodiment, determining the second text set according to the semantic similarity, the correlation coefficient, and the first historical training text set includes:
[0044] According to the semantic similarity and the correlation coefficient, the first historical training text set is divided into texts to generate a third text set;
[0045] The second text set is determined based on the third text set.
[0046] It should be noted that the number of the third text sets can be n, where n is a positive integer, i.e., text segmentation can generate n third text sets. The value of n can be preset according to actual needs. In one example, determining the second text set based on the third text set can be to extract text from each third text set to obtain the second text set, i.e., the second text set includes the text extracted from each third text set.
[0047] In the process of determining the second text set, the historical training texts in the first historical training text set can be first divided into texts according to semantic similarity and correlation coefficient, that is, the text division takes into account semantic similarity and correlation coefficient. In this way, for a certain text, if the semantic similarity between one of the other two texts and the certain text is low but the correlation coefficient is high, and the semantic similarity between the other text of the other two texts and the certain text is high but the correlation coefficient is low, these two texts can also be divided into a group of the certain text. Through the text division of this embodiment, the semantic similarity and the correlation coefficient can be comprehensively considered, which can increase the possibility of texts with large differences in semantic similarity but small correlation coefficients being assigned to the same group, or increase the possibility of texts with small differences in semantic similarity but large correlation coefficients being assigned to the same group. In this way, the balance of text division can be improved.
[0048] In one embodiment, the first historical training text set is divided into texts according to the semantic similarity and the correlation coefficient to generate the third text set, including:
[0049] For every two historical training texts in the first historical training text set, a first target similarity between the two historical training texts is obtained according to a correlation coefficient between the semantic similarity between the two historical training texts and text category labels corresponding to the two historical training texts;
[0050] According to the first target similarity, the texts in the first historical training text set are divided to generate a third text set.
[0051] It should be noted that the first target similarity can also be called weighted similarity. The weight of the semantic similarity and the weight of the correlation coefficient can be pre-set according to actual conditions, and both are values greater than 0 and less than or equal to 1. For example, as an example, the weight of the semantic similarity and the weight of the correlation coefficient can both be 1.
[0052] After obtaining the first target similarity between every two historical training texts in the first historical training text set, the first target similarity can be used to divide the texts in the first historical training text set to generate a third text set. In this embodiment, in the process of dividing the historical training texts, not only the semantic similarity and the correlation coefficient are considered, but also the first target similarity obtained by weighting the semantic similarity and the correlation coefficient is used to divide the text, thereby improving the balance of text division and improving the text division effect.
[0053] In one embodiment, the texts in the first historical training text set are divided according to the first target similarity to generate a third text set, including:
[0054] According to the first target similarity, the text in the first historical training text set is divided into n texts to generate n third text sets;
[0055] Among them, in each text segmentation process:
[0056] When the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set are used as a third text set, where k is the result of rounding up the total number of texts in the first historical training text set divided by n;
[0057] When the number of undivided texts in the first historical training text set is greater than k, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set.
[0058] It should be understood that after each text division, the text in the generated third text set has been divided, that is, the text in the third text set in the first historical training text set is the divided text, and the undivided text in the first historical training text set no longer includes the text in the third text set. The undivided text in the first historical training text set will be updated. As the division progresses, the undivided text in the first historical training text set will become less and less until all the text in the first historical training text set has been divided. That is, it can be understood that in each text division process, the undivided text in the first historical training text set is the latest. For example, the first historical training text set includes 99 historical training texts (i.e., texts A1, A2, ..., A98, A99), n is 10, k is 10, and before the first text segmentation, the unsegmented texts are A1-A99. After the first text segmentation, a third text set generated includes A1-A10, i.e., after the first text segmentation, texts A1-A10 have been segmented. Thus, after the first text segmentation, the unsegmented texts in the first historical training text set include texts A11-A99. The second text segmentation is continued, and a third text set generated after the second text segmentation includes texts A11-A 20, that is, after the second text division, text A11-A20 has been divided, so that after the second text division, the undivided text in the first historical training text set includes text A21-A99, and so on, the next text division is performed, after the n-1th text division, the undivided text in the first historical training text set includes text A91-A99, and the nth text division is continued. A third text set generated after the nth text division includes A91-A99, that is, after the nth text division, the undivided text in the first historical training text set is empty, that is, the text division of the first historical training text set is completed.
[0059] In addition, in each text segmentation process, it is necessary to determine whether the number of currently undivided texts in the first historical training text set is greater than k. Different determination results will be used to perform different operations. Specifically, if the number of currently undivided texts in the first historical training text set is greater than k, a third text set needs to be generated based on the first target similarity between the currently undivided texts in the first historical training text set. For example, in the above example, after the first text segmentation process divides A1-A10 into a third text set, the undivided texts in the first historical training text set are the above texts A11-A99, which is 89 and greater than k. When continuing the second text segmentation process, the text segmentation can be performed based on the first target similarity between these 89 undivided texts. If the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set can be directly used as a third text set. In this case, the third text set formed includes all the training texts in the undivided texts in the current first historical training text set.
[0060] That is, in this embodiment, in each text segmentation process, the corresponding segmentation operation can be performed according to the number of currently undivided texts in the first historical training text set. That is, when the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set are used as a third text set. When the number of undivided texts in the first historical training text set is greater than k, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set to achieve text segmentation. In this way, the flexibility of text segmentation can be improved.
[0061] In one embodiment, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set, including:
[0062] According to the first target similarity between the first historical training text and each second historical training text, k-1 historical training texts are determined from the second historical training texts; wherein the first historical training text is any historical training text in the undivided texts in the first historical training text set, the second historical training text is a text in the undivided texts in the first historical training text set that does not include the first historical training text, the first target similarity between the k-1 historical training texts and the first historical training text is greater than the first target similarity between the third historical training text and the first historical training text, and the third historical training text is a text in the second historical training text that does not include the k-1 training texts;
[0063] A third text set is generated based on the first historical training text k-1 training texts.
[0064] It can be understood that the second historical training text is the text other than the first historical training text in the undivided text in the first historical training text set. A first historical training text can be selected from the undivided text in the first historical training text set, and then the historical training texts with the first target similarity before k-1 with the first historical training text can be selected from the second historical training text. These k-1 historical training texts and the first historical training text are combined into k historical training texts to form a third text set. That is, each time the text segmentation process is executed, as long as the number of undivided texts in the first historical training text set is greater than k, k historical training texts (the first historical training text in the undivided text in the first historical training text set and the historical training texts with the first target similarity before k-1 with the first historical training text) can be selected as a third text set. After the k historical training texts are divided, the undivided texts in the first historical training text set do not include these k historical training texts. In this way, in the subsequent execution of the next text segmentation process, the undivided texts after the previous text segmentation continue to be divided. It should be noted that there are many ways to select the first historical training text, which are not specifically limited in this example. For example, as an example, it can be randomly selected.
[0065] In this embodiment, the top k-1 historical training texts with the first target similarity to the first historical training text can be divided into a group with the first historical training text to form a third text set. Since the first target similarity is the weighted sum of the semantic similarity and the correlation coefficient, the training texts with a large difference in semantic similarity but a small difference in correlation coefficient with the first historical training text can be divided into the same group, and the training texts with a large difference in correlation coefficient but a small difference in semantic similarity with the first historical training text can also be divided into the same group. This can reduce the situation where text division is more concentrated due to division due to a certain factor, improve the balance of text division, and thus improve the text selection effect.
[0066] In one embodiment, the texts in the first historical training text set are divided according to the first target similarity, and before the third text set is generated, the method further includes: arranging the first target similarities in descending order.
[0067] In this embodiment, since the first target similarities between every two historical training texts in the first historical training text set are pre-arranged in descending order, that is, the first target similarities are sorted from large to small, thus, in the process of selecting k-1 historical training texts with larger first target similarities, the first k-1 first target similarities can be directly selected from the sorted first target similarities, and the texts corresponding to the first k-1 first target similarities can be selected, thereby improving the efficiency of text selection.
[0068] In one embodiment, the third text set includes a fourth text set and a fifth text set, the number of historical training texts in the fourth text set is greater than a preset number, and the number of historical training texts in the fifth text set is less than or equal to the preset number;
[0069] According to the third text set, the second text set is determined, including:
[0070] Extracting a preset number of texts from each text set in the fourth text set to obtain a sixth text set;
[0071] According to the six text sets and the fifth text set, the second text set is obtained.
[0072] Since the third text set may include a fourth text set whose number of historical training texts is greater than the preset number, it is necessary to extract texts from each text set in the fourth text set. For example, the texts can be randomly extracted. The sixth text set can include texts extracted from each text set in the fourth text set. For example, the number of fourth text sets is 2, that is, there are 2 fourth text sets in the third text set whose number of historical training texts is greater than the preset number. A preset number of texts is extracted from one of the fourth text sets, and a preset number of texts is also extracted from the other fourth text set, that is, 2 times the preset number of texts are extracted. The sixth text set includes texts extracted from the two fourth text sets, that is, 2 times the preset number of texts. However, for the fifth text set, since the number of its texts is less than or equal to the preset number, that is, the number of texts is small, it is not necessary to extract, and all the texts in the fifth text set can be used. That is, after obtaining the sixth text set, the sixth text set and the fifth text set can be used to obtain the second text set. The second text set can include the texts in the sixth text set and the texts in the fifth text set. For example, if the number of texts in text set 1 and text set 2 in the third text set is greater than the preset number, then a preset number of texts are extracted from text set 1 and text set 2 respectively, that is, twice the preset number of texts are obtained, the number of texts in text set 3 in the third text set is the preset number, and the number of texts in text set 4 in the third text set is less than the preset number, for example, L, then the total number of texts in text set 3 and text set 4 is (preset number + L), then these twice the preset number of texts and (preset number + L) texts are merged to obtain a second text set, which includes (3 times the preset number + L) texts.
[0073] It should be understood that the third text set includes M fourth text sets and N fifth text sets, M and N are integers, and the sum of M and N can be n. If M is 0, it means that the third text set does not include a text set whose number of historical training texts is greater than a preset number, and the fourth text set is an empty set, and the text extracted from it is also empty. If N is 0, it means that the third text set does not include a text set whose number of historical training texts is less than or equal to a preset number, and the fifth text set is an empty set.
[0074] Through the text extraction of the present embodiment, for the fourth text set with a larger number, a preset number of texts are evenly extracted from each fourth text set, and for the fifth text set with a smaller number (less than or equal to the preset number), all the texts in these fifth text sets are used. In this way, the balance of the number of text extraction can be ensured as much as possible, so as to ensure the balance of texts from different text sets in the third text set in the second text set.
[0075] In one example, the preset number can be determined in advance based on the computing resources of the first electronic device (for example, including but not limited to memory resources, CPU resources, etc., as a further example, it can be the remaining computing resources), and the first electronic device is used to train the text classification model based on the target training text set. The larger the number of training texts, the more complex the training, the longer the time required, and the greater the machine resources required. The preset number directly affects the number of training texts used to train the model. The larger the preset number, the larger the number of texts in the target training text set generated in the end. In this example, the determination of the preset number takes into account the computing resources of the machine (i.e., the first electronic device) for model training to ensure that the subsequent machine is within the range that the first electronic device can bear when training based on the sixth text set obtained by extracting texts from the third text set according to the preset number and the number of texts in the target training sample set composed of the fifth text set, so as to improve the smoothness of the subsequent first electronic device in performing model training.
[0076] In one embodiment, determining the correlation coefficient between text category labels includes:
[0077] For every two historical training texts in the first historical training text set:
[0078] When the text label categories corresponding to the two historical training texts are the same, determining the correlation coefficient between the text label categories corresponding to the two historical training texts according to the total number of category labels corresponding to the training texts in the first historical training text set, wherein the correlation coefficient between the text label categories corresponding to the two historical training texts is inversely proportional to the total number of category labels; or
[0079] In the case where the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined to be a preset value.
[0080] It should be noted that the preset value can be preset and can be set to a smaller value. For example, as an example, the preset value can be set to 0. In addition, as an example, according to the total number of category labels corresponding to the training texts in the first historical training text set, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined, and the reciprocal of the total number of category labels can be used as the correlation coefficient between the text label categories corresponding to the two historical training texts.
[0081] In this embodiment, in the process of determining the correlation coefficient between the text category labels corresponding to any two historical training texts in the first historical training text set, when the text label categories corresponding to the two historical training texts are the same, the correlation coefficient between the text label categories corresponding to the two historical training texts can be determined based on the total number of category labels corresponding to the training texts in the first historical training text set; when the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts can be determined as a preset value. That is, in this embodiment, different methods can be used to determine the correlation parameter in the above two different situations to improve the flexibility of determining the correlation parameter.
[0082] The process of the training text generation method is described in detail below with a specific embodiment. This embodiment is described by taking the training text generation method applied to the financial industry scenario as an example.
[0083] like Figure 2 As shown, the specific process of the training text generation method of this embodiment is as follows:
[0084] First, newly added texts in the financial industry scenario (for example, public opinion and customer complaint text data) are obtained, that is, the first text set in the financial industry scenario is obtained. In addition, the historical training text set of the text classification model that needs to be retrained is also considered, that is, the first historical training text set also needs to be obtained.
[0085] Then, stop word filtering and word segmentation processing can be performed on each historical training text in the first historical training text set, and then a semantic feature vector of each historical training text in the first historical training text set can be generated; for example, as an example, the word2vec algorithm, doc2vec algorithm, bert algorithm, etc. can be used for vectorization to obtain the semantic feature vector of each historical training text.
[0086] Secondly, for every two historical training texts in the first historical training text set, the semantic similarity between the semantic feature vectors of the two historical training texts is calculated, and the correlation coefficient between the text category labels corresponding to the two historical training texts is calculated. The semantic similarity between the two historical training texts and the correlation coefficient between the text category labels corresponding to the two historical training texts are weighted and summed to obtain the first target similarity between the two historical training texts:
[0087] For example, the cosine similarity algorithm is used to calculate the semantic similarity value a1 (the value range of a1 can be ((0, 1]), for the category label corresponding to the historical training text, combined with the total number of category labels s of the training texts in the first historical training text set, if the category labels of the two historical training texts are different, the correlation coefficient (i.e., category label coefficient) a2 between the category labels of the two historical training texts is set to 1 / s, for example, as an example, s=10, then a2=1 / 10=0.1, and for example, s=2, then a2=1 / 2=0.5. If the category labels of the two historical training texts are the same, the correlation coefficient a2 between the text category labels of the two historical training texts is set to a preset value (e.g., 0). It should be noted that once the first historical training text set is obtained, the corresponding total number of category labels s is fixed, and s can be any integer greater than 1 and less than the total number of texts in the first historical training text set. What affects the correlation coefficient is whether the text category labels corresponding to the historical training texts are the same (i.e., whether they are the same category). If they are the same, the inverse of s is used as the correlation coefficient. If they are different, the preset value is used as the correlation coefficient;
[0088] Add the semantic similarity and category label coefficient of the two historical training texts (f=a1+a2), calculate the first target similarity between the two historical training texts, and sort the first target similarities between every two historical training texts in the first historical training text set in descending order, that is, sort them from large to small.
[0089] Furthermore, the texts in the first historical training text set are divided using the first target similarity and the correlation parameter to generate n third text sets (for example, third text set 1, third text set 2, ..., third text set n):
[0090] Combining the total number of texts u and the number of similar sets n in the first historical training text set, calculate k (k is the result of u divided by n and rounded up). In the text segmentation process, it is necessary to segment n times to obtain n third text sets, that is, each segmentation obtains a third text set. In the first division process, if the number of texts in the first historical training text set is greater than k, the first historical training text is randomly selected from the first historical training text set, and according to the sorted first target similarity, the historical training texts with the first target similarity before k-1 are selected, and the first k-1 historical training texts are selected to form a third text set 1 (i.e., similarity set 1) with the first historical training text. The texts in the third text set 1 have been divided. At this time, the undivided texts in the first historical training text set do not include the texts in the third text set 1. In the next division process, the undivided texts in the first historical training text set after the previous division are used for division; then the second division is performed (the division process is similar to the first division process, except that the undivided texts in the first historical training text set no longer include the texts in the third text set 1) to form a third text set 2 (similar set 2), and the text division is iterated n times. When all the texts in the first historical training text set are divided (i.e., all the texts in the first historical training text set are assigned to n third text sets), n third text sets are obtained. It should be noted that, during the division process, if the number of undivided texts in the current latest first training text set is less than or equal to k, the undivided texts in the first training text set can be formed into a third text set, thus completing the division of all texts in the first historical training text set. After n text divisions are performed, the texts in the first historical training text set are divided, and n third text sets are generated, each of which has a number of texts less than or equal to k.
[0091] Then, p (preset number) texts are randomly extracted from each third text set, and the texts extracted from each third text set are summarized to form a second text set; it should be noted that p can be determined in advance according to the computing resources of the first electronic device, for example, the larger the computing resources, the larger p, and the smaller the computing resources, the smaller p. In addition, it should be noted that during the text extraction process of the third text set, for the fourth text set whose number of texts in the third text set is greater than p, p texts are extracted from each text set in the fourth text set, and for the fifth text set whose number of texts in the third text set is not greater than p, there is no need to extract, and all the texts in these fifth text sets can be used, and the texts extracted from each text set in the fourth text set and the texts in the fifth text set are merged to form the second text set.
[0092] Finally, the second text set is merged with the first text set to generate a target training text set.
[0093] Subsequently, the available text classification model can be retrained in the generated target training text set to update the text classification model parameters. After the training is completed, the trained text classification model can be deployed in actual scenarios (for example, financial industry scenarios, etc.), that is, the text to be classified in the actual scenario is classified. It should be noted that there are many types of text classification models, which are not specifically limited in this embodiment. For example, as an example, the text classification model can include but is not limited to the bert+textcnn model, the fasttext model, the textcnn model, the TextBiLSTM+Attention model, etc.
[0094] like Figure 3 As shown in FIG. 1 , a flowchart of training a text classification model according to an embodiment is shown. The specific process is as follows:
[0095] First, a target training text set is obtained, which may be obtained by directly calling the training text generation method of the above embodiment, or the target training text set may also be obtained by the training text generation method of the above embodiment;
[0096] Secondly, the category labels of the texts in the target training text set. It should be noted that the texts in the target training text set that belong to the first historical training text set already have corresponding category labels, which can be obtained. For the texts in the target training text set that do not belong to the first historical training text set (i.e., belong to the first text set), they can be categorized and the corresponding category labels can be obtained.
[0097] Use the target training text set and the corresponding category labels to train the text classification model, update the model parameters, and use the test set and the corresponding category labels to verify the text classification model. After the verification, the trained text classification model can be obtained, and the trained text classification model can be deployed to the online service system in the actual application scenario;
[0098] The online service system in the actual application scenario can call the text classification model to perform text classification, etc.
[0099] In actual application scenarios, the online service system can generate new texts, that is, generate new samples, which can be added to the first text set to facilitate the selection of subsequent training texts to generate new target training text sets, etc.
[0100] In the scheme of the embodiment of the present application, in the text segmentation process of selecting the training text scheme, the correlation parameter between the text category labels is added, and the text segmentation is performed using the first target similarity obtained by the weighted sum of the semantic similarity and the correlation parameter, so that the text category distribution in the third text set of the text segmentation is more balanced, and in the process of extracting text from the divided third text set to obtain the second text set, the memory resources and other computing resources of the machine used to train the model are taken into consideration. In this way, by merging the extracted second text set and the first text set in the actual scenario, the target training text set for model training is obtained. In the subsequent machine training process based on the target training text set, the model training effect can be improved while reducing the machine memory occupancy and training time. The model is then used for text classification to improve the accuracy of text classification.
[0101] See also Figure 4 , Figure 4 4 is a structural diagram of a training text generation device 400 provided in an embodiment of the present application, which can implement the details of the training text generation method in the above embodiment and achieve the same effect. Figure 4 As shown, the training text generating device 400 includes:
[0102] A first acquisition module 401 is used to acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts;
[0103] A first determination module 402 is used to determine the semantic similarity between historical training texts and the correlation coefficient between text category labels;
[0104] A second determination module 403 is used to determine a second text set according to the semantic similarity, the correlation coefficient and the first historical training text set;
[0105] The text set acquisition module 404 is used to obtain a target training text set according to the second text set and the first text set.
[0106] In one embodiment, the second determining module 403 includes:
[0107] A division unit, used for dividing the first historical training text set into texts according to semantic similarity and correlation coefficient to generate a third text set;
[0108] The first determining unit is used to determine the second text set according to the third text set.
[0109] In one embodiment, the division unit comprises:
[0110] A similarity determination unit is used to obtain, for each two historical training texts in the first historical training text set, a first target similarity between the two historical training texts according to a semantic similarity between the two historical training texts and a correlation coefficient between text category labels corresponding to the two historical training texts;
[0111] The text segmentation unit is used to segment the text in the first historical training text set according to the first target similarity to generate a third text set.
[0112] In one embodiment, the text segmentation unit is specifically used to:
[0113] According to the first target similarity, the text in the first historical training text set is divided into n texts to generate n third text sets;
[0114] Among them, in each text segmentation process:
[0115] When the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set are used as a third text set, where k is the result of rounding up the total number of texts in the first historical training text set divided by n;
[0116] When the number of undivided texts in the first historical training text set is greater than k, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set.
[0117] In one embodiment, the apparatus 400 further includes:
[0118] The sorting module is used for the text segmentation unit to segment the text in the first historical training text set according to the first target similarity, and before generating the third text set, the first target similarity is arranged in descending order.
[0119] In one embodiment, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set, including:
[0120] According to the first target similarity between the first historical training text and each second historical training text, k-1 historical training texts are determined from the second historical training texts; wherein the first historical training text is any historical training text in the undivided texts in the first historical training text set, the second historical training text is a text in the undivided texts in the first historical training text set that does not include the first historical training text, the first target similarity between the k-1 historical training texts and the first historical training text is greater than the first target similarity between the third historical training text and the first historical training text, and the third historical training text is a text in the second historical training text that does not include the k-1 training texts;
[0121] A third text set is generated based on the first historical training text k-1 training texts.
[0122] In one embodiment, the third text set includes a fourth text set and a fifth text set, the number of historical training texts in the fourth text set is greater than a preset number, and the number of historical training texts in the fifth text set is less than or equal to the preset number;
[0123] The first determining unit includes:
[0124] an extraction unit, configured to extract a preset number of texts from each text set in the fourth text set to obtain a sixth text set;
[0125] The text determination unit is used to obtain a second text set according to the six text sets and the fifth text set.
[0126] In one embodiment, the first determining module 402 is specifically configured to:
[0127] For every two historical training texts in the first historical training text set:
[0128] When the text label categories corresponding to the two historical training texts are the same, determining the correlation coefficient between the text label categories corresponding to the two historical training texts according to the total number of category labels corresponding to the training texts in the first historical training text set, wherein the correlation coefficient between the text label categories corresponding to the two historical training texts is inversely proportional to the total number of category labels; or
[0129] In the case where the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined to be a preset value.
[0130] The training text generation device 400 provided in the embodiment of the present application can implement each process of the training text generation method in the above embodiment, and will not be described again here to avoid repetition.
[0131] Figure 5 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present application.
[0132] The electronic device 500 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. Those skilled in the art will appreciate that Figure 5The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present application, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0133] The processor 510 is used for:
[0134] Acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts;
[0135] Determine the semantic similarity between historical training texts and the correlation coefficient between text category labels;
[0136] Determine a second text set according to the semantic similarity, the correlation coefficient and the first historical training text set;
[0137] A target training text set is obtained according to the second text set and the first text set.
[0138] In one embodiment, the processor 510 is specifically configured to:
[0139] According to the semantic similarity and the correlation coefficient, the first historical training text set is divided into texts to generate a third text set;
[0140] The second text set is determined based on the third text set.
[0141] In one embodiment, the processor 510 is specifically configured to:
[0142] For every two historical training texts in the first historical training text set, a first target similarity between the two historical training texts is obtained according to a correlation coefficient between the semantic similarity between the two historical training texts and text category labels corresponding to the two historical training texts;
[0143] According to the first target similarity, the texts in the first historical training text set are divided to generate a third text set.
[0144] In one embodiment, the processor 510 is specifically configured to:
[0145] According to the first target similarity, the text in the first historical training text set is divided into n texts to generate n third text sets;
[0146] Among them, in each text segmentation process:
[0147] When the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set are used as a third text set, where k is the result of rounding up the total number of texts in the first historical training text set divided by n;
[0148] When the number of undivided texts in the first historical training text set is greater than k, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set.
[0149] In one embodiment, the processor 510 is further configured to:
[0150] The texts in the first historical training text set are divided according to the first target similarity, and before generating the third text set, the first target similarity is arranged in descending order.
[0151] In one embodiment, the processor 510 is specifically configured to:
[0152] In one embodiment, a third text set is generated according to the first target similarity between the undivided texts in the first historical training text set, including:
[0153] According to the first target similarity between the first historical training text and each second historical training text, k-1 historical training texts are determined from the second historical training texts; wherein the first historical training text is any historical training text in the undivided texts in the first historical training text set, the second historical training text is a text in the undivided texts in the first historical training text set that does not include the first historical training text, the first target similarity between the k-1 historical training texts and the first historical training text is greater than the first target similarity between the third historical training text and the first historical training text, and the third historical training text is a text in the second historical training text that does not include the k-1 training texts;
[0154] A third text set is generated based on the first historical training text k-1 training texts.
[0155] In one embodiment, the third text set includes a fourth text set and a fifth text set, the number of historical training texts in the fourth text set is greater than a preset number, and the number of historical training texts in the fifth text set is less than or equal to the preset number;
[0156] Processors, specifically for:
[0157] Extracting a preset number of texts from each text set in the fourth text set to obtain a sixth text set;
[0158] According to the six text sets and the fifth text set, the second text set is obtained.
[0159] In one embodiment, the processor is specifically configured to:
[0160] For every two historical training texts in the first historical training text set:
[0161] When the text label categories corresponding to the two historical training texts are the same, determining the correlation coefficient between the text label categories corresponding to the two historical training texts according to the total number of category labels corresponding to the training texts in the first historical training text set, wherein the correlation coefficient between the text label categories corresponding to the two historical training texts is inversely proportional to the total number of category labels; or
[0162] In the case where the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined to be a preset value.
[0163] The electronic device 500 provided in the embodiment of the present application can implement each process of the training text generation method of the above-mentioned embodiments, and also has the same beneficial technical effects as the above-mentioned training text generation method embodiments, and the details will not be repeated here.
[0164] It should be understood that in the embodiment of the present application, the radio frequency unit 501 can be used for receiving and sending signals during information transmission or calls. Specifically, after receiving downlink data from the base station, it is sent to the processor 510 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 501 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 501 can also communicate with the network and other devices through a wireless communication system.
[0165] The electronic device provides users with wireless broadband Internet access through the network module 502, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0166] The audio output unit 503 can convert the audio data received by the RF unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output it as sound. Moreover, the audio output unit 503 can also provide audio output related to a specific function performed by the electronic device 500 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, etc.
[0167] The input unit 504 is used to receive audio or video signals. The input unit 504 may include a graphics processor (GPU) 5041 and a microphone 5042. The graphics processor 5041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 506. The image frame processed by the graphics processor 5041 can be stored in the memory 509 (or other storage medium) or sent via the radio frequency unit 501 or the network module 502. The microphone 5042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 501 in the case of a telephone call mode.
[0168] The electronic device 500 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 5061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 5061 and / or the backlight when the electronic device 500 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 505 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0169] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0170] The user input unit 507 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 5071 or near the touch panel 5071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 5071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 510, receives the command sent by the processor 510 and executes it. In addition, the touch panel 5071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 5071, the user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0171] Furthermore, the touch panel 5071 may be overlaid on the display panel 5061. When the touch panel 5071 detects a touch operation on or near it, it transmits the information to the processor 510 to determine the type of the touch event. Then, the processor 510 provides a corresponding visual output on the display panel 5061 according to the type of the touch event. Figure 5 In the figure, the touch panel 5071 and the display panel 5061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0172] The interface unit 508 is an interface for connecting an external device to the electronic device 500. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 500 or may be used to transmit data between the electronic device 500 and an external device.
[0173] The memory 509 can be used to store software programs and various data. The memory 509 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 509 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0174] The processor 510 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 509 and calling data stored in the memory 509, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 510.
[0175] The electronic device 500 may also include a power supply 511 (such as a battery) for supplying power to each component. Preferably, the power supply 511 may be logically connected to the processor 510 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0176] In addition, the electronic device 500 includes some functional modules not shown, which will not be described in detail here.
[0177] Preferably, an embodiment of the present application also provides an electronic device, including a processor 510, a memory 509, and a computer program stored in the memory 509 and executable on the processor 510. When the computer program is executed by the processor 510, each process of the above-mentioned training text generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0178] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the training text generation method embodiment described above is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0179] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0180] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0181] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A training text generation method, characterized in that: The method comprises: Acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts; Determining the semantic similarity between the historical training texts and the correlation coefficient between the text category labels; Determining a second text set according to the semantic similarity, the correlation coefficient, and the first historical training text set; A target training text set is obtained according to the second text set and the first text set.
2. The method according to claim 1, characterized in that The determining of the second text set according to the semantic similarity, the correlation coefficient and the first historical training text set comprises: According to the semantic similarity and the correlation coefficient, the first historical training text set is divided into texts to generate a third text set; The second text set is determined according to the third text set.
3. The method according to claim 2, characterized in that The step of dividing the first historical training text set into text segments according to the semantic similarity and the correlation coefficient to generate a third text set includes: For every two historical training texts in the first historical training text set, obtaining a first target similarity between the two historical training texts according to a correlation coefficient between the semantic similarity between the two historical training texts and text category labels corresponding to the two historical training texts; The texts in the first historical training text set are divided according to the first target similarity to generate the third text set.
4. The method according to claim 3, characterized in that The step of dividing the text in the first historical training text set according to the first target similarity to generate the third text set includes: According to the first target similarity, performing n text divisions on the text in the first historical training text set to generate n third text sets; Among them, in each text segmentation process: When the number of undivided texts in the first historical training text set is less than or equal to k, the undivided texts in the first historical training text set are used as a third text set, where k is the result of rounding up the total number of texts in the first historical training text set divided by n; When the number of undivided texts in the first historical training text set is greater than k, a third text set is generated according to a first target similarity between the undivided texts in the first historical training text set.
5. The method according to claim 4, characterized in that The step of generating a third text set according to the first target similarity between the undivided texts in the first historical training text set comprises: According to the first target similarity between the first historical training text and each second historical training text, k-1 historical training texts are determined from the second historical training texts; wherein the first historical training text is any historical training text in the undivided texts in the first historical training text set, the second historical training text is a text in the undivided texts in the first historical training text set that does not include the first historical training text, and the first target similarity between the k-1 historical training texts and the first historical training text is greater than the first target similarity between the third historical training text and the first historical training text, and the third historical training text is a text in the second historical training text that does not include the k-1 training texts; A third text set is generated based on the k-1 training texts of the first historical training texts.
6. The method according to claim 4, characterized in that Before dividing the texts in the first historical training text set according to the first target similarity to generate the third text set, the method further includes: The first target similarities are arranged in descending order.
7. The method according to claim 2, characterized in that: The third text set includes a fourth text set and a fifth text set, the number of historical training texts in the fourth text set is greater than a preset number, and the number of historical training texts in the fifth text set is less than or equal to the preset number; Determining the second text set according to the third text set includes: Extracting a preset number of texts from each text set in the fourth text set to obtain a sixth text set; The second text set is obtained according to the six text sets and the fifth text set.
8. The method according to any one of claims 1 to 7, characterized in that Determining the correlation coefficient between the text category labels includes: For every two historical training texts in the first historical training text set: In the case where the text label categories corresponding to the two historical training texts are the same, determining a correlation coefficient between the text label categories corresponding to the two historical training texts according to the total number of category labels corresponding to the training texts in the first historical training text set, wherein the correlation coefficient between the text label categories corresponding to the two historical training texts is inversely proportional to the total number of category labels; or In the case that the text label categories corresponding to the two historical training texts are different, the correlation coefficient between the text label categories corresponding to the two historical training texts is determined to be a preset value.
9. A training text generation device, characterized in that: The device comprises: A first acquisition module, used to acquire a first historical training text set and a first text set, wherein the first historical training text set includes a plurality of historical training texts and text category labels of the historical training texts; A first determination module is used to determine the semantic similarity between the historical training texts and the correlation coefficient between the text category labels; A second determination module, configured to determine a second text set according to the semantic similarity, the correlation coefficient and the first historical training text set; The text set acquisition module is used to obtain a target training text set according to the second text set and the first text set.
10. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the training text generation method according to any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the training text generation method according to any one of claims 1 to 8 are implemented.