Text category recognition method and related equipment

By training the text classification model and predicting the classified text, the problem of low classification efficiency in massive text data is solved, and the rapid and effective classification and information management of text are realized.

CN112966110BActive Publication Date: 2025-03-25CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110286227.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-17
Publication Date
2025-03-25
Estimated Expiration
2041-03-17

AI Technical Summary

Technical Problem

In massive text data, how to quickly and effectively classify texts to achieve information management and extraction and avoid major losses in information technology.

Method used

By obtaining the training samples, training the preset text classification model to be trained, obtaining the text classification model, and then inputting the text to be classified into the text classification model to obtain a category prediction probability set, and finally determining the target text category of the text to be classified based on these probabilities.

Benefits of technology

It realizes the rapid and effective classification of text, improves the efficiency of text management and information extraction, and avoids major losses in information technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112966110B_ABST
    Figure CN112966110B_ABST
Patent Text Reader

Abstract

The present application discloses a text category recognition method and related equipment, which are applied to electronic devices, and the method includes: obtaining training samples; using the training samples to train a preset text classification model to be trained to obtain a text classification model; obtaining a text to be classified, inputting the text to be classified into the text classification model, and obtaining a category prediction probability set, wherein the category prediction probability set includes the prediction probability that the sample to be classified belongs to a preset text category; based on the category prediction probability set, determining the target text category to which the text to be classified belongs in the preset text category. The use of the embodiments of the present application is conducive to improving the efficiency of text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic technology, and in particular to a text category recognition method and related equipment. Background Art

[0002] With the development of the Internet, a huge amount of text data is constantly generated, making text classification occupy an important position in information processing. Since there is a large amount of information in text data, if this information cannot be managed and extracted quickly and effectively, it will cause significant losses to corporate and social information technology. Therefore, how to use effective and fast methods to identify text to achieve classification is a key issue that needs to be solved urgently. Summary of the invention

[0003] The embodiments of the present application provide a text category recognition method and related equipment, which are conducive to fast and effective classification of text.

[0004] In a first aspect, an embodiment of the present application provides a text category recognition method, the method comprising:

[0005] Get training samples;

[0006] Using the training samples to train a preset text classification model to be trained to obtain a text classification model;

[0007] Acquire a text to be classified, input the text to be classified into the text classification model, and obtain a category prediction probability set, wherein the category prediction probability set includes a prediction probability that the sample to be classified belongs to a preset text category;

[0008] Based on the category prediction probability set, a target text category to which the to-be-classified text belongs is determined in the preset text categories.

[0009] In a second aspect, an embodiment of the present application provides a text category recognition device, the device comprising:

[0010] A first acquisition unit, used to acquire training samples;

[0011] A training unit, used to train a preset text classification model to be trained using the training samples to obtain a text classification model;

[0012] A second acquisition unit, used for acquiring the text to be classified;

[0013] An input unit, used for inputting the to-be-classified text into the text classification model to obtain a set of category prediction probabilities, wherein the set of category prediction probabilities includes a prediction probability that the to-be-classified sample belongs to a preset text category;

[0014] A determination unit is used to determine, based on the category prediction probability set, a target text category to which the to-be-classified text belongs in the preset text categories.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the method described in the first aspect of the embodiment of the present application.

[0016] In a fourth aspect, 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, wherein the computer program enables a computer to execute part or all of the steps described in the method described in the first aspect of the embodiment of the present application.

[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the method described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.

[0018] It can be seen that in the embodiment of the present application, the electronic device first obtains a training sample, and then uses the training sample to train a preset text classification model to be trained to obtain a text classification model, and then obtains the text to be classified, inputs the text to be classified into the text classification model, and obtains a category prediction probability set, the category prediction probability set includes the prediction probability that the sample to be classified belongs to a preset text category, and finally, based on the category prediction probability set, determines the target text category to which the text to be classified belongs in the preset text category. Since the text classification model to be trained is firstly trained, and then the trained text classification model is used to classify the text, it is conducive to fast and effective text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] 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.

