WO2021119949A1 - Text classification model training method, text classification method and apparatus, and electronic device - Google Patents

Text classification model training method, text classification method and apparatus, and electronic device Download PDF

Info

Publication number
WO2021119949A1
WO2021119949A1 PCT/CN2019/125747 CN2019125747W WO2021119949A1 WO 2021119949 A1 WO2021119949 A1 WO 2021119949A1 CN 2019125747 W CN2019125747 W CN 2019125747W WO 2021119949 A1 WO2021119949 A1 WO 2021119949A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
classification model
text classification
sample set
prediction result
Prior art date
Application number
PCT/CN2019/125747
Other languages
French (fr)
Chinese (zh)
Inventor
刘园林
Original Assignee
深圳市欢太科技有限公司
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市欢太科技有限公司, Oppo广东移动通信有限公司 filed Critical 深圳市欢太科技有限公司
Priority to PCT/CN2019/125747 priority Critical patent/WO2021119949A1/en
Priority to CN201980100570.9A priority patent/CN114424186A/en
Publication of WO2021119949A1 publication Critical patent/WO2021119949A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification

Definitions

  • This application relates to the field of data processing technology, and in particular to a text classification model training method, text classification method, device and electronic equipment.
  • the embodiments of the present application provide a text classification model training method, text classification method, device, and electronic equipment, so as to improve the accuracy of classifying multi-level and multi-label text.
  • an embodiment of the present application provides a text classification model training method, including:
  • the second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
  • this application provides a text classification method, including:
  • the text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
  • an embodiment of the present application provides a text classification model training device, including:
  • the first obtaining module is used to obtain the first text sample set
  • a prediction module configured to input the first text sample set into the text classification model for text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
  • a judging module configured to compare the first prediction result with the real result, and judge whether the first prediction result meets a preset condition
  • An adjustment module configured to adjust the text classification model to obtain an adjusted text classification model if the first prediction result does not meet the preset condition
  • a processing module configured to process the target text whose first prediction result in the first text sample set does not meet a preset condition according to a preset processing mode, to obtain a second text sample set;
  • the training module is configured to input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
  • an embodiment of the present application provides a text classification device, including:
  • the second acquisition module is used to acquire a text set to be classified
  • the calling module is used to call the pre-trained text classification model
  • a classification module configured to input the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified
  • the text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
  • an embodiment of the present application provides a storage medium on which a computer program is stored, wherein, when the computer program is executed on a computer, the computer is caused to execute the text classification model training method provided in this embodiment Or text classification method.
  • an embodiment of the present application provides an electronic device including a memory and a processor, the memory stores a computer program, and the processor invokes the computer program stored in the memory to execute:
  • an embodiment of the present application provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor invokes the computer program stored in the memory to execute:
  • the text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
  • FIG. 1 is a schematic diagram of the first process of a text classification model training method provided by an embodiment of the application.
  • FIG. 2 is a schematic diagram of the second process of the text classification model training method provided by an embodiment of the application.
  • FIG. 3 is a schematic diagram of the third process of the text classification model training method provided by an embodiment of the application.
  • FIG. 4 is a schematic flowchart of a text classification method provided by an embodiment of the application.
  • Fig. 5 is a schematic structural diagram of a text classification model training method provided by an embodiment of the application.
  • FIG. 6 is a schematic structural diagram of a text classification device provided by an embodiment of the application.
  • FIG. 7 is a first structural diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a second structure of an electronic device provided by an embodiment of the present application.
  • the embodiments of the present application provide a text classification model training method and text classification method.
  • the text classification model training method and text classification method are applied to electronic devices.
  • the electronic device can be a smart phone, a tablet computer, a palmtop computer, a notebook computer, or a desktop computer that is equipped with a processor and has processing capabilities.
  • FIG. 1 is a schematic diagram of a first process of a text classification model training method provided by an embodiment of the present application.
  • the text classification model training method may include the following processes:
  • the first text sample set contains multiple first texts.
  • the text to be processed can be obtained first, and then the text to be processed can be segmented to obtain multiple first texts. Encoding is performed to obtain a plurality of first tags, and the first text and the first tags corresponding to the first text form a first text sample set.
  • the text to be processed can be segmented.
  • multiple text content in the browsing page can be captured, and the text content of the text to be processed can be several hundred Words, thousands of words, or tens of thousands of words, these text contents are used as the text to be processed, and multiple first texts can be obtained by performing word segmentation processing on the text to be processed.
  • multiple database texts in the database can also be obtained, and then the text to be processed is randomly obtained from the database text, the text to be processed is processed to obtain the target database text, and the target database text and the first text are combined into the first text.
  • Set of text samples are randomly obtained from the database text, the text to be processed is processed to obtain the target database text, and the target database text and the first text are combined into the first text.
  • the first text sample set is input to the text classification model.
  • the first text classification model can recognize multiple first texts, thereby classifying the first text, and obtaining the first text corresponding to the first text.
  • One prediction result Among them, each first text has its own corresponding prediction result.
  • step 104 is entered. Able to achieve the expected text classification effect. If the training result does not meet the preset condition, go to step 105.
  • the preset condition is to determine whether the first prediction result reaches 80% of the preset result, if the first prediction result reaches 80% of the preset result, it means that the prediction result of the text classification model is accurate; if the first prediction If the result is less than 80% of the preset result, it means that the prediction result of the text classification model is not very accurate, and the text classification model still needs to be trained.
  • the text classification model has been trained.
  • additional text sample sets can be obtained, for example, obtained from a database or randomly obtained through the network, and then input into the text classification model, if the prediction result meets the preset conditions , It means that the text classification model has been trained.
  • the text classification model is not suitable for classifying the first text sample set, and it may also be that the text classification model cannot complete the first set of samples alone.
  • the classification of a text sample set needs to add other models, or delete or add part of the structure in the text classification model, so as to realize the structural adjustment of the text classification model.
  • the number of convolutional layers or pooling layers of the convolutional neural network can be adjusted to achieve different feature extraction.
  • the final adjustment is The second label classification model.
  • the loss function in the text classification model can be adjusted according to the training result to obtain the second label classification model. Specifically, the loss function can be weighted.
  • the neural network model parameters can be adjusted according to the training result, the loss function of the neural network, and the preset result. Specifically, the neural network model parameters can be adjusted according to the training result and the loss function of the neural network. And the loss value is obtained from the preset result, and then the adjustment direction of the neural network is determined according to the loss value, and finally the parameters of the neural network are adjusted to obtain the second label classification model.
  • target texts that do not meet a preset condition in the first text may be obtained, and multiple target texts may be segmented according to a preset length to obtain multiple second texts.
  • one of the first texts is "Yuanmingyuan horse head issued a physical examination report today, with white scale inside”. If the preset length is 4 characters, the first text can be divided to obtain "Yuanmingyuan horse head, For the second texts released today, physical examination report, internal attachment, and white gutter, multiple second texts can be combined into a second text sample set.
  • the preset length can be set to hundreds or thousands of words.
  • the first text can be divided according to the preset length of 300. To get multiple second texts.
  • the second text sample set can be input to the adjusted text classification model to continue to predict the second text sample set, and then obtain the second prediction corresponding to the second text As a result, the second prediction result is compared with the actual result corresponding to the second text, and it is judged whether the second prediction result meets the preset condition. If the second prediction result meets the preset condition, the training of the text classification model is stopped.
  • the text classification model can already accurately classify the input files.
  • step 105 If the second prediction result still does not meet the preset condition, then go to step 105 to continue training the text classification model.
  • the prediction result of the text classification model meets the preset condition, it means that the text classification model has been trained.
  • the trained text classification model can accurately classify and recognize multi-label text.
  • the text classification model In the process of training the text classification model, by adjusting and optimizing the input text samples, and at the same time adjusting and optimizing the text classification model, the text classification model can accurately achieve the text classification effect in the process of predicting multi-label text. .
  • the first sample set is input into the text classification model for text category prediction; the obtained first prediction result is compared with the real result, and it is judged whether the first prediction result satisfies the prediction.
  • Set conditions if the preset conditions are not met, the text classification model is adjusted to obtain the adjusted text classification model; according to the preset processing method, the first prediction result in the first text sample set does not meet the preset conditions for the target text Processing is performed to obtain a second text sample set; the second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
  • the trained text classification model can classify multi-label texts and at the same time improve the accuracy of text classification.
  • FIG. 2 is a schematic diagram of the second process of the training method of the text classification model provided by the embodiment of the present application.
  • the training method of the text classification model includes the following processes:
  • the acquired text to be processed may be words, words, paragraphs, articles, etc., and the number of words in the text to be processed may be hundreds, thousands, or tens of thousands.
  • Text segmentation processing for example, you can divide the words in the paragraph, or divide the sentences in the article, and so on. You can also perform word segmentation processing on the text to be processed through the word segmenter. After the word segmentation process is performed on the text to be processed, the text after the word segmentation is the first text, and the first text includes multiple ones.
  • the text to be processed can be processed according to the model specifically adopted by the text classification model.
  • the text classification model is a model that does not require word segmentation, such as the BERT model
  • the text does not need to be segmented.
  • each first text needs to be coded, so that each first text has its own corresponding label, so that the multiple first texts can be distinguished.
  • the tags corresponding to the first text can be integrated, and multiple tags can be spliced and integrated into one tag.
  • the target first labels below the lowest label level can be obtained, and these target first labels are processed in subsequent steps.
  • labels below the lowest label level can be obtained.
  • the preset label level is 5, but there are 7 first labels of the same type.
  • the seven first labels are arranged from high to low as A, B, C, D, E, F, G.
  • label F and label G are lower than the lowest label level.
  • the label F and the label G can be determined to be the target first label, and the target first label F and the target first label G can be classified into the first label E of the lowest label level.
  • the tail tag is processed in this way.
  • tags of the same type can be integrated according to a preset tag hierarchy.
  • tags of the same type can be obtained from multiple first tags, where tags of the same type are A, B, C, D, E
  • the five first labels are integrated according to the preset label hierarchy.
  • the corresponding texts of the five first labels of A, B, C, D, and E are "current affairs", “domestic current affairs”, and “ “venue Current Affairs”, “Policies”, “San Nong”, if the default label level is 5 levels, and the first label needs to be spliced from high level to low level, then the combined label will be "ABCDE".
  • first labels of the same type can be integrated to form multiple integrated labels to reduce the number of labels.
  • Tag coding may be performed on multiple integrated tags. For example, onehot encoding may be used to code the integrated tags, and finally the integrated tags and the text corresponding to the integrated tags form the first text sample set.
  • FIG. 3 is a schematic diagram of the third process of the training method of the text classification model provided by the embodiment of the present application.
  • the training method of the text classification model may include the following processes:
  • invalid characters in the text to be processed can be filtered and deleted to ensure the authenticity of the text to be processed, and then the filtered text to be processed is segmented to obtain multiple first texts.
  • Multiple first texts are text-encoded to obtain multiple first tags.
  • tags of the same type can be integrated to form an integrated tag, and finally multiple integrated tags are tag-encoded, and finally the integrated tags
  • the text corresponding to the integrated label forms a first text sample set.
  • the first text sample set is input to the text classification model.
  • the first text classification model can recognize multiple first texts, thereby classifying the first text, and obtaining the first text corresponding to the first text.
  • One prediction result Among them, each first text has its own corresponding prediction result, and the sigmoid function can be used to calculate the accuracy value of the first prediction result.
  • the first prediction result can be compared with the actual result corresponding to the first text to determine whether the first prediction result meets a preset condition. For example, it can be determined whether the accuracy of the first prediction result reaches The preset accuracy rate, if the accuracy rate of the first prediction result does not reach the preset accuracy rate, the text classification model is adjusted.
  • the parameters of the text classification model can be adjusted.
  • the loss function of the text classification model can be obtained, and the first prediction result and the real result can be input into the loss function to obtain the loss value, which is adjusted according to the target loss value.
  • the parameters of the text classification model are adjusted so that the loss value of the text classification model is less than or equal to the target loss value.
  • the text classification model can also be concatenated with a preset model to adjust the text classification model.
  • the text classification model before the adjustment uses the BERT model, and the BERT model can also be concatenated.
  • Neural network model to form a new text classification model can also be concatenated.
  • the structure of the text classification model can be adjusted.
  • the text classification model uses an integrated model composed of a BERT model and a convolutional neural network model.
  • the convolutional neural network model can be multiplied.
  • the scale convolution kernel may implement multiple different pooling operations, and the number of layers of the convolutional neural network can also be changed.
  • the settings of some parameters in the text classification model before the adjustment are correct, and there is no need to adjust them.
  • These parameters that do not need to be adjusted are preset parameters.
  • Setting parameters can continue to adjust the text classification model, and the finally adjusted text classification model can continue to be used for the next training until the prediction result output by the text classification model meets the preset conditions.
  • the target tags are integrated through a preset label level to obtain the tail tags of the target tags, and some of the tail tags of the target tags can be selected to be included in the target tags of the lowest tag level.
  • the segmented text is encoded to obtain the target label, the target label is integrated through the preset label level, and the tail label of the target label is obtained.
  • the tail labels of some target labels can be selected to be included in the target label of the lowest label level.
  • high-confidence text and target text can be selected from the database and combined into a second text sample set.
  • the second text sample set can be input to the adjusted text classification model to continue to predict the second text sample set, and then obtain the second prediction corresponding to the second text As a result, the second prediction result is compared with the actual result corresponding to the second text, and it is judged whether the second prediction result meets the preset condition. If the second prediction result meets the preset condition, the training of the text classification model is stopped.
  • the text classification model can already accurately classify the input files.
  • the trained text classification model can accurately classify and recognize multi-label text.
  • the text category prediction is performed by inputting the first text sample set into the text classification model to obtain the first prediction result corresponding to the first text sample; if the first prediction result does not meet the preset condition
  • adjust the text classification model obtain the preset parameters of the text classification model, and set the preset parameters in the adjusted model; perform text segmentation on the target text according to the preset length to obtain multiple segmented texts;
  • a plurality of segmented texts are encoded to obtain a second text sample set; the second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the prediction condition.
  • a trained text classification model is obtained.
  • the trained text classification model can classify multi-level and multi-label text, and the prediction accuracy of the text classification model can also achieve the expected effect.
  • FIG. 4 is a text classification method provided by an embodiment of the present application.
  • the method includes the following processes:
  • the invalid characters in the text to be classified can be filtered and deleted to ensure the authenticity of the text to be classified.
  • the text encoding of multiple texts to be classified can obtain multiple text labels to be classified. Considering the large number of texts to be classified, you can Tag integration is performed on tags of the same type to form a text-to-be-categorized integrated label, and finally a plurality of text-to-be-categorized integration tags are tag-encoded, and finally the text-to-be-categorized integration tags and text to be classified form a text-to-be-categorized set.
  • the text classification model can accurately predict most of the text.
  • the text classification sub-model can also be concatenated after the text classification model. The classification sub-model can adjust the accuracy of text classification according to actual needs.
  • the accuracy of the classification result of the text to be classified is not very high, but it has reached a high degree of accuracy and can be used for multi-level and multi-label The text to be classified is classified.
  • the lowest-level tail label of the text label to be classified can be input into the text classification sub-model, so as to realize the text classification corresponding to the text corresponding to the lowest-level tail label of the text label to be classified, thereby achieving more accurate text classification. effect.
  • the text set to be classified is obtained; the pre-trained text classification model is invoked; the text set to be classified is input to the pre-trained text classification model to obtain the classification result of the text to be classified; The text corresponding to the lowest-level label, and the text corresponding to the lowest label-level label continues to be text categorized.
  • the classification of multi-level and multi-label text is realized, and the accuracy of text classification is improved.
  • FIG. 5 is a schematic structural diagram of a text classification model training device provided by an embodiment of the present application.
  • the text classification model training device 500 includes: a first acquisition module 510, a prediction module 520, a judgment module 530, and an adjustment module 540, a processing module 550, and a training module 560.
  • the first obtaining module 510 is configured to obtain a first text sample set
  • the prediction module 520 is configured to input the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
  • the judging module 530 is configured to compare the first prediction result with the real result, and determine whether the first prediction result meets a preset condition
  • the adjustment module 540 is configured to adjust the text classification model to obtain an adjusted text classification model if the first prediction result does not meet the preset condition;
  • the processing module 550 is configured to process the target text in the first text sample set whose first prediction result does not meet the preset condition according to a preset processing mode, to obtain a second text sample set;
  • the training module 560 is configured to input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
  • the first obtaining module 510 is specifically configured to obtain a text to be processed, perform word segmentation processing on the text to be processed to obtain a plurality of the first texts; and encode the first text to obtain all the texts.
  • a first label corresponding to the first text; and a plurality of the first labels are integrated according to a preset label level to obtain the first text sample set.
  • the first obtaining module 510 is specifically configured to obtain a target first label whose label level is lower than the lowest label level among the preset label levels; and classify the target first label into the lowest label Among the first tags in the hierarchy; multiple first tags of the same type are integrated according to the preset tag hierarchy to obtain a first text sample set.
  • the adjustment module 540 is specifically configured to input the first prediction result and the real result into the loss function of the text classification model to obtain a loss value; The parameters of the text classification model are adjusted.
  • the adjustment module 540 is specifically configured to adjust the network structure of the text classification model according to the first prediction result and the real result; connect the adjusted text classification model in series with a preset model .
  • the adjustment module 540 is specifically configured to obtain the loss function of the text classification model; and perform weighting processing on the loss function according to the first prediction result and the real result.
  • the adjustment module 540 is specifically configured to obtain preset parameters of the text classification model; and set the preset parameters in the adjusted text classification model.
  • the first sample set is obtained by the first obtaining module 510, and the prediction module 520 inputs the first sample set into the text classification model for text category prediction; the judgment module 530 will obtain the first sample set.
  • the prediction result is compared with the actual result to determine whether the first prediction result meets the preset condition; the adjustment module 540 adjusts the text classification model when the first prediction result does not meet the preset condition to obtain the adjusted text classification model
  • the processing module 550 processes the target text in the first text sample set whose first prediction result does not meet the preset conditions according to a preset processing method to obtain a second text sample set; the training module 560 inputs the second text sample set to the adjustment
  • the subsequent text classification model continues to train until the prediction result of the text classification model meets the preset conditions.
  • the trained text classification model can accurately classify multi-level and multi-label text.
  • FIG. 6 is a schematic structural diagram of a text classification device provided by an embodiment of the present application.
  • the text classification device 600 specifically includes: a second acquisition module 610, a calling module 620, and a classification module 630.
  • the second obtaining module 610 is used to obtain a target text set
  • the calling module 620 is used to call a pre-trained text classification model
  • the classification module 630 is configured to input the target text set into the pre-trained text classification model to obtain a classification result of the target text;
  • the text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiment of the application.
  • the classification module 630 is also used to input the lowest-level tail label of the text label to be classified into the text classification sub-model, so as to realize the text classification of the text corresponding to the lowest-level tail label of the text label to be classified, thereby achieving more accurate text Classification effect.
  • the second acquisition module 610 acquires the text set to be classified; the calling module 620 calls the pre-trained text classification model; the classification module 630 inputs the text set to be classified into the pre-trained text classification model to The classification result of the text to be classified is obtained; the classification module 630 may also obtain the lowest-level label corresponding to the text to be classified, and continue to perform text classification on the text corresponding to the label of the lowest label level. In this way, the classification of multi-level and multi-label text is realized, and the accuracy of text classification is improved.
  • the image attribute recognition device provided in this embodiment of the application belongs to the same concept as the image attribute recognition method in the above embodiment, and the image attribute that can be run on the image attribute recognition device is any one provided in the method embodiment.
  • the specific implementation process of the method please refer to the image processing method embodiment, which will not be repeated here.
  • the embodiment of the present application provides a computer-readable storage medium on which a computer program is stored.
  • the computer executes the network model training method or image provided in the embodiment of the present application. ⁇ Treatment methods.
  • the storage medium may be a magnetic disk, an optical disc, a read only memory (Read Only Memory, ROM,), or a random access device (Random Access Memory, RAM), etc.
  • An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory.
  • the processor is configured to execute the computer program stored in the memory by calling the computer program stored in the memory.
  • Example provides the training method of the network model or the image attribute recognition method.
  • the above-mentioned electronic device may be a mobile terminal such as a tablet computer or a smart phone.
  • a mobile terminal such as a tablet computer or a smart phone.
  • FIG. 7 is a schematic diagram of the first structure of an electronic device provided by an embodiment of this application.
  • the electronic device 700 may include components such as a memory 701 and a processor 702. Those skilled in the art can understand that the structure of the electronic device shown in FIG. 7 does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or a combination of certain components, or different component arrangements.
  • the memory 701 may be used to store software programs and modules.
  • the processor 702 executes various functional applications and data processing by running the computer programs and modules stored in the memory 701.
  • the memory 701 may mainly include a storage program area and a storage data area.
  • the storage program area may store an operating system, a computer program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data created by the use of electronic equipment, etc.
  • the processor 702 is the control center of the electronic device. It uses various interfaces and lines to connect the various parts of the entire electronic device. It executes the electronic device by running or executing the application program stored in the memory 701 and calling the data stored in the memory 701. The various functions and processing data of the electronic equipment can be used to monitor the electronic equipment as a whole.
  • the memory 701 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • the memory 701 may further include a memory controller to provide the processor 702 with access to the memory 701.
  • the processor 702 in the electronic device will load the executable code corresponding to the process of one or more application programs into the memory 701 according to the following instructions, and the processor 702 will run and store the executable code in the memory 701.
  • processor 702 when the processor 702 adjusts the text classification model, it may execute:
  • the parameters of the text classification model are adjusted according to the loss value.
  • processor 702 when the processor 702 adjusts the text classification model, it may execute:
  • a preset model is connected in series with the adjusted text classification model.
  • processor 702 when the processor 702 adjusts the text classification model, it may execute:
  • processor 702 when it adjusts the text classification model, it may execute:
  • the preset parameters are set in the adjusted text classification model.
  • the processor 702 when the processor 702 processes the target text whose first prediction result in the first text sample set does not meet a preset condition according to a preset processing manner, it may execute:
  • the processor 702 may execute:
  • the processor 702 when the processor 702 executes to integrate a plurality of the first tags according to a preset tag level to obtain the first text sample set, it may execute:
  • the multiple first tags of the same type are integrated according to the preset tag level to obtain a first text sample set.
  • the processor 702 in the electronic device will load the executable code corresponding to the process of one or more application programs into the memory 701 according to the following instructions, and the processor 702 will run and store the executable code in the memory 701.
  • the text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiment of the application.
  • FIG. 8 is a schematic diagram of a second structure of an electronic device provided by an embodiment of the application.
  • the electronic device further includes a camera component 703, a radio frequency circuit 704, an audio circuit 705, and Power supply 706.
  • the display 703, the radio frequency circuit 704, the audio circuit 705, and the power supply 706 are electrically connected to the processor 702, respectively.
  • the display 703 may be used to display information input by the user or information provided to the user, and various graphical user interfaces. These graphical user interfaces may be composed of graphics, text, icons, videos, and any combination thereof.
  • the display 703 may include a display panel.
  • the display panel may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • the radio frequency circuit 704 may be used to transmit and receive radio frequency signals to establish wireless communication with network equipment or other electronic equipment through wireless communication, and to transmit and receive signals with the network equipment or other electronic equipment.
  • the audio circuit 705 may be used to provide an audio interface between the user and the electronic device through a speaker or a microphone.
  • the power supply 706 can be used to power various components of the electronic device 600.
  • the power supply 706 may be logically connected to the processor 702 through a power management system, so that functions such as charging, discharging, and power consumption management can be managed through the power management system.
  • the electronic device 600 may also include a camera component, a Bluetooth module, etc.
  • the camera component may include an image processing circuit, which may be implemented by hardware and/or software components, and may include defining image signal processing (Image Signal Processing) various processing units of the pipeline.
  • the image processing circuit may at least include: multiple cameras, an image signal processor (Image Signal Processor, ISP processor), a control logic, an image memory, a display, and the like.
  • Each camera can include at least one or more lenses and image sensors.
  • the image sensor may include a color filter array (such as a Bayer filter). The image sensor can obtain the light intensity and wavelength information captured by each imaging pixel of the image sensor, and provide a set of raw image data that can be processed by the image signal processor.
  • the training device/text classification device of the text classification model provided by the embodiment of the application belongs to the same concept as the training method/text classification method of the text classification model in the above embodiments. Any method provided in the training method/text classification method embodiment of the text classification model can be run on the classification device. For the specific implementation process, please refer to the training method/image processing method embodiment of the network model. Go into details again.
  • the training method/text classification method of the text classification model described in the embodiment of the present application a person of ordinary skill in the art can understand all of the training method/image processing method of the network model described in the embodiment of the present application. Or part of the process can be accomplished by controlling the relevant hardware through a computer program.
  • the computer program can be stored in a computer readable storage medium, such as in a memory, and executed by at least one processor. May include the flow of the embodiment of the training method of the network model/the image processing method.
  • the storage medium may be a magnetic disk, an optical disc, a read only memory (ROM, Read Only Memory), a random access memory (RAM, Random Access Memory), etc.
  • the network model training device/image processing device of the embodiment of the present application its functional modules can be integrated into one processing chip, or each module can exist alone physically, or two or more modules can be used. Integrated in a module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software functional modules. If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk, etc. .

