Text Classification Method, Apparatus, Computer Device, and Storage Medium
Through the cross-language text classification method, the correlation analysis model is used to combine the text feature vectors of the first and second languages, and the problem of insufficient annotation text in the cross-language text classification is solved, and text type annotation is realized in the first language without type annotation, which improves the expansion speed of text classification.
Patent Information
- Application Number
- CN202011520850.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2040-12-21
AI Technical Summary
When classifying cross-language texts, the prior art faces the problem of insufficient labeling text, especially when text in the first language does not have type labeling, it is difficult to realize effective text type labeling.
The first natural language processing model obtains the feature vector of the first language text, combines the correlation analysis of the embedded vector of the target text type and the second language text feature vector, and uses the correlation analysis model to determine the type of text to be classified to realize cross-language text classification.
When the first language text has no type annotation, accurate text type annotation is realized, which improves the expansion speed of text classification among texts in different languages.
Smart Images

Figure CN113392211B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a text classification method, apparatus, computer equipment and storage medium. Background Art
[0002] Currently, text classification is widely used in content-related products, such as news classification, article classification, and intent classification. Generally, text classification is targeted at text in a specific language, such as Chinese or English. However, when a product needs to expand into other languages, insufficient annotated text may be encountered in the early stages of the product.
[0003] In related technologies, this problem is solved with the help of a translation model and a small amount of annotations. That is, when a text in the first language has a large number of type annotations, a first text with a large number of type annotations can be obtained by combining the translation model with a second text with a small number of type annotations. However, this solution still requires the first text to have a certain amount of type annotations. Summary of the Invention
[0004] Embodiments of the present invention provide a text classification method, apparatus, computer device, and storage medium, which can implement type annotation of a first language text with the aid of annotated second language text when the first language text does not have type annotation.
[0005] An embodiment of the present invention provides a text classification method, which includes:
[0006] Obtaining a first text feature vector of a text to be classified by using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language;
[0007] Obtaining a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type;
[0008] Analyzing the correlation between the first text feature vector and the target embedding vector based on the correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model to obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model and the first natural language processing model have the same training task;
[0009] The text type of the text to be classified is determined according to the correlation analysis result.
[0010] An embodiment of the present invention further provides a text classification device, comprising:
[0011] a language processing unit, configured to obtain a first text feature vector of a text to be classified using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language;
[0012] an embedding unit, configured to obtain a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type;
[0013] a correlation analysis unit, configured to analyze the correlation between the first text feature vector and the target embedding vector using a correlation relationship between the target embedding vector and a second text feature vector provided by a correlation analysis model, and obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model and the first natural language processing model have the same training task;
[0014] The classification unit is used to determine the text type of the text to be classified according to the correlation analysis result.
[0015] In an optional example, the apparatus of this embodiment further includes:
[0016] Analysis model training unit, used for:
[0017] Extracting a second text feature vector from the second sample text using the trained second natural language processing model, wherein the second sample text has a type label, the type label includes a real text type of the second sample text, and the real text type includes the target text type;
[0018] Obtaining an embedding vector corresponding to a preset text type, where the embedding vector is used to represent the preset text type and includes feature information of a text in a second language under the preset text type;
[0019] Based on the second text feature vector and the embedding vector, obtaining a correlation sample, the correlation sample including the second text feature vector and the embedding vector, the sample label of the correlation sample including: label information for indicating whether the real text type is related to the preset text type;
[0020] Analyzing the correlation between the second text feature vector and the embedding vector in the correlation sample by using the correlation relationship between the embedding vector provided by the correlation analysis model to be trained and the second text feature vector;
[0021] Based on the correlation analysis result and the sample label, the parameters of the correlation analysis model are adjusted until a training end condition of the correlation analysis model is met, wherein the parameters include parameters corresponding to the correlation relationship.
[0022] In an optional example, the apparatus of this embodiment further includes: a natural language model training unit, configured to:
[0023] Obtaining a first sample text, and mapping the first sample text into a target vector space using a first natural language processing model to be trained to obtain a feature vector of the first sample text;
[0024] Obtaining a first task result corresponding to the training task of the first natural language processing model based on the first sample text feature vector, and adjusting parameters of the first natural language processing model based on the first task result to obtain a trained first natural language processing model;
[0025] Obtaining a second sample text, and mapping the second sample text to the target vector space using a second natural language processing model to be trained to obtain a feature vector of the second sample text;
[0026] Based on the second sample text feature vector, a second task result corresponding to the training task of the second natural language processing model is obtained, and the parameters of the second natural language processing model are adjusted based on the second task result to obtain a trained second natural language processing model.
[0027] In an optional example, the analysis model training unit is used to:
[0028] Convert the preset text type into an initial vector of a specific vector format;
[0029] Performing word-missing processing on the second sample text to obtain a post-word-missing text, and extracting a third text feature vector of the post-word-missing text using the second natural language processing model;
[0030] Obtaining a prediction sample, where the prediction sample includes the third text feature vector and the initial vector, and a prediction sample label of the prediction sample includes words missing from the second sample text;
[0031] Mapping the third text feature vector and the initial vector using a text prediction model, and predicting the missing words in the post-missing-word text based on the mapping result to obtain a predicted missing word;
[0032] Adjusting the parameters of the text prediction model according to the predicted missing words and the predicted sample labels to obtain an adjusted text prediction model;
[0033] The initial vector of the preset text type is mapped using the adjusted text prediction model to obtain an embedding vector of the preset text type.
[0034] In an optional example, the text prediction model includes a mapping layer and a prediction layer, the mapping layer having mapping parameters; and an analysis model training unit, configured to:
[0035] splicing the third text feature vector and the initial vector to obtain a spliced vector, and using the spliced vector as a prediction sample;
[0036] Mapping the concatenated vector using the mapping parameters of the mapping layer to obtain a mapping vector;
[0037] Analyzing the mapping vector by the prediction layer to predict the missing words in the text after the missing words to obtain the predicted missing words;
[0038] Obtaining mapping sub-parameters of the initial vector from the mapping parameters according to the position of the initial vector in the concatenated vector;
[0039] The initial vector is mapped based on the mapping sub-parameter to obtain an embedding vector of a preset text type.
[0040] In an optional example, the number of the target text types is at least two;
[0041] A correlation analysis unit, configured to analyze the correlation between the first text feature vector and each target embedding vector based on the correlation relationship between the target embedding vector and the second text feature vector corresponding to each target text type provided by the correlation analysis model, and obtain a correlation score for the text to be classified under each target text type, wherein the correlation score is used to indicate the likelihood that the text type of the text to be classified is the target text type;
[0042] The classification unit is used to determine the target text type with the highest relevance score, which is the text type of the text to be classified.
[0043] In an optional example, the correlation analysis model includes at least one classification module, wherein one classification module corresponds to one text type;
[0044] Correlation analysis unit, used to:
[0045] Inputting the first text feature vector and the target embedding vector into a classification module corresponding to the target text type;
[0046] The correlation between the target embedding vector and the second text feature vector provided by each classification module is analyzed to obtain the correlation score of the text to be classified under each target text type.
[0047] This embodiment further provides a storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the text classification method described above.
[0048] This embodiment also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-described text classification method when executing the program.
[0049] The present embodiment discloses a text classification method, apparatus, computer equipment and storage medium, which obtains a first text feature vector of a text to be classified through a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text of the first language; obtains a target embedding vector of a target text type, wherein the target embedding vector is used to characterize the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type; analyzes the correlation between the target embedding vector and the second text feature vector provided by a correlation analysis model, and obtains a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in the second language, and the second natural language processing model has the same training task as the first natural language processing model; determines the text of the text to be classified according to the correlation analysis result. Type, in this embodiment, the training task of the second natural language processing model is the same as that of the first natural language processing model, which can make an approximate linear mapping relationship exist between the text feature vectors in the first language and the second language, and the target embedding vector includes the feature information of the text in the second language under the target text type, so that the correlation relationship provided by the correlation analysis model can accurately express the relationship between the target embedding vector of the target text type and the second text feature vector. Therefore, on the basis of the special relationship between the first and second text feature vectors, the correlation relationship provided by the correlation analysis model can accurately analyze the correlation between the first text feature vector and the target embedding vector, thereby obtaining the relationship between the type of the text to be classified and the target text, thereby finally realizing the classification of the text to be classified in the first language without the first sample text of the first language having a type annotation, realizing cross-language classification in the case of no type annotation in one language, which is conducive to improving the expansion speed of text classification between texts in different languages. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1a is a schematic diagram of a text classification system provided by an embodiment of the present invention;
[0052] Figure 1b is a flowchart of a text classification method provided by an embodiment of the present invention;
[0053] Figure 2a is a flowchart of a training method for a correlation analysis model provided by an embodiment of the present invention;
[0054] Figure 2b 1 is a schematic diagram of training a natural language processing model provided by an embodiment of the present invention;
[0055] Figure 2c 1 is a schematic diagram of a method for obtaining an embedding vector according to an embodiment of the present invention;
[0056] Figure 2d Schematic diagram of the structure of the text prediction model provided by an embodiment of the present invention;
[0057] Figure 2e Schematic diagram of the principle of the correlation analysis model provided by an embodiment of the present invention;
[0058] Figure 2f Schematic diagram of classifying text to be classified based on a correlation analysis model provided by an embodiment of the present invention;
[0059] Figure 3 1 is a structural diagram of a text classification device provided by an embodiment of the present invention;
[0060] Figure 4 It is a structural diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.
[0062] Embodiments of the present invention provide a text classification method, apparatus, computer device, and storage medium. Specifically, embodiments of the present invention provide a text classification method applicable to a computer device. The computer device may be a terminal, such as a mobile phone, tablet computer, or laptop computer. The computer device may also be a server, such as a single server or a server cluster consisting of multiple servers.
[0063] For example, a text classification device can be integrated into the terminal.
[0064] In this embodiment, the text classification method can be executed by the terminal or the server alone, or can be executed by the terminal and the server together.
[0065] The embodiment of the present invention will take a computer device as a server as an example to introduce a text classification method.
[0066] refer to Figure 1a An embodiment of the present invention provides a text classification system including a terminal 10 and a server 20; the terminal 10 and the server 20 are connected via a network, such as a wired or wireless network, wherein a text classification device is integrated in the server 20.
[0067] Among them, the server 20 can be used to obtain a first text feature vector of the text to be classified through a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text of the first language; obtain a target embedding vector of the target text type, wherein the target embedding vector is used to characterize the target text type, and the target embedding vector includes feature information of the text in the second language under the target text type; analyze the correlation between the target embedding vector and the second text feature vector provided by the correlation analysis model, and obtain a correlation analysis result, wherein the second text feature vector is extracted from the second sample text by the second natural language processing model, the second sample text is a text in the second language, and the second natural language processing model has the same training task as the first natural language processing model; determine the text type of the text to be classified according to the correlation analysis result.
[0068] Among them, the producer of the text to be classified is not limited, and it can be uploaded to the server 20 by the user through the terminal 10. After receiving the text to be classified, the server 20 can execute the above scheme to obtain its text type, and then store the text to be classified and the text type in the server 20 accordingly.
[0069] It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0070] The embodiment of the present invention will be described from the perspective of a text classification device, which can be specifically integrated in a server, or can also be integrated in a terminal. Compared with related technologies, the text classification method of this embodiment can classify text in the first language without any type of annotation in the text of the first language.
[0071] The embodiment of the present invention provides a text classification method, which can be executed by a processor of a server, such as Figure 1b As shown, the specific process of the text classification method can be as follows:
[0072] 101. Obtaining a first text feature vector of a text to be classified using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language;
[0073] In one example, the first language and the second language described below are different, and the specific languages of the two languages are not limited, such as English, Korean, Chinese, Japanese, etc., which are not limited in this embodiment.
[0074] The first natural language processing model of this embodiment and the second natural language model described below (which may be respectively referred to as Pre-Model A and Pre-Model B) are models that can be constructed using any existing natural language processing (NLP) principles, which can extract text feature vectors from text. The training tasks of the first natural language processing model and the second natural language processing model are the same, but the training tasks are not limited. In one example, the training tasks can be predicting missing words in a text, predicting the answer information of a text (question), and so on.
[0075] In a special example, the first natural language processing model and the second natural language processing model can be the same model. Since the models are the same, the training tasks are naturally the same. In other examples, the first natural language processing model and the second natural language processing model can be two independent models. In this embodiment, the training tasks of the first natural language processing model and the second natural language processing model are the same, which can make the text feature vector extracted from the text of the first language by the first natural language processing model (i.e., the first text feature vector) and the text feature vector extracted from the text of the second language by the second natural language processing model (i.e., the second text feature vector) have an approximate linear mapping relationship, so that the correlation relationship between the target embedding vector and the second text feature vector learned by the correlation analysis model in the following text can be applied to the correlation analysis of the first text feature vector and the target embedding vector, thereby realizing cross-language text type labeling and ensuring good results.
[0076] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to linguistics. NLP technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0077] In this embodiment, the first natural language processing model and the second natural language model can be based on text preprocessing technology, such as word / sentence segmentation, word / sentence classification, and semantic understanding technology, such as morphological analysis, syntactic analysis, and semantic analysis.
[0078] Among them, the first natural language processing model and the second natural language model can be: BERT (Bidirectional Encoder Representations from Transformers, dialogue model) model, RoBERTa (A Robustly Optimized BERT Pretraining Approach) improved dialogue model, etc.
[0079] The model structures of the first natural language processing model and the second natural language processing model can be the same. For example, both models include a vector mapping layer and a task layer, wherein the vector mapping layer is used to extract text feature vectors from the text, and the task layer is used to obtain the task results of the model based on the text feature vectors. For example, if the task is a classification layer, a classification result is obtained; if the task is to output missing words in the text, the task result is the predicted missing words. This embodiment has no restrictions on this. After the first and second natural language processing models are trained, only the vector mapping layer can be used to obtain the text feature vectors of the text.
[0080] The vector mapping layer may further include at least one network layer, and the type of the network layer is not limited, for example, it may include at least two convolutional layers.
[0081] Optionally, the step of “obtaining a first text feature vector of the text to be classified using a first natural language processing model” may include:
[0082] A first text feature vector of the text to be classified is obtained through a vector mapping layer of the first natural language processing model.
[0083] In this embodiment, the text feature vector extracted from the second language text using the second natural language processing model may be referred to as a second text feature vector.
[0084] The text feature vectors such as the first text feature vector and the second text feature vector in this embodiment may include underlying text information extracted from the text, such as character vectors, word vectors, syntax vectors, sentence vectors, and the like.
[0085] Optionally, the step of “obtaining a first text feature vector of the text to be classified through a vector mapping layer of the first natural language processing model” may include:
[0086] Obtaining sentence vectors of the text to be classified through the vector mapping layer of the first natural language processing model;
[0087] Based on all sentence vectors of the text to be classified, a first text feature vector of the text to be classified is obtained.
[0088] The sentence vectors may be concatenated in the order of the sentences in the text to be classified to obtain the first text feature vector.
[0089] Optionally, the step of “obtaining a first text feature vector of the text to be classified through a vector mapping layer of the first natural language processing model” may include:
[0090] Obtaining at least two of a character vector, a word vector, a syntactic vector, and a sentence vector of the text to be classified through a vector mapping layer of the first natural language processing model;
[0091] Perform vector fusion on the acquired vectors of the text to be classified to obtain a first text feature vector of the text to be classified.
[0092] In one example, the first natural language processing model and the second natural language processing model may be semantic recognition models, and the first text feature vector and the second text feature vector may be semantic feature vectors.
[0093] 102. Obtain a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a second language text of the target text type;
[0094] In this embodiment, the target embedding vector can be obtained based on label embedding technology. Specifically, a second language text with category annotations (i.e., type labels containing the actual text type) can be obtained, and the embedding vector of the actual text type can be obtained through label embedding technology. Label embedding refers to a technology that can summarize the embedding vector of a text category based on the common characteristics of text samples under a text category.
[0095] In this embodiment, the embedding vector for a particular text type includes information shared by all texts of that text type, learned from the text feature vectors of the texts of that text type (the vectors obtained by the aforementioned natural language processing model). In other words, the feature information of the second language text of the target text type included in the target embedding vector can be understood as feature information shared by all texts of the target text type in the second language.
[0096] To facilitate understanding of the embedding vector, we will now illustrate the scheme for obtaining the embedding vector. Optionally, the embedding vector is obtained based on the label embedding technology, see Figure 2c , the solution for obtaining the embedding vector corresponding to the preset text type may include:
[0097] Convert the preset text type into an initial vector of a specific vector format;
[0098] Performing word-missing processing on the second sample text to obtain a post-word-missing text, and extracting a third text feature vector of the post-word-missing text through a second natural language processing model;
[0099] Obtaining a prediction sample, where the prediction sample includes the third text feature vector and the initial vector, and the prediction sample label of the prediction sample includes the words missing in the second sample text;
[0100] Mapping the third text feature vector and the initial vector using a text prediction model, and predicting the missing words in the text after the missing words based on the mapping result to obtain the predicted missing words;
[0101] Adjust the text prediction model based on the predicted missing words and predicted sample labels until the text prediction model meets the training end conditions;
[0102] The initial vector of the preset text type is mapped through the text prediction model to obtain the embedded vector of the preset text type.
[0103] Among them, as long as the preset text type is set to the above-mentioned target text type, the target embedding vector of the target text type can be obtained.
[0104] The specific vector format may include a one-hot vector format, and the preset text type may be converted into a one-hot vector.
[0105] The converted one-hot vector can be determined based on the number of preset text types and the dimension of the second text feature vector. For example, if the number of preset text types is 8, the one-hot vector must be able to represent at least 8 different objects. In one example, the initial vector can be an 8-dimensional vector, with each position in the dimension representing a preset text type. For example, for text types 1-8, the initial vectors are 10000000, 01000000, 00100000, ..., 00000001, respectively.
[0106] Furthermore, if the dimension of the text feature vector is N*M, i.e., N rows and M columns, the preset text type can be converted into an N*1-dimensional one-hot vector, i.e., a one-hot vector, to facilitate the concatenation of the initial vector of the preset text type and the text feature vector.
[0107] The missing word processing of the second sample text may be random, that is, words in the second sample text are randomly selected and deleted.
[0108] Optionally, the step of "adjusting the text prediction model according to the predicted missing words and the predicted sample labels until the text prediction model meets the training end condition" may include:
[0109] Adjust the text prediction model based on the predicted missing words and predicted sample labels;
[0110] Return to the step of "performing word-missing processing on the second sample text to obtain a text after the word-missing text, and extracting a third text feature vector of the text after the word-missing text through the second natural language processing model" until the text prediction model meets the training end condition.
[0111] The model loss of the text prediction model can be calculated based on the difference between the predicted missing word and the words in the predicted sample label, and the text prediction model can be adjusted based on the loss function. Optionally, the word vector of the predicted missing word and the word vector of the predicted sample label can be obtained, and the model loss of the text prediction model can be calculated based on the vector similarity between the two word vectors. The vector similarity can be represented by vector distance.
[0112] The text prediction model meets the training end condition, which may include: the number of training times of the text prediction model exceeds a second preset training time threshold, or the model loss of the text prediction model is lower than a preset loss threshold.
[0113] Among them, the text prediction model can be constructed using common deep models such as Bert, CNN, RNN, and LSTM.
[0114] In this embodiment, Text A can represent the first sample text, and Text B can represent the second sample text. The text prediction model can be understood as a joint training model, which can be trained based on the third text feature vector and the initial vector of the preset text type. However, its prediction goal is to predict the word w that is cut out. Different prediction samples can be formed by cutting out different words w. For example, if the true text type of Text B (Tag B) is 0, cut out w1 and get a sample<X_B1,Y=0> , where Y is Tag B, remove w2 and get a sample<X_B2,Y=0> , remove w3 and get a sample<X_B3,Y=0> In this way, a large number of samples can be obtained to train the text prediction model.
[0115] refer to Figure 2d In one example, the text prediction model may include a mapping layer and a prediction layer, wherein the mapping layer has mapping parameters. The mapping parameters may be represented by a mapping matrix.
[0116] In this embodiment, the specific process of obtaining the prediction sample may include: splicing the third text feature vector and the initial vector to obtain a spliced vector, and using the spliced vector as the prediction sample.
[0117] Among them, a third text feature vector can be spliced with at least one initial vector, and the initial vector can be directly spliced after the third text feature vector. For example, the third text feature vector is an N*M vector, and the initial vector is an N*1 vector. After direct splicing, an N*(M+1) vector is obtained, and the vector in the last column of the spliced vector is the initial vector; or, the initial vector can also be inserted into the third text feature vector so that the initial vector has information of the third text feature vector before and after.
[0118] Optionally, the step of "mapping the third text feature vector and the initial vector through a text prediction model, and predicting the missing words in the text after the missing words based on the mapping results to obtain predicted missing words" may include: mapping the concatenated vector through mapping parameters of a mapping layer to obtain a mapping vector; analyzing the mapping vector through a prediction layer to predict the missing words in the text after the missing words to obtain predicted missing words.
[0119] In this embodiment, the initial vector is spliced into the third text feature vector, which is similar to writing the preset text type as a word into the second sample text, and the training task of the text prediction model is to identify the missing words in the prediction sample. Because of the missing words, in order to accurately predict the missing words, the text prediction model will refer to the context information when expressing each word, that is, the mapping layer of the text prediction model will also refer to the third text feature vector before and after the preset text type when mapping the initial vector of the preset text type. Therefore, the embedded vector of the preset text type learned by the text prediction model will include some information of the third text feature vector, and the text prediction model is constantly trained, and different third text features are used. There are differences between the feature vectors, but when the second sample text of the second language belongs to the same preset text type such as the target text type, the preset text type has some commonalities, and the differences of the different third text feature vectors cannot help achieve good predictions. During the training (parameter optimization) of the text prediction model, they are automatically eliminated (or their weights are reduced) by the text prediction model. The text prediction model will automatically increase the weight parameters of the feature information expressing the commonality of the third text feature vectors. As a result, the mapping layer learns more and more about the association between the preset text type and the third text feature vector, and the mapping sub-parameters of the preset text type increasingly contain common feature information in the text of the preset text type. This is also the reason why the target embedding vector of this embodiment includes the feature information common to the text of the second language under the target text type.
[0120] Correspondingly, the step of “mapping the initial vector of the preset text type through the text prediction model to obtain the embedding vector of the preset text type” may include:
[0121] According to the position of the initial vector in the concatenated vector, the mapping sub-parameters of the initial vector are obtained from the mapping parameters;
[0122] The initial vector is mapped based on the mapping sub-parameters to obtain an embedding vector of the preset text type.
[0123] For example, if the initial vector is in the last column of the concatenated vector, the parameters for mapping the last column vector of the concatenated vector are obtained from the mapping parameters as mapping sub-parameters of the initial vector.
[0124] The text in this embodiment can be of any nature, such as news text, article text, etc. These texts can be categorized into different text types based on their nature. The text types can be configured based on different dimensions, with multiple text types configured for each dimension. For example, for news text, the text types that can be configured based on the content dimension may include: sports news, technology news, entertainment news, etc.; the text types that can be configured based on the region dimension may include: domestic news, international news, etc. This embodiment imposes no restrictions on the configuration of text types.
[0125] 103. Analyze the correlation between the first text feature vector and the target embedding vector by using the correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model to obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model is trained on the same task as the first natural language processing model;
[0126] The correlation analysis model in this embodiment is trained based on the second text feature vector of the second sample text and the embedding vector of the real text type of the second sample text.
[0127] Among them, the embedding vector of the real text type of the second sample text can be achieved through the embedding vector acquisition scheme described above, which will not be repeated here.
[0128] From the above description of the scheme for obtaining the embedding vector of the preset text type, it can be seen that the target embedding vector contains the feature information of the text of the second language of the target text type, and is obtained based on the mapping of the third text feature vector embedded with the initial vector of the target text type. Therefore, there is also a certain correlation between the target embedding vector itself and the second text feature vector of the second sample text, or a certain mapping relationship. The text prediction model learns this correlation through training, that is, the correlation relationship in this embodiment. Therefore, the correlation relationship can more accurately reflect the correlation relationship between the target embedding vector and the second text feature vector of the second sample text of the target text type, and the first text feature vector and the second text feature vector have an approximately linear mapping relationship, so the correlation relationship can be well used to analyze the correlation between the first text feature vector and the target embedding vector.
[0129] In this embodiment, the correlation analysis model can be implemented based on the structure of any existing classification model. For example, the correlation analysis model can include fully connected layers. The number of fully connected layers can be determined by the number of text types in the classification tasks of the correlation analysis model. For example, if the correlation analysis model includes n (n>1) classification tasks, then the correlation analysis model includes n fully connected layers.
[0130] In order to have a detailed understanding of the correlation analysis model in this embodiment, the following first describes the training process of the correlation analysis model. The training of the correlation analysis model is performed before step 101.
[0131] refer to Figure 2a ,The training process of the correlation analysis model includes:
[0132] 201. Extracting a second text feature vector from a second sample text using the trained second natural language processing model, wherein the second sample text has a type label, the type label includes a real text type of the second sample text, and the real text type includes a target text type;
[0133] The second natural language processing model is trained based on a text sample of the second language. In one example, the second natural language processing model can directly use an already trained model. The training of the second natural language processing model can be completed before obtaining the second sample text.
[0134] For example, if the second language is Chinese, the second natural language processing model can be any model that can extract feature vectors of Chinese text. In this embodiment, any pre-trained second natural language processing model can be obtained to execute step 201. The first natural language processing model in this embodiment can be a model newly constructed based on the model structure of the pre-trained second natural language processing model after obtaining the model, and having the same training task.
[0135] The process of extracting the second text feature vector by the second natural language model can refer to the aforementioned description of the process of obtaining the first text feature vector, which will not be repeated here.
[0136] 202. Obtain an embedding vector corresponding to a preset text type, where the embedding vector is used to represent the preset text type and includes feature information of a second language text of the preset text type.
[0137] The embedding vector of the preset text type may be pre-stored in the server. In step 202 , the embedding vector may be directly obtained. The method for obtaining the embedding vector of the preset text type is described in the aforementioned example and will not be repeated here.
[0138] Alternatively, the server may store mapping parameters corresponding to the preset text type, and in step 202, the preset text type may be mapped to an embedding vector using the mapping parameters.
[0139] 203. Obtain a correlation sample based on the second text feature vector and the embedding vector, where the correlation sample includes the second text feature vector and the embedding vector, and the sample label of the correlation sample includes label information indicating whether the real text type is related to the preset text type;
[0140] 204. Analyze the correlation between the second text feature vector and the embedding vector in the correlation sample based on the correlation relationship between the embedding vector and the second text feature vector provided by the correlation analysis model to be trained;
[0141] 205. Based on the correlation analysis results and the sample labels, adjust the parameters of the correlation analysis model until the training end condition of the correlation analysis model is met, wherein the parameters include parameters corresponding to the correlation relationship.
[0142] It is understandable that as the correlation analysis model to be trained is trained more times, the correlation relationship between the embedding vector provided by the model and the second text feature vector will be continuously corrected, and the correlation relationship will become more and more accurate.
[0143] Adjusting the parameters of the correlation analysis model based on the correlation analysis results and sample labels may include:
[0144] Calculate the classification loss of the correlation analysis model based on the correlation classification results and sample labels;
[0145] Adjust the parameters of the correlation analysis module based on the classification loss.
[0146] The second text feature vector and the embedding vector in the above-mentioned correlation sample may exist independently or may be fused into a new vector, and this embodiment has no limitation on this.
[0147] Optionally, the training termination condition of the correlation analysis model may include the number of training times reaching a first preset training times threshold, or the classification loss being lower than a preset loss threshold.
[0148] In one example, the second natural language processing model can also be obtained through real-time training, that is, both the first natural language processing model and the second natural language processing model need to be trained in real time in this embodiment.
[0149] Optionally, before step 201, the following steps may also be included:
[0150] Obtaining a first sample text, and mapping the first sample text into a target vector space using a first natural language processing model to be trained to obtain a feature vector of the first sample text;
[0151] Obtaining a first task result corresponding to a training task of a first natural language processing model based on the first sample text feature vector, and adjusting parameters of the first natural language processing model based on the first task result to obtain a trained first natural language processing model;
[0152] Obtaining a second sample text, and mapping the second sample text into a target vector space using a second natural language processing model to be trained to obtain a feature vector of the second sample text;
[0153] Based on the second sample text feature vector, a second task result corresponding to the training task of the second natural language processing model is obtained, and the parameters of the second natural language processing model are adjusted based on the second task result to obtain a trained second natural language processing model.
[0154] The training tasks of the above two natural language processing models are the same. The text feature vectors extracted by the two natural language processing models can have the same vector dimension, and there is an approximate linear mapping relationship between the first and second text feature vectors.
[0155] For example, let Text A represent the first sample text and Text B represent the second sample text. Figure 2b ,Before step 201, two natural language processing models need to be trained.
[0156] After the natural language processing model training is completed, the first and second text feature vectors can be extracted respectively through two models. Pre(A) represents the first text feature vector and Pre(B) represents the second text feature vector. The relationship between Pre(A) and Pre(B) can be approximately expressed as: pre(A=a*pre(B))+b, where a>0 and b is arbitrary.
[0157] The training processes of the two natural language processing models can be independent of each other, and the order in which the two models are trained is not limited.
[0158] Alternatively, the training processes of the two natural language processing models can be correlated. It is understood that during model training, the correlation between the two text feature vectors increasingly approaches the relationship of the above expression. In one example, the training of the two models can be performed synchronously. After the training of the two models is completed, the value of a can be calculated based on the first text feature vector and the second text feature vector and the above formula. When a remains substantially stable, the model training termination condition can be considered met, and the training of the two models can be stopped.
[0159] In order to facilitate the understanding of the correlation analysis model, this embodiment Figure 2eThe model's schematic diagram is also shown. Unlike traditional classification tasks, this model no longer considers text classification as inputting text X and its category Y. Instead, it converts the task into inputting the label embeddings (embedding vectors) of text X and category Y, and outputting whether the two are related (represented by 0 / 1), or a correlation score. This allows full utilization of text type embeddings to address cross-language labeling challenges.
[0160] Figure 2e The samples and type labels in are processed by the previously trained second natural language processing model and mapping sub-parameters, respectively, and converted into new samples, such as<X_B1,Y=0> This original sample is transformed into <(X_B1,0),1>,<(X_B1,2),0>,<(X_B1,3),0>,<(X_B1,2),0>, where (X_B1,2) represents the input to the correlation analysis model: text X_B1 and text category 2 (corresponding vectors), and 0 indicates that X_B1 is not related to text type 2. Therefore, using the correlation analysis model training scheme, a highly accurate correlation analysis model can be trained to characterize the correlation between the text feature vector and the text type embedding vector.
[0161] In this embodiment, the correlation relationship between the second text feature vector and the embedding vector provided by the correlation analysis model can be expressed as f(pre(B), embed(Y)), where pre(B) represents the second text feature vector obtained by the second natural language processing model to extract features from the text of the second language, and embed(Y) represents the embedding vector of the text category Y. In view of the approximate linear mapping relationship between the first text feature vector pre(A) and the second text feature vector pre(B) given in the above content, see Figure 2f When the text type embedding vector label embedding, i.e., embed(Y), and the first text feature vector pre(A) are put together, after the Relation model analyzes the correlation, the correlation relationship between the first text feature vector and the embedding vector is obtained, i.e., f(a*pre(B)+b,embed(Y)). Here, a is the coefficient of the linear mapping relationship between the first text feature vector pre(A) and the second text feature vector pre(B), which can be extracted. The value of a may change, but it is still a positive number. b can be understood as a constant. Therefore, when the text feature vector X_A (text in the first language) is input into the correlation analysis model, the value of f is also a positive mapping compared to X_B (text in the second language). Therefore, the larger the value, the higher the corresponding Y label probability.
[0162] 104. Determine the text type of the text to be classified based on the correlation analysis results.
[0163] In this embodiment, the number of target text types is at least two; step 103 may specifically include:
[0164] The correlation relationship between the target embedding vector corresponding to each target text type and the second text feature vector provided by the correlation analysis model is used to analyze the correlation between the first text feature vector and each target embedding vector to obtain the correlation score of the text to be classified under each target text type, wherein the correlation score is used to indicate the possibility that the text type of the text to be classified is the target text type. In an example, the higher the correlation score, the higher the possibility that the text type of the text to be classified is the target text type.
[0165] Correspondingly, step 104 may specifically include: determining the target text type with the highest relevance score as the text type of the text to be classified.
[0166] The target text type with the highest correlation score may also be determined by a correlation analysis model, and this embodiment has no limitation on this.
[0167] Specifically, assuming there are text types 0-10, the label embeddings corresponding to text types 0-10 and the pre-trained representation of text X_A (the first text feature vector) are input into the correlation analysis model together to obtain the correlation scores corresponding to each text type. The text type with the highest correlation score can be determined as the text type of text X_A.
[0168] In an optional example, the structure of the correlation analysis model includes at least one classification module, wherein one classification module corresponds to one text type, and the step of "analyzing the correlation between the first text feature vector and each target embedding vector corresponding to each target text type provided by the correlation analysis model and the second text feature vector, and obtaining the correlation score of the text to be classified under each target text type" may include: inputting the first text feature vector and the target embedding vector into the classification module corresponding to the target text type; analyzing the correlation between the target embedding vector and the second text feature vector provided by each classification module, and obtaining the correlation score of the text to be classified under each target text type.
[0169] The classification module may include a fully connected layer, wherein the first text feature vector and the target embedding vector may be fused and input into the fully connected layer, and the fully connected layer scores the correlation between the first text feature vector and the target embedding vector.
[0170] Optionally, the first text feature vector and the target embedding vector may be concatenated and input into a fully connected layer.
[0171] Alternatively, in one example, the classification module may convolve the first text feature vector to extract a first convolution vector feature, convolve the target embedding vector to extract a second convolution vector feature, calculate similarity between the first convolution vector feature and the second convolution vector feature, and determine a correlation score based on the similarity. The higher the similarity, the higher the correlation score.
[0172] According to this embodiment, a first text feature vector of a text to be classified in a first language can be obtained through a first natural language processing model. A correlation analysis model is used to provide a correlation relationship between a target embedding vector of a target text type and a second text feature vector. The correlation between the first text feature vector and the target embedding vector is analyzed to determine the text type of the text to be classified. The second text feature vector is extracted from the text in the second language by a second natural language processing model. The target embedding vector includes feature information of the text in the second language under the target text type. Therefore, the accuracy of the correlation relationship can be guaranteed. Since the training tasks of the two language processing models are the same, there is an approximately linear mapping relationship between the two text feature vectors. Therefore, based on the correlation relationship, the correlation between the first text feature vector and the target embedding vector can be accurately analyzed to achieve text classification. Therefore, based on the second sample text with a small amount of text type annotation, the first sample text in the first language can be finally classified without the first sample text in the first language having a type annotation, achieving the purpose of cross-language classification in the absence of type annotation in one language, which is conducive to improving the expansion speed of text classification between texts in different languages.
[0173] In order to better implement the above method, the embodiment of the present invention also provides a text classification device, which can be integrated into a terminal or a server. Figure 3 The text classification device comprises:
[0174] A language processing unit 301 is configured to obtain a first text feature vector of a text to be classified using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language;
[0175] An embedding unit 302 is configured to obtain a target embedding vector for a target text type, wherein the target embedding vector is used to represent the target text type and includes feature information of a second language text of the target text type;
[0176] a correlation analysis unit 303 configured to analyze the correlation between the first text feature vector and the target embedding vector using a correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model, and obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text being a text in a second language, and the second natural language processing model having the same training task as the first natural language processing model;
[0177] The classification unit 304 is configured to determine the text type of the text to be classified according to the correlation analysis result.
[0178] In an optional example, the apparatus of this embodiment further includes:
[0179] Analysis model training unit, used for:
[0180] A second text feature vector is extracted from the second sample text through the trained second natural language processing model, wherein the second sample text has a type label, the type label includes a real text type of the second sample text, and the real text type includes a target text type.
[0181] Obtaining an embedding vector corresponding to a preset text type, where the embedding vector is used to represent the preset text type and includes feature information of a second language text of the preset text type;
[0182] Based on the second text feature vector and the embedding vector, obtaining a correlation sample, the correlation sample including the second text feature vector and the embedding vector, the sample label of the correlation sample including: label information for indicating whether the real text type is related to the preset text type;
[0183] Analyzing the correlation between the second text feature vector and the embedding vector in the correlation sample by using the correlation relationship between the embedding vector and the second text feature vector provided by the correlation analysis model to be trained;
[0184] Based on the correlation analysis results and the sample labels, the parameters of the correlation analysis model are adjusted until the training end condition of the correlation analysis model is met, wherein the parameters include parameters corresponding to the correlation relationship.
[0185] In an optional example, the apparatus of this embodiment further includes: a natural language model training unit, configured to:
[0186] Obtaining a first sample text, and mapping the first sample text into a target vector space using a first natural language processing model to be trained to obtain a feature vector of the first sample text;
[0187] Obtaining a first task result corresponding to a training task of a first natural language processing model based on the first sample text feature vector, and adjusting parameters of the first natural language processing model based on the first task result to obtain a trained first natural language processing model;
[0188] Obtaining a second sample text, and mapping the second sample text into a target vector space using a second natural language processing model to be trained to obtain a feature vector of the second sample text;
[0189] Based on the second sample text feature vector, a second task result corresponding to the training task of the second natural language processing model is obtained, and the parameters of the second natural language processing model are adjusted based on the second task result to obtain a trained second natural language processing model.
[0190] In an optional example, the analysis model training unit is used to:
[0191] Convert the preset text type into an initial vector of a specific vector format;
[0192] Performing word-missing processing on the second sample text to obtain a post-word-missing text, and extracting a third text feature vector of the post-word-missing text through a second natural language processing model;
[0193] Obtaining a prediction sample, where the prediction sample includes the third text feature vector and the initial vector, and the prediction sample label of the prediction sample includes the words missing in the second sample text;
[0194] Mapping the third text feature vector and the initial vector using a text prediction model, and predicting the missing words in the text after the missing words based on the mapping result to obtain the predicted missing words;
[0195] Adjust the parameters of the text prediction model according to the predicted missing words and the predicted sample labels to obtain an adjusted text prediction model;
[0196] The initial vector of the preset text type is mapped through the adjusted text prediction model to obtain the embedding vector of the preset text type.
[0197] In an optional example, the text prediction model includes a mapping layer and a prediction layer, wherein the mapping layer has mapping parameters; and an analysis model training unit, configured to:
[0198] Splicing the third text feature vector and the initial vector to obtain a spliced vector, and using the spliced vector as a prediction sample;
[0199] Map the concatenated vector using the mapping parameters of the mapping layer to obtain a mapping vector;
[0200] The mapping vector is analyzed through the prediction layer to predict the missing words in the text after the missing words are obtained;
[0201] According to the position of the initial vector in the concatenated vector, the mapping sub-parameters of the initial vector are obtained from the mapping parameters;
[0202] The initial vector is mapped based on the mapping sub-parameters to obtain an embedding vector of the preset text type.
[0203] In an optional example, the number of target text types is at least two;
[0204] A correlation analysis unit is configured to analyze the correlation between the first text feature vector and each target embedding vector based on the correlation relationship between the target embedding vector corresponding to each target text type and the second text feature vector provided by the correlation analysis model, and obtain a correlation score for the text to be classified under each target text type, wherein the correlation score is used to indicate the likelihood that the text type of the text to be classified is the target text type;
[0205] The classification unit is used to determine the target text type with the highest relevance score, which is the text type of the text to be classified.
[0206] In an optional example, the relevance analysis model includes at least one classification module, wherein one classification module corresponds to one text type;
[0207] Correlation analysis unit, used to:
[0208] Input the first text feature vector and the target embedding vector into a classification module corresponding to the target text type;
[0209] Through the correlation relationship between the target embedding vector and the second text feature vector provided by each classification module, the correlation between the target embedding vector and the first text feature vector is analyzed to obtain the correlation score of the text to be classified under each target text type.
[0210] By using the device of this embodiment, it is possible to ultimately classify the text to be classified in the first language when only the second sample text is type-labeled and the text sample of the first language is not type-labeled, thereby achieving the purpose of cross-language classification in the case of no type labeling in one language, which is conducive to improving the expansion speed of text classification between texts in different languages.
[0211] In addition, an embodiment of the present invention further provides a computer device, which may be a terminal or a server. Figure 4 , which shows a schematic diagram of the structure of a computer device involved in an embodiment of the present invention, specifically:
[0212] The computer device may include one or more processing core processors 401, one or more computer readable storage media memories 402, a power supply 403, an input unit 404 and other components. Those skilled in the art will understand that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.
[0213] Processor 401 is the control center of the computer device. It utilizes various interfaces and circuits to connect the various components of the entire computer device, runs or executes software programs and / or modules stored in memory 402, and accesses data stored in memory 402 to perform various functions of the computer device and process data, thereby performing overall testing of the computer device. Optionally, processor 401 may include one or more processing cores; preferably, processor 401 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 401.
[0214] The memory 402 can be used to store software programs and modules. The processor 401 runs the software programs and modules stored in the memory 402, thereby performing various functional applications and data processing. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may 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 may store data created according to the use of the computer device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0215] The computer device also includes a power supply 403 for supplying power to various components. Preferably, the power supply 403 can be logically connected to the processor 401 via a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 403 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0216] The computer device may further include an input unit 404, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0217] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the computer device will load the executable files corresponding to one or more application processes into the memory 402 according to the following instructions, and the processor 401 will run the application stored in the memory 402 to implement various functions as follows:
[0218] Obtaining a first text feature vector of a text to be classified by using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language;
[0219] Obtaining a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type;
[0220] Analyzing the correlation between the first text feature vector and the target embedding vector based on the correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model to obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model and the first natural language processing model have the same training task;
[0221] The text type of the text to be classified is determined according to the correlation analysis result.
[0222] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0223] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0224] To this end, an embodiment of the present invention further provides a storage medium storing a plurality of instructions, which can be loaded by a processor to execute the steps of any text classification method provided in an embodiment of the present invention.
[0225] According to one aspect of the present application, a computer program product or computer program is also provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.
[0226] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0227] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0228] Since the instructions stored in the storage medium can execute the steps in any text classification method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any text classification method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0229] The above is a detailed introduction to a text classification method, device, computer equipment and storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A text classification method, characterized in that: include: Obtaining a first text feature vector of a text to be classified by using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language; Obtaining a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type; The correlation between the target embedding vector and the second text feature vector provided by the correlation analysis model is analyzed, and the correlation between the first text feature vector and the target embedding vector is obtained, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model has the same training task as the first natural language processing model; the relationship between the first text feature vector and the second text feature vector is expressed as: pre(A)=a×pre(B)+b, a is the coefficient of the relationship between pre(A) and pre(B), b is a constant, Pre(A) represents the first text feature vector, Pre(B) represents the second text feature vector, and the first sample text and the second sample text are both mapped to the target vector space; The text type of the text to be classified is determined according to the correlation analysis result.
2. The text classification method according to claim 1, characterized in that Before obtaining the first text feature vector of the text to be classified by the first natural language processing model, the method further includes: Extracting a second text feature vector from the second sample text using the trained second natural language processing model, wherein the second sample text has a type label, the type label includes a real text type of the second sample text, and the real text type includes the target text type; Obtaining an embedding vector corresponding to a preset text type, where the embedding vector is used to represent the preset text type and includes feature information of a text in a second language under the preset text type; Based on the second text feature vector and the embedding vector, obtaining a correlation sample, the correlation sample including the second text feature vector and the embedding vector, the sample label of the correlation sample including: label information for indicating whether the real text type is related to the preset text type; Analyzing the correlation between the second text feature vector and the embedding vector in the correlation sample by using the correlation relationship between the embedding vector and the second text feature vector provided by the correlation analysis model to be trained; Based on the correlation analysis result and the sample label, the parameters of the correlation analysis model are adjusted until a training end condition of the correlation analysis model is met, wherein the parameters include parameters corresponding to the correlation relationship.
3. The text classification method according to claim 2, characterized in that Before extracting the second text feature vector from the second sample text, the trained second natural language processing model further includes: Obtaining a first sample text, and mapping the first sample text into a target vector space using a first natural language processing model to be trained to obtain a feature vector of the first sample text; Obtaining a first task result corresponding to the training task of the first natural language processing model based on the first sample text feature vector, and adjusting parameters of the first natural language processing model based on the first task result to obtain a trained first natural language processing model; Obtaining a second sample text, and mapping the second sample text to the target vector space using a second natural language processing model to be trained to obtain a feature vector of the second sample text; Based on the second sample text feature vector, a second task result corresponding to the training task of the second natural language processing model is obtained, and the parameters of the second natural language processing model are adjusted based on the second task result to obtain a trained second natural language processing model.
4. The text classification method according to claim 2, characterized in that The obtaining of the embedding vector corresponding to the preset text type includes: Convert the preset text type to the initial vector in one-hot vector format; Performing word-missing processing on the second sample text to obtain a post-word-missing text, and extracting a third text feature vector of the post-word-missing text using the second natural language processing model; Obtaining a prediction sample, where the prediction sample includes the third text feature vector and the initial vector, and a prediction sample label of the prediction sample includes words missing from the second sample text; Mapping the third text feature vector and the initial vector using a text prediction model, and predicting the missing words in the post-missing-word text based on the mapping result to obtain a predicted missing word; Adjusting the parameters of the text prediction model according to the predicted missing words and the predicted sample labels to obtain an adjusted text prediction model; The initial vector of the preset text type is mapped using the adjusted text prediction model to obtain an embedding vector of the preset text type.
5. The text classification method according to claim 4, characterized in that The text prediction model includes a mapping layer and a prediction layer, wherein the mapping layer has mapping parameters; and obtaining the prediction sample includes: splicing the third text feature vector and the initial vector to obtain a spliced vector, and using the spliced vector as a prediction sample; The method of mapping the third text feature vector and the initial vector by a text prediction model, and predicting the missing words in the post-missing-word text based on the mapping result to obtain the predicted missing words, includes: Mapping the concatenated vector using the mapping parameters of the mapping layer to obtain a mapping vector; Analyzing the mapping vector by the prediction layer to predict the missing words in the text after the missing words to obtain the predicted missing words; Mapping the initial vector of the preset text type by using the adjusted text prediction model to obtain the embedded vector of the preset text type includes: Obtaining mapping sub-parameters of the initial vector from the mapping parameters according to the position of the initial vector in the concatenated vector; The initial vector is mapped based on the mapping sub-parameter to obtain an embedding vector of a preset text type.
6. The text classification method according to any one of claims 1 to 5, characterized in that: The number of the target text types is at least two; The correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model, analyzing the correlation between the first text feature vector and the target embedding vector, and obtaining a correlation analysis result, including: Analyzing the correlation between the target embedding vector and the second text feature vector corresponding to each target text type provided by the correlation analysis model, the correlation between the first text feature vector and each target embedding vector is obtained, and a correlation score of the text to be classified under each target text type is obtained, wherein the correlation score is used to indicate the possibility that the text type of the text to be classified is the target text type; Determining the text type of the to-be-classified text according to the correlation analysis result includes: The target text type with the highest relevance score is determined as the text type of the text to be classified.
7. The text classification method according to claim 6, characterized in that The correlation analysis model includes at least one classification module, wherein one classification module corresponds to one text type; The correlation relationship between the target embedding vector and the second text feature vector corresponding to each target text type provided by the correlation analysis model, analyzing the correlation between the first text feature vector and each target embedding vector, and obtaining the correlation score of the text to be classified under each target text type, including: Inputting the first text feature vector and the target embedding vector into a classification module corresponding to the target text type; The correlation between the target embedding vector and the second text feature vector provided by each classification module is analyzed to obtain the correlation score of the text to be classified under each target text type.
8. A text classification device, characterized in that: include: a language processing unit, configured to obtain a first text feature vector of a text to be classified using a first natural language processing model, wherein the text to be classified is a text in a first language, and the first natural language processing model is trained based on a first sample text in the first language; an embedding unit, configured to obtain a target embedding vector of a target text type, wherein the target embedding vector is used to represent the target text type, and the target embedding vector includes feature information of a text in a second language under the target text type; A correlation analysis unit is configured to analyze the correlation between the first text feature vector and the target embedding vector through the correlation relationship between the target embedding vector and the second text feature vector provided by the correlation analysis model, and obtain a correlation analysis result, wherein the second text feature vector is extracted by a second natural language processing model from a second sample text, the second sample text is a text in a second language, and the second natural language processing model has the same training task as the first natural language processing model; the relationship between the first text feature vector and the second text feature vector is expressed as: pre(A)=a×pre(B)+b, where a is the coefficient of the relationship between pre(A) and pre(B), b is a constant, Pre(A) represents the first text feature vector, Pre(B) represents the second text feature vector, and the first sample text and the second sample text are both mapped to the target vector space; The classification unit is used to determine the text type of the text to be classified according to the correlation analysis result.
9. A storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Morphology analysis for machine translation
US20150154184A1
Text classification method, apparatus, computer device and storage medium
WO2020082569A1