[0020] Figure 1 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0021] Figure 2It is a flowchart of a text category recognition method provided in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application;

[0023] Figure 4 A schematic diagram of the structure of a text category recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0025] The following are detailed descriptions of each.

[0026] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0028] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.

[0029] The electronic device may include a computing device or other processing device connected to a wireless modem, among other things.

[0030] like Figure 1 As shown, Figure 11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device includes at least one of the following: a processor, a memory, a signal processor, a transceiver, a random access memory (RAM), a sensor, etc. Among them, the memory, the signal processor, the RAM, and the sensor are connected to the processor, and the transceiver is connected to the signal processor.

[0031] Among them, the sensor includes at least one of the following: a light sensor, a gyroscope, an infrared proximity sensor, a fingerprint sensor, a pressure sensor, and the like. Among them, the light sensor, also known as an ambient light sensor, is used to detect the brightness of ambient light. The light sensor may include a photosensitive element and an analog-to-digital converter. Among them, the photosensitive element is used to convert the collected light signal into an electrical signal, and the analog-to-digital converter is used to convert the above electrical signal into a digital signal. Optionally, the light sensor may also include a signal amplifier, which may amplify the electrical signal converted by the photosensitive element and output it to the analog-to-digital converter. The above-mentioned photosensitive element may include at least one of a photodiode, a phototransistor, a photoresistor, and a silicon photocell.

[0032] Among them, the processor is the control center of the electronic device, which uses various interfaces and lines to connect the various parts of the entire electronic device, and performs various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory, and calling data stored in the memory, thereby monitoring the electronic device as a whole.

[0033] The processor may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor.

[0034] The memory is used to store software programs and / or modules, and the processor executes various functional applications and data processing of the electronic device by running the software programs and / or modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a software program required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0035] The embodiments of the present application are described in detail below.

[0036] like Figure 2As shown, a flowchart of a text category recognition method provided by an embodiment of the present application is applied to the above electronic device, and specifically includes the following steps:

[0037] Step 201: Obtain training samples.

[0038] The training samples may include inclusive training samples and exclusive training samples. The inclusive training samples mean that the samples belong to a certain sample category, and the exclusive training samples mean that the samples do not belong to a certain sample category.

[0039] Step 202: using the training samples to train the text classification model to be trained to obtain a text classification model.

[0040] The text classification model to be trained may include an exclusive text classification model to be trained and an inclusive text classification model to be trained, the exclusive text classification model to be trained corresponds to exclusive training samples, and the inclusive text classification model to be trained corresponds to inclusive training samples.

[0041] The text classification model includes an exclusive text classification model and an inclusive text classification model. The exclusive text classification model corresponds to the exclusive text classification model to be trained, and the inclusive text classification model corresponds to the inclusive text classification model to be trained.

[0042] Step 203: Obtain the text to be classified, input the text to be classified into the text classification model, and obtain a category prediction probability set, wherein the category prediction probability set includes the prediction probability that the sample to be classified belongs to a preset text category.

[0043] The text to be classified can be inclusive text or exclusive text.

[0044] The preset text category includes at least one text category, and the category prediction probability set includes the probability that the sample to be classified belongs to each preset text category.

[0045] Among them, the category prediction probabilities of the text to be classified in different text categories may be the same or different.

[0046] Among them, text categories can be news topics, spam, user comments, etc.

[0047] Step 204: Based on the category prediction probability set, determine the target text category to which the to-be-classified text belongs in the preset text categories.

[0048] Among them, the text category corresponding to the largest prediction probability in the category prediction probability set is determined as the target text category.

