A text classification method and related device
By training a general classification model with text samples that mix the first and second languages, the problem that classification models cannot be directly used in new language scenarios in the prior art is solved, and the rapid iterative text classification ability is achieved.
Patent Information
- Application Number
- CN202011222967.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-05
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2040-11-05
AI Technical Summary
When expanding language business, the original classification model cannot be used in new language scenarios and needs to be retrained. Due to the small number of labeled text and the long training cycle, it affects the rapid iteration of the product.
By obtaining a large number of first language text samples and a small number of second language text samples, mix and generate a training sample set, and train a general classification model to avoid the model fitting the first language features first and reduce the impact on the second language text classification ability.
It realizes general model training for text classification in a second language environment, reduces the time to wait for manual annotation, and improves the iteration speed of product expansion business.
Smart Images

Figure CN112214605B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a text classification method and related devices. Background Art
[0002] Text classification is often used in products related to text content, such as news classification, article classification, intent classification, etc. It is generally achieved by using classification models to identify and classify the text in news, articles, Moments, and comments.
[0003] Generally speaking, classification models used for text classification are mostly for texts in a certain language, such as Chinese, English, etc. However, when the product needs to expand its business in other languages, the originally practical network model will not be able to be used in the new language scenario, and the classification model suitable for the new language scenario can only be retrained.
[0004] However, in the early stages of expanding language services, the amount of annotated text needed to train classification models was very small, and the sample volume required for model training could only be accumulated slowly through manual annotation. This resulted in a long training cycle for classification models, which was not conducive to rapid product iteration. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a text classification method and related devices, which no longer require waiting for manual annotation of sufficient new language text samples, thereby improving the iteration speed of product expansion business.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] On the one hand, the present application provides a text classification method, the method comprising:
[0008] Acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, wherein the first sample set includes a first number of first text samples, and the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotated labels obtained based on the same annotation rule, and the first number is greater than the second number;
[0009] Generate a training sample set according to the first sample set and the second sample set;
[0010] Training an initial general classification model based on the training sample set to obtain a general classification model, wherein when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence for inputting the initial general classification model;
[0011] The unlabeled text is classified and labeled by using the general classification model, and the unlabeled text is text corresponding to the second language.
[0012] On the other hand, the present application provides a text classification device, the device comprising: an acquisition unit, a generation unit, a training unit and a classification unit;
[0013] The acquisition unit is used to acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, the first sample set includes a first number of first text samples, the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotated labels obtained based on the same annotation rule, and the first number is greater than the second number;
[0014] The generating unit is configured to generate a training sample set according to the first sample set and the second sample set;
[0015] The training unit is used to train an initial general classification model based on the training sample set to obtain a general classification model, and when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence input into the initial general classification model;
[0016] The classification unit is used to classify and annotate the unlabeled text by using the general classification model, and the unlabeled text is the text corresponding to the second language.
[0017] In another aspect, the present application provides a computer device, the device comprising a processor and a memory:
[0018] The memory is used to store program code and transmit the program code to the processor;
[0019] The processor is used to execute the method described in the above aspects according to the instructions in the program code.
[0020] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.
[0021] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes 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 the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.
[0022] It can be seen from the above technical solution that when the service is expanded from the text environment of the first language to the text environment of the second language, the number of second text samples with annotated labels corresponding to the second language is generally insufficient to realize the training of the classification model, so a first sample set corresponding to the first language and a second sample set corresponding to the second language can be obtained. Since a large number of first text samples with annotated labels can be obtained based on the text environment of the first language, the number of first text samples included in the first sample set will be greater than the number of second text samples included in the second text set. Since the first text sample and the second text sample have the annotation labels obtained based on the same annotation rule, that is, they have the same classification purpose, even if the languages are different, the identification meaning of the determined annotation labels is universal, so the first sample set and the second sample set can be mixed to generate a training sample set, and the initial general classification model is trained based on the training sample set including both the first text sample and the second text sample. During the training process, the first text sample and the second text sample will be used as input data of the initial general classification model in a similar alternating manner, so that during the training process, the initial general classification model can not only fully absorb the association between the text features and the annotation labels of the two languages, thereby learning the classification characteristics that are not related to the language itself, but also will not appear because the first text sample is continuously input during training, causing the model to first fit the associated knowledge of the first language, but instead reduce the classification ability of the second language text. In this way, it is achieved that a general classification model that can be used for text classification in the second language is trained with the help of a large number of accurate first text samples, and it is no longer necessary to wait for the time of manually annotating a sufficient number of second text samples, thereby improving the iteration speed of product expansion business. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 A schematic diagram of an application scenario of the text classification method provided in an embodiment of the present application;
[0025] Figure 2 A flowchart of a text classification method provided in an embodiment of the present application;
[0026] Figure 3 It is a schematic diagram of the corresponding texts in different languages;
[0027] Figure 4 A schematic diagram of a general classification model training framework provided in an embodiment of the present application;
[0028] Figure 5 A schematic diagram of a general classification model training process provided in an embodiment of the present application;
[0029] Figure 6 A schematic diagram of a general classification model training process provided in an embodiment of the present application;
[0030] Figure 7 A flowchart of a text classification method provided in an embodiment of the present application;
[0031] Figure 8 A schematic diagram of a text classification device provided in an embodiment of the present application;
[0032] Fig. 9 A schematic diagram of the structure of a server provided in an embodiment of the present application;
[0033] Fig.10 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The embodiments of the present application are described below in conjunction with the accompanying drawings.
[0035] In view of the problem in the related art that in the early stage of expanding language services from a first language to a second language, the number of second text samples with annotated labels required for training a classification model corresponding to the second language is very small, the present application proposes a text classification method and related devices, which realize the training of a general classification model that can be used for text classification in a second language with the help of a large number of first text samples with annotated labels corresponding to the first language.
[0036] The text classification method provided in the embodiment of the present application is based on artificial intelligence. Artificial Intelligence (AI) is a theory, method, technology and application system that uses 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. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.
[0037] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0038] In the embodiments of the present application, the artificial intelligence software technologies mainly involved include the above-mentioned natural language processing, machine learning / deep learning and other directions. For example, it may involve text preprocessing (Text preprocessing) and semantic understanding (Semantic understanding) in natural language processing (NLP), and it may also involve deep learning (Deep Learning) and transfer learning (transfer learning) in machine learning (Machine learning, ML), including various types of artificial neural networks (Artificial Neural Network, ANN).
[0039] The text classification method provided in this application can be applied to text classification devices with data processing capabilities, such as terminal devices and servers. Specifically, the terminal device can be a smart phone, a desktop computer, a laptop computer, a tablet computer, a smart speaker, a smart watch, etc., but is not limited thereto; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0040] The text classification device may have the ability to implement natural language processing, and NLP is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology generally includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph and other technologies. In an embodiment of the present application, the text classification device can process the text through technologies such as text preprocessing and semantic understanding in natural language processing.
[0041] The text classification device can have machine learning capabilities. Machine learning is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks.
[0042] The artificial intelligence model used in the text classification method provided in the embodiment of the present application mainly involves the application of neural networks, and the classification and labeling of texts are achieved through neural networks.
[0043] In order to facilitate understanding of the technical solution of the present application, the text classification method provided in the embodiment of the present application is introduced below in combination with actual application scenarios, taking the server as a text classification device.
[0044] See also Figure 1 , Figure 1 Schematic diagram of the application scenario of the text classification method provided in the embodiment of the present application. The actual application scenario is for a news reading product. When it is promoted from the Chinese market to the English market, it is necessary to have the ability to classify and annotate the English text involved, for example, it is possible to determine the annotation labels corresponding to English news, such as entertainment news, sports news, financial news, etc.
[0045] The server 100 obtains a first sample set 201 corresponding to a first language and a second sample set 202 corresponding to a second language. In this embodiment, the first language is Chinese, and the first sample set 201 includes a first number, for example, 10,000 first text samples.<X_A,Y> , X_A represents the text content of the first text sample, Y represents the annotation label corresponding to the text content, the second language is English, and the second sample set 202 includes a second number, for example, 100 second text samples<X_B,Y> , X_B represents the text content of the second text sample, and Y represents the annotation label corresponding to the text content.
[0046] It can be seen that the first text sample<X_A,Y> and the second text sample<X_B,Y> The annotation label Y is obtained based on the same annotation rule. The annotation label Y can represent different categories through different numbers. For example, Y=0 represents entertainment news, Y=1 represents sports news, and Y=2 represents financial news.
[0047] Although Chinese and English are different languages, the first text sample<X_A,Y> and the second text sample<X_B,Y> The corresponding label Y has a universal meaning. Thus, the first sample set 201 and the second sample set 202 can be mixed to generate a training sample set 203. Figure 1 As shown, according to the first text samples including 10000<X_A,Y> The first sample set 201 includes 100 second text samples<X_B,Y> The training sample set 203 is determined based on the second sample set 202 .
[0048] During training, the first text sample in the input sequence used to input the initial general classification model<X_A,Y> and the second text sample<X_B,Y> Mixed permutation, the input sequence identifier is based on the first text sample<X_A,Y> and the second text sample<X_B,Y> The purpose of the mixed arrangement is to avoid fitting the initial general classification model in the first language first, which will lead to a decrease in the classification ability of the general classification model for the second language text. Therefore, in the above training process, the first text sample in the training sample set 203<X_A,Y> and the second text sample<X_B,Y> will be used as input data for the initial general classification model in a similar alternating manner. For example, after training the two first text samples<X_A,Y> Then, train a second text sample<X_B,Y> Then train a first text sample<X_A,Y> , ···, until the initial general classification model is trained and the general classification model is obtained.
[0049] During the training process, the initial general classification model can not only fully absorb the relationship between the text features and annotation labels of Chinese and English, thereby learning classification characteristics that are unrelated to the language itself, but also avoid the problem of continuous input of the first text sample during training.<X_A,Y> This causes the model to first fit the associated knowledge of the first language, which in turn reduces the ability to classify second language texts.
[0050] Therefore, the unannotated English text<X_B> Input into the trained general classification model to obtain the unlabeled English text<X_B> The corresponding label Y category makes it possible to train a general classification model that can be used for text classification in English with the help of a large number of accurate Chinese samples. There is no need to wait for sufficient English samples to be manually labeled, which improves the iteration speed of the news reading product expansion business.
[0051] In conjunction with the accompanying drawings, a text classification method provided in an embodiment of the present application is introduced below using a server as a text classification device.
[0052] See also Figure 2, which is a flowchart of a text classification method provided by an embodiment of the present application. Figure 2 As shown, the text classification method includes the following steps:
[0053] S201: Acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language.
[0054] When the business of a product expands from the text environment of the first language to the text environment of the second language, in the early stage of the expansion of the second language text environment, the number of second text samples with annotated labels in the second sample set corresponding to the second language is small. If only a small number of second text samples are used to train the classification model required for the second language, the classification model will not be fully trained, and the generalization of the trained classification model is poor. If the second language text is slowly annotated manually to obtain the second text samples with annotated labels, it will not only waste manpower, but also lead to a long cycle for training the classification model required for the second language, which is not conducive to the rapid iteration of the product.
[0055] Based on this, when training the classification model required for the second language, in order to make the trained classification model more accurate and in a shorter time, more text samples can be obtained to train the classification model required for the second language. Therefore, the embodiment of the present application not only adopts the second sample set corresponding to the second language, but also adopts the first sample set corresponding to the first language. The first sample set includes a first number of first text samples, and the second sample set includes a second number of second text samples. Since the business of the product is relatively mature in the text environment of the first language, a large number of first text samples with annotated labels can be obtained. It can be understood that the first number will be greater than the second number.
[0056] Furthermore, although the first text sample and the second text sample correspond to the first language and the second language respectively and have different text contents, the first text sample and the second text sample have annotation labels obtained based on the same annotation rules, that is, they have the purpose of unified classification, and the identification meaning of the determined annotation labels is universal and has nothing to do with the language type. Therefore, even if the text contents of the first language and the second language are different, the classification model required for the second language can be trained with the help of the first text sample with annotation labels in the first sample set.
[0057] Thus, a first sample set corresponding to the first language and a second sample set corresponding to the second language can be obtained. Figure 3 , which is a schematic diagram of texts corresponding to different languages. In this figure, the left figure a represents the first sample set, including the first sample text with annotated labels, the middle figure b represents the second sample set, including the second sample text with annotated labels, and the right figure c represents the unannotated text corresponding to the second language, which is used for subsequent classification and annotation. Figure 3 It can be seen that the number of first text samples in the first sample set is greater than the number of second text samples in the second sample set.
[0058] S202: Generate a training sample set according to the first sample set and the second sample set.
[0059] Although the general classification model required for the second language can be trained with the help of the first text samples with annotated labels in the first sample set, the initial general classification model cannot be trained using only the first sample set. This is because the initial general classification model can only learn text features about the first language, and it is difficult to learn the relationship between the text features in the first language and the text features in the second language in classification. The model has poor generalization in the second language environment and cannot be used in the text environment of the second language.
[0060] Based on this, the embodiment of the present application mixes the first sample set and the second sample set to generate a training sample set, and uses the training sample set to train the general classification model required for the second language, so that the general classification model can not only learn about the text features of the first language, but also learn about the text features of the second language, thereby enabling the general classification model to be used in the text environment of the second language and have better generalization.
[0061] S203: Training an initial general classification model based on the training sample set to obtain a general classification model.
[0062] If, when using a training sample set to train an initial general classification model, the initial general classification model is first trained using a first sample set in the training sample set, and then the initial general classification model is continued to be trained using a second sample set in the training sample set, due to the large number of the first sample set, the initial general classification model will first be fitted based on the text features of the first language, and even overfitting may occur, resulting in that when the second sample set is used to continue training the initial general classification model, the initial general classification model pre-trained based on the first sample set is only applicable to the text environment of the first language because it is first fitted based on the text features of the first language, and thus cannot fully learn the text features of the second text samples in the second sample set, or even cannot learn the text features of the second text samples in the second sample set, thereby reducing the classification and recognition accuracy of the initial general classification model for the second language, and thus cannot better learn the text features of the second language in the subsequent training process.
[0063] In order to avoid the above situation, the first sample set can be avoided from being continuously input into the initial general classification model. When training the initial general classification model, the first text sample and the second text sample are mixed, for example, input into the initial general classification model in a similar alternating manner, and the initial general classification model will simultaneously learn the text features of the first language and the text features of the second language. Among them, the initial general classification model is an initialized model, that is, the initial general classification model has not been trained, and is not a classification model that uses the second sample set to adjust parameters after the first sample set is pre-trained. The first text sample and the second text sample are mixed and arranged in the input sequence of the initial general classification model, and the input sequence identifies the order of training the initial general model based on the first text sample and the second text sample as input data, so as to ensure that when training the initial general classification model, the initial general classification model can fully learn the association between the text features of the first language and the annotation label while fully learning the association between the text features of the second language and the annotation label, so that the trained general classification model learns the classification characteristics that are not related to the language type, so as to be suitable for the text environment of the second language.
[0064] Although there are differences between the first language and the second language in the language domain, for the text classification task, the first language and the second language have common classification labels for texts, that is, in different languages, texts with the same meaning are represented in the form of text features, for example, text features can be data structures such as word vectors, word vectors, sentence vectors, etc., and the distribution of text features with the same meaning in their respective language spaces is similar. Using the idea of transfer learning, we can find text features with the same meaning between the first language domain and the second language domain, and then use these text features to transfer knowledge and map the text features of the first language domain and the second language domain from the original space to the new feature space. In this way, in the new feature space, the distribution of text features of the first language and the second language is similar, so that in the new feature space, the first text samples with annotated labels in the first language domain can be better used for classification training, so that the trained general classification model can determine the spatial distribution information corresponding to the text features of the first language and the second language, and the spatial mapping relationship corresponding to the texts with the same meaning in the first language and the second language, and finally realize the text classification of unlabeled texts in the second language domain. Moreover, the general classification model obtained through training is not only applicable to the text environment of the second language, but also to the text environment of the first language. When necessary, the general classification model can be used to classify unlabeled texts in the first language field.
[0065] For the convenience of explanation, two examples are used below with Chinese as the first language and English as the second language.
[0066] Example 1: When analyzing user comments on a product, the initial general classification model can learn during the training process that Chinese words such as "good" and "excellent" express positive emotions, English words such as "good" and "excellent" express positive emotions, Chinese words such as "bad" and "bad" express negative emotions, and English words such as "bad" and "poor" express negative emotions. Through training, the general classification model can know that in Chinese, the text features under the meaning category of positive emotions are distributed in the R1 region of the feature space, and the text features under the meaning category of negative emotions are distributed in the R2 region of the feature space. In English, the text features under the meaning category of positive emotions are distributed in the R3 region of the feature space, and the text features under the meaning category of negative emotions are distributed in the R4 region of the feature space. Moreover, through training the general classification model can also learn the spatial mapping relationship between the R1 region and the R3 region, and the text features in the R3 region and the R1 region both express positive emotions, and the spatial mapping relationship between the R2 region and the R4 region, and the text features in the R2 region and the R4 region both express negative emotions.
[0067] In this way, when classifying and annotating unlabeled texts based on the obtained general classification model, when a second language text input into the general classification model has not appeared in the second text sample before, the general classification model can obtain the meaning category of the text by obtaining the spatial distribution information and spatial mapping relationship based on the aforementioned transfer learning, even if it has not yet learned the meaning of the text. For example, when the text "not good" input into the general classification model is an unfamiliar text that the general classification model has not learned in the training, the general classification model will determine the possible meaning of the text by the area where the text feature of "not good" is located in the feature space. For example, if the area is R4, the general classification model can determine that the text "not good" should belong to a text classified as a text with negative emotions based on the meaning type embodied by the R4 area, the R4 area has a spatial mapping relationship with the R2 area, and both express negative emotions.
[0068] Example 2: When classifying the annotation labels corresponding to news, the initial general classification model can learn in the training process that the meanings of Chinese words such as "apple" and "watermelon" belong to the fruit category, the meanings of words such as "cabbage" and "eggplant" belong to the vegetable category, and the meanings of words such as "chicken" belong to the meat category. In English, the meanings of words such as "Apple" and "watermelon" belong to the fruit category, and the meanings of words such as "Chinese cabbage" and "eggplant" belong to the vegetable category. Regardless of Chinese or English, the feature distribution in their respective language systems is similar. Therefore, in Chinese, the text features of the word meaning belonging to the fruit category are distributed in the R5 area of the feature space, the text features of the word meaning belonging to the vegetable category are distributed in the R6 area of the feature space, and the text features of the word meaning belonging to the meat category are distributed in the R7 area of the feature space. In the English feature space, the text features of the word meaning belonging to the fruit category are distributed in the R8 area of the feature space, and the text features of the word meaning belonging to the vegetable category are distributed in the R9 area of the feature space. Although Chinese and English are different languages, both languages are used to classify the annotation labels corresponding to news. Regardless of Chinese or English, the vocabulary that appears in the news category is basically fixed, so the initial general classification model can also learn the spatial mapping relationship between Chinese text features and English text features with the same meaning during the training process. For example, the R5 area has a spatial mapping relationship with the R8 area, and the R6 area has a spatial mapping relationship with the R9 area.
[0069] In this way, when the text "beef" input into the general classification model is an unfamiliar text that the general classification model has not learned in the training before, the general classification model will determine that the text feature is distributed in the R10 area in the English feature space based on the text feature of "beef", by comparing the spatial distribution information of the Chinese feature space and the English feature space and the spatial mapping relationship corresponding to the text with the same meaning of the determined Chinese text features and English text features. For example, in the English feature space, the spatial distribution information of the R8 area, the R9 area and the R10 area is similar to the spatial distribution information of the R5 area, the R6 area and the R7 area in the Chinese feature space, and the R5 area has a spatial mapping relationship with the R8 area, and the R6 area has a spatial mapping relationship with the R9 area. Therefore, it can be judged that the R10 area has a spatial mapping relationship with the R7 area, wherein the meaning classification of the text feature of the R7 area in the Chinese feature space is meat. Therefore, the meaning classification of the text feature of the R10 area in the English feature space should be meat, and the annotation label of "beef" is meat.
[0070] S204: Classify and annotate the unlabeled text using the general classification model, where the unlabeled text is text corresponding to the second language.
[0071] The unlabeled text corresponding to the second language is input into the trained general classification model to obtain the classification annotations corresponding to the unlabeled text. Therefore, although the second text sample has fewer annotation labels, it can be used with the help of the annotation labels of the first text sample. The annotation labels of the first text sample are not only more in number but also more accurate. The first sample set and the second sample set are mixed to jointly train a general classification model that can be used for text classification in the second language. It is no longer necessary to wait for the time of manually annotating a sufficient number of second text samples, which improves the iteration speed of product expansion business.
[0072] It can be seen that when the number of second text samples corresponding to the second language is small, the initial general classification model can be trained based on a training sample set that includes both first text samples and second text samples. During the training process, the first text samples and the second text samples will be used as input data for the initial general classification model in a similar alternating manner, so that during the training process, the initial general classification model can not only fully absorb the association between the text features and the annotation labels of the two languages and learn classification characteristics that are not related to the language itself, but also will not have the problem of the model fitting the associated knowledge of the first language first due to the continuous input of the first text samples during training, which in turn reduces the classification ability of the second language text. In this way, a general classification model that can be used for text classification in the second language is trained with the help of a large number of accurate first text samples, and there is no need to wait for the time of manually annotating a sufficient number of second text samples, which improves the iteration speed of product expansion business.
[0073] In order to avoid the situation where the initial general classification model is fitted in the first language first, resulting in a decrease in the general classification model's ability to classify text in the second language, the first text sample and the second text sample in the input sequence for inputting the initial general classification model are mixed and arranged. The following introduces three training methods for the initial general classification model based on the mixed arrangement of the first text sample and the second text sample as input.
[0074] Method 1: In a training sample set, the first text sample and the second text sample are mixed and arranged, and then an initial general classification model is trained based on the training sample set. For example, the text samples in the training sample set can be sequentially input into the initial general classification model to obtain a general classification model.
[0075] Method 2: Randomly extract the first text sample or the second text sample from the training sample set as the input of the initial general classification model to ensure that the first text sample is not continuously input into the initial general classification model, so as to train the initial general classification model and obtain a general classification model.
[0076] Method 3: Not only method 1 but also method 2 is used. Specifically, in the training sample set, the first text sample and the second text sample are mixed, and the first text sample or the second text sample is randomly selected as the initial universal classification model input to train the initial universal classification model to obtain the universal classification model.
[0077] In practical applications, the number of first text samples in the first sample set may be much larger than the number of second text samples in the second sample set, that is, the first number is much larger than the second number. In order to avoid the situation that in the subsequent training process, even if the first text sample and the second text sample are mixed and input into the initial general classification model, the initial general classification model will still learn too many text features for the first language, so that the trained general classification model is not suitable for the text environment of the second language, thus, based on the first number, the number of second text samples in the second sample set can be appropriately increased, and the training sample set can be generated based on the first sample set and the expanded second sample set, so as to balance the number of first text samples in the first sample set and the number of second text samples in the second sample set in the training sample set, so that the first number and the second number are the same or similar, and the training sample set is generated according to the expanded second sample set and the first sample set, so that the proportion of the text features of the first language and the text features of the second language learned by the initial general classification model is the same or similar, so as to avoid the initial general classification model learning too many text features about the first language during the training process, fitting on the first language, and reducing the classification and recognition accuracy of the classification model for the second language.
[0078] For example, in a training sample set, the number of first text samples in the first sample set is 1000, and the number of second text samples in the second sample set is 100. Based on the first number of 1000, the second text samples are copied from 100 to 1000, so that the number of second text samples in the expanded second sample set is also 1000. The first sample set and the expanded second sample set are mixed to generate a training sample set. At this time, the number of second text samples in the training sample set is the same as the number of first text samples.
[0079] In order to make the technical solution of the present application more clear to those skilled in the art, Figure 4-Figure 6 The training process of the initial general classification model is explained.
[0080] See also Figure 4, which is a schematic diagram of a general classification model training framework provided in an embodiment of the present application. The training framework includes three models, namely a first feature model, a second feature model and an initial general classification model. Among them, the first feature model is used to extract text features of the first text sample in the first sample set, such as the character vector, word vector, sentence vector, etc. of the first text sample. The second feature model is used to extract text features of the second text sample in the second sample set, such as the character vector, word vector, sentence vector, etc. of the second text sample. The initial general classification model is used to obtain the pending labels corresponding to the first text sample and the second text sample respectively. As can be seen from the above, the text classification objectives of the first language and the second language are the same, so the same initial general classification model can be used for training, so as to obtain a general classification model that is independent of the language type.
[0081] The embodiments of the present application do not specifically limit the first feature model and the second feature model. For example, it can be a deformation-based bidirectional encoding representation (Bidirectional Encoder Representations from Transformers, BERT) model, a generalized autoregressive pretraining for language understanding (Generalized Autoregressive Pretraining for Language Understanding, XLNet) model, a robustly optimized BERT pretraining (Robustly OptimizedBERT Pretraining Approach, RoBERTa) model, and other models.
[0082] It should be noted that in the training framework, the first feature model and the second feature model are trained models. For example, before training the initial general classification model, the first feature model is trained using the first text sample through the GPU cluster, and the second feature model is trained using the second text sample, so that the text features corresponding to the first text sample and the second text sample can be extracted respectively through the trained first feature model and the second feature model.
[0083] As can be seen from the above, the training sample set includes both the first text sample and the second text sample. When training based on the training sample set, if the first text sample is encountered, Figure 5 The training process shown in the figure trains the initial general model. If a second text sample is encountered, it can be used Figure 6 The training process shown trains the initial general model, which is introduced below.
[0084] See also Figure 5 , which is a schematic diagram of a general classification model training process provided in an embodiment of the present application.
[0085] A first text sample extracted from a training sample set is input into a first feature model, so that text features of the first text sample are extracted through the first feature model. The text features of the first text sample are input into an initial general classification model, and a first pending label corresponding to the first text sample is obtained through the initial general classification model. The parameters of the initial general classification model are adjusted according to the first pending label and the annotation label corresponding to the first text sample.
[0086] See also Figure 6 , which is a schematic diagram of a general classification model training process provided in an embodiment of the present application.
[0087] The second text sample extracted from the training sample set is input into the second feature model, so as to extract the text features of the second text sample through the second feature model. The text features of the second text sample are input into the initial general classification model, and the second pending label corresponding to the second text sample is obtained through the initial general classification model. The parameters of the initial general classification model are adjusted according to the second pending label and the annotated label corresponding to the second text sample.
[0088] Thus, the first text sample is extracted through the first feature model, and the second text sample is extracted through the second feature model, and the two will not be confused with each other. For example, when the first text sample is an article, the word vector of the article can be extracted through the first feature model, and then input into the initial general classification model for further training. In this way, the text features of text samples in different languages can be extracted in a targeted manner, and the initial general classification model can be better trained.
[0089] In order to ensure the consistency of the training process of the initial general classification model, only the parameters of the initial general classification model can be adjusted during the training of the initial general classification model, and the parameters of the first feature model and the second feature model can be fixed unchanged. During the training process, the parameters of the first feature model and the second feature model remain unchanged, which can ensure that the rules of the extracted text features are the same. Even if there are errors in the extracted text features, the errors are the same and will not change. Therefore, the initial general classification model can pay better attention to the spatial distribution information of the text features in the corresponding language and the spatial mapping relationship between the text features of the first language and the second language during training, and then the trained general classification model can have classification characteristics that are independent of the language itself, and obtain better classification results.
[0090] The technical solution provided by this application can be applied to various products involving text content, such as information flow products, forum products, community products, e-commerce products, etc. Taking news reading products as an example, the annotation labels of the first text sample or the second text sample are used to identify the text category of the corresponding text sample, such as entertainment news, sports news, etc. The unannotated text in the second language can be classified and annotated through a general classification model to identify the text category of the unannotated text through the determined annotation labels. In this way, the text category corresponding to the second language news can be determined.
[0091] Furthermore, in the early stage of the expansion of the second language text environment, a general classification model can be used as a cross-language emergency measure. After obtaining more annotation labels corresponding to unlabeled texts in the second language, for example, slowly accumulating the annotation labels corresponding to the unlabeled texts through manual operation, or obtaining the annotation labels corresponding to the unlabeled texts through a general classification model, the classification model corresponding to the second language can be trained based on the unlabeled texts with determined annotation labels and the second sample set, so that the second classification model is more targeted in the text environment corresponding to the second language, thereby improving the classification and recognition accuracy of the classification model for the second language.
[0092] When the business of the product continues to expand to the third language, the same method can be used (see the above-mentioned partial description of the embodiment of the general classification model for classifying unlabeled text in the second language) to help the business of the product pass the initial expansion in the third language text environment through the general classification model. Specifically, a third sample set corresponding to the third language is obtained, the third sample set includes a third number of third text samples, the third text samples and the first text samples and the second sample set have annotated labels obtained based on the same annotation rule, the first number is greater than the third number, and the present application does not limit the relationship between the second number and the third number. Then a training sample set is generated according to the first sample set, the second sample set and the third sample set. When the initial general classification model is trained based on the training sample set, the first text sample, the second text sample and the third text sample are mixed and arranged in the input sequence for inputting the initial general classification model, so as to obtain a general classification model. Thus, a general classification model can be obtained with the help of a first text sample with annotated labels in the first language and a second text sample with annotated labels in the second language, so as to classify and annotate the unlabeled text in the third language.
[0093] Next, the text classification method provided by the embodiment of the present application will be introduced in combination with a specific scenario. The scenario is that a company promotes a chat application product APP of the company from the Chinese market to the English market, that is, the first language is Chinese and the second language is English. The company hopes to analyze the sentiment polarity of the user comments of the APP by English users to analyze whether the user likes or dislikes the APP, so as to improve the APP and enhance the user experience. Figure 7 , which is a flowchart of a text classification method provided in an embodiment of the present application, the method comprising:
[0094] S701: Acquire a Chinese sample set corresponding to Chinese and an English sample set corresponding to English.
[0095] Due to the small number of English text samples in the early stage of promotion, it is impossible to train a sentiment polarity classification model with strong generalization. In addition, increasing the number of English text samples through manual labeling not only wastes manpower, but also leads to a longer cycle for training the sentiment polarity classification model required for English, which is not conducive to the rapid promotion of the APP to the English market.
[0096] Based on this, Chinese text samples with annotated labels can be obtained to help train the sentiment polarity classification model required for English. The Chinese sample set includes a first number of Chinese text samples, and the English sample set includes a second number of English text samples. Regardless of the annotated labels of the Chinese text samples or the annotated labels of the English text samples, they are annotated with the same annotating rules. It can be understood that the first number is greater than the second number.
[0097] S702: Copy the English text samples in the English sample set, expand the number of the English text samples to a first number, and obtain an expanded English sample set.
[0098] In the actual promotion process, the number of Chinese text samples is generally much larger than the number of English text samples. In order to avoid the initial general sentiment polarity classification model learning too many text features about Chinese in the subsequent training process, thereby reducing the classification and recognition accuracy of English text features, it is necessary to balance the number of English text samples and the number of Chinese text samples. Therefore, based on the first number, the English text samples can be copied so that the number in the expanded English sample set reaches the first number.
[0099] S703: Generate a training sample set according to the Chinese sample set and the expanded English sample set.
[0100] Chinese text samples and expanded English text samples are mixed to generate a training sample set, so that when training the initial universal sentiment polarity classification model, the number of Chinese text samples and English text samples input into the classification model is the same, so that the classification model can not only learn about Chinese text features, but also learn about English text features, so that the universal sentiment polarity classification model can be used in an English text environment and has good generalization.
[0101] S704: Training an initial universal sentiment polarity classification model based on the training sample set to obtain a universal sentiment polarity classification model.
[0102] During the training process, Chinese text samples and English text samples are mixed and arranged and input into the initial universal sentiment polarity classification model to avoid the initial universal sentiment polarity classification model being fitted to Chinese first.
[0103] During training, if a Chinese text sample is extracted from the training sample set, the text features of the Chinese text sample are extracted through the first feature model, and based on the text features of the Chinese text sample, the corresponding first pending label is obtained through the initial general sentiment polarity classification model, and the model parameters of the initial general sentiment polarity classification model are adjusted according to the first pending label and the annotation label corresponding to the Chinese text sample.
[0104] If an English text sample is extracted from the training sample set, the text features of the English text sample are extracted through the second feature model, and based on the text features of the English text sample, the corresponding second pending label is obtained through the initial general sentiment polarity classification model, and the model parameters of the initial general sentiment polarity classification model are adjusted based on the second pending label and the annotation label corresponding to the English text sample.
[0105] The initial general sentiment polarity classification model can adopt the three training methods as described above, which will not be repeated here.
[0106] S705: Classify and annotate the unlabeled text in English through a general sentiment polarity classification model, so as to identify the sentiment polarity of the unlabeled text through the determined annotation label.
[0107] The unlabeled text corresponding to English is input into the trained general sentiment polarity classification model to obtain the classification annotations corresponding to the unlabeled text in English. Among them, the classification annotations can be positive sentiment types and negative sentiment types. Therefore, although there are fewer annotation labels for English text samples, with the help of a large number of annotation labels for Chinese text samples, the Chinese sample set and the English sample set can be mixed to jointly train a general sentiment polarity classification model that can be used for text classification of unlabeled text in English, so that there is no need to wait for the time of manually annotating a sufficient number of English text samples, which improves the iteration speed of product expansion business.
[0108] S706: Based on the unlabeled text with the determined label and the English sample set, a sentiment polarity classification model corresponding to English is trained.
[0109] Therefore, when the APP is promoted from the Chinese market to the English market, the general sentiment polarity classification model can be trained by using the annotated labels of a large number of Chinese text samples and the annotated labels of a small number of English text samples, so as to use the general sentiment polarity classification model to analyze the sentiment polarity of text without annotated labels in English user comments. After obtaining a large number of English text samples with annotated labels through the general sentiment polarity classification model, a sentiment polarity classification model dedicated to the corresponding English can be trained, so that the general sentiment polarity classification model can help the APP to quickly analyze the sentiment polarity of English user comments in the early stage of promotion. In the later stage of promotion, the corresponding English sentiment polarity classification model can be trained based on a sufficient number of English text samples, so as to improve the APP, enable the APP to iterate quickly, and enhance the user experience.
[0110] In view of the text classification method provided in the above embodiment, the embodiment of the present application also provides a text classification device.
[0111] See also Figure 8 , Figure 8 A schematic diagram of a text classification device provided in an embodiment of the present application. Figure 8 As shown, the text classification device 800 includes an acquisition unit 801, a generation unit 802, a training unit 803 and a classification unit 804:
[0112] The acquisition unit 801 is used to acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, the first sample set includes a first number of first text samples, the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotation labels obtained based on the same annotation rule, and the first number is greater than the second number;
[0113] The generating unit 802 is configured to generate a training sample set according to the first sample set and the second sample set;
[0114] The training unit 803 is used to train an initial general classification model based on the training sample set to obtain a general classification model, and when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence input into the initial general classification model;
[0115] The classification unit 804 is used to classify and annotate the unlabeled text by using the general classification model, where the unlabeled text is text corresponding to the second language.
[0116] As a possible implementation, the training method of the training unit 803 includes any one of the following methods, or a combination of multiple methods:
[0117] Method 1: Mix and arrange the first text sample and the second text sample in the training sample set, and train the initial general classification model based on the training sample set to obtain a general classification model; or,
[0118] Method 2: randomly extracting the first text sample or the second text sample from the training sample set as the input of the initial general classification model to train the initial general classification model to obtain a general classification model.
[0119] As a possible implementation manner, the generating unit 802 is configured to:
[0120] Based on the first quantity, expanding the number of samples of the second sample set according to the second text sample to obtain an expanded second sample set;
[0121] A training sample set is generated according to the first sample set and the expanded second sample set.
[0122] As a possible implementation manner, during the training process, the training unit 803 is used to:
[0123] For a first text sample extracted from the training sample set, extracting text features of the first text sample by using a first feature model;
[0124] According to the text features of the first text sample, obtaining a corresponding first pending label through the initial general classification model;
[0125] Adjusting the model parameters of the initial general classification model according to the first undetermined label and the annotated label corresponding to the first text sample;
[0126] For a second text sample extracted from the training sample set, extracting text features of the second text sample by using a second feature model;
[0127] According to the text features of the second text sample, obtaining a corresponding second pending label through the initial general classification model;
[0128] The model parameters of the initial general classification model are adjusted according to the second undetermined label and the annotated label corresponding to the second text sample.
[0129] As a possible implementation manner, the general classification model determines through the training the spatial distribution information corresponding to the text features of the first language and the second language, respectively, and the spatial mapping relationship between the text features corresponding to the texts with the same meaning in the first language and the second language.
[0130] As a possible implementation manner, the annotation label of the first text sample or the second text sample is used to identify the text category of the corresponding text sample, and the classification unit 804 is used to:
[0131] The unlabeled text is classified and labeled by using the general classification model, so as to identify the text category of the unlabeled text by using the determined annotation label.
[0132] As a possible implementation, the device further includes a second language classification model generation unit, which is used to:
[0133] A classification model corresponding to the second language is trained based on the unlabeled text with determined labeled labels and the second sample set.
[0134] As a possible implementation, the device further includes a general model generation unit for multiple languages, which is used to:
[0135] Acquire a third sample set corresponding to a third language, the third sample set including a third number of third text samples, the third text samples and the first text samples having annotation labels obtained based on the same annotation rule, and the first number is greater than the third number;
[0136] Generate the training sample set according to the first sample set, the second sample set and the third sample set;
[0137] In the step of training an initial universal classification model based on the training sample set to obtain a universal classification model, when training the initial universal classification model, the first text sample, the second text sample, and the third text sample are mixed and arranged in an input sequence for inputting the initial universal classification model;
[0138] When the unlabeled text is classified and labeled by the general classification model, the unlabeled text also includes text corresponding to the third language.
[0139] The text classification device provided in the above embodiment trains an initial general classification model based on a training sample set including both the first text sample and the second text sample. During the training process, the first text sample and the second text sample are used as input data of the initial general classification model in a similar alternating manner, so that during the training process, the initial general classification model can not only fully absorb the association between the text features and the annotation labels of the two languages, thereby learning classification characteristics that are not related to the language itself, but also avoid the problem that the model first fits the associated knowledge of the first language due to the continuous input of the first text sample during training, which in turn reduces the classification ability of the second language text. In this way, a general classification model that can be used for text classification in the second language is trained with the help of a large number of accurate first text samples, and there is no need to wait for the time of manually annotating a sufficient number of second text samples, thereby improving the iteration speed of product expansion business.
[0140] The embodiment of the present application also provides a computer device. The computer device provided by the embodiment of the present application will be introduced from the perspective of hardware instantiation.
[0141] See also Fig. 9 , Fig. 9 14 is a schematic diagram of a server structure provided in an embodiment of the present application. The server 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1422 (for example, one or more processors) and memory 1432, and one or more storage media 1430 (for example, one or more mass storage devices) storing application programs 1442 or data 1444. Among them, the memory 1432 and the storage medium 1430 may be short-term storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1422 may be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the server 1400.
[0142] The server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0143] The steps performed by the server in the above embodiment can be based on the Fig. 9 The server structure shown.
[0144] The CPU 1422 is used to execute the following steps:
[0145] Acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, wherein the first sample set includes a first number of first text samples, and the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotated labels obtained based on the same annotation rule, and the first number is greater than the second number;
[0146] Generate a training sample set according to the first sample set and the second sample set;
[0147] Training an initial general classification model based on the training sample set to obtain a general classification model, wherein when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence for inputting the initial general classification model;
[0148] The unlabeled text is classified and labeled by using the general classification model, and the unlabeled text is text corresponding to the second language.
[0149] Optionally, the CPU 1422 may also execute the method steps of any specific implementation of the text classification method in the embodiments of the present application.
[0150] With respect to the text classification method described above, an embodiment of the present application further provides a terminal device for text classification, so that the above text classification method can be implemented and applied in practice.
[0151] See also Fig.10 , Fig.10 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. For the sake of convenience, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The terminal device can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), etc., taking the terminal device as a mobile phone as an example:
[0152] Fig.10 FIG. 1 is a block diagram showing a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present application. Fig.10The mobile phone includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art will understand that Fig.10 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0153] Combine the following Fig.10 A detailed introduction to the various components of the mobile phone:
[0154] The RF circuit 1510 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 1580 for processing; in addition, the designed uplink data is sent to the base station. Usually, the RF circuit 1510 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, referred to as LNA), a duplexer, etc. In addition, the RF circuit 1510 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0155] The memory 1520 can be used to store software programs and modules. The processor 1580 implements various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1520. The memory 1520 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1520 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0156] The input unit 1530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 1531 or near the touch panel 1531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1531 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1580, and can receive and execute the command sent by the processor 1580. In addition, the touch panel 1531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 1531, the input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0157] The display unit 1540 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1540 may include a display panel 1541. Optionally, the display panel 1541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 1531 may cover the display panel 1541. When the touch panel 1531 detects a touch operation on or near it, it is transmitted to the processor 1580 to determine the type of touch event. Subsequently, the processor 1580 provides a corresponding visual output on the display panel 1541 according to the type of touch event. Although in Fig.10 In the embodiment, the touch panel 1531 and the display panel 1541 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 1531 and the display panel 1541 can be integrated to realize the input and output functions of the mobile phone.
[0158] The mobile phone may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1541 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1541 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0159] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the mobile phone. The audio circuit 1560 can transmit the received audio data to the speaker 1561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the processor 1580 for processing, and then sent to another mobile phone through the RF circuit 1510, or the audio data is output to the memory 1520 for further processing.
[0160] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 1570. It provides users with wireless broadband Internet access. Fig.10 A WiFi module 1570 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.
[0161] The processor 1580 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in the memory 1520 and calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units; preferably, the processor 1580 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1580.
[0162] The mobile phone also includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0163] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0164] In the embodiment of the present application, the memory 1520 included in the mobile phone can store program codes and transmit the program codes to the processor.
[0165] The processor 1580 included in the mobile phone can execute the text classification method provided in the above embodiment according to the instructions in the program code.
[0166] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the text classification method provided in the above embodiment.
[0167] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device performs the text classification method provided in various optional implementations of the above aspects.
[0168] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the above-mentioned storage medium can be at least one of the following media: read-only memory (English: read-only memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.
[0169] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0170] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A text classification method, characterized in that: The method comprises: Acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, wherein the first sample set includes a first number of first text samples, and the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotated labels obtained based on the same annotation rule, and the first number is greater than the second number; Generate a training sample set according to the first sample set and the second sample set; Training an initial general classification model based on the training sample set to obtain a general classification model, wherein when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence for inputting the initial general classification model; The unlabeled text is classified and labeled by using the general classification model, and the unlabeled text is text corresponding to the second language.
2. The method according to claim 1, characterized in that The step of training the initial universal classification model based on the training sample set to obtain the universal classification model includes any of the following methods, or a combination of multiple methods: Method 1: Mix and arrange the first text sample and the second text sample in the training sample set, and train the initial general classification model based on the training sample set to obtain a general classification model; or, Method 2: randomly extracting the first text sample or the second text sample from the training sample set as the input of the initial general classification model to train the initial general classification model to obtain a general classification model.
3. The method according to claim 1, characterized in that The step of generating a training sample set according to the first sample set and the second sample set includes: Based on the first quantity, expanding the number of samples of the second sample set according to the second text sample to obtain an expanded second sample set; A training sample set is generated according to the first sample set and the expanded second sample set.
4. The method according to claim 1, characterized in that: The process of training the initial general classification model based on the training sample set includes: For a first text sample extracted from the training sample set, extracting text features of the first text sample by using a first feature model; According to the text features of the first text sample, obtaining a corresponding first pending label through the initial general classification model; Adjusting the model parameters of the initial general classification model according to the first undetermined label and the annotated label corresponding to the first text sample; For a second text sample extracted from the training sample set, extracting text features of the second text sample by using a second feature model; According to the text features of the second text sample, obtaining a corresponding second pending label through the initial general classification model; The model parameters of the initial general classification model are adjusted according to the second undetermined label and the annotated label corresponding to the second text sample.
5. The method according to claim 1, characterized in that: The general classification model determines, through the training, the spatial distribution information corresponding to the text features of the first language and the second language, respectively, and the spatial mapping relationship between the text features corresponding to the texts having the same meaning in the first language and the second language.
6. The method according to claim 1, characterized in that The annotation label of the first text sample or the second text sample is used to identify the text category of the corresponding text sample, and the classification and annotation of the unlabeled text by the general classification model includes: The unlabeled text is classified and labeled by using the general classification model, so as to identify the text category of the unlabeled text by using the determined annotation label.
7. The method according to claim 6, characterized in that The method further comprises: A classification model corresponding to the second language is trained based on the unlabeled text with determined labeled labels and the second sample set.
8. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Acquire a third sample set corresponding to a third language, the third sample set including a third number of third text samples, the third text samples and the first text samples having annotation labels obtained based on the same annotation rule, and the first number is greater than the third number; The step of generating a training sample set according to the first sample set and the second sample set includes: Generate the training sample set according to the first sample set, the second sample set and the third sample set; In the step of training an initial universal classification model based on the training sample set to obtain a universal classification model, when training the initial universal classification model, the first text sample, the second text sample, and the third text sample are mixed and arranged in an input sequence for inputting the initial universal classification model; When the unlabeled text is classified and labeled by the general classification model, the unlabeled text also includes text corresponding to the third language.
9. A text classification device, characterized in that: The device comprises: an acquisition unit, a generation unit, a training unit and a classification unit; The acquisition unit is used to acquire a first sample set corresponding to a first language and a second sample set corresponding to a second language, the first sample set includes a first number of first text samples, the second sample set includes a second number of second text samples, the first text samples and the second text samples have annotated labels obtained based on the same annotation rule, and the first number is greater than the second number; The generating unit is configured to generate a training sample set according to the first sample set and the second sample set; The training unit is used to train an initial general classification model based on the training sample set to obtain a general classification model, and when training the initial general classification model, the first text sample and the second text sample are mixed and arranged in an input sequence input into the initial general classification model; The classification unit is used to classify and annotate the unlabeled text by using the general classification model, and the unlabeled text is the text corresponding to the second language.
10. The device according to claim 9, characterized in that The training method of the training unit includes any one of the following methods, or a combination of multiple methods: Method 1: Mix and arrange the first text sample and the second text sample in the training sample set, and train the initial general classification model based on the training sample set to obtain a general classification model; or, Method 2: randomly extracting the first text sample or the second text sample from the training sample set as the input of the initial general classification model to train the initial general classification model to obtain a general classification model.
11. The device according to claim 9, characterized in that The generating unit is used for: Based on the first quantity, expanding the number of samples of the second sample set according to the second text sample to obtain an expanded second sample set; A training sample set is generated according to the first sample set and the expanded second sample set.
12. The device according to claim 9, characterized in that The training unit, in the process of training the initial general classification model based on the training sample set, is used to: For a first text sample extracted from the training sample set, extracting text features of the first text sample by using a first feature model; According to the text features of the first text sample, obtaining a corresponding first pending label through the initial general classification model; Adjusting the model parameters of the initial general classification model according to the first undetermined label and the annotated label corresponding to the first text sample; For a second text sample extracted from the training sample set, extracting text features of the second text sample by using a second feature model; According to the text features of the second text sample, obtaining a corresponding second pending label through the initial general classification model; The model parameters of the initial general classification model are adjusted according to the second undetermined label and the annotated label corresponding to the second text sample.
13. The device according to claim 9, characterized in that The general classification model determines, through the training, the spatial distribution information corresponding to the text features of the first language and the second language, respectively, and the spatial mapping relationship between the text features corresponding to the texts having the same meaning in the first language and the second language.
14. The device according to claim 9, characterized in that The annotation label of the first text sample or the second text sample is used to identify the text category of the corresponding text sample, and the classification unit is used to: The unlabeled text is classified and labeled by using the general classification model, so as to identify the text category of the unlabeled text by using the determined annotation label.
15. The device according to claim 14, characterized in that The device also includes a classification model generating unit for a second language, which is used to: A classification model corresponding to the second language is trained based on the unlabeled text with determined labeled labels and the second sample set.
16. The device according to any one of claims 9 to 12, characterized in that: The device also includes a general model generation unit for multiple languages, which is used to: Acquire a third sample set corresponding to a third language, the third sample set including a third number of third text samples, the third text samples and the first text samples having annotation labels obtained based on the same annotation rule, and the first number is greater than the third number; Generate the training sample set according to the first sample set, the second sample set and the third sample set; In the step of training an initial universal classification model based on the training sample set to obtain a universal classification model, when training the initial universal classification model, the first text sample, the second text sample, and the third text sample are mixed and arranged in an input sequence for inputting the initial universal classification model; When the unlabeled text is classified and labeled by the general classification model, the unlabeled text also includes text corresponding to the third language.
17. A computer device, characterized in that: The device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the method according to any one of claims 1 to 8 according to the instructions in the program code.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 8.
19. 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 executes the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Chinese text classification method
CN109902173A
Model training method for text analysis, text classification method and device
CN110046248A