Abstract

A text classification model training method, a text classification method and apparatus, and an electronic device. The training method comprises: obtaining a first text sample set (101); inputting the first text sample set to a text classification model to obtain a first prediction result (102); if the first prediction result does not satisfy a preset condition, adjusting the text classification model (105); and inputting a second sample set to the adjusted text classification model until the prediction result of the text classification model satisfies the preset condition (107).

Description

文本分类模型训练方法、文本分类方法、装置及电子设备Text classification model training method, text classification method, device and electronic equipment 技术领域Technical field
本申请涉及数据处理技术领域,尤其涉及一种文本分类模型训练方法、文本分类方法、装置及电子设备。This application relates to the field of data processing technology, and in particular to a text classification model training method, text classification method, device and electronic equipment.
背景技术Background technique
随着互联网以及移动互联网的蓬勃发展,待分析的文档数量急剧上升。如何对不同粒度文本(如句子、段落、文档)进行类别标记对信息发现、信息浏览和分析具有重要意义。比如,在内容分发业务中诸多业务实现需要依赖细粒度标签才能更好的完成,如细粒度标签可以丰富用户画像标签库,更完美地刻画用户形象,可以支持信息流更加细粒度的推荐。而实际业务中能够发掘出来的有效标签有数以万计,其中比较重要的会有数千之多,能按数千量级的大规模多级标签集合对文本打标的技术也就显得尤为重要。With the vigorous development of the Internet and mobile Internet, the number of documents to be analyzed has risen sharply. How to classify texts with different granularities (such as sentences, paragraphs, documents) is of great significance for information discovery, information browsing and analysis. For example, in the content distribution business, the realization of many services needs to rely on fine-grained tags. For example, fine-grained tags can enrich the user portrait tag library, better describe the user's image, and support more fine-grained recommendation of information flow. There are tens of thousands of effective tags that can be discovered in the actual business, and thousands of them are more important. The technology that can mark text with a large-scale multi-level tag collection of the order of thousands is particularly important. .
目前有方案是对每个层级的标签各自建立自己的文本分类模型,最后将多个模型的推理结果整合起来;还有方案是利用神经网络构建多级文本多标签分类模型,并根据该模型得到训练文本的文本类别预测结果;还有方案是将当前待分类的文本分别输入训练过的多个文本分类模型,计算各个层文本的概率,利用各层级概率乘积进行推理最后一级标签,并利用层级之间的标签关系反推获取各个级别的标签。At present, there is a solution to build its own text classification model for each level of label, and finally to integrate the inference results of multiple models; another solution is to use a neural network to build a multi-level text and multi-label classification model, and get it based on the model. The text category prediction result of the training text; another solution is to input the current text to be classified into multiple trained text classification models, calculate the probability of each layer of text, use the product of the probabilities of each level to infer the last level of label, and use The label relationship between the levels is reversed to obtain the labels of each level.
但是现有及模型方案中存在几大问题,一是对于多数量的标签不能达到良好的预测结果;二是不能根据标签的变化来对模型进行迭代学习,不能对标签的层级关系进行很好的预测;三是对多数量标签进行处理时计算量较大且耗时较长。However, there are several major problems in the existing and model solutions. One is that good prediction results cannot be achieved for a large number of tags; the other is that the model cannot be iteratively learned according to the changes of tags, and the hierarchical relationship of the tags cannot be well performed. Prediction; The third is that the processing of a large number of tags is computationally intensive and time-consuming.
发明内容Summary of the invention
本申请实施例提供一种文本分类模型训练方法、文本分类方法、装置及电子设备,以提高对多级多标签的文本进行分类的准确率。The embodiments of the present application provide a text classification model training method, text classification method, device, and electronic equipment, so as to improve the accuracy of classifying multi-level and multi-label text.
第一方面,本申请实施例提供了一种文本分类模型训练方法,包括:In the first aspect, an embodiment of the present application provides a text classification model training method, including:
获取第一文本样本集;Obtain the first text sample set;
将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;Inputting the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;Comparing the first prediction result with the real result, and judging whether the first prediction result meets a preset condition;
若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;If the first prediction result does not meet the preset condition, adjusting the text classification model to obtain an adjusted text classification model;
根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;Processing, according to a preset processing manner, the target text in the first text sample set whose first prediction result does not meet the preset condition, to obtain a second text sample set;
将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训 练,直至所述文本分类模型的预测结果满足所述预设条件为止。The second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
第二方面,本申请本提供一种文本分类方法,包括:In the second aspect, this application provides a text classification method, including:
获取待分类文本集;Obtain the text set to be classified;
调用预先训练的文本分类模型;Call a pre-trained text classification model;
将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;Inputting the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
其中所述文本分类模型为采用本申请实施例提供的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
第三方面,本申请实施例提供了一种文本分类模型的训练装置,包括:In the third aspect, an embodiment of the present application provides a text classification model training device, including:
第一获取模块,用于获取第一文本样本集;The first obtaining module is used to obtain the first text sample set;
预测模块,用于将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;A prediction module, configured to input the first text sample set into the text classification model for text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
判断模块,用于将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;A judging module, configured to compare the first prediction result with the real result, and judge whether the first prediction result meets a preset condition;
调整模块,用于若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;An adjustment module, configured to adjust the text classification model to obtain an adjusted text classification model if the first prediction result does not meet the preset condition;
处理模块,用于根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;A processing module, configured to process the target text whose first prediction result in the first text sample set does not meet a preset condition according to a preset processing mode, to obtain a second text sample set;
训练模块,用于将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。The training module is configured to input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
第四方面,本申请实施例提供了一种文本分类装置,包括:In a fourth aspect, an embodiment of the present application provides a text classification device, including:
第二获取模块,用于获取待分类文本集;The second acquisition module is used to acquire a text set to be classified;
调用模块,用于调用预先训练的文本分类模型;The calling module is used to call the pre-trained text classification model;
分类模块,用于将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;A classification module, configured to input the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
其中所述文本分类模型为采用本申请实施例提供的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
第五方面,本申请实施例提供一种存储介质,其上存储有计算机程序,其中,当所述计算机程序在计算机上执行时,使得所述计算机执行本实施例提供的文本分类模型的训练方法或文本分类方法。In a fifth aspect, an embodiment of the present application provides a storage medium on which a computer program is stored, wherein, when the computer program is executed on a computer, the computer is caused to execute the text classification model training method provided in this embodiment Or text classification method.
第六方面,本申请实施例提供一种电子设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器通过调用所述存储器中存储的所述计算机程序,用于执行:In a sixth aspect, an embodiment of the present application provides an electronic device including a memory and a processor, the memory stores a computer program, and the processor invokes the computer program stored in the memory to execute:
获取第一文本样本集;Obtain the first text sample set;
将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;Inputting the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;Comparing the first prediction result with the real result, and judging whether the first prediction result meets a preset condition;
若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;If the first prediction result does not meet the preset condition, adjusting the text classification model to obtain an adjusted text classification model;
根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;Processing, according to a preset processing manner, the target text in the first text sample set whose first prediction result does not meet the preset condition, to obtain a second text sample set;
将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。Inputting the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model satisfies the preset condition.
第七方面,本申请实施例提供一种电子设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器通过调用所述存储器中存储的所述计算机程序,用于执行:In a seventh aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor invokes the computer program stored in the memory to execute:
获取待分类文本集;Obtain the text set to be classified;
调用预先训练的文本分类模型;Call a pre-trained text classification model;
将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;Inputting the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
其中所述文本分类模型为采用本申请实施例提供的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the training method of the text classification model provided in the embodiment of the present application.
附图说明Description of the drawings
下面结合附图,通过对本申请的具体实施方式详细描述,将使本申请的技术方案及其它有益效果显而易见。The following detailed description of specific implementations of the present application in conjunction with the accompanying drawings will make the technical solutions and other beneficial effects of the present application obvious.
图1为本申请实施例提供的文本分类模型训练方法的第一流程示意图。FIG. 1 is a schematic diagram of the first process of a text classification model training method provided by an embodiment of the application.
图2为本申请实施例提供的文本分类模型训练方法的第二流程示意图。FIG. 2 is a schematic diagram of the second process of the text classification model training method provided by an embodiment of the application.
图3为本申请实施例提供的文本分类模型训练方法的第三流程示意图。FIG. 3 is a schematic diagram of the third process of the text classification model training method provided by an embodiment of the application.
图4为本申请实施例提供的文本分类方法的流程示意图。FIG. 4 is a schematic flowchart of a text classification method provided by an embodiment of the application.
图5为本申请实施例提供的文本分类模型训练方法的结构示意图。Fig. 5 is a schematic structural diagram of a text classification model training method provided by an embodiment of the application.
图6为本申请实施例提供的文本分类装置的结构示意图。FIG. 6 is a schematic structural diagram of a text classification device provided by an embodiment of the application.
图7是本申请实施例提供的电子设备的第一结构示意图。FIG. 7 is a first structural diagram of an electronic device provided by an embodiment of the present application.
图8是本申请实施例提供的电子设备的第二结构示意图。FIG. 8 is a schematic diagram of a second structure of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例用于解释本申请,而非对本申请的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本申请相关的部分而非全部结构。The application will be further described in detail below with reference to the drawings and embodiments. It is understandable that the specific embodiments described here are used to explain the application, but not to limit the application. In addition, it should be noted that, for ease of description, the drawings only show a part of the structure related to the present application instead of all of the structure.
这里所使用的术语仅仅是为了描述具体实施例而不意图限制示例性实施例。除非上下文明确地另有所指,否则这里所使用的单数形式“一个”、“一项”还意图包括复数。还应当理解的是,这里所使用的术语“包括”和/或“包含”规定所陈述的特征、整数、步骤、操作、单元和/或组件的存在,而不排除存在或添加一个或更多其他特征、整数、步骤、操作、单元、组件和/或其组合。The terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments. Unless the context clearly dictates otherwise, the singular forms "a" and "one" used herein are also intended to include the plural. It should also be understood that the terms "including" and/or "comprising" used herein specify the existence of the stated features, integers, steps, operations, units and/or components, and do not exclude the existence or addition of one or more Other features, integers, steps, operations, units, components, and/or combinations thereof.
本申请实施例提供一种文本分类模型的训练方法及文本分类方法,该文本分类模型的训练方法及文本分类方法应用于电子设备。其中,电子设备可以是 智能手机、平板电脑、掌上电脑、笔记本电脑、或者台式电脑等配置有处理器而具有处理能力的设备。The embodiments of the present application provide a text classification model training method and text classification method. The text classification model training method and text classification method are applied to electronic devices. Among them, the electronic device can be a smart phone, a tablet computer, a palmtop computer, a notebook computer, or a desktop computer that is equipped with a processor and has processing capabilities.
请参阅图1,图1是本申请实施例提供的文本分类模型训练方法的第一流程示意图。其中该文本分类模型训练方法可以包括以下流程:Please refer to FIG. 1. FIG. 1 is a schematic diagram of a first process of a text classification model training method provided by an embodiment of the present application. The text classification model training method may include the following processes:
101、获取第一文本样本集。101. Obtain a first text sample set.
第一文本样本集中包含多个第一文本,其中,在获取第一文本样本集的过程中,可以先获取待处理文本,然后对待处理文本进行分割,得到多个第一文本,对第一文本进行编码以得到多个第一标签,第一文本及第一文本对应的第一标签组成第一文本样本集。The first text sample set contains multiple first texts. In the process of obtaining the first text sample set, the text to be processed can be obtained first, and then the text to be processed can be segmented to obtain multiple first texts. Encoding is performed to obtain a plurality of first tags, and the first text and the first tags corresponding to the first text form a first text sample set.
例如,获取的待处理文本中有多段文字,可以通过对待处理文本进行分词,例如在浏览文章或者新闻时,可以捕获浏览页面中的多个文字内容,其中待处理文本的文字内容可以为几百字、几千字或者几万字,将这些文字内容作为待处理文本,通过对待处理文本进行分词处理,就可以得到多个第一文本。For example, if there are multiple pieces of text in the acquired text to be processed, the text to be processed can be segmented. For example, when browsing articles or news, multiple text content in the browsing page can be captured, and the text content of the text to be processed can be several hundred Words, thousands of words, or tens of thousands of words, these text contents are used as the text to be processed, and multiple first texts can be obtained by performing word segmentation processing on the text to be processed.
在一些实施方式中,也可以获取数据库中的多个数据库文本,再从数据库文本中随机获取待处理文本,对待处理文本进行处理得到目标数据库文本,将目标数据库文本和第一文本组合成第一文本样本集。In some embodiments, multiple database texts in the database can also be obtained, and then the text to be processed is randomly obtained from the database text, the text to be processed is processed to obtain the target database text, and the target database text and the first text are combined into the first text. Set of text samples.
102、将第一文本样本集输入至文本分类模型进行文本类别预测,以得到第一文本样本对应的第一预测结果。102. Input the first text sample set into a text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample.
在获取第一文本样本集之后,将第一文本样本集输入至文本分类模型,第文本分类模型能够对多个第一文本进行识别,从而对第一文本进行分类,得到第一文本对应的第一预测结果。其中,每一个第一文本都有各自对应的预测结果。After the first text sample set is obtained, the first text sample set is input to the text classification model. The first text classification model can recognize multiple first texts, thereby classifying the first text, and obtaining the first text corresponding to the first text. One prediction result. Among them, each first text has its own corresponding prediction result.
103、将第一预测结果和真实结果进行对比,判断第一预测结果是否满足预设条件。103. Compare the first prediction result with the real result, and determine whether the first prediction result meets a preset condition.
其中,在获取到第一预测结果之后,可以判断第一文本对应的第一预测结果是否满足预设条件,若满足,则文本分类模型已经训练完成,进入步骤104中。能够达到预期的文本分类效果。若训练结果不满足预设条件,则进入步骤105中。Wherein, after the first prediction result is obtained, it can be judged whether the first prediction result corresponding to the first text meets the preset condition, if it is satisfied, the text classification model has been trained, and step 104 is entered. Able to achieve the expected text classification effect. If the training result does not meet the preset condition, go to step 105.
例如,在预设条件为判断第一预测结果是否达到预设结果的80%,若第一预测结果达到预设结果的80%,则说明文本分类模型的预测结果是准确的;若第一预测结果小于预设结果的80%,则说文本明分类模型的预测结果并不是很准确,还需要继续对文本分类模型进行训练。For example, if the preset condition is to determine whether the first prediction result reaches 80% of the preset result, if the first prediction result reaches 80% of the preset result, it means that the prediction result of the text classification model is accurate; if the first prediction If the result is less than 80% of the preset result, it means that the prediction result of the text classification model is not very accurate, and the text classification model still needs to be trained.
104、若第一预测结果满足预设条件,则文本分类模型已训练完成。104. If the first prediction result meets the preset condition, the text classification model has been trained.
可以理解的是,在第一预测结果满足预设条件的情况下,则停止对文本分类模型的训练,此时文本分类模型已经训练完成。It is understandable that when the first prediction result meets the preset condition, the training of the text classification model is stopped, and the training of the text classification model has been completed at this time.
在一些实施方式中,为了进一步判断文本分类模型是否已训练完成,可以另外获取文本样本集,例如从数据库中获取或者通过网络随机获取,然后输入至文本分类模型中,若预测结果满足预设条件,则说明文本分类模型已训练完 成。In some embodiments, in order to further determine whether the text classification model has been trained, additional text sample sets can be obtained, for example, obtained from a database or randomly obtained through the network, and then input into the text classification model, if the prediction result meets the preset conditions , It means that the text classification model has been trained.
105、若第一预测结果不满足预设条件,则对文本分类模型进行调整,以得到调整后的文本分类模型。105. If the first prediction result does not meet the preset condition, adjust the text classification model to obtain an adjusted text classification model.
可以理解的是,若第一预测结果与真实结果之间相差较大,则有可能是文本分类模型不适合对第一文本样本集进行分类,还有可能是文本分类模型并不能独自完成对第一文本样本集的分类,需要加入其他模型,或者对文本分类模型中部分结构进行删除或增加,从而实现对文本分类模型的结构调整。It is understandable that if there is a large difference between the first prediction result and the real result, it may be that the text classification model is not suitable for classifying the first text sample set, and it may also be that the text classification model cannot complete the first set of samples alone. The classification of a text sample set needs to add other models, or delete or add part of the structure in the text classification model, so as to realize the structural adjustment of the text classification model.
在一些实施方式中,当文本分类模型中包含卷积神经网络,可以对卷积神经网络的卷积层或者池化层的层数进行调整,以此来实现不同的特征提取,最终调整后得到第二标签分类模型。In some embodiments, when the text classification model includes a convolutional neural network, the number of convolutional layers or pooling layers of the convolutional neural network can be adjusted to achieve different feature extraction. The final adjustment is The second label classification model.
在一些实施方式中,若文本分类模型中包含神经网络,可以根据训练结果对文本分类模型中的损失函数进行调整,以此来得到第二标签分类模型,具体的可以对损失函数进行加权处理。In some embodiments, if the text classification model includes a neural network, the loss function in the text classification model can be adjusted according to the training result to obtain the second label classification model. Specifically, the loss function can be weighted.
在一些实施方式中,若文本分类模型中包含神经网络,可以根据训练结果、神经网络的损失函数以及预设结果对神经网络模型参数进行调整,具体的,可以根据训练结果、神经网络的损失函数以及预设结果得到损失值,然后根据损失值确定对神经网络的调整方向,最终对神经网络进行参数调整,得到第二标签分类模型。In some embodiments, if a neural network is included in the text classification model, the neural network model parameters can be adjusted according to the training result, the loss function of the neural network, and the preset result. Specifically, the neural network model parameters can be adjusted according to the training result and the loss function of the neural network. And the loss value is obtained from the preset result, and then the adjustment direction of the neural network is determined according to the loss value, and finally the parameters of the neural network are adjusted to obtain the second label classification model.
106、根据预设处理方式对第一文本样本集中第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集。106. Process the target text whose first prediction result in the first text sample set does not meet the preset condition according to a preset processing mode, to obtain a second text sample set.
在一些实施方式中,可以获取第一文本中不满足预设条件的目标文本,对多个目标文本根据预设长度进行分割,来得到多个第二文本。例如,其中一个第一文本为“圆明园马首今天发布体检报告,内部附着白色水垢”,若预设长度为4个字的长度,则可以将该第一文本进行分割,得到“圆明园马首、今天发布、体检报告、内部附着、白色水沟”这几个第二文本,多个第二文本可以组合成第二文本样本集。In some implementation manners, target texts that do not meet a preset condition in the first text may be obtained, and multiple target texts may be segmented according to a preset length to obtain multiple second texts. For example, one of the first texts is "Yuanmingyuan horse head issued a physical examination report today, with white scale inside". If the preset length is 4 characters, the first text can be divided to obtain "Yuanmingyuan horse head, For the second texts released today, physical examination report, internal attachment, and white gutter, multiple second texts can be combined into a second text sample set.
需要说明的是,在实际的应用中,可以设置预设长度可以为几百字或者几千字,比如,预设长度为300字的时候,可以对第一文本按照预设长度300来进行分割来得到多个第二文本。It should be noted that in actual applications, the preset length can be set to hundreds or thousands of words. For example, when the preset length is 300 words, the first text can be divided according to the preset length of 300. To get multiple second texts.
在一些实施方式中,还可以获取不满足预设条件的目标文本以及获取数据库中可预测的真实文本数据,将第一标签和可预测的真实文本数据组合形成第二文本样本集。In some embodiments, it is also possible to obtain target texts that do not meet preset conditions and obtain predictable real text data in the database, and combine the first label and the predictable real text data to form a second text sample set.
107、将第二文本样本集输入至调整后的文本分类模型中继续进行训练,直至文本分类模型的预测结果满足预设条件为止。107. Input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
可以理解的是,在获取到第二文本样本集之后,可以将第二文本样本集输入至调整后的文本分类模型继续对第二文本样本集进行预测,然后获取第二文本对应的第二预测结果,将第二预测结果和第二文本对应的真实结果进行对比,判断第二预测结果是否满足预设条件,若第二预测结果满足预设条件,则停止 对文本分类模型进行训练,此时文本分类模型已经可以准确对输入的文件进行分类。It is understandable that after the second text sample set is obtained, the second text sample set can be input to the adjusted text classification model to continue to predict the second text sample set, and then obtain the second prediction corresponding to the second text As a result, the second prediction result is compared with the actual result corresponding to the second text, and it is judged whether the second prediction result meets the preset condition. If the second prediction result meets the preset condition, the training of the text classification model is stopped. The text classification model can already accurately classify the input files.
如果第二预测结果仍然不满足预设条件,则转至步骤105中继续对文本分类模型进行训练,一直到文本分类模型的预测结果满足预设条件的时候,说明文本分类模型已经训练完成。通过对输入的文本样本集进行数据改变以及对文本分类模型的调整,在训练完成的文本分类模型能够准确的对多标签的文本进行分类识别。If the second prediction result still does not meet the preset condition, then go to step 105 to continue training the text classification model. When the prediction result of the text classification model meets the preset condition, it means that the text classification model has been trained. By changing the data of the input text sample set and adjusting the text classification model, the trained text classification model can accurately classify and recognize multi-label text.
在对文本分类模型的训练过程中,通过对输入的文本样本进行调整优化,同时对文本分类模型进行调整优化,能够使得文本分类模型在对多标签文本的预测过程中能够准确的实现文本分类效果。In the process of training the text classification model, by adjusting and optimizing the input text samples, and at the same time adjusting and optimizing the text classification model, the text classification model can accurately achieve the text classification effect in the process of predicting multi-label text. .
由上述可知,通过获取第一样本集,将第一样本集输入至文本分类模型中进行文本类别预测;将得到的第一预测结果和真实结果进行对比,判断第一预测结果是否满足预设条件;若不满足预设条件,则对文本分类模型进行调整,以得到调整后的文本分类模型;根据预设处理方式对第一文本样本集中第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;将第二文本样本集输入至调整后的文本分类模型中继续进行训练,直至文本分类模型的预测结果满足预设条件为止。训练完成的文本分类模型能够对多标签的文本进行分类,同时还能提高文本分类的准确性。It can be seen from the above that by obtaining the first sample set, the first sample set is input into the text classification model for text category prediction; the obtained first prediction result is compared with the real result, and it is judged whether the first prediction result satisfies the prediction. Set conditions; if the preset conditions are not met, the text classification model is adjusted to obtain the adjusted text classification model; according to the preset processing method, the first prediction result in the first text sample set does not meet the preset conditions for the target text Processing is performed to obtain a second text sample set; the second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition. The trained text classification model can classify multi-label texts and at the same time improve the accuracy of text classification.
请继续参阅图2,图2是本申请实施例提供的文本分类模型的训练方法的第二流程示意图。在获取第一文本样本集之前,该文本分类模型的训练方法包括以下流程:Please continue to refer to FIG. 2. FIG. 2 is a schematic diagram of the second process of the training method of the text classification model provided by the embodiment of the present application. Before obtaining the first text sample set, the training method of the text classification model includes the following processes:
201、获取待处理文本,对待处理文本进行分词处理以得到多个第一文本。201. Obtain a text to be processed, and perform word segmentation processing on the text to be processed to obtain multiple first texts.
在一种实施方式中,获取的待处理文本可能是字、词、段落、文章等,待处理文本的字数可以是几百、几千或者几万,在获取到待处理文本之后,可以对待处理文本进行分词处理,比如,可以对段落中的词进行划分,或者对文章中的句子进行划分等等。还可以通过分词器对待处理文本进行分词处理。在对待处理文本进行分词处理之后,分词之后的文本为第一文本,其中第一文本包括多个。In an embodiment, the acquired text to be processed may be words, words, paragraphs, articles, etc., and the number of words in the text to be processed may be hundreds, thousands, or tens of thousands. After the text to be processed is acquired, it can be processed. Text segmentation processing, for example, you can divide the words in the paragraph, or divide the sentences in the article, and so on. You can also perform word segmentation processing on the text to be processed through the word segmenter. After the word segmentation process is performed on the text to be processed, the text after the word segmentation is the first text, and the first text includes multiple ones.
需要说明的是,可以根据文本分类模型具体采用的模型来待处理文本进行处理,例如,当文本分类模型为不需要分词的模型的时候,比如为BERT模型的时候,是不需要对文本进行分词处理的,此时可以直接将多个待处理文本作为第一文本样本输入至文本分类模型之中的;当文本分类模型为需要分词的模型的时候,例如卷积神经网络模型,此时是需要对待处理文本进行分词处理的,从而得到多个第一文本样本。It should be noted that the text to be processed can be processed according to the model specifically adopted by the text classification model. For example, when the text classification model is a model that does not require word segmentation, such as the BERT model, the text does not need to be segmented. For processing, you can directly input multiple texts to be processed as the first text sample into the text classification model; when the text classification model is a model that requires word segmentation, such as a convolutional neural network model, it is required at this time Perform word segmentation processing on the text to be processed, thereby obtaining multiple first text samples.
202、对第一文本进行编码以得到对应的第一标签。202. Encode the first text to obtain a corresponding first label.
可以理解的是,在获取到多个第一文本之后,需要对每一个第一文本进行编码,从而使得每一个第一文本有自己对应的标签,使得多个第一文本之间区分开来。It is understandable that after obtaining multiple first texts, each first text needs to be coded, so that each first text has its own corresponding label, so that the multiple first texts can be distinguished.
203、获取标签层级低于预设标签层级中最低标签层级的目标第一标签。203. Obtain the target first label whose label level is lower than the lowest label level in the preset label levels.
在第一文本的数量较多时,可以对第一文本对应的标签进行整合,将多个标签拼接整合成一个标签。但是在同类型的第一标签较多的情况下,可以获取低于最低标签层级的目标第一标签,在后续步骤中对这些目标第一标签进行处理。When the number of the first text is large, the tags corresponding to the first text can be integrated, and multiple tags can be spliced and integrated into one tag. However, when there are many first labels of the same type, the target first labels below the lowest label level can be obtained, and these target first labels are processed in subsequent steps.
可以理解的是,在实际业务数据往往是非均衡的,而细粒度标签数量庞大需要进行部分向上一级标签归集处理。如果细粒度标签对应的业务数据数量为0或近乎为0,实际上对于这些标签的预测结果是整体的影响整体的预测结果的,这部分标签可以称之为无效标签或低数据量标签,需要向其上一级标签归集并不再处理。It is understandable that the actual business data is often unbalanced, and the large number of fine-grained tags requires some upper-level tag collection processing. If the number of business data corresponding to fine-grained tags is 0 or almost 0, the prediction results for these tags will actually affect the overall prediction results. This part of the tags can be called invalid tags or low data volume tags. Collect to its superior label and no longer process it.
204、将目标第一标签归入到最低标签层级的第一标签之中。204. Classify the target first label into the first label of the lowest label level.
在一些实施例中,在同类型的第一标签较多的情况下,可以获取低于最低标签层级的标签,例如,预设标签层级为5级,但是同类型的第一标签有7个,这七个第一标签按照等级由高到低排列为A、B、C、D、E、F、G,在预设标签层级为5级的情况下,标签F和标签G低于最低标签层级的标签E,此时,标签F和标签G可以确定为是目标第一标签,可以将目标第一标签F和目标第一标签G归入到最低标签层级的第一标签E中。以此方式来处理尾部标签。In some embodiments, when there are many first labels of the same type, labels below the lowest label level can be obtained. For example, the preset label level is 5, but there are 7 first labels of the same type. The seven first labels are arranged from high to low as A, B, C, D, E, F, G. When the default label level is 5, label F and label G are lower than the lowest label level. At this time, the label F and the label G can be determined to be the target first label, and the target first label F and the target first label G can be classified into the first label E of the lowest label level. The tail tag is processed in this way.
205、将多个同类型的第一标签按照预设标签层级进行整合以得到第一文本样本集。205. Integrate multiple first tags of the same type according to a preset tag level to obtain a first text sample set.
在一些实施例中,可以将同类型的标签按照预设标签层级进行整合,例如,在多个第一标签中获取同类型的标签,其中同类型的标签有A、B、C、D、E这五个第一标签,按照预设标签层级来对第一标签进行整合,A、B、C、D、E这五个第一标签分别对应的文本为“时政”、“国内时政”、“内地时政”,“方针政策”、“三农”,若预设标签层级为5个层级,且第一标签需要由高层级到低层级拼接,则拼接整合后的标签为“A-B-C-D-E”,其中该标签对应的文本为“时政-国内时政-内地时政-方针政策-三农”,同理,可以对多个同类型的第一标签进行整合形成多个整合标签,以此来减少标签的数量。In some embodiments, tags of the same type can be integrated according to a preset tag hierarchy. For example, tags of the same type can be obtained from multiple first tags, where tags of the same type are A, B, C, D, E The five first labels are integrated according to the preset label hierarchy. The corresponding texts of the five first labels of A, B, C, D, and E are "current affairs", "domestic current affairs", and " "Mainland Current Affairs", "Policies", "San Nong", if the default label level is 5 levels, and the first label needs to be spliced from high level to low level, then the combined label will be "ABCDE". The corresponding text of the label is "Current Affairs-Domestic Current Affairs-Mainland Current Affairs-Policies-Agriculture, Rural Areas and Rural Areas". Similarly, multiple first labels of the same type can be integrated to form multiple integrated labels to reduce the number of labels.
对多个整合标签可以进行标签编码,例如,可以采用onehot编码来对整合标签进行编码,最终整合标签和整合标签对应的文本形成第一文本样本集。Tag coding may be performed on multiple integrated tags. For example, onehot encoding may be used to code the integrated tags, and finally the integrated tags and the text corresponding to the integrated tags form the first text sample set.
请继续参阅图3,图3是本申请实施例提供的文本分类模型的训练方法的第三流程示意图。该文本分类模型的训练方法可以包括以下流程:Please continue to refer to FIG. 3, which is a schematic diagram of the third process of the training method of the text classification model provided by the embodiment of the present application. The training method of the text classification model may include the following processes:
301、获取第一文本样本集。301. Obtain a first set of text samples.
在获取第一文本样本集之前,可以对待处理文本中的无效字符进行过滤删除,以保证待处理文本的数据真实性,然后对过滤后的待处理文本进行分词处理得到多个第一文本,对多个第一文本进行文本编码得到多个第一标签,考虑到第一标签的数量较多,可以对同类型的标签进行标签整合形成整合标签,最后多个整合标签进行标签编码,最终整合标签和整合标签对应的文本形成第一 文本样本集。Before obtaining the first text sample set, invalid characters in the text to be processed can be filtered and deleted to ensure the authenticity of the text to be processed, and then the filtered text to be processed is segmented to obtain multiple first texts. Multiple first texts are text-encoded to obtain multiple first tags. Considering the large number of first tags, tags of the same type can be integrated to form an integrated tag, and finally multiple integrated tags are tag-encoded, and finally the integrated tags The text corresponding to the integrated label forms a first text sample set.
302、将第一文本样本集输入至文本分类模型进行文本类别预测,以得到第一文本样本对应的第一预测结果。302. Input the first text sample set into a text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample.
在获取第一文本样本集之后,将第一文本样本集输入至文本分类模型,第文本分类模型能够对多个第一文本进行识别,从而对第一文本进行分类,得到第一文本对应的第一预测结果。其中,每一个第一文本都有各自对应的预测结果,可以采用sigmoid函数来计算第一预测结果的准确率值。After the first text sample set is obtained, the first text sample set is input to the text classification model. The first text classification model can recognize multiple first texts, thereby classifying the first text, and obtaining the first text corresponding to the first text. One prediction result. Among them, each first text has its own corresponding prediction result, and the sigmoid function can be used to calculate the accuracy value of the first prediction result.
303、在第一预测结果不满足预设条件的情况下,对文本分类模型进行调整。303. When the first prediction result does not meet the preset condition, adjust the text classification model.
在获取的第一预测结果后,可以对第一预测结果和第一文本对应的真实结果进行对比,判断第一预测结果是否满足预设条件,例如,可以判断第一预测结果的准确率是否达到预设准确率,如果第一预测结果的准确率没有达到预设准确率,则对文本分类模型进行调整。After the first prediction result is obtained, the first prediction result can be compared with the actual result corresponding to the first text to determine whether the first prediction result meets a preset condition. For example, it can be determined whether the accuracy of the first prediction result reaches The preset accuracy rate, if the accuracy rate of the first prediction result does not reach the preset accuracy rate, the text classification model is adjusted.
在一些实施方式中,可以对文本分类模型的参数进行调整,例如,可以获取文本分类模型的损失函数,在损失函数中输入第一预测结果和真实结果,得到损失值,根据目标损失值来调整文本分类模型的参数进行调整,使得文本分类模型的损失值小于或等于目标损失值。In some embodiments, the parameters of the text classification model can be adjusted. For example, the loss function of the text classification model can be obtained, and the first prediction result and the real result can be input into the loss function to obtain the loss value, which is adjusted according to the target loss value. The parameters of the text classification model are adjusted so that the loss value of the text classification model is less than or equal to the target loss value.
在一些实施方式中,还可以对文本分类模型与预设模型进行串联,来对文本分类模型进行调整,例如,调整前的文本分类模型采用的是BERT模型,在BERT模型之后还可以串联卷积神经网络模型,从而形成新的文本分类模型。In some embodiments, the text classification model can also be concatenated with a preset model to adjust the text classification model. For example, the text classification model before the adjustment uses the BERT model, and the BERT model can also be concatenated. Neural network model to form a new text classification model.
在一些实施方式中,可以对文本分类模型的结构进行调整,例如,文本分类模型采用的是BERT模型加卷积神经网络模型组合成的集成模型,此时,可以对卷积神经网络模型进行多尺度卷积核或者实现多个不同的池化操作,还可以对卷积神经网络的层数进行改变。In some embodiments, the structure of the text classification model can be adjusted. For example, the text classification model uses an integrated model composed of a BERT model and a convolutional neural network model. In this case, the convolutional neural network model can be multiplied. The scale convolution kernel may implement multiple different pooling operations, and the number of layers of the convolutional neural network can also be changed.
304、获取文本分类模型的预设参数,将预设参数设置在调整后的模型之中。304. Obtain preset parameters of the text classification model, and set the preset parameters in the adjusted model.
可以理解的是,在调整之前的文本分类模型之中一些参数的设置是正确的,无需再对其进行调整,这些无需调整的参数为预设参数,在对文本分类模型的调整过程中,可以对调整之前的文本分类模型的预设参数进行获取,使得文本分类模型可以基于这些预设参数进行迁移学习,以保证在对文本分类模型的训练过程中减少训练时长和训练次数,同时基于这些预设参数能够对文本分类模型继续进行调整,最终调整后的文本分类模型可以继续用于下一次训练,直至文本分类模型输出的预测结果满足预设条件为止。It is understandable that the settings of some parameters in the text classification model before the adjustment are correct, and there is no need to adjust them. These parameters that do not need to be adjusted are preset parameters. During the adjustment of the text classification model, you can Obtain the preset parameters of the text classification model before adjustment, so that the text classification model can perform transfer learning based on these preset parameters to ensure that the training time and number of training are reduced during the training of the text classification model, and based on these preset parameters. Setting parameters can continue to adjust the text classification model, and the finally adjusted text classification model can continue to be used for the next training until the prediction result output by the text classification model meets the preset conditions.
305、根据预设长度对目标文本进行文本分割以得到多个分割文本。305. Perform text segmentation on the target text according to the preset length to obtain multiple segmented texts.
可以理解的是,在第一文本样本集中必定有一些文本是不能被文本分类模型预测出来的,此时,需要对第一预测结果不满足预设条件的目标文本按照预设长度对目标文本进行分割,得到多个分割文本。It is understandable that there must be some texts in the first text sample set that cannot be predicted by the text classification model. At this time, it is necessary to perform the target text according to the preset length for the target text whose first prediction result does not meet the preset conditions. Split to get multiple split texts.
在一些实施方式中,通过预设标签层级对目标标签进行整合,获取目标标 签的尾部标签,可以选择部分目标标签的尾部标签归入到最低标签层级的目标标签中。In some embodiments, the target tags are integrated through a preset label level to obtain the tail tags of the target tags, and some of the tail tags of the target tags can be selected to be included in the target tags of the lowest tag level.
在一些实施方式中,还可以在数据库中选取无标签的文本作为输入样本,然后将这些无标签文本输入至调整之前的文本分类模型中,选取预测概率大于预设阈值的标签对应的文本作为高置信文本,将高置信文本和目标文本共同作为新的文本样本集,也就是第二文本样本集。In some embodiments, it is also possible to select unlabeled text in the database as input samples, and then input these unlabeled texts into the text classification model before adjustment, and select the text corresponding to the label whose prediction probability is greater than the preset threshold as the high Confidence text, the high-confidence text and the target text are used together as a new text sample set, that is, the second text sample set.
306、对多个分割文本进行编码,以得到第二文本样本集。306. Encode multiple segmented texts to obtain a second text sample set.
在一些实施方式中,对分割文本进行编码得到目标标签,通过预设标签层级对目标标签进行整合,获取目标标签的尾部标签,可以选择部分目标标签的尾部标签归入到最低标签层级的目标标签中,还可以在数据库中选取高可置信的文本和目标文本组合成第二文本样本集。In some embodiments, the segmented text is encoded to obtain the target label, the target label is integrated through the preset label level, and the tail label of the target label is obtained. The tail labels of some target labels can be selected to be included in the target label of the lowest label level. In the database, high-confidence text and target text can be selected from the database and combined into a second text sample set.
307、将第二文本样本集输入至调整后的文本分类模型之中继续进行训练,直至文本分类模型的预测结果满足预测条件为止。307. Input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the prediction condition.
可以理解的是,在获取到第二文本样本集之后,可以将第二文本样本集输入至调整后的文本分类模型继续对第二文本样本集进行预测,然后获取第二文本对应的第二预测结果,将第二预测结果和第二文本对应的真实结果进行对比,判断第二预测结果是否满足预设条件,若第二预测结果满足预设条件,则停止对文本分类模型进行训练,此时文本分类模型已经可以准确对输入的文件进行分类。It is understandable that after the second text sample set is obtained, the second text sample set can be input to the adjusted text classification model to continue to predict the second text sample set, and then obtain the second prediction corresponding to the second text As a result, the second prediction result is compared with the actual result corresponding to the second text, and it is judged whether the second prediction result meets the preset condition. If the second prediction result meets the preset condition, the training of the text classification model is stopped. The text classification model can already accurately classify the input files.
如果第二预测结果仍然不满足预设条件,则重复上述步骤继续对文本分类模型进行训练,一直到文本分类模型的预测结果满足预设条件的时候,说明文本分类模型已经训练完成。通过对输入的文本样本集进行数据改变以及对文本分类模型的调整,在训练完成的文本分类模型能够准确的对多标签的文本进行分类识别。If the second prediction result still does not meet the preset condition, repeat the above steps to continue training the text classification model until the prediction result of the text classification model meets the preset condition, indicating that the text classification model has been trained. By changing the data of the input text sample set and adjusting the text classification model, the trained text classification model can accurately classify and recognize multi-label text.
由上述可知,本申请实施例中通过将第一文本样本集输入至文本分类模型进行文本类别预测,以得到第一文本样本对应的第一预测结果;在第一预测结果不满足预设条件的情况下,对文本分类模型进行调整;获取文本分类模型的预设参数,将预设参数设置在调整后的模型之中;根据预设长度对目标文本进行文本分割以得到多个分割文本;对多个分割文本进行编码,以得到第二文本样本集;将第二文本样本集输入至调整后的文本分类模型之中继续进行训练,直至文本分类模型的预测结果满足预测条件为止。从而获得训练完成的文本分类模型,训练完成的文本分类模型能够对多级多标签的文本进行分类,同时文本分类模型的预测准确率也能达到预期效果。It can be seen from the above that, in the embodiment of the present application, the text category prediction is performed by inputting the first text sample set into the text classification model to obtain the first prediction result corresponding to the first text sample; if the first prediction result does not meet the preset condition In this case, adjust the text classification model; obtain the preset parameters of the text classification model, and set the preset parameters in the adjusted model; perform text segmentation on the target text according to the preset length to obtain multiple segmented texts; A plurality of segmented texts are encoded to obtain a second text sample set; the second text sample set is input into the adjusted text classification model to continue training until the prediction result of the text classification model meets the prediction condition. Thus, a trained text classification model is obtained. The trained text classification model can classify multi-level and multi-label text, and the prediction accuracy of the text classification model can also achieve the expected effect.
请继续参阅图4,图4是本申请实施例提供的文本分类方法。该方法包括以下流程:Please continue to refer to FIG. 4, which is a text classification method provided by an embodiment of the present application. The method includes the following processes:
401、获取待分类文本集。401. Obtain a text set to be classified.
可以对待分类文本中的无效字符进行过滤删除,以保证待分类文本的数据真实性,对多个待分类文本进行文本编码得到多个待分类文本标签,考虑到待 分类文本的数量较多,可以对同类型的标签进行标签整合形成待分类文本整合标签,最后多个待分类文本整合标签进行标签编码,最终待分类文本整合标签和待分类文本形成待分类文本集。The invalid characters in the text to be classified can be filtered and deleted to ensure the authenticity of the text to be classified. The text encoding of multiple texts to be classified can obtain multiple text labels to be classified. Considering the large number of texts to be classified, you can Tag integration is performed on tags of the same type to form a text-to-be-categorized integrated label, and finally a plurality of text-to-be-categorized integration tags are tag-encoded, and finally the text-to-be-categorized integration tags and text to be classified form a text-to-be-categorized set.
402、调用预先训练的文本分类模型。402. Call a pre-trained text classification model.
需要说明的是,在训练完成文本分类模型之后,该文本分类模型可以对大部分文本进行准确预测,但是考虑对文本分类的精确度,还可以在文本分类模型之后串联文本分类子模型,该文本分类子模型可以根据实际需要调整对文本分类的精度。It should be noted that after the text classification model is trained, the text classification model can accurately predict most of the text. However, considering the accuracy of text classification, the text classification sub-model can also be concatenated after the text classification model. The classification sub-model can adjust the accuracy of text classification according to actual needs.
403、将待分类文本集输入至预先训练的文本分类模型,以得到待分类文本的分类结果。403. Input the text set to be classified into a pre-trained text classification model to obtain a classification result of the text to be classified.
可以理解的是,将待分类文本集输入至预先训练的文本分类模型后,待分类文本的分类结果的精度并不是非常高,但是已经达到了较高的准确度,能够对多级多标签的待分类文本进行分类。It is understandable that after inputting the text set to be classified into the pre-trained text classification model, the accuracy of the classification result of the text to be classified is not very high, but it has reached a high degree of accuracy and can be used for multi-level and multi-label The text to be classified is classified.
404、获取待分类文本对应的最低层级的标签,对最低标签层级的标签对应的文本继续进行文本分类。404. Obtain the lowest-level label corresponding to the text to be classified, and continue text classification on the text corresponding to the lowest label-level label.
在一些实施例中,可以将待分类文本标签最低层级的尾部标签输入至文本分类子模型中,从而实现对待分类文本标签最低层级的尾部标签对应的文本进行文本分类,从而实现更加精确的文本分类效果。In some embodiments, the lowest-level tail label of the text label to be classified can be input into the text classification sub-model, so as to realize the text classification corresponding to the text corresponding to the lowest-level tail label of the text label to be classified, thereby achieving more accurate text classification. effect.
由上述可知,本申请实施例中通过获取待分类文本集;调用预先训练的文本分类模型;将待分类文本集输入至预先训练的文本分类模型,以得到待分类文本的分类结果;获取待分类文本对应的最低层级的标签,对最低标签层级的标签对应的文本继续进行文本分类。从而实现对多级多标签的文本进行分类,提高了文本分类的准确度。It can be seen from the above that in this embodiment of the application, the text set to be classified is obtained; the pre-trained text classification model is invoked; the text set to be classified is input to the pre-trained text classification model to obtain the classification result of the text to be classified; The text corresponding to the lowest-level label, and the text corresponding to the lowest label-level label continues to be text categorized. In this way, the classification of multi-level and multi-label text is realized, and the accuracy of text classification is improved.
请参阅图5,图5是本申请实施例提供的文本分类模型的训练装置的结构示意图,该文本分类模型的训练装置500包括:第一获取模块510、预测模块520、判断模块530、调整模块540、处理模块550、训练模块560。Please refer to FIG. 5. FIG. 5 is a schematic structural diagram of a text classification model training device provided by an embodiment of the present application. The text classification model training device 500 includes: a first acquisition module 510, a prediction module 520, a judgment module 530, and an adjustment module 540, a processing module 550, and a training module 560.
第一获取模块510,用于获取第一文本样本集;The first obtaining module 510 is configured to obtain a first text sample set;
预测模块520,用于将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;The prediction module 520 is configured to input the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
判断模块530,用于将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;The judging module 530 is configured to compare the first prediction result with the real result, and determine whether the first prediction result meets a preset condition;
调整模块540,用于若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;The adjustment module 540 is configured to adjust the text classification model to obtain an adjusted text classification model if the first prediction result does not meet the preset condition;
处理模块550,用于根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;The processing module 550 is configured to process the target text in the first text sample set whose first prediction result does not meet the preset condition according to a preset processing mode, to obtain a second text sample set;
训练模块560,用于将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。The training module 560 is configured to input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
在一些实施例中,第一获取模块510,具体用于获取待处理文本,对所述待处理文本进行分词处理以得到多个所述第一文本;对所述第一文本进行编码以得到所述第一文本对应的第一标签;根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集。In some embodiments, the first obtaining module 510 is specifically configured to obtain a text to be processed, perform word segmentation processing on the text to be processed to obtain a plurality of the first texts; and encode the first text to obtain all the texts. A first label corresponding to the first text; and a plurality of the first labels are integrated according to a preset label level to obtain the first text sample set.
在一些实施例中,第一获取模块510,具体用于获取标签层级低于所述预设标签层级中最低标签层级的目标第一标签;将所述目标第一标签归入到所述最低标签层级的第一标签之中;将多个同类型的所述第一标签按照所述预设标签层级进行整合以得到第一文本样本集。In some embodiments, the first obtaining module 510 is specifically configured to obtain a target first label whose label level is lower than the lowest label level among the preset label levels; and classify the target first label into the lowest label Among the first tags in the hierarchy; multiple first tags of the same type are integrated according to the preset tag hierarchy to obtain a first text sample set.
在一些实施例中,调整模块540,具体用于将所述第一预测结果和所述真实结果输入至所述文本分类模型的损失函数中,以得到损失值;根据所述损失值对所述文本分类模型的参数进行调整。In some embodiments, the adjustment module 540 is specifically configured to input the first prediction result and the real result into the loss function of the text classification model to obtain a loss value; The parameters of the text classification model are adjusted.
在一些实施例中,调整模块540,具体用于根据所述第一预测结果和所述真实结果对所述文本分类模型的网络结构进行调整;对调整后的所述文本分类模型串联预设模型。In some embodiments, the adjustment module 540 is specifically configured to adjust the network structure of the text classification model according to the first prediction result and the real result; connect the adjusted text classification model in series with a preset model .
在一些实施例中,调整模块540,具体用于获取所述文本分类模型的损失函数;根据所述第一预测结果和所述真实结果对所述损失函数进行加权处理。In some embodiments, the adjustment module 540 is specifically configured to obtain the loss function of the text classification model; and perform weighting processing on the loss function according to the first prediction result and the real result.
在一些实施例中,调整模块540,具体用于获取所述文本分类模型的预设参数;将所述预设参数设置在所述调整后的文本分类模型之中。In some embodiments, the adjustment module 540 is specifically configured to obtain preset parameters of the text classification model; and set the preset parameters in the adjusted text classification model.
由上述可知,本申请实施例中,通过第一获取模块510获取第一样本集,预测模块520将第一样本集输入至文本分类模型中进行文本类别预测;判断模块530将得到的第一预测结果和真实结果进行对比,判断第一预测结果是否满足预设条件;调整模块540在第一预测结果不满足预设条件时,对文本分类模型进行调整,以得到调整后的文本分类模型;处理模块550根据预设处理方式对第一文本样本集中第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;训练模块560将第二文本样本集输入至调整后的文本分类模型中继续进行训练,直至文本分类模型的预测结果满足预设条件为止。训练完成的文本分类模型能够准确对多级多标签的文本进行分类。It can be seen from the above that, in the embodiment of the present application, the first sample set is obtained by the first obtaining module 510, and the prediction module 520 inputs the first sample set into the text classification model for text category prediction; the judgment module 530 will obtain the first sample set. 1. The prediction result is compared with the actual result to determine whether the first prediction result meets the preset condition; the adjustment module 540 adjusts the text classification model when the first prediction result does not meet the preset condition to obtain the adjusted text classification model The processing module 550 processes the target text in the first text sample set whose first prediction result does not meet the preset conditions according to a preset processing method to obtain a second text sample set; the training module 560 inputs the second text sample set to the adjustment The subsequent text classification model continues to train until the prediction result of the text classification model meets the preset conditions. The trained text classification model can accurately classify multi-level and multi-label text.
请继续参阅图6,图6是本申请实施例提供的文本分类装置的结构示意图,该文本分类装置600具体包括:第二获取模块610、调用模块620、分类模块630。Please continue to refer to FIG. 6, which is a schematic structural diagram of a text classification device provided by an embodiment of the present application. The text classification device 600 specifically includes: a second acquisition module 610, a calling module 620, and a classification module 630.
第二获取模块610,用于获取目标文本集;The second obtaining module 610 is used to obtain a target text set;
调用模块620,用于调用预先训练的文本分类模型;The calling module 620 is used to call a pre-trained text classification model;
分类模块630,用于将所述目标文本集输入至所述预先训练的文本分类模型,以得到所述目标文本的分类结果;The classification module 630 is configured to input the target text set into the pre-trained text classification model to obtain a classification result of the target text;
所述文本分类模型为本申请实施例提供的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiment of the application.
其中分类模块630,还用于将待分类文本标签最低层级的尾部标签输入至文本分类子模型中,从而实现对待分类文本标签最低层级的尾部标签对应的文 本进行文本分类,从而实现更加精确的文本分类效果。The classification module 630 is also used to input the lowest-level tail label of the text label to be classified into the text classification sub-model, so as to realize the text classification of the text corresponding to the lowest-level tail label of the text label to be classified, thereby achieving more accurate text Classification effect.
由上述可知,本申请实施例中通过第二获取模块610获取待分类文本集;调用模块620调用预先训练的文本分类模型;分类模块630将待分类文本集输入至预先训练的文本分类模型,以得到待分类文本的分类结果;分类模块630还可以获取待分类文本对应的最低层级的标签,对最低标签层级的标签对应的文本继续进行文本分类。从而实现对多级多标签的文本进行分类,提高了文本分类的准确度。It can be seen from the above that in this embodiment of the present application, the second acquisition module 610 acquires the text set to be classified; the calling module 620 calls the pre-trained text classification model; the classification module 630 inputs the text set to be classified into the pre-trained text classification model to The classification result of the text to be classified is obtained; the classification module 630 may also obtain the lowest-level label corresponding to the text to be classified, and continue to perform text classification on the text corresponding to the label of the lowest label level. In this way, the classification of multi-level and multi-label text is realized, and the accuracy of text classification is improved.
应当说明的是,本申请实施例提供的图像属性识别装置与上文实施例中的图像属性识别方法属于同一构思,在图像属性识别装置上可以运行图像属性是被方法实施例中提供的任一方法,其具体实现过程详见图像的处理方法实施例,此处不再赘述。It should be noted that the image attribute recognition device provided in this embodiment of the application belongs to the same concept as the image attribute recognition method in the above embodiment, and the image attribute that can be run on the image attribute recognition device is any one provided in the method embodiment. For the specific implementation process of the method, please refer to the image processing method embodiment, which will not be repeated here.
本申请实施例提供一种计算机可读的存储介质,其上存储有计算机程序,当其存储的计算机程序在计算机上执行时,使得计算机执行如本申请实施例提供的网络模型的训练方法或图像的处理方法。The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the stored computer program is executed on a computer, the computer executes the network model training method or image provided in the embodiment of the present application.的处理方法。 Treatment methods.
其中,存储介质可以是磁碟、光盘、只读存储器(Read Only Memory,ROM,)或者随机存取器(Random Access Memory,RAM)等。Among them, the storage medium may be a magnetic disk, an optical disc, a read only memory (Read Only Memory, ROM,), or a random access device (Random Access Memory, RAM), etc.
本申请实施例还提供一种电子设备,包括存储器,处理器,所述存储器中存储有计算机程序,所述处理器通过调用所述存储器中存储的所述计算机程序,用于执行如本申请实施例提供的网络模型的训练方法或图像属性识别方法。An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor is configured to execute the computer program stored in the memory by calling the computer program stored in the memory. Example provides the training method of the network model or the image attribute recognition method.
例如,上述电子设备可以是诸如平板电脑或者智能手机等移动终端。请参阅图7,图7为本申请实施例提供的电子设备的第一种结构示意图。For example, the above-mentioned electronic device may be a mobile terminal such as a tablet computer or a smart phone. Please refer to FIG. 7. FIG. 7 is a schematic diagram of the first structure of an electronic device provided by an embodiment of this application.
该电子设备700可以包括存储器701、处理器702等部件。本领域技术人员可以理解,图7中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。The electronic device 700 may include components such as a memory 701 and a processor 702. Those skilled in the art can understand that the structure of the electronic device shown in FIG. 7 does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or a combination of certain components, or different component arrangements.
存储器701可用于存储软件程序以及模块,处理器702通过运行存储在存储器701的计算机程序以及模块,从而执行各种功能应用以及数据处理。存储器701可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的计算机程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据电子设备的使用所创建的数据等。The memory 701 may be used to store software programs and modules. The processor 702 executes various functional applications and data processing by running the computer programs and modules stored in the memory 701. The memory 701 may mainly include a storage program area and a storage data area. The storage program area may store an operating system, a computer program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data created by the use of electronic equipment, etc.
处理器702是电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器701内的应用程序,以及调用存储在存储器701内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。The processor 702 is the control center of the electronic device. It uses various interfaces and lines to connect the various parts of the entire electronic device. It executes the electronic device by running or executing the application program stored in the memory 701 and calling the data stored in the memory 701. The various functions and processing data of the electronic equipment can be used to monitor the electronic equipment as a whole.
此外,存储器701可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器701还可以包括存储器控制器,以提供处理器702对存储器701的访问。In addition, the memory 701 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 701 may further include a memory controller to provide the processor 702 with access to the memory 701.
在本实施例中,电子设备中的处理器702会按照如下的指令,将一个或一 个以上的应用程序的进程对应的可执行代码加载到存储器701中,并由处理器702来运行存储在存储器701中的应用程序,从而实现流程:In this embodiment, the processor 702 in the electronic device will load the executable code corresponding to the process of one or more application programs into the memory 701 according to the following instructions, and the processor 702 will run and store the executable code in the memory 701. The application program in 701, so as to realize the process:
获取第一文本样本集;Obtain the first text sample set;
将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;Inputting the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;Comparing the first prediction result with the real result, and judging whether the first prediction result meets a preset condition;
若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;If the first prediction result does not meet the preset condition, adjusting the text classification model to obtain an adjusted text classification model;
根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;Processing, according to a preset processing manner, the target text in the first text sample set whose first prediction result does not meet the preset condition, to obtain a second text sample set;
将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。Inputting the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model satisfies the preset condition.
在一些实施方式中,处理器702执行对所述文本分类模型进行调整时,可以执行:In some implementation manners, when the processor 702 adjusts the text classification model, it may execute:
将所述第一预测结果和所述真实结果输入至所述文本分类模型的损失函数中,以得到损失值;Inputting the first prediction result and the real result into the loss function of the text classification model to obtain a loss value;
根据所述损失值对所述文本分类模型的参数进行调整。The parameters of the text classification model are adjusted according to the loss value.
在一些实施方式中,处理器702执行对所述文本分类模型进行调整时,可以执行:In some implementation manners, when the processor 702 adjusts the text classification model, it may execute:
根据所述第一预测结果和所述真实结果对所述文本分类模型的网络结构进行调整;Adjusting the network structure of the text classification model according to the first prediction result and the real result;
对调整后的所述文本分类模型串联预设模型。A preset model is connected in series with the adjusted text classification model.
在一些实施方式中,处理器702执行对所述文本分类模型进行调整时,可以执行:In some implementation manners, when the processor 702 adjusts the text classification model, it may execute:
获取所述文本分类模型的损失函数;Acquiring the loss function of the text classification model;
根据所述第一预测结果和所述真实结果对所述损失函数进行加权处理。Perform weighting processing on the loss function according to the first prediction result and the real result.
具体的,处理器702执行对所述文本分类模型进行调整时,可以执行:Specifically, when the processor 702 adjusts the text classification model, it may execute:
获取所述文本分类模型的预设参数;Acquiring preset parameters of the text classification model;
将所述预设参数设置在所述调整后的文本分类模型之中。The preset parameters are set in the adjusted text classification model.
在一些实施方式中,处理器702执行根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理时,可以执行:In some implementation manners, when the processor 702 processes the target text whose first prediction result in the first text sample set does not meet a preset condition according to a preset processing manner, it may execute:
根据预设长度对所述目标文本进行文本分割以得到多个分割文本;Performing text segmentation on the target text according to a preset length to obtain multiple segmented texts;
对所述分割文本进行编码得到所述第二文本样本集。Encoding the segmented text to obtain the second text sample set.
在一些实施方式中,处理器702在获取第一文本样本集之前,可以执行:In some implementation manners, before acquiring the first text sample set, the processor 702 may execute:
获取待处理文本,对所述待处理文本进行分词处理以得到多个所述第一文本;Acquiring a text to be processed, and performing word segmentation processing on the text to be processed to obtain a plurality of the first texts;
对所述第一文本进行编码以得到所述第一文本对应的第一标签;Encoding the first text to obtain a first label corresponding to the first text;
根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集。Integrating a plurality of the first tags according to a preset tag level to obtain the first text sample set.
在一些实施方式中,处理器702在执行根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集时,可以执行:In some implementation manners, when the processor 702 executes to integrate a plurality of the first tags according to a preset tag level to obtain the first text sample set, it may execute:
获取标签层级低于所述预设标签层级中最低标签层级的目标第一标签;Acquiring the target first label whose label level is lower than the lowest label level in the preset label levels;
将所述目标第一标签归入到所述最低标签层级的第一标签之中;Classify the target first label into the first label of the lowest label level;
将多个同类型的所述第一标签按照所述预设标签层级进行整合以得到第一文本样本集。The multiple first tags of the same type are integrated according to the preset tag level to obtain a first text sample set.
在本实施例中,电子设备中的处理器702会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行代码加载到存储器701中,并由处理器702来运行存储在存储器701中的应用程序,从而实现流程:In this embodiment, the processor 702 in the electronic device will load the executable code corresponding to the process of one or more application programs into the memory 701 according to the following instructions, and the processor 702 will run and store the executable code in the memory 701. The application program in 701, so as to realize the process:
获取待分类文本集;Obtain the text set to be classified;
调用预先训练的文本分类模型;Call a pre-trained text classification model;
将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;Inputting the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
所述文本分类模型为本申请实施例提供的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by the training method of the text classification model provided in the embodiment of the application.
请参照图8,图8为本申请实施例提供的电子设备的第二结构示意图,与图7所示电子设备的区别在于,电子设备还包括:摄像组件703、射频电路704、音频电路705以及电源706。其中,显示器703、射频电路704、音频电路705以及电源706分别与处理器702电性连接。Please refer to FIG. 8. FIG. 8 is a schematic diagram of a second structure of an electronic device provided by an embodiment of the application. The difference from the electronic device shown in FIG. 7 is that the electronic device further includes a camera component 703, a radio frequency circuit 704, an audio circuit 705, and Power supply 706. Among them, the display 703, the radio frequency circuit 704, the audio circuit 705, and the power supply 706 are electrically connected to the processor 702, respectively.
该显示器703可以用于显示由用户输入的信息或提供给用户的信息以及各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示器703可以包括显示面板,在某些实施方式中,可以采用液晶显示器(Liquid Crystal Display,LCD)、或者有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板。The display 703 may be used to display information input by the user or information provided to the user, and various graphical user interfaces. These graphical user interfaces may be composed of graphics, text, icons, videos, and any combination thereof. The display 703 may include a display panel. In some embodiments, the display panel may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED).
射频电路704可以用于收发射频信号,以通过无线通信与网络设备或其他电子设备建立无线通讯,与网络设备或其他电子设备之间收发信号。The radio frequency circuit 704 may be used to transmit and receive radio frequency signals to establish wireless communication with network equipment or other electronic equipment through wireless communication, and to transmit and receive signals with the network equipment or other electronic equipment.
音频电路705可以用于通过扬声器、传声器提供用户与电子设备之间的音频接口。The audio circuit 705 may be used to provide an audio interface between the user and the electronic device through a speaker or a microphone.
电源706可以用于给电子设备600的各个部件供电。在一些实施例中,电源706可以通过电源管理系统与处理器702逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The power supply 706 can be used to power various components of the electronic device 600. In some embodiments, the power supply 706 may be logically connected to the processor 702 through a power management system, so that functions such as charging, discharging, and power consumption management can be managed through the power management system.
尽管图8中未示出,电子设备600还可以包括摄像组件、蓝牙模块等,摄像组件可以包括图像处理电路,图像处理电路可以利用硬件和/或软件组件实现,可包括定义图像信号处理(Image Signal Processing)管线的各种处理单元。图像处理电路至少可以包括:多个摄像头、图像信号处理器(Image Signal Processor,ISP处理器)、控制逻辑器、图像存储器以及显示器等。其中每个 摄像头至少可以包括一个或多个透镜和图像传感器。图像传感器可包括色彩滤镜阵列(如Bayer滤镜)。图像传感器可获取用图像传感器的每个成像像素捕捉的光强度和波长信息,并提供可由图像信号处理器处理的一组原始图像数据。Although not shown in FIG. 8, the electronic device 600 may also include a camera component, a Bluetooth module, etc. The camera component may include an image processing circuit, which may be implemented by hardware and/or software components, and may include defining image signal processing (Image Signal Processing) various processing units of the pipeline. The image processing circuit may at least include: multiple cameras, an image signal processor (Image Signal Processor, ISP processor), a control logic, an image memory, a display, and the like. Each camera can include at least one or more lenses and image sensors. The image sensor may include a color filter array (such as a Bayer filter). The image sensor can obtain the light intensity and wavelength information captured by each imaging pixel of the image sensor, and provide a set of raw image data that can be processed by the image signal processor.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见上文针对文本分类模型的训练方法/文本分类方法的详细描述,此处不再赘述。In the above embodiments, the description of each embodiment has its own focus. For parts that are not detailed in an embodiment, please refer to the detailed description of the training method/text classification method of the text classification model above. Go into details again.
本申请实施例提供的所述文本分类模型的训练装置/文本分类装置与上文实施例中的文本分类模型的训练方法/文本分类方法属于同一构思,在所述文本分类模型的训练装置/文本分类装置上可以运行所述文本分类模型的训练方法/文本分类方法实施例中提供的任一方法,其具体实现过程详见所述网络模型的训练方法/图像的处理方法实施例,此处不再赘述。The training device/text classification device of the text classification model provided by the embodiment of the application belongs to the same concept as the training method/text classification method of the text classification model in the above embodiments. Any method provided in the training method/text classification method embodiment of the text classification model can be run on the classification device. For the specific implementation process, please refer to the training method/image processing method embodiment of the network model. Go into details again.
需要说明的是,对本申请实施例所述文本分类模型的训练方法/文本分类方法而言,本领域普通技术人员可以理解实现本申请实施例所述网络模型的训练方法/图像的处理方法的全部或部分流程,是可以通过计算机程序来控制相关的硬件来完成,所述计算机程序可存储于一计算机可读取存储介质中,如存储在存储器中,并被至少一个处理器执行,在执行过程中可包括如所述网络模型的训练方法/图像的处理方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)等。It should be noted that for the training method/text classification method of the text classification model described in the embodiment of the present application, a person of ordinary skill in the art can understand all of the training method/image processing method of the network model described in the embodiment of the present application. Or part of the process can be accomplished by controlling the relevant hardware through a computer program. The computer program can be stored in a computer readable storage medium, such as in a memory, and executed by at least one processor. May include the flow of the embodiment of the training method of the network model/the image processing method. Wherein, the storage medium may be a magnetic disk, an optical disc, a read only memory (ROM, Read Only Memory), a random access memory (RAM, Random Access Memory), etc.
对本申请实施例的所述网络模型的训练装置/图像的处理装置而言,其各功能模块可以集成在一个处理芯片中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中,所述存储介质譬如为只读存储器,磁盘或光盘等。For the network model training device/image processing device of the embodiment of the present application, its functional modules can be integrated into one processing chip, or each module can exist alone physically, or two or more modules can be used. Integrated in a module. The above-mentioned integrated modules can be implemented in the form of hardware or software functional modules. If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk, etc. .
以上对本申请实施例所提供的文本分类模型训练方法、文本分类方法、装置及电子设备进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The text classification model training method, text classification method, device, and electronic equipment provided by the embodiments of the application are described in detail above. Specific examples are used in this article to illustrate the principles and implementation of the application. The description of the above embodiments It is only used to help understand the methods and core ideas of this application; at the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation and scope of application. In summary, this The content of the description should not be construed as a limitation on this application.