[0049] It can be seen that in the embodiment of the present application, the electronic device first obtains a training sample, and then uses the training sample to train a preset text classification model to be trained to obtain a text classification model, and then obtains the text to be classified, inputs the text to be classified into the text classification model, and obtains a category prediction probability set, the category prediction probability set includes the prediction probability that the sample to be classified belongs to a preset text category, and finally, based on the category prediction probability set, determines the target text category to which the text to be classified belongs in the preset text category. Since the text classification model to be trained is firstly trained, and then the trained text classification model is used to classify the text, it is conducive to fast and effective text classification.

[0050] In a possible implementation, the adopting the training sample to train a preset text classification model to be trained to obtain a text classification model includes:

[0051] Dividing the training samples into inclusive training samples and exclusive training samples based on sample identifiers;

[0052] Training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain an exclusionary text classification model;

[0053] The inclusive text classification model to be trained is trained based on the inclusive training samples to obtain an inclusive text classification model.

[0054] Among them, the sample identifiers of all inclusive training samples are the same, the sample identifiers of all exclusive training samples are the same, and the sample identifiers of inclusive training samples and exclusive training samples are different.

[0055] Among them, there is at least one inclusive training sample and at least one inclusive training sample.

[0056] The number of inclusive training samples may be greater than or equal to the number of exclusive training samples, or the number of inclusive training samples may be less than the number of exclusive training samples.

[0057] It can be seen that in the embodiment of the present application, inclusive training samples are used to train the inclusive text classification model to be trained, and exclusive training samples are used to train the exclusive text classification model to be trained. This is conducive to ensuring that when the text to be classified is a problematic text, the text to be classified can be classified as exclusive text, thereby ensuring the accuracy of text classification.

[0058] In a possible implementation, the training of the exclusionary text classification model to be trained based on the exclusionary training samples to obtain the exclusionary text classification model includes:

[0059] Inputting the exclusionary training sample into a first preset classification model to obtain an inclusive prediction probability set and an exclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the exclusionary training sample belongs to the preset text category, and the exclusive prediction probability set includes the probability that the exclusionary training sample is excluded from the preset text category;

[0060] Based on the inclusive prediction probability set and the exclusive prediction probability set, the exclusive text classification model to be trained is trained to obtain the exclusive text classification model.

[0061] Among them, the preset text categories include at least one text category, the number of exclusive training samples is greater than or equal to one, and since the first preset classification model is used to normalize the exclusive training samples, an inclusive prediction probability set corresponding to each exclusive training sample and an exclusive prediction probability set corresponding to each exclusive training sample can be obtained. The inclusive prediction probability set includes the probability that the corresponding exclusive training sample belongs to each text category, and the exclusive prediction probability set includes the probability that the corresponding exclusive training sample is excluded from each text category.

[0062] In a possible implementation, the training of the to-be-trained exclusionary text classification model based on the inclusive prediction probability set and the exclusive prediction probability set to obtain the exclusionary text classification model includes:

[0063] Determining an inclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set, and determining an exclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set;

[0064] Obtaining a first loss value based on a first loss function, a set of inclusive prediction probabilities corresponding to the exclusive training samples, and a set of exclusive prediction probabilities corresponding to the exclusive training samples;

[0065] When the first loss value is greater than or equal to the first preset loss value, the first preset model parameters are adjusted based on the first loss value and the back propagation algorithm until the first loss value is less than the first preset loss value, thereby obtaining the exclusionary text classification model.

[0066] Among them, since the preset text category includes at least one text category and the number of exclusive training samples is greater than or equal to one, an exclusive training sample A is arbitrarily selected from the exclusive training samples each time, and then the first loss value is determined based on the inclusive prediction probability set corresponding to the exclusive training sample A, the exclusive prediction probability set corresponding to the exclusive training sample A and the first loss function. If the first loss value is less than the first preset loss value, the first preset model parameters are adjusted, and an exclusive training sample other than the exclusive training sample A is arbitrarily selected from the exclusive training samples again as the exclusive training sample A until the first loss value is less than the first preset loss value.

