Text classification model training method and device
By generating and adjusting the semantic feature vectors in the text classification model, it solves the problem of manually setting coarse granularity of classification labels, achieves accurate output of the text classification model and automated accurate classification, and improves classification efficiency.
Patent Information
- Application Number
- CN202010158022.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-09
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-03-09
AI Technical Summary
In the existing technology, the granularity of manually set classification labels is relatively coarse, which cannot meet the precise recommendation of user needs, and fine-grained annotation requires a large amount of manual annotation, which is time-consuming and labor-intensive.
By obtaining the text and title of the sample text, the semantic feature vectors of the text and title are generated, and according to the preset number of text classification tags, the matching feature vector pairs are selected, and the text classification model parameters are adjusted to maximize or minimize the feature vector value. Train models for accurate classification.
It achieves accurate output of text classification models, can automatically classify large amounts of text data accurately, improves classification efficiency and accuracy, and is more efficient than manual annotation.
Smart Images

Figure CN111552802B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a text classification model training method, device, electronic device and storage medium. Background Art
[0002] At present, many applications such as news and forums that facilitate users to obtain information usually include personalized recommendation functions to push information that users may be interested in, thereby obtaining a higher user experience. Accurate classification labels are the key to classifying large amounts of data and the basis for ensuring the accuracy of recommended content. Currently, commonly used classification labels are generally manually set, such as sports, entertainment, music, technology, etc.
[0003] However, this type of classification label has a coarse granularity and cannot meet the needs of providing accurate recommendations to users. If fine-grained classification labels are manually established, a large amount of data needs to be manually labeled and classified, which is time-consuming and labor-intensive. Summary of the invention
[0004] The present disclosure provides a text classification model training method, device, electronic device and storage medium to at least solve the problem that the granularity of manually set classification labels in the related art is relatively coarse and cannot meet the needs of achieving accurate recommendations to users. The technical solutions of the present disclosure are as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a text classification model training method is provided, comprising:
[0006] Obtaining a sample text; a single sample text includes: a body text and a title corresponding to the body text;
[0007] Inputting the sample text into a text classification model to be trained to generate a text semantic feature vector of the body of the sample text in different dimensions and a title semantic feature vector of the title of the sample text in the different dimensions; wherein the maximum dimension of the different dimensions is determined based on the number of preset text classification labels;
[0008] From the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions, select at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension as a first type of semantic feature vector pair;
[0009] Based on the positive and negative sample types of the sample text, the parameters of the text classification model are adjusted so as to maximize or minimize the value of the text semantic feature vector in the first category of semantic feature vector pairs and the value of the title semantic feature vector in the first category of semantic feature vector pairs, thereby performing training on the text classification model to be trained.
[0010] In an optional implementation, the positive and negative sample types based on the sample text are adjusted by adjusting the parameters of the text classification model so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, and the training of the trained text classification model is performed, specifically comprising:
[0011] If the type of the sample text is a positive sample, the parameters of the text classification model are adjusted to maximize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, thereby performing training of the text classification model;
[0012] If the type of the sample text is a negative sample, the parameters of the text classification model are adjusted to minimize the value of the text semantic feature vector in the first category of semantic feature vector pairs and the value of the title semantic feature vector in the first category of semantic feature vector pairs, thereby performing training on the text classification model.
[0013] In an optional implementation, the text classification model training method further includes:
[0014] From the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions, at least one pair of text semantic feature vectors and title semantic feature vectors that match different preset text classification labels and have the same dimensions are selected as the second type of semantic feature vector pair;
[0015] The method of training the text classification model to be trained by adjusting the parameters of the text classification model based on the positive and negative sample types of the sample text so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, further includes:
[0016] If the type of the sample text is a positive sample, the training of the text classification model is performed by adjusting the parameters of the text classification model so as to minimize the value of the text semantic feature vector in the second type of semantic feature vector pair and the value of the title semantic feature vector in the second type of semantic feature vector pair.
[0017] In an optional implementation, at least one pair of text semantic feature vectors and title semantic feature vectors matching the same text classification label and having the same dimension is selected from the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions as the first type of semantic feature vector pair, specifically including:
[0018] Selecting a specified number of text semantic feature vectors in order from large to small according to the values of the text semantic feature vectors under the different dimensions;
[0019] Selecting the specified number of title semantic feature vectors in order from large to small according to the values of the title semantic feature vectors in the different dimensions;
[0020] From the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors, select at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension as the first type of semantic feature vector pair.
[0021] In an optional implementation, according to any of the text classification model training methods, the text classification model to be trained includes a pseudo twin neural network; then, the sample text is input into the text classification model to be trained to generate a text semantic feature vector of the body of the sample text in different dimensions and a title semantic feature vector of the title of the sample text in the different dimensions, specifically including:
[0022] The main text and title in the sample text are respectively input into the two-sided neural networks of the pseudo-twin neural network to obtain the main text semantic feature vectors of the main text of the sample text in different dimensions, and the title semantic feature vectors of the title of the sample text in the different dimensions.
[0023] According to a second aspect of an embodiment of the present disclosure, a text classification method is provided, including:
[0024] Acquire text data; the text data includes a text and a title corresponding to the text;
[0025] The text data is input into a trained text classification model to obtain a classification label for the text data.
[0026] According to a third aspect of an embodiment of the present disclosure, a text classification model training device is provided, comprising:
[0027] The sample acquisition module is configured to acquire sample text; a single sample text includes: a body text and a title corresponding to the body text;
[0028] A generating module is configured to input the sample text into a text classification model to be trained, so as to generate a text semantic feature vector of the body of the sample text in different dimensions, and a title semantic feature vector of the title of the sample text in the different dimensions; wherein the maximum dimension among the different dimensions is determined based on the number of preset text classification labels;
[0029] A first-category semantic feature vector pair generation module is configured to select at least one pair of the text semantic feature vector and the title semantic feature vector that match the same text classification label and have the same dimension from the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions as the first-category semantic feature vector pair;
[0030] An execution training module is configured to execute positive and negative sample types based on the sample text, and to train the text classification model to be trained by adjusting the parameters of the text classification model so as to maximize or minimize the value of the text semantic feature vector in the first category semantic feature vector pair generated by the first category semantic feature vector pair generation module and the value of the title semantic feature vector in the first category semantic feature vector pair generated by the first category semantic feature vector pair generation module.
[0031] According to a fourth aspect of an embodiment of the present disclosure, a text classification device is provided, including:
[0032] An acquisition module is configured to acquire text data; the text data includes a text and a title corresponding to the text;
[0033] The classification module is configured to input the text data into a trained text classification model to obtain a classification label for the text data.
[0034] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0035] A processor; a memory for storing instructions executable by the processor;
[0036] Wherein, the processor is configured to execute any one of the steps of the text classification model training method in the first aspect above.
[0037] According to a sixth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the text classification model training methods in the first aspect.
[0038] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, which, when executed on an electronic device, enables the text classification model training electronic device to perform: the method steps of any one of the text classification model training methods in the first aspect above.
[0039] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0040] When training a text classification model, by respectively generating a text semantic feature vector and a title semantic feature vector of a text sample, and selecting a first type of semantic feature vector pair from the generated text semantic feature vector and title semantic feature vector, the text classification model is trained by adjusting the model parameters so that the value of the text semantic feature vector and the value of the title semantic feature vector in the selected first type of semantic feature vector pair are maximized or minimized, so that the classification result of the text of the text sample output by the model and the classification result of the title of the text sample are consistent. When the classification result of the text of the text sample output by the text classification model and the classification result of the title of the text sample are consistent, it is considered that this is a trained text classification model, and the classification result output by the trained text classification model can accurately express the category of the text sample. Further, a large amount of text data can be automatically and accurately classified by the trained text classification model.
[0041] On the other hand, since the number of text classification labels can be set in advance, in practical applications, a larger number of text classification labels can be set as needed, so that the text classification model trained by the solution of the present invention can have the following features: automatically matching corresponding text classification labels for text data from as rich text classification labels as possible. Therefore, compared with the method of manual annotation classification, the efficiency of text classification can be improved, and accurate text classification can be achieved.
[0042] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings herein are incorporated into the specification and constitute a part of the present disclosure, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0044] Figure 1 The figure is a flowchart of a text classification model training method according to an exemplary embodiment.
[0045] Figure 2 It is a schematic diagram of the structure of a neural network according to an exemplary embodiment.
[0046] Figure 3 It is a schematic diagram of the structure of a specific neural network according to an exemplary embodiment.
[0047] Figure 4 The figure is a flow chart of a text classification method according to an exemplary embodiment.
[0048] Figure 5 It is a block diagram of a text classification model training device according to an exemplary embodiment.
[0049] Figure 6 The invention is a block diagram of a device for text classification according to an exemplary embodiment.
[0050] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0051] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0053] The technical solution provided in this article is applied to the field of machine learning technology. Machine learning technology can realize the intelligence of machines by training models and is widely used in practical scenarios such as classification and clustering. Machine learning can use digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Machine learning is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Machine learning enables machines to have the functions of perception, reasoning and decision-making by studying the design principles and implementation methods of various intelligent machines.
[0054] Figure 1 is a flowchart of a text classification model training method according to an exemplary embodiment. Figure 1As shown, the method can achieve accurate classification of text. The execution subject of the method includes but is not limited to servers, personal computers, laptops, tablet computers, smart phones and other intelligent electronic devices that can execute predetermined processing processes such as numerical calculations and / or logical calculations by running predetermined programs or instructions. Among them, the server can be a single network server or a server group composed of multiple network servers or a cloud composed of a large number of computers or network servers based on cloud computing. The method can include the following steps:
[0055] In step 11, sample text is obtained.
[0056] In one or more embodiments of the present disclosure, a single sample text may include: a body text and a title corresponding to the body text. For example, the sample text may be news, specifically including news content and news title, or may be paper content and paper title.
[0057] In a specific implementation, the sample text can be divided into positive samples and negative samples. In one or more embodiments of the present disclosure, a single positive sample may include: a text and a title matching the text, which can be understood as the text of the text and the original title of the text. For example, the content of a certain news is "Xiaomi mobile phone held a new mobile phone conference with model XX at a certain time and place", and the original title matching the news content can be "Xiaomi mobile phone conference", and it can be known that the title matching the text can be a title that can reflect the content of the text; correspondingly, a single negative sample may include: a text and a title that does not match the text, which can be understood as the text of the text and a non-original title that does not match the text, wherein the non-original title that does not match the text can be any title other than the original title of the text, for example, the content of the above news is "Xiaomi mobile phone held a new mobile phone conference with model XX at a certain time and place", and the non-original title that does not match the news content can be "a certain singer's concert", and it can be known that the title that does not match the text can be a title that cannot reflect the content of the text.
[0058] In practical applications, positive and negative samples can be constructed through manual annotation.
[0059] In step 12, the sample text obtained in step 11 is input into the text classification model to be trained to generate text semantic feature vectors of the body of the sample text in different dimensions and title semantic feature vectors of the title of the sample text in different dimensions.
[0060] In practical applications, considering that in the embodiments of the present disclosure, a text semantic feature vector and a title semantic feature vector will be generated for the title and text of the sample text respectively for model training, the inventors have examined the models in the related art that can be used to process two inputs. After research, it was found that there are two models in the related art that process different inputs, namely the twin neural network model and the pseudo-twin neural network model. Among them, the former is suitable for processing situations where the two inputs are "relatively similar". The latter is suitable for processing situations where the two inputs are "certainly different". For example, if you want to calculate the semantic similarity of two sentences or words, use the former; if you want to verify whether the descriptions of the title and the text are consistent, consider using the latter.
[0061] Based on the fact that the sample text in the embodiment of the present disclosure contains two parts, namely the main text and the title, and it is also verified whether the title and the main text description are consistent, the text classification model in the embodiment of the present disclosure can be a pseudo-twin neural network.
[0062] By adopting the pseudo-twin neural network, semantic feature vectors can be extracted for the main text and title respectively, so that model training can be carried out by combining the main text and title features of the sample text.
[0063] In practical applications, the pseudo-twin neural network may include two inputs and two-sided neural networks. The types of the two-sided neural networks may specifically be convolutional neural networks (CNN) or recurrent neural networks (RNN).
[0064] The structural diagram of the pseudo-twin neural network can be shown as follows Figure 2 As shown, it specifically includes: input layer, embedding layer, neural network (NN) layer, ultra-high dimensional representation layer, matching layer. In practical applications, the neural networks on both sides of the pseudo twin neural network can use the same type of neural network or different types of neural networks. This application does not limit the specific type of neural network used.
[0065] In one or more embodiments of the present disclosure, the main text and title in the sample text can be respectively input into the two-sided neural networks of the pseudo-twin neural network, so as to obtain the main text semantic feature vectors of the sample text in different dimensions and the title semantic feature vectors of the title of the sample text in the different dimensions.
[0066] Specifically, the text and title of the text sample can be passed through the input layer, embedding layer, NN layer and ultra-high dimensional representation layer of the neural network on both sides to obtain the text semantic feature vector and title semantic feature vector in different dimensions. The different dimensions here can include 1 dimension to L dimension. The maximum dimension, i.e. L, can be determined based on the number of preset text classification labels. For example, L can be the same as the number of preset text classification labels - for example, if there are 10,000 preset text classification labels, then L = 10,000.
[0067] The number of preset text classification labels here may be a manually set number, which can be understood as setting how many categories the text samples are divided into, and the set number may generally be in the millions, etc. The specific number value may be determined according to actual conditions.
[0068] It is understandable that the more text classification labels there are, the more refined the classification results output by the model can be, and the effect of fine-grained classification of text can be achieved.
[0069] In practical applications, the model can adopt an unsupervised learning method to classify text samples according to the number of preset text classification labels, that is, output the classification results of the text samples, and further output the text classification label of each text sample.
[0070] In practical applications, the specific form of a text classification label can be a string composed of characters or numbers output by the model.
[0071] In step 13, at least one pair of text semantic feature vectors and title semantic feature vectors matching the same text classification label and having the same dimension is selected from the text semantic feature vectors under different dimensions and the title semantic feature vectors under different dimensions as the first type of semantic feature vector pair.
[0072] Here, the text semantic feature vectors in different dimensions and the title semantic feature vectors in different dimensions may be generated through step 12.
[0073] In practical applications, the degree of text semantics expressed by text semantic feature vectors in different dimensions may be different, or in other words, the values of text semantic feature vectors in different dimensions may be different. Generally, it can be considered that the value of the text semantic feature vector is relatively large, indicating that the text feature vector expresses the text semantics with high accuracy; similarly, the value of the title semantic feature vector is large, indicating that the text feature vector expresses the title semantics with high accuracy. Conversely, the value of the text / title semantic feature vector is relatively small, indicating that the text / title semantic feature vector expresses the text / title semantics with low accuracy.
[0074] In one or more embodiments of the present disclosure, selecting at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension from the text semantic feature vectors under different dimensions and the title semantic feature vectors under different dimensions as the first type of semantic feature vector pair may specifically include:
[0075] Selecting a specified number of text semantic feature vectors in order from large to small according to the values of the text semantic feature vectors under different dimensions;
[0076] Selecting the specified number of title semantic feature vectors in order from large to small according to the values of the title semantic feature vectors in different dimensions;
[0077] From the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors, at least one pair of text semantic feature vectors and title semantic feature vectors matching the same text classification label and having the same dimension is selected as a first type of semantic feature vector pair.
[0078] Among them, selecting a specified number of text semantic feature vectors in sequence may include arranging the values of the text semantic feature vectors from large to small according to the values of the text semantic feature vectors in different dimensions, and selecting the first K text semantic feature vectors in the arrangement results in sequence. The K here can be the specified number. In practical applications, the specified number can be determined according to actual needs, for example, it can be 1 or 3.
[0079] Accordingly, selecting a specified number of title semantic feature vectors in sequence may include arranging the values of the title semantic feature vectors from large to small according to the values of the title semantic feature vectors in different dimensions, and selecting the first K title semantic feature vectors in the arrangement results in sequence.
[0080] In the disclosed embodiment, by selecting the larger text semantic feature vector among the values of the text semantic feature vector under different dimensions and the larger title semantic feature vector among the values of the title semantic feature vector under different dimensions, and then forming a first type of semantic feature vector, the samples used for training the model can at least include samples that can relatively accurately express the semantics of the text and title, so as to ensure that the model output results can match the actual semantics of the sample text as much as possible in the subsequent model training process.
[0081] In practical applications, the number of selected title semantic feature vectors and text semantic feature vectors can be the same, so as to facilitate the subsequent selection of the first type of semantic feature vector pairs.
[0082] In order to understand how to select the first type of semantic feature vector pairs, such as Figure 3As shown, the embodiments of the present disclosure are explained in combination with the ultra-high dimensional representation layer and the matching layer.
[0083] Among them, in the ultra-high-dimensional representation layer, the TopK text semantic feature vectors are selected, that is, the first K text semantic feature vectors in the arrangement result are selected. If the specified number is set to 3, then in the neural network on the side corresponding to the text, 3 text semantic feature vectors can be selected in descending order according to the value of the text semantic feature vector. It is assumed that these 3 text semantic feature vectors include: 2-dimensional text semantic feature vector, (L-2)-dimensional text semantic feature vector and (L-1)-dimensional text semantic feature vector.
[0084] In practical applications, it can be considered that these three text semantic feature vectors can be the three text semantic feature vectors that most accurately express the semantics of the text, or it can be said that the classification result of the text of the text sample output by the model at this time can be the classification label corresponding to these three text semantic feature vectors.
[0085] Accordingly, the TopK title semantic feature vectors are selected, that is, the first K title semantic feature vectors in the arrangement result are selected. If the specified number is set to 3, in the neural network on one side corresponding to the title, 3 title semantic feature vectors can be selected according to the order of the title semantic feature vector values from large to small. It is assumed that these 3 title semantic feature vectors include: a 2-dimensional title semantic feature vector, a 3-dimensional title semantic feature vector, and a (L-1)-dimensional title semantic feature vector.
[0086] In practical applications, it can be considered that these three title semantic feature vectors can be the three title semantic feature vectors that most accurately express the semantics of the title, or it can be said that the classification result of the title output by the model at this time can be the classification label corresponding to these three title semantic feature vectors.
[0087] Next, in the matching layer, mapping matching is performed based on the dimensions.
[0088] It can be known that among the three selected text semantic feature vectors and the three title semantic feature vectors, the 2-dimensional text semantic feature vector and the 2-dimensional title semantic feature vector are semantic feature vectors of the same dimension, that is, it can be considered that the 2-dimensional text semantic feature vector and the 2-dimensional title semantic feature vector are mapped and matched. When the selected text semantic feature vector and the selected title semantic feature vector contain the text semantic feature vector and the title semantic feature vector of the same dimension, it can be considered that the text classification labels corresponding to the selected text semantic feature vector and the selected title semantic feature vector of the same dimension can jointly represent the category of the text sample, that is, the text classification labels corresponding to the selected text semantic feature vector and the selected title semantic feature vector of the same dimension are the same. Then, the selected 2-dimensional text semantic feature vector and the 2-dimensional title semantic feature vector can be a first-class semantic feature vector pair that matches the same text classification label and has the same dimension. It can be understood that, for positive samples, generally speaking, the selected first-class semantic feature vector pair can include at least one pair.
[0089] In practical applications, after selecting a specified number of text semantic feature vectors, the vector values of other unselected text semantic feature vectors can be set to 0, and after selecting a specified number of title semantic feature vectors, the vector values of other unselected title semantic feature vectors can be set to 0, so as to distinguish the selected text semantic feature vectors and title semantic feature vectors within the specified number from other unselected semantic feature vectors.
[0090] The text semantic feature vector and the title semantic feature vector after the vector value is set to 0 can be considered as feature vectors that cannot accurately represent the text semantics and the title semantics.
[0091] In practical applications, such as Figure 3 As shown, in the selected text semantic feature vector and the selected title semantic feature vector, except for the case where the mapping match can be achieved, for example, Figure 3 In addition to the 2-dimensional text semantic feature vector and the 2-dimensional title semantic feature vector, and the (L-1)-dimensional text semantic feature vector and the (L-1)-dimensional title semantic feature vector, there are also cases where there is no mapping match, that is, only the selected text semantic feature vector or only the selected title semantic feature vector is included in the same dimension - for example, Figure 3 The 3-dimensional title semantic feature vector and the (L-2)-dimensional text semantic feature vector in .
[0092] For the case where there is no mapping match, it can be considered that the text classification label corresponding to the title semantic feature vector can only represent the category of the title of the text sample, and the text classification label corresponding to the text semantic feature vector can only represent the category of the text of the text sample, and they cannot jointly represent the category of the text sample.
[0093] In one or more embodiments of the present disclosure, among the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors, the text semantic feature vectors other than the first type of semantic feature vector pairs and the title semantic feature vectors under the same dimension that are not selected within the specified number can be used as the second type of semantic feature vector pairs. For example, Figure 3 The (L-2)-dimensional text semantic feature vector selected in the middle box and the title semantic feature vector under this dimension that is not selected in the specified data can be the second type of semantic feature vector pair.
[0094] As described above, the title semantic feature vectors not selected within the specified number may be title semantic feature vectors whose vector values are set to 0, that is, the text classification label corresponding to the title semantic feature vector whose vector value is set to 0 cannot accurately represent the category of the title, while the main text semantic feature vectors selected within the specified number can accurately represent the category of the text. Then, it can be considered that the main text semantic feature vectors selected within the specified number and the title semantic feature vectors not selected within the specified number under the same dimension may be second-type semantic feature vector pairs corresponding to different text classification labels and having the same dimension.
[0095] Correspondingly, among the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors, the title semantic feature vectors other than the first type of semantic feature vector pairs and the text semantic feature vectors under the same dimension that are not selected within the specified number can also be used as the second type of semantic feature vector pairs. Figure 3 The 3-dimensional title semantic feature vector selected in the box and the text semantic feature vector under this dimension that is not selected in the specified data can be the second type of semantic feature vector pair.
[0096] As described above, the main text semantic feature vector that is not selected within the specified number can be a main text semantic feature vector whose vector value is set to 0, that is, the text classification label corresponding to the main text semantic feature vector whose vector value is set to 0 cannot accurately represent the category of the main text, while the text classification label corresponding to the title semantic feature vector selected within the specified number can accurately represent the category of the title. Then it can be considered that the main text semantic feature vector selected within the specified number and the title semantic feature vector that is not selected within the specified number under the same dimension can be a pair of second-type semantic feature vectors corresponding to different text classification labels and having the same dimension. It can be understood that for negative samples, generally speaking, the selected second-type semantic feature vector pair can include at least one pair.
[0097] In step 14, based on the positive and negative sample types of the sample text, the parameters of the text classification model are adjusted so that the value of the text semantic feature vector in the first type of semantic feature vector pair selected in step 13 and the value of the title semantic feature vector in the first type of semantic feature vector pair selected in step 13 are maximized or minimized, thereby performing training on the text classification model to be trained.
[0098] In practical applications, during the model training process, for positive and negative samples of text samples, the expected model output results can usually be different.
[0099] In the disclosed embodiment, since the positive sample can be a sample consisting of a text and a title matching the text, the expected output result for the positive sample can specifically include: the category of the text output by the expected model and the category of the output title are the same. It can be understood that when the category of the text output by the model is the same as the category of the title, it is considered that the category output by the model can accurately represent the category of the positive sample. If different categories appear, it can be considered that the model is not a well-trained text classification model.
[0100] For negative samples, since negative samples can be samples consisting of the main text and a title that does not match the main text, the expected output result for the negative samples can specifically include: the category of the main text output by the expected model and the category of the output title are different. It can be understood that since the main text and the title do not match, the category of the main text and the category of the title can be different. When the same category appears, it can also be considered that the model is not a well-trained text classification model.
[0101] In the model training process, since the expected model output results for the positive and negative sample types of the text samples are usually different, in one or more embodiments of the present disclosure, the text classification model training process may specifically include:
[0102] If the type of the sample text is a positive sample, the parameters of the text classification model are adjusted to maximize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, thereby performing training of the text classification model;
[0103] If the type of the sample text is a negative sample, the parameters of the text classification model are adjusted to minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, and the training of the text classification model is performed.
[0104] Wherein, adjusting the parameters of the text classification model may specifically include: adjusting the value of the text semantic feature vector and the value of the title semantic feature vector in the first type of semantic feature vector pair according to the loss value predicted by the objective function or loss function, etc., and the positive and negative sample types of the text sample. Wherein, the predicted loss value may specifically be the cosine distance between the text semantic feature vector and the title semantic feature vector under the same dimension predicted.
[0105] Specifically, for positive samples, iterative training is performed by increasing the value of the text semantic feature vector and the value of the title semantic feature vector in the first category of semantic feature vector pairs, so that the category of the text and the category of the title in the output results of the text classification model are the same. It can be understood that through iterative training, the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors contain the first category of semantic feature vector pairs, but do not contain the second category of semantic feature vector pairs.
[0106] For negative samples, iterative training is performed by reducing the value of the text semantic feature vector and the value of the title semantic feature vector in the first category of semantic feature vector pairs, so that the category of the text and the category of the title in the output results of the text classification model to be trained are different. It can be understood that through iterative training, the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors contain the second category of semantic feature vector pairs, but do not contain the first category of semantic feature vector pairs.
[0107] As described above, since in the training process of the text classification model, for the positive samples, the category of the text output by the expected model and the category of the output title are the same, then for the positive samples, in addition to performing the training of the text classification model in a manner that maximizes the value of the text semantic feature vector and the value of the title semantic feature vector in the first category of semantic feature vector pairs, in one or more embodiments of the present disclosure, the training process of the text classification model may also include: adjusting the parameters of the text classification model in a manner that minimizes the value of the text semantic feature vector in the second category of semantic feature vector pairs and the value of the title semantic feature vector in the second category of semantic feature vector pairs, and performing the training of the text classification model.
[0108] Specifically, for positive samples, iterative training can be performed by increasing the value of the text semantic feature vector and the value of the title semantic feature vector in the first type of semantic feature vector pair, and decreasing the value of the text semantic feature vector and the value of the title semantic feature vector in the second type of semantic feature vector pair based on the loss value predicted by the objective function or loss function, so that the category of the text and the category of the title in the results output by the text classification model are the same.
[0109] Correspondingly, the adjustment of the parameters of the text classification model may also include: adjusting the value of the text semantic feature vector and the value of the title semantic feature vector in the second type of semantic feature vector pair according to the loss value predicted by the objective function or the loss function, and the positive and negative sample types of the text sample.
[0110] In the disclosed embodiment, in addition to the first type of semantic feature vector pairs, semantic feature vector pairs consisting of text semantic feature vectors and title semantic feature vectors that match different text classification labels and have the same dimension (called second type of semantic feature vector pairs) can also be selected for model training.
[0111] The advantage of doing so is that the performance of the model is generally determined by two factors: one is the characteristics of the training samples; the other is the number of training samples. In the embodiment of the present disclosure, by selecting the second type of semantic feature vector pairs as training samples, the number of training samples can be sufficiently rich, thereby ensuring that the model has good performance.
[0112] Through the disclosed embodiments, when training a text classification model, by respectively generating a text semantic feature vector and a title semantic feature vector of a text sample, and selecting a first type of semantic feature vector pair and a second type of semantic feature vector pair from the generated text semantic feature vector and title semantic feature vector, and adjusting model parameters according to the types of positive and negative samples of the text sample, the text classification model is trained. During the model training process, for positive samples, the classification results of the text output by the text classification model are consistent with the classification results of the title, and for negative samples, the classification results of the text output by the text classification model are inconsistent with the classification results of the title, so as to obtain a trained text classification model. Furthermore, a large amount of text data can be automatically and accurately classified through the trained text classification model.
[0113] On the other hand, since the number of text classification labels can be set in advance, in practical applications, a larger number of text classification labels can be set as needed, so that the text classification model trained by the solution of the present invention can have the following features: automatically matching corresponding text classification labels for text data from as rich text classification labels as possible. Therefore, compared with the method of manual annotation classification, the efficiency of text classification can be improved, and accurate text classification can be achieved.
[0114] Figure 4 is a flowchart of a text classification method based on a text classification model training method according to an exemplary embodiment. Figure 4 As shown, the method may include the following steps:
[0115] Step 21: Get text data.
[0116] The text data may include a text and a title corresponding to the text. In practical applications, the text data may specifically include a text and a title matching the text.
[0117] Step 22: Input the text data into the trained text classification model to obtain the classification label of the text data.
[0118] Optionally, the trained text classification model can be but is not limited to the above Figure 1 The training method of the text classification model shown is trained. The relevant description of the training method for the text classification model can be referred to Figure 1 To avoid redundancy, the contents shown are not described here again.
[0119] Among them, the neural network used in the text classification model can adopt the pseudo-twin neural network described in the above-mentioned embodiment of the present disclosure. Based on the text classification model using the pseudo-twin neural network in the above-mentioned embodiment of the present disclosure, the classification label of the text data containing two parts of content, the text data of the main text and the title, can be accurately output, that is, the category of the text data can be output.
[0120] In practical applications, after a large amount of text data is classified, it can be used to recommend texts to online users in a personalized manner based on the classification labels of the text data, that is, to recommend content that users may be interested in, so as to improve the user experience.
[0121] By adopting the text classification method in the embodiment of the present disclosure, it is possible to achieve automatic and accurate classification of text. Compared with manual classification, a large amount of text data can be automatically classified, and the accuracy and efficiency of text classification are improved.
[0122] Figure 5 is a block diagram of a text classification model training device according to an exemplary embodiment. Figure 5 The device includes a sample acquisition module 32, a generation module 33, a first type semantic feature vector pair generation module 34, and an execution module 35.
[0123] The sample acquisition module 32 is configured to acquire sample text; a single sample text includes: a body text and a title corresponding to the body text;
[0124] The generating module 33 is configured to input the sample text into the text classification model to be trained, so as to generate the text semantic feature vector of the body of the sample text in different dimensions, and the title semantic feature vector of the title of the sample text in different dimensions; wherein the maximum dimension among the different dimensions is determined based on the number of preset text classification labels;
[0125] The first type semantic feature vector pair generating module 34 is configured to select at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension from the text semantic feature vectors under different dimensions and the title semantic feature vectors under different dimensions as the first type semantic feature vector pair;
[0126] The execution training module 35 is configured to execute positive and negative sample types based on sample text, and to perform training on the text classification model to be trained by adjusting the parameters of the text classification model so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair generated by the first type of semantic feature vector pair generation module and the value of the title semantic feature vector in the first type of semantic feature vector pair generated by the first type of semantic feature vector pair generation module.
[0127] The specific workflow of the above-mentioned device embodiment is: a sample acquisition module 32, which acquires sample text; a generation module 33, which inputs the sample text into the text classification model to be trained to generate text semantic feature vectors of the text of the sample text in different dimensions and title semantic feature vectors of the title of the sample text in different dimensions; a first-category semantic feature vector pair generation module 34, which selects at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimensions from the text semantic feature vectors in different dimensions and the title semantic feature vectors in different dimensions as the first-category semantic feature vector pair; and an execution training module 35, which adjusts the parameters of the text classification model based on the positive and negative sample types of the sample text so as to maximize or minimize the value of the text semantic feature vector in the first-category semantic feature vector pair generated by the first-category semantic feature vector pair generation module and the value of the title semantic feature vector in the first-category semantic feature vector pair generated by the first-category semantic feature vector pair generation module, thereby performing training on the text classification model to be trained.
[0128] In one embodiment, the execution training module 35 specifically includes:
[0129] A first positive sample training unit is configured to perform, if the type of the sample text is a positive sample, training of the text classification model by adjusting parameters of the text classification model so as to maximize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair;
[0130] The negative sample training unit is configured to perform training of the text classification model by adjusting the parameters of the text classification model if the type of the sample text is a negative sample, so as to minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair.
[0131] In one embodiment, the text classification model training device further includes: a second type of semantic feature vector pair generation module; the second type of semantic feature vector pair generation module is configured to select at least one pair of text semantic feature vectors and title semantic feature vectors that match different preset text classification labels and have the same dimensions from the text semantic feature vectors under different dimensions and the title semantic feature vectors under different dimensions as the second type of semantic feature vector pair; then,
[0132] The execution training module 35 also includes: a second positive sample training subunit; the second positive sample training subunit is configured to execute, if the type of the sample text is a positive sample, the parameters of the text classification model to be trained are adjusted so as to minimize the value of the text semantic feature vector in the second type of semantic feature vector pair and the value of the title semantic feature vector in the second type of semantic feature vector pair, to perform training of the text classification model.
[0133] In one embodiment, the first type semantic feature vector pair generating module 34 specifically includes:
[0134] The first selection unit is configured to select a specified number of text semantic feature vectors in order from large to small according to the values of the text semantic feature vectors under different dimensions;
[0135] The second selection unit is configured to select the specified number of title semantic feature vectors in order from large to small according to the values of the title semantic feature vectors in different dimensions;
[0136] The first-category semantic feature vector pair selection unit is configured to select at least one pair of text semantic feature vectors and title semantic feature vectors that match the same preset text classification label and have the same dimension from a specified number of selected text semantic feature vectors and a specified number of title semantic feature vectors as the first-category semantic feature vector pair.
[0137] In one embodiment, the text classification model to be trained includes a pseudo-twin neural network; then,
[0138] The generation module 33 is configured to specifically input the main text and title in the sample text into the two-side neural networks of the pseudo-twin neural network respectively, so as to obtain the main text semantic feature vector of the main text of the sample text in different dimensions, and the title semantic feature vector of the title of the sample text in the different dimensions.
[0139] Through the disclosed embodiments, when training a text classification model, by respectively generating a text semantic feature vector and a title semantic feature vector of a text sample, and selecting a first type of semantic feature vector pair and a second type of semantic feature vector pair from the generated text semantic feature vector and title semantic feature vector, and adjusting model parameters according to the type of positive and negative samples of the text sample, the text classification model is trained, and during the model training process, the classification result of the text output for the positive sample and the classification result of the title are consistent, while the classification result of the text output for the negative sample and the classification result of the title are inconsistent, so as to obtain a trained text classification model. Furthermore, a large amount of text data can be automatically and accurately classified through the trained text classification model.
[0140] On the other hand, since the number of text classification labels can be set in advance, in practical applications, a larger number of text classification labels can be set as needed, so that the text classification model trained by the solution of the present invention can have the following features: automatically matching corresponding text classification labels for text data from as rich text classification labels as possible. Therefore, compared with the method of manual annotation classification, the efficiency of text classification can be improved, and accurate text classification can be achieved.
[0141] Figure 6 is a block diagram of a text classification device according to an exemplary embodiment. Figure 6 The device includes an acquisition module 41 and a classification module 42.
[0142] The acquisition module 41 is configured to execute acquisition of text data; the text data includes a text and a title corresponding to the text;
[0143] The classification module 42 is configured to input the text data into a trained text classification model to obtain a classification label for the text data.
[0144] The specific working process of the above device embodiment is that the acquisition module 41 acquires text data, and the classification module 42 inputs the text data into a trained text classification model to obtain a classification label for the text data.
[0145] By using the text classification device in the embodiment of the present disclosure, automatic and accurate classification of text can be achieved. Compared with manual labeling of categories, a large amount of text data can be automatically classified, and the accuracy and efficiency of text classification are improved.
[0146] The present disclosure also provides an electronic device, the schematic diagram of which can be seen in FIG. Figure 7 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0147] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0148] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0149] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a text classification model training device at the logical level. The processor executes the program stored in the memory and is used to perform at least the following operations:
[0150] Obtain sample text; a single sample text includes: a body text and a title corresponding to the body text;
[0151] Inputting the sample text into the text classification model to be trained to generate the text semantic feature vector of the body of the sample text in different dimensions and the title semantic feature vector of the title of the sample text in different dimensions; wherein the maximum dimension among the different dimensions is determined based on the number of preset text classification labels;
[0152] From the text semantic feature vectors under different dimensions and the title semantic feature vectors under different dimensions, select at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension as the first type of semantic feature vector pair;
[0153] Based on the positive and negative sample types of the sample text, the parameters of the text classification model are adjusted to maximize or minimize the value of the text semantic feature vector in the first category of semantic feature vector pairs and the value of the title semantic feature vector in the first category of semantic feature vector pairs, thereby performing training on the text classification model to be trained.
[0154] The above application Figure 1The method performed by the text classification model training device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (FP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0155] The electronic device may also perform Figure 1 Method for executing text classification model training device in Chinese, and realizing text classification model training device in Figure 1 The functions of the illustrated embodiments will not be described in detail in the embodiments of the present disclosure.
[0156] The embodiment of the present invention further 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 embodiment of the text classification model training method 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.
[0157] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0158] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A text classification model training method, characterized in that: include: Get sample text; The single sample text includes: a body text and a title corresponding to the body text; Inputting the sample text into a text classification model to be trained to generate a text semantic feature vector of the body of the sample text in different dimensions and a title semantic feature vector of the title of the sample text in the different dimensions; wherein the maximum dimension of the different dimensions is determined based on the number of preset text classification labels; Selecting a specified number of text semantic feature vectors in descending order of the values of the text semantic feature vectors under the different dimensions; selecting a specified number of title semantic feature vectors in descending order of the values of the title semantic feature vectors under the different dimensions; selecting at least one pair of text semantic feature vectors and title semantic feature vectors that match the same text classification label and have the same dimension from the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors as a first-category semantic feature vector pair; From the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions, at least one pair of text semantic feature vectors and title semantic feature vectors that match different text classification labels and have the same dimensions are selected as second-category semantic feature vector pairs, wherein, among the selected specified number of text semantic feature vectors and the selected specified number of title semantic feature vectors, the text semantic feature vectors other than those constituting the first-category semantic feature vector pairs and the title semantic feature vectors under the same dimension that are not selected within the specified number are selected as second-category semantic feature vector pairs; Based on the positive and negative sample types of the sample text, the parameters of the text classification model are adjusted so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, thereby training the text classification model to be trained; If the type of the sample text is a positive sample, the parameters of the text classification model are adjusted so as to minimize the value of the text semantic feature vector in the second type of semantic feature vector pair and the value of the title semantic feature vector in the second type of semantic feature vector pair, thereby performing training of the text classification model; The method of training the text classification model to be trained by adjusting the parameters of the text classification model based on the positive and negative sample types of the sample text so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair specifically includes: If the type of the sample text is a positive sample, the parameters of the text classification model are adjusted to maximize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair, thereby performing training of the text classification model; If the type of the sample text is a negative sample, the parameters of the text classification model are adjusted to minimize the value of the text semantic feature vector in the first category of semantic feature vector pairs and the value of the title semantic feature vector in the first category of semantic feature vector pairs, thereby performing training on the text classification model.
2. The text classification model training method according to claim 1, characterized in that: The text classification model to be trained includes a pseudo-twin neural network; then, Inputting the sample text into the text classification model to be trained to generate the text semantic feature vector of the body of the sample text in different dimensions and the title semantic feature vector of the title of the sample text in the different dimensions, specifically including: The main text and title in the sample text are respectively input into the two-sided neural networks of the pseudo-twin neural network to obtain the main text semantic feature vectors of the main text of the sample text in different dimensions, and the title semantic feature vectors of the title of the sample text in the different dimensions.
3. A text classification method based on the text classification model training method according to claim 1, characterized in that: The text classification method comprises: Acquire text data; the text data includes a text and a title corresponding to the text; The text data is input into a trained text classification model to obtain a classification label for the text data.
4. A text classification model training device, characterized in that: include: A sample acquisition module is configured to execute acquisition of sample text; The single sample text includes: a body text and a title corresponding to the body text; A generating module is configured to input the sample text into a text classification model to be trained, so as to generate a text semantic feature vector of the body of the sample text in different dimensions, and a title semantic feature vector of the title of the sample text in the different dimensions; wherein the maximum dimension among the different dimensions is determined based on the number of preset text classification labels; A first-category semantic feature vector pair generation module is configured to select at least one pair of the text semantic feature vector and the title semantic feature vector that match the same text classification label and have the same dimension from the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions as the first-category semantic feature vector pair; The second type of semantic feature vector pair generation module is configured to select at least one pair of text semantic feature vectors and title semantic feature vectors that match different text classification labels and have the same dimension from the text semantic feature vectors under the different dimensions and the title semantic feature vectors under the different dimensions as the second type of semantic feature vector pair, wherein, among the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors, the text semantic feature vectors other than those constituting the first type of semantic feature vector pairs and the title semantic feature vectors under the same dimension that are not selected within the specified number are used as the second type of semantic feature vector pairs; An execution training module is configured to execute positive and negative sample types based on the sample text, and to train the text classification model to be trained by adjusting the parameters of the text classification model so as to maximize or minimize the value of the text semantic feature vector in the first type of semantic feature vector pair generated by the first type of semantic feature vector pair generation module and the value of the title semantic feature vector in the first type of semantic feature vector pair generated by the first type of semantic feature vector pair generation module; The execution training module further includes: a second positive sample training unit configured to execute, if the type of the sample text is a positive sample, the parameters of the text classification model to be trained are adjusted so as to minimize the value of the text semantic feature vector in the second type of semantic feature vector pair and the value of the title semantic feature vector in the second type of semantic feature vector pair, to execute the training of the text classification model; The first type of semantic feature vector pair generation module specifically includes: The first selection unit is configured to select a specified number of text semantic feature vectors in order from large to small according to the values of the text semantic feature vectors under the different dimensions; The second selection unit is configured to select the specified number of title semantic feature vectors in sequence according to the values of the title semantic feature vectors in different dimensions from large to small; A first-category semantic feature vector pair selection unit is configured to select at least one pair of the text semantic feature vector and the title semantic feature vector that match the same text classification label and have the same dimension from the selected specified number of text semantic feature vectors and the specified number of title semantic feature vectors as the first-category semantic feature vector pair; The execution training module specifically includes: A first positive sample training unit is configured to perform, if the type of the sample text is a positive sample, training the text classification model by adjusting the parameters of the text classification model so as to maximize the value of the text semantic feature vector in the first type of semantic feature vector pair and the value of the title semantic feature vector in the first type of semantic feature vector pair; The negative sample training unit is configured to perform training of the text classification model by adjusting the parameters of the text classification model if the type of the sample text is a negative sample, so as to minimize the value of the text semantic feature vector in the first category of semantic feature vector pairs and the value of the title semantic feature vector in the first category of semantic feature vector pairs.
5. The text classification model training device according to claim 4, characterized in that: The text classification model to be trained includes a pseudo-twin neural network; then, The generation module is configured to specifically input the main text and title in the sample text into the two-side neural networks of the pseudo-twin neural network respectively, so as to obtain the main text semantic feature vector of the main text of the sample text in different dimensions, and the title semantic feature vector of the title of the sample text in the different dimensions.
6. A text classification device based on the text classification model training device according to claim 4, characterized in that: The text classification device comprises: An acquisition module is configured to acquire text data; the text data includes a text and a title corresponding to the text; The classification module is configured to input the text data into a trained text classification model to obtain a classification label for the text data.
7. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the text classification model training method as described in any one of claims 1 to 3.
8. A storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the text classification model training method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Sentiment word extension-based short text sentiment classifying method
CN108376133A
System-log classification method
CN108427720A
Small sample video identification method
CN108537119A
Document recommending method, device, equipment and computer readable medium
CN108897871A
Text classification method combining title and text attention mechanism
CN109753567A