Claims (20)

  1. 一种文本分类模型的训练方法,其中,所述方法包括:A method for training a text classification model, wherein the method includes:
    获取第一文本样本集;Obtain the first text sample set;
    将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;Inputting the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
    将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;Comparing the first prediction result with the real result, and judging whether the first prediction result meets a preset condition;
    若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;If the first prediction result does not meet the preset condition, adjusting the text classification model to obtain an adjusted text classification model;
    根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;Processing, according to a preset processing manner, the target text in the first text sample set whose first prediction result does not meet the preset condition, to obtain a second text sample set;
    将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。Inputting the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model satisfies the preset condition.
  2. 根据权利要求1所述的文本分类模型的训练方法,其中,所述对所述文本分类模型进行调整,包括:The method for training a text classification model according to claim 1, wherein said adjusting said text classification model comprises:
    将所述第一预测结果和所述真实结果输入至所述文本分类模型的损失函数中,以得到损失值;Inputting the first prediction result and the real result into the loss function of the text classification model to obtain a loss value;
    根据所述损失值对所述文本分类模型的参数进行调整。The parameters of the text classification model are adjusted according to the loss value.
  3. 根据权利要求1所述的文本分类模型的训练方法,其中,所述对所述文本分类模型进行调整,包括:The method for training a text classification model according to claim 1, wherein said adjusting said text classification model comprises:
    根据所述第一预测结果和所述真实结果对所述文本分类模型的网络结构进行调整;Adjusting the network structure of the text classification model according to the first prediction result and the real result;
    对调整后的所述文本分类模型串联预设模型。A preset model is connected in series with the adjusted text classification model.
  4. 根据权利要求1所述的文本分类模型的训练方法,其中,所述对所述文本分类模型进行调整,包括:The method for training a text classification model according to claim 1, wherein said adjusting said text classification model comprises:
    获取所述文本分类模型的损失函数;Acquiring the loss function of the text classification model;
    根据所述第一预测结果和所述真实结果对所述损失函数进行加权处理。Perform weighting processing on the loss function according to the first prediction result and the real result.
  5. 根据权利要求1至4任一项所述的文本分类模型的训练方法,其中,所述对所述文本分类模型进行调整包括:The method for training a text classification model according to any one of claims 1 to 4, wherein said adjusting the text classification model comprises:
    获取所述文本分类模型的预设参数;Acquiring preset parameters of the text classification model;
    将所述预设参数设置在所述调整后的文本分类模型之中。The preset parameters are set in the adjusted text classification model.
  6. 根据权利要求1至4任一项所述的文本分类模型的训练方法,其中,所述根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,包括:The training method of a text classification model according to any one of claims 1 to 4, wherein the first prediction result in the first text sample set does not meet a preset condition for the target text according to a preset processing mode Processing, including:
    根据预设长度对所述目标文本进行文本分割以得到多个分割文本;Performing text segmentation on the target text according to a preset length to obtain multiple segmented texts;
    对所述分割文本进行编码得到所述第二文本样本集。Encoding the segmented text to obtain the second text sample set.
  7. 根据权利要求1至4任一项所述的文本分类模型的训练方法,其中, 在所述获取第一文本样本集之前,所述方法还包括:The method for training a text classification model according to any one of claims 1 to 4, wherein, before the obtaining the first text sample set, the method further comprises:
    获取待处理文本,对所述待处理文本进行分词处理以得到多个所述第一文本样本;Acquiring a text to be processed, and performing word segmentation processing on the text to be processed to obtain a plurality of the first text samples;
    对所述第一文本样本进行编码以得到所述第一文本样本对应的第一标签;Encoding the first text sample to obtain a first label corresponding to the first text sample;
    根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集。Integrating a plurality of the first tags according to a preset tag level to obtain the first text sample set.
  8. 根据权利要求7所述的文本分类模型的训练方法,其中,所述根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集,包括:8. The method for training a text classification model according to claim 7, wherein said integrating a plurality of said first labels according to a preset label level to obtain said first text sample set comprises:
    获取标签层级低于所述预设标签层级中最低标签层级的目标第一标签;Acquiring the target first label whose label level is lower than the lowest label level in the preset label levels;
    将所述目标第一标签归入到所述最低标签层级的第一标签之中;Classify the target first label into the first label of the lowest label level;
    将多个同类型的所述第一标签按照所述预设标签层级进行整合以得到第一文本样本集。The multiple first tags of the same type are integrated according to the preset tag level to obtain a first text sample set.
  9. 一种文本分类方法,其中,包括:A text classification method, which includes:
    获取待分类文本集;Obtain the text set to be classified;
    调用预先训练的文本分类模型;Call a pre-trained text classification model;
    将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;Inputting the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
    所述文本分类模型为采用权利要求1至8任一项所述的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the text classification model training method according to any one of claims 1 to 8.
  10. 一种文本分类模型的训练装置,其中,包括:A training device for a text classification model, which includes:
    第一获取模块,用于获取第一文本样本集;The first obtaining module is used to obtain the first text sample set;
    预测模块,用于将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;A prediction module, configured to input the first text sample set into the text classification model for text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
    判断模块,用于将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;A judging module, configured to compare the first prediction result with the real result, and judge whether the first prediction result meets a preset condition;
    调整模块,用于若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;An adjustment module, configured to adjust the text classification model to obtain an adjusted text classification model if the first prediction result does not meet the preset condition;
    处理模块,用于根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;A processing module, configured to process the target text whose first prediction result in the first text sample set does not meet a preset condition according to a preset processing mode, to obtain a second text sample set;
    训练模块,用于将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。The training module is configured to input the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model meets the preset condition.
  11. 一种文本分类的装置,其中,包括:A text classification device, which includes:
    第二获取模块,用于获取待分类文本集;The second acquisition module is used to acquire a text set to be classified;
    调用模块,用于调用预先训练的文本分类模型;The calling module is used to call the pre-trained text classification model;
    分类模块,用于将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;A classification module, configured to input the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
    所述文本分类模型为采用权利要求1至8任一项所述的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the text classification model training method according to any one of claims 1 to 8.
  12. 一种存储介质,其中,所述存储介质中存储有计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行权利要求1至8任一项所述的文本分类模型的训练方法或权利要求9所述的文本分类方法。A storage medium, wherein a computer program is stored in the storage medium, and when the computer program is run on a computer, the computer is caused to execute the method for training a text classification model according to any one of claims 1 to 8 Or the text classification method of claim 9.
  13. 一种电子设备,其中,所述电子设备包括处理器和存储器,所述存储器中存储有计算机程序,所述处理器通过调用所述存储器中存储的所述计算机程序,用于执行:An electronic device, wherein the electronic device includes a processor and a memory, and a computer program is stored in the memory, and the processor is configured to execute:
    获取第一文本样本集;Obtain the first text sample set;
    将所述第一文本样本集输入至所述文本分类模型进行文本类别预测,以得到所述第一文本样本对应的第一预测结果;Inputting the first text sample set into the text classification model to perform text category prediction, so as to obtain a first prediction result corresponding to the first text sample;
    将所述第一预测结果和真实结果进行对比,判断所述第一预测结果是否满足预设条件;Comparing the first prediction result with the real result, and judging whether the first prediction result meets a preset condition;
    若所述第一预测结果不满足所述预设条件,则对所述文本分类模型进行调整,以得到调整后的文本分类模型;If the first prediction result does not meet the preset condition, adjusting the text classification model to obtain an adjusted text classification model;
    根据预设处理方式对所述第一文本样本集中所述第一预测结果不满足预设条件的目标文本进行处理,以得到第二文本样本集;Processing, according to a preset processing manner, the target text in the first text sample set whose first prediction result does not meet the preset condition, to obtain a second text sample set;
    将所述第二文本样本集输入至所述调整后的文本分类模型中继续进行训练,直至所述文本分类模型的预测结果满足所述预设条件为止。Inputting the second text sample set into the adjusted text classification model to continue training until the prediction result of the text classification model satisfies the preset condition.
  14. 根据权利要求13所述的电子设备,其中,所述处理器用于执行:The electronic device according to claim 13, wherein the processor is configured to execute:
    将所述第一预测结果和所述真实结果输入至所述文本分类模型的损失函数中,以得到损失值;Inputting the first prediction result and the real result into the loss function of the text classification model to obtain a loss value;
    根据所述损失值对所述文本分类模型的参数进行调整。The parameters of the text classification model are adjusted according to the loss value.
  15. 根据权利要求13所述的电子设备,其中,所述处理器用于执行:The electronic device according to claim 13, wherein the processor is configured to execute:
    根据所述第一预测结果和所述真实结果对所述文本分类模型的网络结构进行调整;Adjusting the network structure of the text classification model according to the first prediction result and the real result;
    对调整后的所述文本分类模型串联预设模型。A preset model is connected in series with the adjusted text classification model.
  16. 根据权利要求13至15任一项所述的电子设备,其中,所述处理器用于执行:The electronic device according to any one of claims 13 to 15, wherein the processor is configured to execute:
    获取所述文本分类模型的预设参数;Acquiring preset parameters of the text classification model;
    将所述预设参数设置在所述调整后的文本分类模型之中。The preset parameters are set in the adjusted text classification model.
  17. 根据权利要求13至15任一项所述的电子设备,其中,所述处理器用于执行:The electronic device according to any one of claims 13 to 15, wherein the processor is configured to execute:
    根据预设长度对所述目标文本进行文本分割以得到多个分割文本;Performing text segmentation on the target text according to a preset length to obtain multiple segmented texts;
    对所述分割文本进行编码得到所述第二文本样本集。Encoding the segmented text to obtain the second text sample set.
  18. 根据权利要求13至15任一项所述的电子设备,其中,所述处理器用于执行:The electronic device according to any one of claims 13 to 15, wherein the processor is configured to execute:
    获取待处理文本,对所述待处理文本进行分词处理以得到多个所述第一文本;Acquiring a text to be processed, and performing word segmentation processing on the text to be processed to obtain a plurality of the first texts;
    对所述第一文本进行编码以得到所述第一文本对应的第一标签;Encoding the first text to obtain a first label corresponding to the first text;
    根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集。Integrating a plurality of the first tags according to a preset tag level to obtain the first text sample set.
  19. 根据权利要求13至15任一项所述的电子设备,其中,所述处理器用于执行:The electronic device according to any one of claims 13 to 15, wherein the processor is configured to execute:
    获取待处理文本,对所述待处理文本进行分词处理以得到多个所述第一文本;Acquiring a text to be processed, and performing word segmentation processing on the text to be processed to obtain a plurality of the first texts;
    对所述第一文本进行编码以得到所述第一文本对应的第一标签;Encoding the first text to obtain a first label corresponding to the first text;
    根据预设标签层级对多个所述第一标签进行整合以得到所述第一文本样本集。Integrating a plurality of the first tags according to a preset tag level to obtain the first text sample set.
  20. 一种电子设备,其中,所述电子设备包括处理器和存储器,所述存储器中存储有计算机程序,所述处理器通过调用所述存储器中存储的所述计算机程序,用于执行:An electronic device, wherein the electronic device includes a processor and a memory, and a computer program is stored in the memory, and the processor is configured to execute:
    获取待分类文本集;Obtain the text set to be classified;
    调用预先训练的文本分类模型;Call a pre-trained text classification model;
    将所述待分类文本集输入至所述预先训练的文本分类模型,以得到所述待分类文本的分类结果;Inputting the text set to be classified into the pre-trained text classification model to obtain a classification result of the text to be classified;
    所述文本分类模型为采用权利要求1至8任一项所述的文本分类模型的训练方法得到的文本分类模型。The text classification model is a text classification model obtained by using the text classification model training method according to any one of claims 1 to 8.