[0067] Among them, the first loss function is p i represents the probability that the training sample belongs to the i-th text category, q i Represents the probability that the training sample is excluded from the i-th text category.

[0068] For example, if there are three text categories (text category A, text category B, and text category C), the probability that training sample A belongs to text category A is 0.8, the probability that it belongs to text category B is 0.7, and the probability that it belongs to text category C is 0.5. The probability that training sample A is excluded from text category A is 0.8, the probability that it is excluded from text category B is 0.6, and the probability that it is excluded from text category C is 0.3. Then the loss value corresponding to training sample A is -(0.8*log(0.8)+0.7*log(0.6)+0.5*log(0.3)).

[0069] The adjustment of the current first preset model parameters is performed on the basis of the first preset model parameters obtained by the last adjustment.

[0070] The first preset model parameter may be a positive number or a negative number.

[0071] It can be seen that in the embodiment of the present application, when the first loss value is less than the first preset loss value, an exclusionary text classification model is obtained, which is beneficial to improving the accuracy of determining the text classification.

[0072] In a possible implementation, the training of the inclusive text classification model to be trained based on the inclusive training samples to obtain the inclusive text classification model includes:

[0073] Inputting the inclusive training sample into a second preset classification model to obtain an inclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the inclusive training sample belongs to the preset text category;

[0074] Determining a set of annotation probabilities based on the annotations of the inclusive training samples, wherein the set of annotation probabilities includes probabilities that the inclusive training samples are annotated as the preset text classification;

[0075] Based on the inclusive prediction probability set and the annotation probability set, the inclusive text classification model to be trained is trained to obtain the inclusive text classification model.

[0076] Among them, the preset text categories include at least one text category, the number of inclusive training samples is greater than or equal to one, and the second preset classification model is used to normalize the inclusive training samples, so that an inclusive prediction probability set corresponding to each inclusive training sample and a labeling probability set corresponding to each inclusive training sample can be obtained, the inclusive prediction probability set includes the probability that the corresponding inclusive training sample belongs to each text category, and the labeling probability set includes the probability that the corresponding inclusive training sample is labeled as each text category.

[0077] Different text categories correspond to different annotations.

[0078] Among them, the text category that the inclusive training sample is labeled as is determined by the annotation of the training text. If the inclusive training sample is labeled as a certain text category, the annotation probability corresponding to the certain text category is 1, and the annotation probability corresponding to the text category other than the certain text category is 0.

[0079] For example, if there are three text categories (text category A, text category B, and text category C), and the training sample is labeled as belonging to text category A, then the labeling probability set corresponding to the training sample is (1, 0, 0).

[0080] In a possible implementation, the training of the inclusive text classification model to be trained based on the inclusive prediction probability set and the labeling probability set to obtain the inclusive text classification model includes:

[0081] Determining an inclusive prediction probability set corresponding to the inclusive training sample in the inclusive prediction probability set, and determining a labeled probability set corresponding to the inclusive training sample in the labeled probability set;

[0082] Obtaining a second loss value based on a second loss function, a set of inclusive prediction probabilities corresponding to the inclusive training samples, and a set of labeled probabilities corresponding to the inclusive training samples;

[0083] When the second loss value is greater than or equal to the second preset loss value, the second preset model parameters are adjusted based on the second loss value and the back propagation algorithm until the second loss value is less than the second preset loss value, thereby obtaining the inclusive text classification model.

[0084] Among them, since the preset text category includes at least one text category and the number of inclusive training samples is greater than or equal to one, an inclusive training sample B is arbitrarily selected from the inclusive training samples each time, and then the second loss value is determined based on the inclusive prediction probability set corresponding to the inclusive training sample B, the annotation probability set corresponding to the inclusive training sample B and the second loss function. If the second loss value is less than the second preset loss value, the second preset model parameters are adjusted, and an inclusive training sample other than the inclusive training sample B is arbitrarily selected from the inclusive training samples again as the inclusive training sample B until the second loss value is less than the second preset loss value.

