Text classification method and device, electronic device, and computer-readable storage medium
By performing the first text classification and text segmentation processing on the classified text, combined with the second text classification, the existing text classification methods have low accuracy and inability to effectively process long texts, and higher text classification accuracy and resource efficiency are achieved.
Patent Information
- Application Number
- CN202110635207.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-08
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2041-06-08
AI Technical Summary
The existing text classification methods have low accuracy, cannot provide a large amount of labeled data, and cannot effectively classify long texts, and cannot accurately locate and predict user intent.
By obtaining the text to be classified, the first text classification process is performed to obtain the first text label. If the probability of multiple tags is greater than the threshold, the text segmentation process is performed to obtain the divided text, and the second text classification process is performed on the divided text to obtain the second text label. Finally, the target text label is determined based on both.
It improves the accuracy of text classification, reduces hardware resource usage, can effectively predict the corresponding tags of text content, and determine the corresponding location of tags, reducing missed judgments and misjudgments.
Smart Images

Figure CN113239204B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of natural language processing, and in particular to a text classification method, a text classification device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of existing network technology and fierce competition among operators, the service quality of customer service call centers (also known as call centers) has become an important part of attracting consumers. For example, call centers receive about 30,000 incoming calls every day. Call centers need to statistically analyze user needs and experiences and respond to public opinions in a timely manner to improve user satisfaction.
[0003] Call centers can collect statistics on user needs by classifying call texts. Call text classification can usually be done using deep learning methods such as keyword matching or convolutional neural networks (CNN) and recurrent neural networks (RNN). In addition, transfer learning based on the Bidirectional Encoder Representations from Transformers (BERT) model and its derived pre-trained models can easily and quickly classify short texts.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] However, when using keyword matching or deep learning methods such as CNN and RNN, annotators need to provide a large amount of labeled data for hierarchical labels or multiple category labels. In addition, the transfer learning of Bert and its derivative pre-trained models is not ideal for the classification of long texts and low label orthogonality of existing call center conversations.
[0006] Based on this, the purpose of the present disclosure is to provide a text classification method, a text classification device, an electronic device and a computer-readable storage medium, thereby overcoming to a certain extent the problems of low accuracy of existing text classification methods, inability to provide a large amount of annotation data, inability to effectively classify long texts, and inability to accurately locate and predict user intentions.
[0007] According to one aspect of the present disclosure, a text classification method is provided, including: obtaining a text to be classified, performing a first text classification process on the text to be classified to obtain a corresponding first text label; when there are multiple first text labels whose label probabilities are greater than a probability threshold, performing a text segmentation process on the text to be classified to obtain a segmented text; performing a second text classification process on the segmented text to obtain a corresponding second text label; and determining a target text label corresponding to the text to be classified based on the first text label and the second text label.
[0008] In an exemplary embodiment of the present disclosure, before obtaining the text to be classified, the method further includes: obtaining the original text, determining the words to be deleted contained in the original text; the words to be deleted include one or more of greetings, modal particles, and stop words; deleting the words to be deleted to obtain the corresponding text to be merged; determining multiple target consecutive short sentences contained in the text to be merged, and merging the multiple target consecutive short sentences to obtain the text to be classified.
[0009] In an exemplary embodiment of the present disclosure, a first text classification process is performed on a text to be classified to obtain a corresponding first text label, including: obtaining a pre-constructed initial model, performing text encoding process on the text to be classified through the initial model to obtain a text vector of the text to be classified; obtaining a pre-constructed first text classification model; the first text classification model is obtained based on the text to be classified and the initial model; performing a first text classification process on the text vector by the first text classification model to obtain a first text label; the first text classification model is trained by the following steps: obtaining a text data set to be classified; the text data set to be classified includes multiple training texts to be classified and training text labels corresponding to each training text to be classified; and training the initial model according to the text data set to be classified to obtain a first text classification model.
[0010] In an exemplary embodiment of the present disclosure, text segmentation is performed on a text to be classified to obtain segmented text, including: determining sentence identifiers corresponding to the text to be classified, and performing text segmentation on the text to be classified according to the sentence identifiers to obtain segmented text; determining paragraph identifiers corresponding to the text to be classified, and performing text segmentation on the text to be classified according to the paragraph identifiers to obtain segmented text; and determining text question and answer pairs contained in the text to be classified, and performing text segmentation on the text to be classified according to the text question and answer pairs to obtain segmented text.
[0011] In an exemplary embodiment of the present disclosure, a second text classification process is performed on the segmented text to obtain a corresponding second text label, including: obtaining a pre-constructed initial model, performing text encoding process on the segmented text through the initial model to obtain a segmented text vector of the segmented text; obtaining a pre-constructed second text classification model; the second text classification model is obtained based on the segmented text and the initial model; performing a second text classification process on the segmented text vector by the second text classification model to obtain a second text label; the second text classification model is trained by the following steps: obtaining a segmented text data set; the segmented text data set includes multiple training segmented texts and training segmented text labels corresponding to each training segmented text; and training the initial model according to the segmented text data set to obtain a second text classification model.
[0012] In an exemplary embodiment of the present disclosure, the method further includes: obtaining a test text to be classified, and determining a test text vector of the test text to be classified; obtaining a first text classification model, inputting the test text vector into the first text classification model, and obtaining a corresponding initial test text label and an initial test label probability; if the initial test label probability is less than a probability threshold, determining the test text label of the test text to be classified, and determining a segmented test text label of the segmented test text corresponding to the test text to be classified; obtaining an updated first text classification model based on the test text to be classified and the test text label, and obtaining an updated second text classification model based on the segmented test text and the segmented test text label.
[0013] In an exemplary embodiment of the present disclosure, a target text label corresponding to a text to be classified is determined based on a first text label and a second text label, including: sorting the first text labels according to the label probabilities of the first text labels to obtain a first label sorting result; determining a target number of first initial valid labels based on the first label sorting result; obtaining the label probability of the second text label, deleting the second text label whose label probability is less than a probability threshold, and obtaining a second initial valid label; obtaining a pre-configured text annotation rule, and determining the target text label based on the text annotation rule, the first initial valid label, and the second initial valid label.
[0014] According to one aspect of the present disclosure, a text classification device is provided, including: a first label determination module, used to obtain a text to be classified, perform a first text classification process on the text to be classified, and obtain a corresponding first text label; a text segmentation module, used to perform a text segmentation process on the text to be classified when there are multiple first text labels with a label probability greater than a probability threshold, and obtain segmented text; a second label determination module, used to perform a second text classification process on the segmented text to obtain a corresponding second text label; and a target label determination module, used to determine a target text label corresponding to the text to be classified based on the first text label and the second text label.
[0015] In an exemplary embodiment of the present disclosure, the text classification device also includes a text preprocessing module, which is used to obtain the original text and determine the words to be deleted contained in the original text; the words to be deleted include one or more of greetings, modal particles, and stop words; delete the words to be deleted to obtain the corresponding text to be merged; determine multiple target consecutive short sentences contained in the text to be merged, and merge the multiple target consecutive short sentences to obtain the text to be classified.
[0016] In an exemplary embodiment of the present disclosure, the first label determination module includes a first label determination unit, which is used to obtain a pre-constructed initial model, perform text encoding processing on the text to be classified through the initial model to obtain a text vector of the text to be classified; obtain a pre-constructed first text classification model; the first text classification model is obtained based on the text to be classified and the initial model; the first text classification model performs a first text classification processing on the text vector to obtain a first text label; the first text classification model is trained through the following steps: obtain a text data set to be classified; the text data set to be classified includes multiple training texts to be classified and training text labels corresponding to each training text to be classified; the initial model is trained according to the text data set to be classified to obtain a first text classification model.
[0017] In an exemplary embodiment of the present disclosure, the text segmentation module includes a text segmentation unit, which is used to determine the sentence identification corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the sentence identification to obtain segmented text; determine the paragraph identification corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the paragraph identification to obtain segmented text; and determine the text question and answer pairs contained in the text to be classified, and perform text segmentation processing on the text to be classified according to the text question and answer pairs to obtain segmented text.
[0018] In an exemplary embodiment of the present disclosure, the second label determination module includes a second label determination unit, which is used to obtain a pre-constructed initial model, perform text encoding processing on the segmented text through the initial model to obtain a segmented text vector of the segmented text; obtain a pre-constructed second text classification model; the second text classification model is obtained based on the segmented text and the initial model; the second text classification model performs a second text classification process on the segmented text vector to obtain a second text label; the second text classification model is trained through the following steps: obtain a segmented text data set; the segmented text data set includes multiple training segmented texts and training segmented text labels corresponding to each training segmented text; the initial model is trained according to the segmented text data set to obtain a second text classification model.
[0019] In an exemplary embodiment of the present disclosure, the text classification device also includes a model updating module, which is used to obtain a test text to be classified and determine a test text vector of the test text to be classified; obtain a first text classification model, input the test text vector into the first text classification model, and obtain a corresponding initial test text label and an initial test label probability; if the initial test label probability is less than a probability threshold, determine the test text label of the test text to be classified, and determine a segmented test text label of the segmented test text corresponding to the test text to be classified; obtain an updated first text classification model based on the test text to be classified and the test text label, and obtain an updated second text classification model based on the segmented test text and the segmented test text label.
[0020] In an exemplary embodiment of the present disclosure, the target label determination module includes a target label determination unit, which is used to sort the first text labels according to the label probabilities of the first text labels to obtain the first label sorting results; determine the target number of first initial valid labels according to the first label sorting results; obtain the label probabilities of the second text labels, delete the second text labels whose label probabilities are less than the probability threshold, and obtain the second initial valid labels; obtain the pre-configured text annotation rules, and determine the target text labels according to the text annotation rules, the first initial valid labels and the second initial valid labels.
[0021] According to one aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods by executing the executable instructions.
[0022] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above methods is implemented.
[0023] According to one aspect of the present disclosure, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text classification method provided in each of the above embodiments.
[0024] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0025] In a text classification method provided in an example embodiment of the present disclosure, a text to be classified is obtained, and a first text classification process is performed on the text to be classified to obtain a corresponding first text label; when there are multiple first text labels with label probabilities greater than a probability threshold, a text segmentation process is performed on the text to be classified to obtain a segmented text; a second text classification process is performed on the segmented text to obtain a corresponding second text label; and a target text label corresponding to the text to be classified is determined based on the first text label and the second text label. Through the text method of the present disclosure, on the one hand, the accuracy of text classification can be improved by comprehensively adopting the first text classification and the second text classification methods for text classification, and the second text classification process can be exempted for text labels with high credibility, thereby reducing hardware resource usage. On the other hand, text classification based on the segmented text can determine the corresponding position of the text label, reduce missed judgments and misjudgments, and effectively predict the label corresponding to the text content.
[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0028] Figure 1 A schematic diagram showing an exemplary system architecture of a text classification method and device to which the embodiments of the present disclosure can be applied;
[0029] Figure 2 A schematic diagram showing the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown;
[0030] Figure 3 A flowchart of a text classification method according to an embodiment of the present disclosure is schematically shown;
[0031] Figure 4 A flowchart of obtaining a first text classification model according to a training text to be classified is schematically shown according to an embodiment of the present disclosure;
[0032] Figure 5 A flowchart of obtaining a second text classification model based on training segmented text according to an embodiment of the present disclosure is schematically shown;
[0033] Figure 6A diagram schematically shows a classification result of using a second text classification model to classify segmented text according to an embodiment of the present disclosure;
[0034] Figure 7 A flowchart of initially annotating text to train a text classification model according to an embodiment of the present disclosure is schematically shown;
[0035] Figure 8 A flowchart of performing rolling update annotation of text to train a text classification model according to an embodiment of the present disclosure is schematically shown;
[0036] Fig. 9 The overall flow chart of determining the target text label of the text to be classified according to one embodiment of the present disclosure is schematically shown;
[0037] Fig.10 The structure diagram of a text classification device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0038] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0039] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0040] Figure 1 A schematic diagram of a system architecture of an exemplary application environment in which a text classification method and apparatus according to an embodiment of the present disclosure can be applied is shown.
[0041] like Figure 1 As shown, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The terminal devices 101, 102, 103 may be various electronic devices with display screens, including but not limited to desktop computers, portable computers, smart phones, tablet computers, etc. It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.
[0042] The text classification method provided in the embodiment of the present disclosure is generally executed by the server 105, and accordingly, the text classification device is generally set in the server 105. However, it is easy for those skilled in the art to understand that the text classification method provided in the embodiment of the present disclosure can also be executed by the terminal devices 101, 102, and 103, and accordingly, the text classification device can also be set in the terminal devices 101, 102, and 103, and this is not particularly limited in the present exemplary embodiment. For example, in an exemplary embodiment, the user can upload the original text to the server 105 through the terminal devices 101, 102, and 103, and the server performs text preprocessing on the original text to obtain the text to be classified through the text classification method provided in the embodiment of the present disclosure, performs text segmentation processing on the text to be classified to obtain the segmented text, and respectively performs text classification processing on the text to be classified and the segmented text to obtain the corresponding target text label, and transmits the target text label to the terminal devices 101, 102, 103, etc.
[0043] Figure 2 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.
[0044] It should be noted that Figure 2 The computer system 200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0045] like Figure 2As shown, the computer system 200 includes a central processing unit (CPU) 201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 202 or a program loaded from a storage part 208 into a random access memory (RAM) 203. Various programs and data required for system operation are also stored in the RAM 203. The CPU 201, the ROM 202, and the RAM 203 are connected to each other via a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.
[0046] The following components are connected to the I / O interface 205: an input section 206 including a keyboard, a mouse, etc.; an output section 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 208 including a hard disk, etc.; and a communication section 209 including a network interface card such as a LAN card, a modem, etc. The communication section 209 performs communication processing via a network such as the Internet. A drive 210 is also connected to the I / O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 210 as needed, so that a computer program read therefrom is installed into the storage section 208 as needed.
[0047] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 209, and / or installed from the removable medium 211. When the computer program is executed by the central processing unit (CPU) 201, the various functions defined in the method and apparatus of the present application are executed. In some embodiments, the computer system 200 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0048] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0049] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0050] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, and the units described may also be arranged in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0051] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being installed in the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiment. For example, the electronic device may implement the following method. Figure 3 to Figure 5 , Figure 7 to Figure 9 The various steps shown, etc.
[0052] The technical solution of the embodiment of the present disclosure is described in detail below:
[0053] Call centers can classify call texts to count user needs. Call text classification can usually use keyword matching or deep learning methods such as CNN and RNN. In addition, transfer learning based on the BERT model and its derived pre-trained models can easily and quickly classify short texts.
[0054] However, when using deep learning methods such as CNN and RNN for text classification, hierarchical labels or labels with more categories require not only more attempts by technical personnel, but also a large amount of labeled data from labelers. In addition, labels with low orthogonality can refer to labels that are easy to confuse when classifying because the two labels describe information that is close. Transfer learning using BERT and its derivative pre-trained models can easily and quickly classify short texts, but the classification effect is not ideal for long texts of existing call center conversations and labels with low orthogonality.
[0055] Based on one or more of the above problems, this exemplary embodiment provides a text classification method. The text classification method can be applied to the above server 105, and can also be applied to one or more of the above terminal devices 101, 102, 103, which is not particularly limited in this exemplary embodiment. Figure 3 As shown, the text classification method may include the following steps S310 to S340:
[0056] Step S310: Obtain the text to be classified, perform a first text classification process on the text to be classified, and obtain a corresponding first text label.
[0057] In this example implementation, the text to be classified may be waiting for text classification processing to determine the text corresponding to the text label. The first text classification processing may be a process of determining the first text label corresponding to the text to be classified. The first text label may be a text label corresponding to the entire text obtained by text classification of the text to be classified as a whole, and the first text label may represent the classification prediction result corresponding to the text to be classified. The number of first labels may be the number of first text labels obtained after the first text classification processing is performed on the text to be classified, and the number of first labels may be one or more.
[0058] The text to be classified is obtained, and the first text classification process is performed on the text to be classified as a whole to obtain the first text label corresponding to the text to be classified as the whole text. After obtaining the first text label, the number of first labels corresponding to the first text label can also be determined.
[0059] Step S320: When there are multiple first text labels whose label probabilities are greater than the probability threshold, the text to be classified is segmented to obtain segmented text.
[0060] In this example implementation, the label probability of the first text label may be a probability value corresponding to each first text label. The probability threshold may be a preset threshold for comparison with the label probability. The text segmentation process may be a process of performing text segmentation on the classified text according to a certain text segmentation method. The segmented text may be the text obtained after performing text segmentation on the classified text.
[0061] After obtaining the first text label corresponding to the text to be classified, the label probability corresponding to the first text label can be obtained. The number of first text labels can be one or more, and the label probability of each first text label can be compared with the probability threshold. When there is only one first text label whose label probability is greater than the probability threshold, the first text label can be used as the target text label corresponding to the text to be classified. When there are multiple first text labels whose label probabilities are all greater than the probability threshold among the first text labels, the text to be classified can be segmented to obtain the corresponding segmented text, so as to perform the next step of processing based on the segmented text.
[0062] Step S330: Perform a second text classification process on the segmented text to obtain a corresponding second text label.
[0063] In this example implementation, the second text classification process may be a text classification process performed on the segmented text. The second text label may be a text label obtained after the second text classification process is performed on the segmented text.
[0064] After obtaining the segmented text, the segmented text can be subjected to a second text classification process to obtain a second text label corresponding to the segmented text. By performing text classification process on the segmented text, the segmented text can be segmentally labeled to facilitate locating the corresponding position of the second text label in the segmented text.
[0065] Step S340: Determine a target text label corresponding to the text to be classified according to the first text label and the second text label.
[0066] In this example implementation, the target text label may be a text label corresponding to the to-be-classified text that is finally determined based on the first text label and the second text label.
[0067] After determining the first text label corresponding to the text to be classified and the second text label corresponding to the segmented text, a preset text annotation rule can be obtained, and the target text label corresponding to the text to be classified can be determined according to the first text label and the second text label and based on the text annotation rule.
[0068] In addition, in this solution, if after the first text classification process is performed on the text to be classified, there is only one first text label among the first text labels obtained whose label probability is greater than the probability threshold, then it is used as the target text label.
[0069] The text classification method provided by the present disclosure, on the one hand, adopts the first text classification method and the second text classification method to perform text classification, which can improve the accuracy of text classification, and can exempt the second text classification process for text labels with high credibility, thereby reducing the occupation of hardware resources. On the other hand, based on the segmented text, the corresponding position of the text label can be determined, the omission and misjudgment can be reduced, and the label corresponding to the text content can be effectively predicted.
[0070] Next, the above steps of this exemplary embodiment are described in more detail.
[0071] In an exemplary embodiment of the present disclosure, an original text is obtained to determine words to be deleted contained in the original text; the words to be deleted include one or more of greetings, modal particles, and stop words; the words to be deleted are deleted to obtain a corresponding text to be merged; a plurality of target consecutive short sentences contained in the text to be merged are determined, and the plurality of target consecutive short sentences are merged to obtain a text to be classified.
[0072] The original text may be an unprocessed text directly obtained. For example, taking a call center of a telephone call as an example, the original text may be a text obtained by directly converting the obtained conversational speech into speech text. The words to be deleted may be words in the original text that have no effect on the text classification result and can be deleted. Greetings may be commonly used communicative languages in daily life. For example, greetings may include words such as "hello", "hello", and "hi". Modal particles may be function words that express moods. For example, modal particles may include "yeah", "ah", "bar", "ne", and so on. Stop words may refer to certain characters or words that are automatically filtered out before or after processing natural language data (or text) in information retrieval in order to save storage space and improve search efficiency. The text to be merged may be the text obtained after deleting the words to be deleted in the original text. The target continuous short sentences may be multiple continuous short sentences connected in the order of sentences in the original text. The merging process may be a process of merging multiple target continuous short sentences into short sentences.
[0073] After obtaining the original text, the words to be deleted contained in the original text can be determined, for example, greetings, modal particles, stop words, etc. contained in the original text. Delete the words to be deleted in the original text to obtain the text to be merged corresponding to the original text. Determine multiple target consecutive short sentences contained in the text to be merged, and merge the determined multiple target consecutive short sentences to obtain the text to be classified. For example, after obtaining the text to be merged, the consecutive short sentences of the same speaker in the text to be merged can be determined as target consecutive short sentences, and the target consecutive short sentences can be merged to obtain the corresponding text to be classified.
[0074] In an exemplary embodiment of the present disclosure, a pre-built initial model is obtained, and text encoding processing is performed on the text to be classified through the initial model to obtain a text vector of the text to be classified; a pre-built first text classification model is obtained; the first text classification model is obtained based on the text to be classified and the initial model; the first text classification model performs a first text classification processing on the text vector to obtain a first text label; the first text classification model is trained through the following steps: obtaining a data set of text to be classified; the data set of text to be classified includes multiple training texts to be classified and training text labels corresponding to each training text to be classified; the initial model is trained according to the data set of text to be classified to obtain the first text classification model.
[0075] Among them, the initial model can be a model pre-built for training the first text classification model. The text encoding process can be a process of performing text encoding on the text to be classified to obtain the corresponding text vector representation. The text vector can be a vector representation of the text to be classified. The first text classification model can be a text classification model obtained by training the initial model using the text to be classified, and the first text classification model can be a classification model used to perform the first full-text prediction on the text to be classified. The first text classification process can be a process of performing text classification on the text to be classified using the first text classification model. The text data set to be classified can be a data set composed of multiple training texts to be classified and their corresponding training text labels. The training text to be classified can be the training data used for training the first text classification model. The training text label can be the corresponding text label obtained after text annotation of the training text to be classified.
[0076] After determining the text to be classified, the text to be classified can be input into the initial model, and the initial model performs text encoding processing on the text to be classified to obtain a text vector corresponding to the text to be classified. For example, since the text to be classified can be a natural language text, after determining the text to be classified, the text to be classified can be input into the BERT encoder to obtain the corresponding text vector (or matrix). Obtain a pre-constructed first text classification model, input the text vector of the text to be classified into the first text classification model, and the first text classification model outputs a first text label corresponding to the text to be classified.
[0077] refer to Figure 4 , Figure 4 A flowchart of obtaining a first text classification model based on training texts to be classified according to an embodiment of the present disclosure is schematically shown. In step S410, a data set of texts to be classified is obtained, and training text labels corresponding to each training text to be classified are obtained. After determining the data set of texts to be classified, the annotator can perform text annotation on the texts to be classified. For example, the annotator can quickly read and find all sentences containing business features and behavioral requirements descriptions for classification and annotation, and then determine the training text labels corresponding to the texts to be classified according to preset annotation rules.
[0078] Specifically, when annotating the text to be classified to determine the first text label, two annotators are required to annotate the same text without knowing each other's annotation results. If the full text annotation results are inconsistent, it will be handed over to a third person for annotation. The annotation system will inform the third person that the text has inconsistent annotations but will not display the annotation results of the first two people. The final annotation result will be based on the third person.
[0079] In step S420, multiple training texts to be classified and their corresponding training text labels in the text data set to be classified are input into the initial model to train the initial model. Specifically, when the training text to be classified is input into the initial model for model training, if the text length of the training text to be classified exceeds 510, the first 510 characters of the training text to be classified are retained. For example, the following training parameters are used for model training. The initial model can use the RoBerta model. The RoBerta model is an enhanced version of the BERT model. The RoBerta model uses larger batches, that is, the number of samples input into the network each time. The learning rate of model training = 2e-5, the maximum length of text = 512, the batch size = 16, the rounds = 3, and the above parameters are used for model training.
[0080] In step S430, after the text data set to be classified and the initial model are used for model training, a corresponding first text classification model can be obtained.
[0081] In an exemplary embodiment of the present disclosure, sentence segmentation identifiers corresponding to the text to be classified are determined, and text segmentation processing is performed on the text to be classified according to the sentence segmentation identifiers to obtain segmented text; paragraph identifiers corresponding to the text to be classified are determined, and text segmentation processing is performed on the text to be classified according to the paragraph identifiers to obtain segmented text; and text question and answer pairs contained in the text to be classified are determined, and text segmentation processing is performed on the text to be classified according to the text question and answer pairs to obtain segmented text.
[0082] Among them, the sentence segmentation mark can be the mark used to separate each short sentence in the text to be classified. For example, the sentence segmentation mark can include ",",",";,".","!","!","?", etc. The text segmentation process can be the process of segmenting the text to be classified according to certain text segmentation rules. The paragraph mark can be the mark used to distinguish different paragraph texts of the text to be classified. The text question and answer pair (Question and Answering) can be the text content corresponding to one question and one answer.
[0083] When obtaining segmented text according to the text to be classified, the corresponding text segmentation rules can be selected according to different usage scenarios to perform text segmentation processing. Specifically, when it is necessary to understand the speaker's intention contained in the text, the text to be classified can be segmented into short sentences or paragraphs. For example, when performing short sentence segmentation processing, the sentence segmentation mark corresponding to the text to be classified can be determined, and the text to be classified can be segmented according to the sentence segmentation mark to obtain the segmented text. The segmented text obtained by performing text segmentation processing on the text to be classified using the sentence segmentation mark can more accurately determine the position of the behavior or demand description in the text when the segmented text is used as training data to train the text classification model in the subsequent text classification model. In addition, when identifying the text intention contained in the text to be classified, the paragraph mark in the text to be classified can also be determined, and the paragraph mark is used to perform text segmentation processing on the text to be classified to obtain the corresponding segmented text. Further, in order to realize the text classification of the automatic question and answer scenario, the text question and answer pairs contained in the text to be classified can be determined, and the text to be classified can be segmented according to the text question and answer pairs to obtain the segmented text.
[0084] Different text segmentation methods are used to segment the classified text, and different segmented text results can be obtained. Since the classified text and the segmented text need to be annotated later to obtain corresponding text labels and segmented text labels, segmented text can expand a text sample into multiple text samples, which increases the training data while reducing the amount of text annotation data, that is, a large amount of annotated text can be generated using less text data.
[0085] It is easy for those skilled in the art to understand that, in some other embodiments, other text segmentation rules can be selected to perform text segmentation processing on the text to be classified. The granularity and method of segmentation can be adjusted according to machine performance and the number of labels to adapt to the implementation requirements of text classification in different scenarios. The present disclosure does not make any special limitation on this.
[0086] In an exemplary embodiment of the present disclosure, a pre-built initial model is obtained, and text encoding processing is performed on the segmented text through the initial model to obtain a segmented text vector of the segmented text; a pre-built second text classification model is obtained; the second text classification model is obtained based on the segmented text and the initial model; the second text classification model performs a second text classification processing on the segmented text vector to obtain a second text label; the second text classification model is trained through the following steps: a segmented text data set is obtained; the segmented text data set includes multiple training segmented texts and training segmented text labels corresponding to each training segmented text; the initial model is trained according to the segmented text data set to obtain a second text classification model.
[0087] Among them, the segmented text can be the text generated after the text to be classified is subjected to text segmentation processing. The segmented text vector can be the corresponding vector representation obtained after the segmented text is subjected to text encoding processing. The second text classification model can be a text classification model obtained by training the initial model using the segmented text, and the second text classification model can be a classification model used to perform segment-by-segment prediction on the text to be classified. The second text classification process can be a process of performing text classification on the segmented text using the second text classification model. The segmented text data set can be a data set consisting of multiple training segmented texts and their corresponding training text labels. The training segmented text can be the training data used for training the second text classification model. The training text label can be the corresponding text label obtained after text annotation of the training segmented text.
[0088] After determining the segmented text according to the text to be classified, the segmented text can be input into the initial model, and the initial model performs text encoding processing on the segmented text to obtain the segmented text vector corresponding to the segmented text. In the same way as the processing of the text to be classified, the segmented text can be input into the BERT encoder to obtain the corresponding segmented text vector (or matrix). Obtain a pre-built second text classification model, input the segmented text vector corresponding to the segmented text into the second text classification model, and the second text classification model outputs the second text label corresponding to the segmented text.
[0089] refer to Figure 5 , Figure 5 A flowchart of obtaining a second text classification model based on training segmented texts according to an embodiment of the present disclosure is schematically shown. In step S510, a segmented text data set and a training segmented text label corresponding to each training segmented text are obtained. After determining the segmented text data set, the annotator can perform text annotation on the segmented texts. For example, the annotator can determine the training segmented text label corresponding to each segmented text according to a preset annotation rule.
[0090] When determining the second text label corresponding to the segmented text, the segmented text may be annotated in the same manner as the text to be classified. If the segmented text annotation results are inconsistent, only the segmented texts with consistent annotation results are used as training data and put into the training data set.
[0091] In step S520, multiple training segmented texts in the segmented text data set and their corresponding training segmented text labels are input into the initial model to train the initial model. Specifically, when the training segmented text is input into the initial model for model training, if the text length of the training segmented text exceeds 510, the first 510 characters of the training text to be classified are retained. Generally, the text length of the segmented text does not exceed 510 characters. When the second text classification model is trained, the initial model can be a BERT model, a RoBerta model, etc., and the corresponding training parameters can be configured as: learning rate = 2e-5, maximum text length = 512, batch size = 16, rounds = 3, and the above parameters are used for model training.
[0092] In step S530, after the segmented text data set and the initial model are used for model training, a corresponding second text classification model can be obtained.
[0093] After obtaining the second text classification model, the second text classification model can be used to perform text classification processing on the segmented text. Figure 6 , Figure 6 The diagram schematically shows the classification result of using the second text classification model to classify the segmented text according to an embodiment of the present disclosure. This embodiment takes the processing of call center call text as an example to illustrate the classification result of the segmented text. Here, after the classification prediction of the text to be classified, the text labels corresponding to the business categories and behavioral requirements of the text to be classified can be obtained. Figure 6 It can be seen that the prediction results of the segmented text under the two categories of business category and behavioral demand are determined by the second text classification model. According to the text annotation rules, the probability threshold can be determined as 0.9. Since the probability corresponding to the label "fault / repair" is greater than the probability threshold 0.9, the credible behavioral demand of the segmented text is "fault / repair". Since in the classification results, "mobile service" occurs first and occupies the most space, appearing 7 times in 13 label categories, the business category is "mobile service".
[0094] It is easy for those skilled in the art to understand that the description of the first text classification model does not mean that there is only one model, but it can also be an integration of multiple models; it can also be that each label category uses a model to determine the corresponding label category. For example, taking the call text in the call center as an example, the business category and behavior demand corresponding to the call text can correspond to a model respectively; in addition, the first text classification model can also be a collection of multiple label category models. The second text classification model is similar, and this disclosure will not elaborate on this.
[0095] In the present disclosure, the text classification model is first trained by initially annotating the text. Figure 7 , Figure 7 The flowchart of performing initial annotation of text to train a text classification model according to an embodiment of the present disclosure is schematically shown. In step S710, a data set of texts to be classified is obtained, and the data set of texts to be classified may contain multiple training texts to be classified. In step S720, the training texts to be classified are subjected to text segmentation processing to obtain training segmented texts. In step S730, training text labels corresponding to each training text to be classified and training segmented text labels corresponding to each training segmented text are obtained. Among them, the training text labels of the training texts to be classified can be obtained by performing text annotation on the training texts to be classified. Similarly, the training segmented text labels can be obtained by performing text annotation on the training segmented texts. In step S740, each training text to be classified and its corresponding training text labels are input into a pre-constructed initial model to train the initial model to obtain a first text classification model; at the same time, multiple training segmented texts and their corresponding training segmented text labels can be input into the pre-constructed initial model to train the initial model to obtain a second text classification model.
[0096] In an exemplary embodiment of the present disclosure, a test text to be classified is obtained, and a test text vector of the test text to be classified is determined; a first text classification model is obtained, and the test text vector is input into the first text classification model to obtain a corresponding initial test text label and an initial test label probability; if the initial test label probability is less than a probability threshold, the test text label of the test text to be classified is determined, and a segmented test text label of a segmented test text corresponding to the test text to be classified is determined; an updated first text classification model is obtained based on the test text to be classified and the test text label, and an updated second text classification model is obtained based on the segmented test text and the segmented test text label.
[0097] Among them, the test text to be classified may be the text to be classified whose text label accuracy needs to be determined. The test text vector may be the corresponding text vector obtained by performing text encoding processing on the test text to be classified. The initial test text label may be the text label obtained after text classification of the test text to be classified using the first text classification model. The initial test label probability may be the probability value corresponding to the test text label. The test text label may be the corresponding label determined after text annotation of the test text to be classified. The segmented test text may be the text obtained after performing text segmentation processing on the test text to be classified. The segmented test text label may be the corresponding label determined after text annotation of the segmented test text.
[0098] refer to Figure 8 , Figure 8The flowchart of rolling update annotation of text to train a text classification model according to an embodiment of the present disclosure is schematically shown. In step S810, the test text to be classified is obtained. In the process of text classification, new text will be continuously generated. For the latest generated text, since it is impossible to determine the accuracy of the text classification model's classification, the latest generated text can be used as the test text to be classified. In step S820, the first text classification model performs text classification processing on the test text to be classified. After the test text to be classified is obtained, the test text to be classified can be subjected to text encoding processing to obtain a test text vector corresponding to the test text to be classified. The first text classification model is obtained, and the test text vector is input into the first text classification model. The first text classification model performs text classification processing on the entire test classification text to be tested, and outputs the corresponding test text label and the test label probability corresponding to the test text label.
[0099] In step S830, the output test label probability is compared with the probability threshold to determine whether the highest label probability of the test text label is lower than the probability threshold. In step S840, if the highest label probability of the test text label is not lower than the probability threshold, the test text to be classified is not put into the text training set, and at this time, there is no need to update the text classification model.
[0100] In step S850, if the probability of the test label with the maximum probability value is still less than the probability threshold, it is necessary to perform text annotation on the test text to be classified, and it is necessary to perform text annotation on the segmented test text after text segmentation processing, so as to obtain the test text label corresponding to the test text to be classified and the segmented test text label corresponding to the segmented test text.
[0101] In step S860, the text data set to be classified and the segmented text data set are updated to regularly update the text classification model. Specifically, the test text to be classified and its corresponding test text label are placed in the text data set to be classified, and the first text classification model is updated according to the text data set to be classified containing the test text to be classified and the test text label corresponding to the test text to be classified, so as to obtain the updated first text classification model. In addition, the segmented test text and its corresponding segmented test text label can also be placed in the segmented text data set, and the second text classification model is updated according to the segmented test text and the segmented test text label corresponding to the segmented test text, so as to obtain the updated second text classification model. By regularly updating the text classification model, the accuracy of the text classification model for text classification can be further improved.
[0102] In an exemplary embodiment of the present disclosure, the first text tags are sorted according to their tag probabilities to obtain a first tag sorting result; a target number of first initial valid tags are determined according to the first tag sorting result; the tag probabilities of the second text tags are obtained, and the second text tags whose tag probabilities are less than a probability threshold are deleted to obtain second initial valid tags; a pre-configured text annotation rule is obtained, and a target text tag is determined according to the text annotation rule, the first initial valid tag, and the second initial valid tag.
[0103] The first label sorting result may be a result obtained by sorting the first text label according to the specific value of the label probability of the first text label. The target number may be a preset number value, for example, the target number may be 3, 5, 7, etc. The first initial valid label may be the first text label ranked in the first label sorting result. The second initial valid label may be the second text label whose label probability value is greater than or equal to the probability threshold. The text annotation rule may be a rule referred to when annotating the text.
[0104] When determining the target text label based on the obtained first text label and the second text label, the first text labels can be sorted from high to low according to the value of the label probability of the first text label to obtain the first label sorting result. When the target number is determined to be 5, the top 5 first text labels can be selected from the first label sorting result as the first initial valid label. After the segmented text is subjected to text classification processing, the second text label can be obtained, the label probability of the second text label is obtained, and the second text label whose label probability is less than the probability threshold is deleted to obtain the second initial valid label.
[0105] After determining the first initial valid label and the second initial valid label, the target text label can be determined from the second initial valid label according to the text annotation rule. For example, when there are multiple text labels with behavioral requirements in the text to be classified, the text label with the largest number of occurrences can be selected as the target text label. For another example, the target text label determined from the second initial valid label according to the text annotation rule must be within the first initial valid label, otherwise the target text label cannot be determined based on the second initial valid label. If the target text label does not reach the probability threshold, the first text label with the highest first label probability value and the second text label with the highest second label probability value are used as the target text labels.
[0106] refer to Fig. 9 , Fig. 9The overall flow chart of determining the target text label of the text to be classified according to an embodiment of the present disclosure is schematically shown. In step S910, the text to be classified is obtained, and the text to be classified is subjected to text encoding processing to obtain a corresponding text vector. In step S920, the obtained text vector is input into the first text classification model, and the text vector is subjected to the first text classification processing to obtain the corresponding first text label. In step S930, it is determined whether there is only one first text label exceeding the probability threshold. The first text label obtained after the first text classification processing is obtained, and it is determined whether there is only one first text label whose label probability is greater than or equal to the probability threshold. In step S940, if so, the determined only first text label is used as the target text label. In step S950, if there are multiple first text labels whose label probabilities are all greater than the probability threshold, the text to be classified is subjected to text segmentation processing to obtain the corresponding segmented text, and the segmented text is subjected to text encoding processing to obtain the segmented text vector. In step S960, the obtained segmented text vector is input into the second text classification model, and the segmented text vector is subjected to the second text classification processing. In step S970, the text classification result is substituted into the text annotation rule. The text classification result obtained after the second text classification process, that is, the second text label, is determined, and the second text label is substituted into the text annotation rule, and the target text label is determined based on the text annotation rule and the first text label and the second text label.
[0107] Taking the processing of call texts of a call center as an example, the call center can use the text classification method disclosed in this disclosure to obtain the call classification results immediately after the call ends, and can use the obtained classification results for statistical reports, public opinion monitoring, business recommendations, etc. In addition, the use of real-time speech-to-text function can also achieve the purpose of real-time prediction of user intentions during a call. The text classification method disclosed in this disclosure can also be used for text classification of other similar text structures, and this disclosure does not make any special restrictions on this.
[0108] It should be noted that the terms "first", "second", etc. used in this application are only for distinguishing different text labels, different text classification processes, different text classification models and different initial valid labels, and should not impose any limitations on this disclosure.
[0109] In summary, the text classification method disclosed in the present invention obtains the text to be classified, performs a first text classification process on the text to be classified, and obtains the corresponding first text label; when there are multiple first text labels with label probabilities greater than the probability threshold, performs text segmentation on the text to be classified to obtain segmented text; performs a second text classification process on the segmented text to obtain the corresponding second text label; and determines the target text label corresponding to the text to be classified according to the first text label and the second text label. Through the text method disclosed in the present invention, on the one hand, by performing text segmentation on the text, a large number of text labels can be generated using less text data, reducing the amount of text required for model training. On the other hand, the comprehensive use of the first text classification model and the second text classification model for text classification can not only improve the accuracy of text classification, but also exempt the credible classification results with high label probabilities from entering the second text classification model for text classification, effectively reducing the occupation of hardware resources. On the other hand, by performing text classification based on the segmented text, the corresponding position of the text label can be determined, which is not easy to miss and can also improve the accuracy of text annotation.
[0110] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0111] Furthermore, in this exemplary embodiment, a text classification device is also provided. The text classification device can be applied to a server or a terminal device. Fig.10 As shown, the text classification device 1000 may include a first label determination module 1010, a text segmentation module 1020, a second label determination module 1030 and a target label determination module 1040. Among them:
[0112] The first label determination module 1010 is used to obtain the text to be classified, perform a first text classification process on the text to be classified, and obtain a corresponding first text label; the text segmentation module 1020 is used to perform a text segmentation process on the text to be classified when there are multiple first text labels with label probabilities greater than a probability threshold, and obtain segmented text; the second label determination module 1030 is used to perform a second text classification process on the segmented text to obtain a corresponding second text label; the target label determination module 1040 is used to determine the target text label corresponding to the text to be classified based on the first text label and the second text label.
[0113] In an exemplary embodiment of the present disclosure, the text classification device also includes a text preprocessing module, which is used to obtain the original text and determine the words to be deleted contained in the original text; the words to be deleted include one or more of greetings, modal particles, and stop words; delete the words to be deleted to obtain the corresponding text to be merged; determine multiple target consecutive short sentences contained in the text to be merged, and merge the multiple target consecutive short sentences to obtain the text to be classified.
[0114] In an exemplary embodiment of the present disclosure, the first label determination module includes a first label determination unit, which is used to obtain a pre-constructed initial model, perform text encoding processing on the text to be classified through the initial model to obtain a text vector of the text to be classified; obtain a pre-constructed first text classification model; the first text classification model is obtained based on the text to be classified and the initial model; the first text classification model performs a first text classification processing on the text vector to obtain a first text label; the first text classification model is trained through the following steps: obtain a text data set to be classified; the text data set to be classified includes multiple training texts to be classified and training text labels corresponding to each training text to be classified; the initial model is trained according to the text data set to be classified to obtain a first text classification model.
[0115] In an exemplary embodiment of the present disclosure, the text segmentation module includes a text segmentation unit, which is used to determine the sentence identification corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the sentence identification to obtain segmented text; determine the paragraph identification corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the paragraph identification to obtain segmented text; and determine the text question and answer pairs contained in the text to be classified, and perform text segmentation processing on the text to be classified according to the text question and answer pairs to obtain segmented text.
[0116] In an exemplary embodiment of the present disclosure, the second label determination module includes a second label determination unit, which is used to obtain a pre-constructed initial model, perform text encoding processing on the segmented text through the initial model to obtain a segmented text vector of the segmented text; obtain a pre-constructed second text classification model; the second text classification model is obtained based on the segmented text and the initial model; the second text classification model performs a second text classification process on the segmented text vector to obtain a second text label; the second text classification model is trained through the following steps: obtain a segmented text data set; the segmented text data set includes multiple training segmented texts and training segmented text labels corresponding to each training segmented text; the initial model is trained according to the segmented text data set to obtain a second text classification model.
[0117] In an exemplary embodiment of the present disclosure, the text classification device also includes a model updating module, which is used to obtain a test text to be classified and determine a test text vector of the test text to be classified; obtain a first text classification model, input the test text vector into the first text classification model, and obtain a corresponding initial test text label and an initial test label probability; if the initial test label probability is less than a probability threshold, determine the test text label of the test text to be classified, and determine a segmented test text label of the segmented test text corresponding to the test text to be classified; obtain an updated first text classification model based on the test text to be classified and the test text label, and obtain an updated second text classification model based on the segmented test text and the segmented test text label.
[0118] In an exemplary embodiment of the present disclosure, the target label determination module includes a target label determination unit, which is used to sort the first text labels according to the label probabilities of the first text labels to obtain the first label sorting results; determine the target number of first initial valid labels according to the first label sorting results; obtain the label probabilities of the second text labels, delete the second text labels whose label probabilities are less than the probability threshold, and obtain the second initial valid labels; obtain the pre-configured text annotation rules, and determine the target text labels according to the text annotation rules, the first initial valid labels and the second initial valid labels.
[0119] The specific details of each module or unit in the above-mentioned text classification device have been described in detail in the corresponding text classification method, so they will not be repeated here.
[0120] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0121] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0122] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A text classification method, characterized in that: include: Acquire a text to be classified, perform a first text classification process on the text to be classified, and obtain a corresponding first text label, where the number of the first text label is one or more; When there are multiple first text labels whose label probabilities are greater than a probability threshold, performing text segmentation processing on the text to be classified to obtain segmented text, wherein the segmented text is obtained by performing text segmentation processing on the text to be classified based on one or more of the sentence segmentation identifiers, paragraph identifiers, and text question-answer pairs corresponding to the text to be classified; Performing a second text classification process on the segmented text to obtain corresponding second text labels, where the number of the second text labels is one or more; Determine a target text label corresponding to the to-be-classified text according to the first text label and the second text label, wherein the number of the target text labels is one or more; The step of determining a target text label corresponding to the text to be classified according to the first text label and the second text label includes: Sorting the first text labels according to the label probabilities of the first text labels to obtain a first label sorting result; Determine a target number of first initial valid tags according to the first tag sorting result; Obtaining the label probability of the second text label, deleting the second text label whose label probability is less than the probability threshold, and obtaining a second initial valid label; A preconfigured text annotation rule is obtained, and the target text label is determined according to the text annotation rule, the first initial valid label, and the second initial valid label.
2. The method according to claim 1, characterized in that Before obtaining the text to be classified, the method further includes: Acquire the original text, and determine the words to be deleted contained in the original text; the words to be deleted include one or more of greetings, modal particles, and stop words; Deleting the words to be deleted to obtain corresponding texts to be merged; A plurality of target consecutive short sentences contained in the text to be merged is determined, and a merging process is performed on the plurality of target consecutive short sentences to obtain the text to be classified.
3. The method according to claim 1, characterized in that The performing a first text classification process on the text to be classified to obtain a corresponding first text label includes: Acquire a pre-built initial model, and perform text encoding processing on the text to be classified by using the initial model to obtain a text vector of the text to be classified; Acquire a pre-built first text classification model; the first text classification model is obtained based on the text to be classified and the initial model; The first text classification model performs the first text classification process on the text vector to obtain the first text label; The first text classification model is trained by the following steps: Acquire a text data set to be classified; the text data set to be classified includes a plurality of training texts to be classified and training text labels corresponding to each training text to be classified; The initial model is trained according to the text data set to be classified to obtain the first text classification model.
4. The method according to claim 1, characterized in that: The step of performing text segmentation processing on the text to be classified to obtain segmented text includes: Determine the sentence segmentation mark corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the sentence segmentation mark to obtain the segmented text; Determine the paragraph mark corresponding to the text to be classified, and perform text segmentation processing on the text to be classified according to the paragraph mark to obtain the segmented text; and Determine the text question-answer pairs contained in the text to be classified, and perform text segmentation processing on the text to be classified according to the text question-answer pairs to obtain the segmented text.
5. The method according to claim 1 or 4, characterized in that: The performing a second text classification process on the segmented text to obtain a corresponding second text label includes: Acquire a pre-built initial model, and perform text encoding processing on the segmented text using the initial model to obtain a segmented text vector of the segmented text; Acquire a pre-built second text classification model; the second text classification model is obtained based on the segmented text and the initial model; The second text classification model performs the second text classification process on the segmented text vector to obtain the second text label; The second text classification model is trained by the following steps: Obtain a segmented text dataset; the segmented text dataset includes a plurality of training segmented texts and training segmented text labels corresponding to each of the training segmented texts; The initial model is trained according to the segmented text data set to obtain the second text classification model.
6. The method according to claim 5, characterized in that The method further comprises: Acquire a test text to be classified, and determine a test text vector of the test text to be classified; Obtain a first text classification model, input the test text vector into the first text classification model, and obtain a corresponding initial test text label and an initial test label probability; If the initial test label probability is less than the probability threshold, determining the test text label of the test text to be classified, and determining the segmented test text label of the segmented test text corresponding to the test text to be classified; An updated first text classification model is obtained according to the test text to be classified and the test text label, and an updated second text classification model is obtained according to the segmented test text and the segmented test text label.
7. A text classification device, characterized in that: include: A first label determination module is used to obtain a text to be classified, perform a first text classification process on the text to be classified, and obtain a corresponding first text label, where the number of the first text labels is one or more; A text segmentation module, configured to perform text segmentation processing on the text to be classified to obtain segmented text when there are multiple first text labels with label probabilities greater than a probability threshold, wherein the segmented text is obtained by performing text segmentation processing on the text to be classified based on one or more of sentence segmentation identifiers, paragraph identifiers, and text question-answer pairs corresponding to the text to be classified; A second label determination module, used for performing a second text classification process on the segmented text to obtain a corresponding second text label, where the number of the second text label is one or more; a target label determination module, used to determine a target text label corresponding to the to-be-classified text according to the first text label and the second text label, wherein the number of the target text labels is one or more; The target tag determination module is further configured to sort the first text tags according to the tag probabilities of the first text tags to obtain a first tag sorting result; Determine a target number of first initial valid tags according to the first tag sorting result; Obtaining the label probability of the second text label, deleting the second text label whose label probability is less than the probability threshold, and obtaining a second initial valid label; A preconfigured text annotation rule is obtained, and the target text label is determined according to the text annotation rule, the first initial valid label, and the second initial valid label.
8. An electronic device, characterized in that: include: processor; as well as A memory, wherein computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the processor, the text classification method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text classification method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Industry categorizing method and system of text, computer equipment and storage medium
CN108520041A
Text classification correction method, device and equipment and computer readable storage medium
CN111198948A