PCT/CN2019/125747 2019-12-16 2019-12-16 Text classification model training method, text classification method and apparatus, and electronic device WO2021119949A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2019/125747 WO2021119949A1 (en) 2019-12-16 2019-12-16 Text classification model training method, text classification method and apparatus, and electronic device
CN201980100570.9A CN114424186A (en) 2019-12-16 2019-12-16 Text classification model training method, text classification device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/125747 WO2021119949A1 (en) 2019-12-16 2019-12-16 Text classification model training method, text classification method and apparatus, and electronic device

Publications (1)

Publication Number Publication Date
WO2021119949A1 true WO2021119949A1 (en) 2021-06-24

Family

ID=76478129

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/125747 WO2021119949A1 (en) 2019-12-16 2019-12-16 Text classification model training method, text classification method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN114424186A (en)
WO (1) WO2021119949A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115129861A (en) * 2022-04-08 2022-09-30 腾讯科技(深圳)有限公司 Text classification method and device, storage medium and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109145108A (en) * 2017-06-16 2019-01-04 贵州小爱机器人科技有限公司 Classifier training method, classification method, device and computer equipment is laminated in text
CN109241288A (en) * 2018-10-12 2019-01-18 平安科技(深圳)有限公司 Update training method, device and the equipment of textual classification model
US20190034823A1 (en) * 2017-07-27 2019-01-31 Getgo, Inc. Real time learning of text classification models for fast and efficient labeling of training data and customization
CN109684475A (en) * 2018-11-21 2019-04-26 斑马网络技术有限公司 Processing method, device, equipment and the storage medium of complaint
CN109815332A (en) * 2019-01-07 2019-05-28 平安科技(深圳)有限公司 Loss function optimization method, device, computer equipment and storage medium
CN109857868A (en) * 2019-01-25 2019-06-07 北京奇艺世纪科技有限公司 Model generating method, file classification method, device and computer readable storage medium
WO2019182593A1 (en) * 2018-03-22 2019-09-26 Equifax, Inc. Text classification using automatically generated seed data

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109145108A (en) * 2017-06-16 2019-01-04 贵州小爱机器人科技有限公司 Classifier training method, classification method, device and computer equipment is laminated in text
US20190034823A1 (en) * 2017-07-27 2019-01-31 Getgo, Inc. Real time learning of text classification models for fast and efficient labeling of training data and customization
WO2019182593A1 (en) * 2018-03-22 2019-09-26 Equifax, Inc. Text classification using automatically generated seed data
CN109241288A (en) * 2018-10-12 2019-01-18 平安科技(深圳)有限公司 Update training method, device and the equipment of textual classification model
CN109684475A (en) * 2018-11-21 2019-04-26 斑马网络技术有限公司 Processing method, device, equipment and the storage medium of complaint
CN109815332A (en) * 2019-01-07 2019-05-28 平安科技(深圳)有限公司 Loss function optimization method, device, computer equipment and storage medium
CN109857868A (en) * 2019-01-25 2019-06-07 北京奇艺世纪科技有限公司 Model generating method, file classification method, device and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115129861A (en) * 2022-04-08 2022-09-30 腾讯科技(深圳)有限公司 Text classification method and device, storage medium and electronic equipment
CN115129861B (en) * 2022-04-08 2024-04-12 腾讯科技(深圳)有限公司 Text classification method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN114424186A (en) 2022-04-29