[0085] The adjustment of the current second preset model parameters is performed on the basis of the second preset model parameters obtained by the last adjustment.

[0086] The second preset model parameter may be a positive number or a negative number.

[0087] Among them, the second loss function is p i represents the probability that the training sample belongs to the i-th text category, represents the probability that the training sample is labeled as the i-th text category.

[0088] For example, if there are three text categories (text category A, text category B, and text category C), the probability that training sample A belongs to text category A is 0.8, the probability that it belongs to text category B is 0.7, and the probability that it belongs to text category C is 0.5, and training sample A is labeled as text category A, then the loss value corresponding to training sample A is -1*log(0.8).

[0089] It can be seen that in the embodiment of the present application, when the second loss value is less than the second preset loss value, a second trained text classification model is obtained, which is conducive to improving the accuracy of determining the text classification.

[0090] In a possible implementation manner, after determining the target text category to which the to-be-classified text belongs based on the N first prediction probabilities, the method further includes:

[0091] Output the target text category and the predicted probability corresponding to the target text category.

[0092] Among them, it can be the target text category and its corresponding predicted probability association output.

[0093] It can be seen that in the embodiment of the present application, outputting the target text category and the predicted probability is helpful to understand the accuracy of text classification.

[0094] With the above Figure 2 For details on the embodiments shown in the drawings, please refer to Figure 3 , Figure 3 1 is a schematic diagram of the structure of another electronic device provided by an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the following steps:

[0095] Get training samples;

[0096] Using the training samples to train a preset text classification model to be trained to obtain a text classification model;

[0097] Acquire a text to be classified, input the text to be classified into the text classification model, and obtain a category prediction probability set, wherein the category prediction probability set includes a prediction probability that the sample to be classified belongs to a preset text category;

[0098] Based on the category prediction probability set, a target text category to which the to-be-classified text belongs is determined in the preset text categories.

[0099] In one implementation of the present application, in terms of using the training samples to train a preset text classification model to be trained to obtain a text classification model, the above program is specifically used to execute instructions for the following steps:

[0100] Dividing the training samples into inclusive training samples and exclusive training samples based on sample identifiers;

[0101] Training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain an exclusionary text classification model;

[0102] The inclusive text classification model to be trained is trained based on the inclusive training samples to obtain an inclusive text classification model.

[0103] In one implementation of the present application, in terms of training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain the exclusionary text classification model, the above program is specifically used to execute instructions for the following steps:

[0104] Inputting the exclusionary training sample into a first preset classification model to obtain an inclusive prediction probability set and an exclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the exclusionary training sample belongs to the preset text category, and the exclusive prediction probability set includes the probability that the exclusionary training sample is excluded from the preset text category;

[0105] Based on the inclusive prediction probability set and the exclusive prediction probability set, the exclusive text classification model to be trained is trained to obtain the exclusive text classification model.

[0106] In one implementation of the present application, in terms of training the to-be-trained exclusionary text classification model based on the inclusive prediction probability set and the exclusive prediction probability set to obtain the exclusionary text classification model, the above program is specifically used to execute instructions for the following steps:

[0107] Determining an inclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set, and determining an exclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set;

[0108] Obtaining a first loss value based on a first loss function, a set of inclusive prediction probabilities corresponding to the exclusive training samples, and a set of exclusive prediction probabilities corresponding to the exclusive training samples;

[0109] When the first loss value is greater than or equal to the first preset loss value, the first preset model parameters are adjusted based on the first loss value and the back propagation algorithm until the first loss value is less than the first preset loss value, thereby obtaining the exclusionary text classification model.

[0110] In one implementation of the present application, in terms of training the inclusive text classification model to be trained based on the inclusive training samples to obtain the inclusive text classification model, the above program is specifically used to execute the following steps:

[0111] Inputting the inclusive training sample into a second preset classification model to obtain an inclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the inclusive training sample belongs to the preset text category;