Similar Documents

Publication Publication Date Title
CN109471938B (en) Text classification method and terminal
CN111126574B (en) Method, device and storage medium for training machine learning model based on endoscopic image
US10621755B1 (en) Image file compression using dummy data for non-salient portions of images
US20190050733A1 (en) Reducing the size of a neural network through reduction of the weight matrices
WO2017202125A1 (en) Text classification method and apparatus
US11494886B2 (en) Hierarchical multiclass exposure defects classification in images
WO2019062413A1 (en) Method and apparatus for managing and controlling application program, storage medium, and electronic device
US10755447B2 (en) Makeup identification using deep learning
WO2022213465A1 (en) Neural network-based image recognition method and apparatus, electronic device, and medium
US11301705B2 (en) Object detection using multiple neural network configurations
WO2021092808A1 (en) Network model training method, image processing method and device, and electronic device
CN111898675B (en) Credit wind control model generation method and device, scoring card generation method, machine readable medium and equipment
WO2023217222A1 (en) Cell information statistical method and apparatus, and device and computer-readable storage medium
WO2021081945A1 (en) Text classification method and apparatus, and electronic device and storage medium
WO2021119949A1 (en) Text classification model training method, text classification method and apparatus, and electronic device
CN113111917A (en) Zero sample image classification method and device based on dual self-encoders
WO2019062411A1 (en) Method for managing and controlling background application program, storage medium, and electronic device
WO2021041342A1 (en) Semantic image retrieval for whole slide images
CN116030375A (en) Video feature extraction and model training method, device, equipment and storage medium
US20230162518A1 (en) Systems for Generating Indications of Relationships between Electronic Documents
WO2022127333A1 (en) Training method and apparatus for image segmentation model, image segmentation method and apparatus, and device
CN115170838A (en) Data screening method and device
CN113850326A (en) Image identification method, device, equipment and storage medium
CN111091198A (en) Data processing method and device
US20220253990A1 (en) Media enhancement using discriminative and generative models with feedback

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19956315

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 17/11/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 19956315

Country of ref document: EP

Kind code of ref document: A1