[0112] Determining a set of annotation probabilities based on the annotations of the inclusive training samples, wherein the set of annotation probabilities includes probabilities that the inclusive training samples are annotated as the preset text classification;

[0113] Based on the inclusive prediction probability set and the annotation probability set, the inclusive text classification model to be trained is trained to obtain the inclusive text classification model.

[0114] In one implementation of the present application, in terms of training the inclusive text classification model to be trained based on the inclusive prediction probability set and the labeled probability set to obtain the inclusive text classification model, the above program is specifically used to execute the following steps:

[0115] Determining an inclusive prediction probability set corresponding to the inclusive training sample in the inclusive prediction probability set, and determining a labeled probability set corresponding to the inclusive training sample in the labeled probability set;

[0116] Obtaining a second loss value based on a second loss function, a set of inclusive prediction probabilities corresponding to the inclusive training samples, and a set of labeled probabilities corresponding to the inclusive training samples;

[0117] When the second loss value is greater than or equal to the second preset loss value, the second preset model parameters are adjusted based on the second loss value and the back propagation algorithm until the second loss value is less than the second preset loss value, thereby obtaining the inclusive text classification model.

[0118] In an implementation of the present application, after determining the target text category to which the to-be-classified text belongs in the preset text category, the above program is further used to execute instructions for the following steps:

[0119] Output the target text category and the predicted probability corresponding to the target text category.

[0120] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process described in the above method embodiment, which will not be described here.

[0121] See also Figure 4 , Figure 4 : is a structural diagram of a text category recognition device provided in an embodiment of the present application, the device comprising:

[0122] A first acquisition unit 401 is used to acquire training samples;

[0123] The training unit 402 is used to train the preset text classification model to be trained using the training samples to obtain the text classification model;

[0124] The second acquisition unit 403 is used to acquire the text to be classified;

[0125] An input unit 404 is used to input the text to be classified into the text classification model to obtain a set of category prediction probabilities, wherein the set of category prediction probabilities includes a prediction probability that the sample to be classified belongs to a preset text category;

[0126] The determination unit 405 is configured to determine, based on the category prediction probability set, a target text category to which the to-be-classified text belongs in the preset text categories.

[0127] In an implementation of the present application, in terms of using the training samples to train a preset text classification model to be trained to obtain a text classification model, the training unit 402 is used to execute instructions for the following steps:

[0128] Dividing the training samples into inclusive training samples and exclusive training samples based on sample identifiers;

[0129] Training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain an exclusionary text classification model;

[0130] The inclusive text classification model to be trained is trained based on the inclusive training samples to obtain an inclusive text classification model.

[0131] In an implementation of the present application, in terms of training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain the exclusionary text classification model, the training unit 402 is used to execute instructions for the following steps:

[0132] Inputting the exclusionary training sample into a first preset classification model to obtain an inclusive prediction probability set and an exclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the exclusionary training sample belongs to the preset text category, and the exclusive prediction probability set includes the probability that the exclusionary training sample is excluded from the preset text category;

[0133] Based on the inclusive prediction probability set and the exclusive prediction probability set, the exclusive text classification model to be trained is trained to obtain the exclusive text classification model.

[0134] In one implementation of the present application, in terms of training the to-be-trained exclusionary text classification model based on the inclusive prediction probability set and the exclusive prediction probability set to obtain the exclusionary text classification model, the training unit 402 is used to execute instructions for the following steps:

[0135] Determining an inclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set, and determining an exclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set;

[0136] Obtaining a first loss value based on a first loss function, a set of inclusive prediction probabilities corresponding to the exclusive training samples, and a set of exclusive prediction probabilities corresponding to the exclusive training samples;

[0137] When the first loss value is greater than or equal to the first preset loss value, the first preset model parameters are adjusted based on the first loss value and the back propagation algorithm until the first loss value is less than the first preset loss value, thereby obtaining the exclusionary text classification model.

[0138] In one implementation of the present application, in terms of training the inclusive text classification model to be trained based on the inclusive training samples to obtain the inclusive text classification model, the training unit 402 is used to execute instructions for the following steps:

[0139] Inputting the inclusive training sample into a second preset classification model to obtain an inclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the inclusive training sample belongs to the preset text category;

[0140] Determining a set of annotation probabilities based on the annotations of the inclusive training samples, wherein the set of annotation probabilities includes probabilities that the inclusive training samples are annotated as the preset text classification;

[0141] Based on the inclusive prediction probability set and the annotation probability set, the inclusive text classification model to be trained is trained to obtain the inclusive text classification model.

[0142] In one implementation of the present application, in terms of training the inclusive text classification model to be trained based on the inclusive prediction probability set and the annotation probability set to obtain the inclusive text classification model, the training unit 402 is used to execute instructions for the following steps:

[0143] Determining an inclusive prediction probability set corresponding to the inclusive training sample in the inclusive prediction probability set, and determining a labeled probability set corresponding to the inclusive training sample in the labeled probability set;

[0144] Obtaining a second loss value based on a second loss function, a set of inclusive prediction probabilities corresponding to the inclusive training samples, and a set of labeled probabilities corresponding to the inclusive training samples;

[0145] When the second loss value is greater than or equal to the second preset loss value, the second preset model parameters are adjusted based on the second loss value and the back propagation algorithm until the second loss value is less than the second preset loss value, thereby obtaining the inclusive text classification model.

[0146] In a possible implementation manner, the text category identification apparatus further includes an output unit 406 .

[0147] In an implementation of the present application, after determining the target text category to which the to-be-classified text belongs in the preset text category, the output unit 406 is used to execute instructions for the following steps:

[0148] Output the target text category and the predicted probability corresponding to the target text category.

[0149] It should be noted that the first acquisition unit 401, the training unit 402, the second acquisition unit 403, the input unit 404, the determination unit 405 and the output unit 406 can be implemented by a processor.

[0150] An embodiment of the present application further provides a computer storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any text category recognition method recorded in the above method embodiments.

[0151] The present application also provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described for the electronic device in the above method. The computer program product may be a software installation package.

[0152] The steps of the method or algorithm described in the embodiment of the present application can be implemented in a hardware manner, or can be implemented by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory (Random Access Memory, RAM), a flash memory, a read-only memory (Read Only Memory, ROM), an erasable programmable read-only memory (Erasable Programmable ROM, EPROM), an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM), a register, a hard disk, a mobile hard disk, a read-only compact disk (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in an access network device, a target network device, or a core network device. Of course, the processor and the storage medium can also be present in an access network device, a target network device, or a core network device as discrete components.

[0153] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiments of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0154] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the embodiments of the present application. It should be understood that the above description is only the specific implementation method of the embodiments of the present application and is not intended to limit the protection scope of the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A text category recognition method, characterized in that: Applied to electronic equipment, the method comprises: Get training samples; The training samples are used to train the preset text classification model to be trained to obtain the text classification model, including: Dividing the training samples into inclusive training samples and exclusive training samples based on sample identifiers; Inputting the exclusionary training sample into a first preset classification model to obtain an inclusive prediction probability set and an exclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the exclusionary training sample belongs to a preset text category, and the exclusive prediction probability set includes the probability that the exclusionary training sample is excluded from the preset text category; based on the inclusive prediction probability set and the exclusive prediction probability set, training the exclusionary text classification model to be trained to obtain an exclusionary text classification model; Training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain an exclusionary text classification model; Training the inclusive text classification model to be trained based on the inclusive training samples to obtain an inclusive text classification model; Acquire a text to be classified, input the text to be classified into the text classification model, and obtain a category prediction probability set, wherein the category prediction probability set includes a prediction probability that the sample to be classified belongs to a preset text category; Based on the category prediction probability set, a target text category to which the to-be-classified text belongs is determined in the preset text categories.

2. The method according to claim 1, characterized in that The method of training the to-be-trained exclusionary text classification model based on the inclusive prediction probability set and the exclusive prediction probability set to obtain the exclusionary text classification model includes: Determining an inclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set, and determining an exclusive prediction probability set corresponding to the exclusive training sample in the inclusive prediction probability set; Obtaining a first loss value based on a first loss function, a set of inclusive prediction probabilities corresponding to the exclusive training samples, and a set of exclusive prediction probabilities corresponding to the exclusive training samples; When the first loss value is greater than or equal to the first preset loss value, the first preset model parameters are adjusted based on the first loss value and the back propagation algorithm until the first loss value is less than the first preset loss value, thereby obtaining the exclusionary text classification model.

3. The method according to claim 1, characterized in that The method of training the inclusive text classification model to be trained based on the inclusive training samples to obtain the inclusive text classification model includes: Inputting the inclusive training sample into a second preset classification model to obtain an inclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the inclusive training sample belongs to the preset text category; Determining a set of annotation probabilities based on the annotations of the inclusive training samples, wherein the set of annotation probabilities includes probabilities that the inclusive training samples are annotated as the preset text classification; Based on the inclusive prediction probability set and the annotation probability set, the inclusive text classification model to be trained is trained to obtain the inclusive text classification model.

4. The method according to claim 3, characterized in that The step of training the inclusive text classification model to be trained based on the inclusive prediction probability set and the labeling probability set to obtain the inclusive text classification model includes: Determining an inclusive prediction probability set corresponding to the inclusive training sample in the inclusive prediction probability set, and determining a labeled probability set corresponding to the inclusive training sample in the labeled probability set; Obtaining a second loss value based on a second loss function, a set of inclusive prediction probabilities corresponding to the inclusive training samples, and a set of labeled probabilities corresponding to the inclusive training samples; When the second loss value is greater than or equal to the second preset loss value, the second preset model parameters are adjusted based on the second loss value and the back propagation algorithm until the second loss value is less than the second preset loss value, thereby obtaining the inclusive text classification model.

5. The method according to claim 4, characterized in that After determining the target text category to which the text to be classified belongs in the preset text categories, the method further includes: Output the target text category and the predicted probability corresponding to the target text category.

6. A text category recognition device, characterized in that: The device comprises: A first acquisition unit, used to acquire training samples; A training unit, used to train a preset text classification model to be trained using the training samples to obtain a text classification model, comprising: Dividing the training samples into inclusive training samples and exclusive training samples based on sample identifiers; Inputting the exclusionary training sample into a first preset classification model to obtain an inclusive prediction probability set and an exclusive prediction probability set, wherein the inclusive prediction probability set includes the probability that the exclusionary training sample belongs to a preset text category, and the exclusive prediction probability set includes the probability that the exclusionary training sample is excluded from the preset text category; based on the inclusive prediction probability set and the exclusive prediction probability set, training the exclusionary text classification model to be trained to obtain an exclusionary text classification model; Training the exclusionary text classification model to be trained based on the exclusionary training samples to obtain an exclusionary text classification model; Training the inclusive text classification model to be trained based on the inclusive training samples to obtain an inclusive text classification model; A second acquisition unit, used for acquiring the text to be classified; An input unit, used for inputting the to-be-classified text into the text classification model to obtain a set of category prediction probabilities, wherein the set of category prediction probabilities includes a prediction probability that the to-be-classified sample belongs to a preset text category; A determination unit is used to determine, based on the category prediction probability set, a target text category to which the to-be-classified text belongs in the preset text categories.

7. An electronic device, characterized in that: The electronic device includes a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is processed to execute instructions of the steps in any one of claims 1-5.

Citation Information

Patent Citations

  • Image recognition method and device, electronic equipment and storage medium

    CN111814810A