Text classification method, device, computer equipment and storage medium

By segmenting long text into semantic blocks and optimizing model parameters, the problem of semantic information loss caused by text length limitations of pre-trained language models is solved, and the accuracy and training efficiency of text classification are improved.

CN114925202BActive Publication Date: 2025-02-25华润数字科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210524671.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-13
Publication Date
2025-02-25
Estimated Expiration
2042-05-13

AI Technical Summary

Technical Problem

In text classification, the prior art, due to the limitation of the input text length by the pre-trained language model, the long text is divided into small pieces, and the semantic information is lost, thereby reducing the classification accuracy.

Method used

A text classification method is proposed. By obtaining training text with classification labels, the text is segmented into semantic blocks using a preset semantic segmentation algorithm, and these semantic blocks are input into the initial classification value evaluation model and text classification model for processing. By adjusting model parameters, optimize the classification value evaluation model and text classification model until the losses converge, thereby improving the accuracy of text classification.

Benefits of technology

By retaining semantic information when segmenting text, selecting semantic blocks with high value for text classification for classification, significantly improving the accuracy of text classification, and at the same time speeding up the training process and reducing training overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114925202B_ABST
    Figure CN114925202B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of artificial intelligence, and relates to a text classification method, device, computer equipment and storage medium, the method comprising: segmenting a training text to obtain a plurality of semantic blocks; inputting each semantic block into an initial classification value assessment model to obtain a classification value score; screening the semantic blocks according to the classification value score to obtain a semantic block queue, and then inputting the initial text classification model to obtain a classification prediction result; determining the semantic block label of each semantic block in the semantic block queue; calculating a first loss based on the semantic block label and the classification value score, and calculating a second loss based on the classification prediction result and the classification label of the training text; adjusting the initial classification value assessment model according to the first loss to obtain a classification value assessment model, and adjusting the initial text classification model according to the second loss to obtain a text classification model; processing the text to be classified through the classification value assessment model and the text classification model to obtain a text classification result. The present application improves the accuracy of text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a text classification method, apparatus, computer equipment and storage medium. Background Art

[0002] With the development of computer technology, computers are increasingly being used in natural language processing. Text classification is an important topic in natural language processing. Usually, a long text is input into a model based on a neural network, and the model outputs the category to which the text belongs. The pre-trained language model has a self-attention mechanism, which can learn the semantic associations contained in the language and has a good effect in text classification.

[0003] The training of pre-trained language models consumes a lot of computing resources, and pre-trained language models also have a limit on the length of the input text. In practical applications, the text to be processed is usually long, so the text is usually directly divided into multiple sub-texts that are smaller than the maximum input length of the model, and then input into the model for text classification. However, this will lose a lot of important semantic information, resulting in low accuracy of text classification. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a text classification method, apparatus, computer device and storage medium to solve the problem of low text classification accuracy.

[0005] In order to solve the above technical problems, the present application embodiment provides a text classification method, which adopts the following technical solution:

[0006] Get training text with classification labels;

[0007] Segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks;

[0008] Inputting each semantic block into an initial classification value assessment model to obtain a classification value score of each semantic block;

[0009] Screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block;

[0010] Inputting the semantic block queue into an initial text classification model to obtain a classification prediction result;

[0011] Determining a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result;

[0012] Calculating a first loss based on the semantic block label and the classification value score, and calculating a second loss based on the classification prediction result and the classification label;

[0013] Adjusting the initial classification value evaluation model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value evaluation model and a text classification model;

[0014] The text to be classified is obtained, and the text to be classified is processed by the classification value evaluation model and the text classification model to obtain a text classification result of the text to be classified.

[0015] In order to solve the above technical problems, the embodiment of the present application further provides a text classification device, which adopts the following technical solution:

[0016] A training acquisition module is used to obtain training text with classification labels;

[0017] A text segmentation module, used to segment the training text according to a preset semantic segmentation algorithm to obtain multiple semantic blocks;

[0018] A semantic block input module, used to input each semantic block into an initial classification value evaluation model to obtain a classification value score of each semantic block;

[0019] A queue generation module, configured to screen the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block;

[0020] A queue input module, used for inputting the semantic block queue into an initial text classification model to obtain a classification prediction result;

[0021] A label determination module, configured to determine a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result;

[0022] A loss calculation module, configured to calculate a first loss based on the semantic block label and the classification value score, and to calculate a second loss based on the classification prediction result and the classification label;

[0023] A model adjustment module, used for adjusting the initial classification value assessment model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value assessment model and a text classification model;

[0024] The text classification module is used to obtain the text to be classified, and process the text to be classified through the classification value evaluation model and the text classification model to obtain the text classification result of the text to be classified.

[0025] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0026] Get training text with classification labels;

[0027] Segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks;

[0028] Inputting each semantic block into an initial classification value assessment model to obtain a classification value score of each semantic block;

[0029] Screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block;

[0030] Inputting the semantic block queue into an initial text classification model to obtain a classification prediction result;

[0031] Determining a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result;

[0032] Calculating a first loss based on the semantic block label and the classification value score, and calculating a second loss based on the classification prediction result and the classification label;

[0033] Adjusting the initial classification value evaluation model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value evaluation model and a text classification model;

[0034] The text to be classified is obtained, and the text to be classified is processed by the classification value evaluation model and the text classification model to obtain a text classification result of the text to be classified.

[0035] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0036] Get training text with classification labels;

[0037] Segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks;

[0038] Inputting each semantic block into an initial classification value assessment model to obtain a classification value score of each semantic block;

[0039] Screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block;

[0040] Inputting the semantic block queue into an initial text classification model to obtain a classification prediction result;

[0041] Determining a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result;

[0042] Calculating a first loss based on the semantic block label and the classification value score, and calculating a second loss based on the classification prediction result and the classification label;

[0043] Adjusting the initial classification value evaluation model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value evaluation model and a text classification model;

[0044] The text to be classified is obtained, and the text to be classified is processed by the classification value evaluation model and the text classification model to obtain a text classification result of the text to be classified.

[0045] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects: obtaining training text with classification labels, segmenting the training text according to a semantic segmentation algorithm, so that the semantic blocks obtained by segmentation have sufficiently rich semantic information; inputting each semantic block into an initial classification value evaluation model to obtain a classification value score, and the classification value score indicates the value of the semantic block to the text classification; thereby selecting semantic blocks with higher classification values ​​to form a semantic block queue, and inputting the semantic block queue into an initial text classification model to obtain a classification prediction result of the training text; based on the classification prediction result, the classification label and a preset label determination algorithm, the semantic block label of each semantic block in the semantic block queue can be obtained unsupervisedly. The semantic block label indicates whether the semantic block is associated with the text classification result; the first loss is calculated according to the semantic block label and the classification value score, the second loss is calculated according to the classification prediction result and the classification label, the initial classification value evaluation model is optimized according to the first loss, and the initial text classification model is optimized according to the second loss, thereby generating a classification value evaluation model and a text classification model; the present application ensures the semantic information of the semantic block when segmenting the text, selects semantic blocks with higher value for text classification for text classification, and improves the accuracy of the final text classification based on the classification value evaluation model and the text classification model. At the same time, due to the improvement in training accuracy, the training process is also accelerated and the training overhead is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0047] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0048] Figure 2 is a flowchart of an embodiment of a text classification method according to the present application;

[0049] Figure 3 is a structural schematic diagram of an embodiment of a text classification device according to the present application;

[0050] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

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

[0053] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0054] like Figure 1 As shown, the system architecture 100 may include 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.

[0055] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0056] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0057] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0058] It should be noted that the text classification method provided in the embodiment of the present application is generally executed by a server, and accordingly, the text classification device is generally set in the server.

[0059] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0060] Continue to refer Figure 2 , shows a flow chart of an embodiment of a text classification method according to the present application. The text classification method comprises the following steps:

[0061] Step S201, obtaining training text with classification labels.

[0062] In this embodiment, the text classification method is executed on the electronic device (eg Figure 1 The server shown in the figure) can communicate with the terminal through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0063] Specifically, when performing model training, it is necessary to first obtain training text with classification labels; the training text can be the text used in the training, and the text label of the training text is used to identify the text category of the training text.

[0064] Step S202, segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks.

[0065] Specifically, the training text is segmented to obtain multiple semantic blocks. The present application can identify text elements with actual semantics in the training text (e.g., words of a specific category in the text) according to a preset semantic segmentation algorithm, and segment the training text based on the identified text elements to ensure that each semantic block obtained has sufficiently rich semantic information.

[0066] Step S203: input each semantic block into the initial classification value evaluation model to obtain the classification value score of each semantic block.

[0067] The initial classification value assessment model may be a classification value assessment model that has not yet completed training, and the classification value assessment model is used to assess the value or contribution of a semantic block in text classification.

[0068] Specifically, each semantic block is input into the initial classification value assessment model to obtain the classification value score of each semantic block. Generally, the more useful the semantic block is for text classification, the higher the classification value score of the semantic block. In one embodiment, for the i-th semantic block obtained by segmentation, the form of inputting the initial classification value assessment model is [[CLS]Si[SEP]], where CLS and SEP represent separators, and Si represents the i-th semantic block.

[0069] In one embodiment, the initial classification value assessment model is constructed based on a pre-trained language model, wherein the pre-trained language model may be a Bert, Roberta or other model.

[0070] Step S204, screening each semantic block according to the classification value score to obtain a semantic block queue containing at least one semantic block.

[0071] Specifically, the higher the classification value score is, the greater the role of the semantic block in text classification can be considered. Each semantic block can be screened according to the classification value score to obtain a semantic block queue, wherein the semantic block queue contains at least one semantic block.

[0072] In one embodiment, a preset value score threshold is obtained, the classification value score is compared with the value score threshold, and semantic blocks with classification value scores greater than the value score threshold are selected to construct a semantic block queue.

[0073] In one embodiment, the semantic blocks are arranged in descending order according to the classification value scores, and then at least one semantic block is selected to obtain a semantic block queue.

[0074] In one embodiment, since the semantic block queue needs to input a text classification model and the text classification model has a maximum input length, it is necessary to ensure that the sum of the text lengths of the semantic blocks in the semantic block queue is less than or equal to the maximum input length of the text classification model.

[0075] Step S205, inputting the semantic block queue into the initial text classification model to obtain the classification prediction result.

[0076] The initial text classification model may be a text classification model that has not yet completed training. The text classification model is used for text classification to determine the category of the text.

[0077] Specifically, the semantic blocks in the semantic block queue have a higher classification value score, and it can be considered that the semantic blocks in the current semantic block queue are text parts in the training text that can play a greater role in text classification. Therefore, the semantic block queue is input into the initial text classification model to obtain a classification prediction result, which can represent the text category of the training text. For example, the classification prediction result shows that the training text can belong to sports news and shows the probability that the training text belongs to sports news.

[0078] In one embodiment, the initial text classification model is constructed based on a pre-trained language model, wherein the pre-trained language model may be a model such as Bert or Roberta.

[0079] Step S206, based on the classification prediction result, the classification label and a preset label determination algorithm, determine the semantic block label of each semantic block in the semantic block queue; the semantic block label identifies whether the semantic block is associated with the text classification result.

[0080] Specifically, the application needs to train the initial classification value assessment model, and the semantic block label of each semantic block in the semantic block queue is required during the training. The semantic block label is used to identify whether the semantic block is related to the text classification result. For example, when the semantic block is related to the text classification result, the semantic block label is set to 1; when the semantic block is not related to the text classification result, the semantic block label is set to 0.

[0081] Semantic block labels can be automatically determined using an unsupervised method. The determination of semantic block labels requires the use of classification prediction results of the semantic block queue, classification labels of the training text, and a preset label determination algorithm.

[0082] Step S207, calculating the first loss based on the semantic block label and the classification value score, and calculating the second loss based on the classification prediction result and the classification label.

[0083] Specifically, the present application requires training the initial classification value evaluation model and the initial text classification model at the same time, wherein the loss of the initial classification value evaluation model during training is recorded as the first loss, and the loss of the initial text classification model during training is recorded as the second loss.

[0084] The first loss can be calculated based on the semantic block labels and classification value scores of each semantic block. Since the semantic block labels can be obtained in an unsupervised manner, the training of the initial classification value assessment model is unsupervised training. The second loss is calculated based on the classification prediction results and classification labels of the training text. The text labels of the training text can be added manually, so the training of the initial text classification model is supervised training.

[0085] Step S208, adjusting the initial classification value assessment model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, to obtain the classification value assessment model and the text classification model.

[0086] Specifically, the model parameters of the initial classification value evaluation model are adjusted with the goal of minimizing the first loss, and the model parameters of the initial text classification model are adjusted with the goal of minimizing the second loss. After the parameters are adjusted, the training text is iteratively processed until both the first loss and the second loss are converged, and the training is stopped to obtain the classification value evaluation model and the text classification model.

[0087] When optimizing the initial classification value assessment model and the initial text classification model, methods such as SGD and Adam can be used for model optimization.

[0088] Step S209, obtaining the text to be classified, and processing the text to be classified through the classification value evaluation model and the text classification model to obtain the text classification result of the text to be classified.

[0089] Specifically, when the model training is completed and the text classification application is performed, the text to be classified is obtained, the classification value evaluation model and the text classification model are used to process the text to be classified, and the text classification model outputs the text classification result of the text to be classified. The text classification result can display the text category of the text to be classified.

[0090] Furthermore, the above step S209 may include: obtaining the text to be classified; segmenting the text to be classified according to a semantic segmentation algorithm to obtain multiple semantic blocks; inputting each semantic block into a classification value assessment model to obtain a classification value score of each semantic block; screening each semantic block according to the classification value score to obtain a semantic block queue containing at least one semantic block; inputting the semantic block queue into a text classification model to obtain a text classification result of the text to be classified.

[0091] Specifically, the text to be classified is obtained, and the text to be classified is segmented according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks. Then each semantic block is input into a classification value assessment model to obtain a classification value score of each semantic block. Each semantic block is screened according to the classification value score to obtain a semantic block queue. The semantic block queue contains at least one semantic block, and the semantic blocks in the semantic block queue have a higher classification value score and have a higher value for text classification. The semantic block queue is input into a text classification model, and the text classification model processes the semantic block queue and outputs a text classification result of the text to be classified.

[0092] In this embodiment, the text to be classified is first segmented according to the semantic segmentation algorithm to obtain semantic blocks containing rich semantic information; the semantic blocks are input into the classification value evaluation model to obtain classification value scores; according to the classification value scores, semantic blocks with higher value for text classification are selected to form a semantic block queue, and then input into the text classification model; the text classification model classifies the text according to the text parts with higher value for text classification, thereby improving the accuracy of text classification.

[0093] In this embodiment, a training text with classification labels is obtained, and the training text is segmented according to a semantic segmentation algorithm so that the segmented semantic blocks have sufficiently rich semantic information; each semantic block is input into an initial classification value evaluation model to obtain a classification value score, and the classification value score indicates the value of the semantic block to the text classification; thereby, semantic blocks with higher classification values ​​are selected to form a semantic block queue, and the semantic block queue is input into the initial text classification model to obtain the classification prediction result of the training text; based on the classification prediction result, the classification label and a preset label determination algorithm, the semantic block label of each semantic block in the semantic block queue can be obtained unsupervisedly, and the semantic block label indicates the semantic value of the semantic block. Whether the block is associated with the text classification result; calculating the first loss according to the semantic block label and the classification value score, calculating the second loss according to the classification prediction result and the classification label, optimizing the initial classification value evaluation model according to the first loss, and optimizing the initial text classification model according to the second loss, thereby generating a classification value evaluation model and a text classification model; the present application ensures the semantic information of the semantic block when segmenting the text, selects the semantic block with higher value for text classification for text classification, and improves the accuracy of the final text classification based on the classification value evaluation model and the text classification model. At the same time, due to the improvement of training accuracy, the training process is also accelerated and the training overhead is reduced.

[0094] Furthermore, the above-mentioned step S202 may include: identifying target words in the training text; segmenting the training text according to the target words and a preset text length condition to obtain multiple semantic blocks; wherein the number of target words in the semantic block is equal to a preset number threshold and the text length of the semantic block is within a preset length interval; or, the text length of the semantic block is equal to the value of the right endpoint of the preset length interval.

[0095] Specifically, natural language processing is performed on the training text to identify target words in the training text. The target words may be words of a specific category in the training text. In one embodiment, the target words may be named entities and verbs in the training text. The identified target words will be used as a reference element during text segmentation.

[0096] The semantic segmentation algorithm restricts text segmentation from two dimensions: target word and text length. Based on the semantic segmentation algorithm, the training text is segmented according to the target word and the preset text length condition, where the text length condition means that the text length of the intercepted semantic block should be within the preset length range [B min ,B max ], B min and B max is a preset value. For example, B min =32, let B max =64.

[0097] When splitting, you need to first intercept B min length of the text. If B min The text of length already contains the preset number threshold N s The target word of B min The length of the text is regarded as a semantic block; and the segmentation continues from the next position of the training text.

[0098] If B min The number of target words in the text of length does not reach the preset number threshold N s , then in B min Length to B max Continue to search for the target word in the text of length until the target word found reaches the preset number threshold N s At this time, the training text is truncated with the position of the last target word found as the end position to obtain a semantic block; and the segmentation continues from the next position of the training text.

[0099] If B min The number of target words in the text of length does not reach the preset number threshold N s , and find B max length, the number of target words still cannot reach the preset number threshold N s , at this time in B max The training text is truncated at the length as the end position to obtain a semantic block; and the segmentation continues from the next position of the training text.

[0100] In one embodiment, the semantic block includes a first part and a second part, wherein the length of the text of the first part is B. min . When splitting, you need to first intercept B min The length of the text gets the first part. Then in B min Length and B max Search for the target word in the text of length until the target word found reaches the preset number threshold N sAt this time, the training text is truncated with the position of the last target word found as the end position to obtain the second part, and a semantic block is obtained based on the first and second parts; and the segmentation continues from the next position of the training text. min Length starts to search to B max length, the number of target words still cannot reach the preset number threshold N s , at this time in B max The training text is cut off at the length as the end position to obtain the second part, and a semantic block is obtained according to the first part and the second part; and the segmentation is continued from the next position of the training text.

[0101] In this embodiment, the training text is segmented according to the target words and the text length condition to obtain multiple semantic blocks. The semantic blocks have a sufficient number of target words while meeting the text length condition, ensuring that the semantic blocks have sufficiently rich semantic information.

[0102] Furthermore, the above step S203 may include: for each semantic block, inputting the semantic block into each sub-model in the initial classification value assessment model to obtain multiple classification value sub-scores; and calculating the classification value score of the semantic block based on each classification value sub-score.

[0103] Specifically, the initial classification value assessment model may include multiple parallel sub-models, and the sub-model may be composed of a pre-trained language model, a fully connected layer, and an activation function. Among them, the pre-trained language model may include models such as Bert, Roberta, LMO, GPT, etc. The activation function may be a function such as relu, sigmoid, etc. In one embodiment, the initial classification value assessment model may be composed of a pre-trained language model component, a fully connected layer, and an activation function, wherein the pre-trained language model component may be composed of multiple pre-trained language models. The classification value score output by the initial classification value assessment model may be between 0 and 1.

[0104] For each semantic block, the semantic block is input into each sub-model in the initial classification value assessment model, and each sub-model outputs the classification value sub-score of the semantic block. Each classification value sub-score can be calculated, such as summing up, to obtain the classification value score of the semantic block.

[0105] In one embodiment, the average of each classification value sub-score is calculated to obtain the classification value score of the semantic block.

[0106] In one embodiment, the weight of each classification value sub-score is determined by a preset weight algorithm, for example, the weight of each classification value sub-score is determined by a hierarchical analysis method, and then the weighted sum of each classification value sub-score is calculated according to the weight to obtain the classification value score of the semantic block.

[0107] In this embodiment, the initial classification value assessment model may include multiple different sub-models, each sub-model outputs a classification value sub-score for the semantic block, and the classification value score of the semantic block is calculated based on the classification value sub-scores output by each sub-model, taking into account the influence of different sub-models to ensure the accuracy of the classification value score.

[0108] Furthermore, the above step S204 may include: arranging each semantic block in descending order according to the classification value score to obtain a candidate queue; adding each semantic block to the initial semantic block queue in sequence according to the arrangement order of the semantic blocks in the candidate queue, and counting the current queue length of the initial semantic block queue; when the current queue length is greater than a preset length threshold, truncating the last added semantic block according to the length threshold to obtain a semantic block queue.

[0109] Specifically, the semantic blocks are sorted in descending order according to the order of the classification value scores of the semantic blocks from large to small to obtain a candidate queue. The initial state of the initial semantic block queue can be empty, and then the semantic blocks in descending order in the candidate queue are added to the initial semantic block queue in sequence, and the current queue length of the initial semantic block queue is counted after each addition.

[0110] If the current queue length is less than the preset length threshold, continue to add semantic blocks; if the current queue length is exactly equal to the length threshold, for example, the length threshold is 512, 8 semantic blocks are added, and the length of each semantic block is 64, then stop adding semantic blocks and determine the latest initial semantic block queue as the semantic block queue. If after adding a semantic block, the current queue length is greater than the length threshold, the semantic block added last time is truncated according to the length threshold to ensure that the length of the remaining semantic block queue is equal to the length threshold, and obtain the semantic block queue. For example, after adding 6 semantic blocks, the queue length is 384, the length of the 7th semantic block is 40, the length of the 8th semantic block is 42, and the length of the 9th semantic block is 50. After adding the 9th semantic block, the current queue length will exceed the length threshold, then the 9th semantic block will be truncated. The length threshold can be the maximum text length allowed to be input by the text classification model.

[0111] In this embodiment, the semantic blocks are sorted in descending order according to the classification value scores, and then the semantic blocks sorted in descending order are added one by one to the initial semantic block queue, so that the semantic blocks that are most valuable for text classification are selected; when the current queue length exceeds the length threshold, the semantic block added for the last time is truncated in time to ensure that the length of the semantic block queue does not exceed the maximum text length allowed by the text classification model.

[0112] Furthermore, the above step S206 may include: for each semantic block in the semantic block queue, generating a complement queue of the semantic block relative to the semantic block queue; inputting the complement queue into the initial text classification model to obtain the complement classification result; determining the semantic block label of the semantic block according to the classification prediction result, the complement classification result and the classification label; the semantic block label identifies whether the semantic block is associated with the text classification result.

[0113] Specifically, for each semantic block in the semantic block queue, the semantic block can be removed from the semantic block queue, and the remaining semantic blocks can constitute the complement queue of the semantic block relative to the semantic block queue. For example, assuming that the semantic block queue contains semantic blocks A, B, C, and D, semantic block A is removed from the semantic block queue, and then semantic blocks B, C, and D constitute the complement queue of semantic block A.

[0114] The complement queue is input into the initial text classification model to obtain the complement classification result. Then, calculations are performed based on the classification prediction results of the semantic block queue, the complement classification results of the complement queue, and the classification labels of the training text, and the semantic block labels of the removed semantic blocks are determined based on the calculation results without manual labeling.

[0115] In one embodiment, the semantic block label of each semantic block in the semantic block queue may be initialized first, wherein the semantic block label is determined in a random value manner, and the semantic block label is used to identify whether the semantic block is associated with the text classification result, including relevance and irrelevance, and 1 may be used to indicate relevance, and 0 may be used to indicate irrelevance; during initialization, it is randomly determined whether the semantic block label is 0 or 1. After the semantic block label of the semantic block is determined according to the classification prediction result, the complement classification result, and the classification label, the initialized label is adjusted according to the determined semantic block label.

[0116] In this embodiment, the semantic block is removed from the semantic block queue to obtain a complement queue, and the complement queue is input into the initial text classification model to obtain the complement classification result. The semantic block label of the semantic block can be automatically determined according to the classification prediction result, the complement classification result and the classification label, thereby reducing the manual workload.

[0117] Furthermore, the above-mentioned step of determining the semantic block label of the semantic block according to the classification prediction result, the complement classification result and the classification label may include: calculating the queue loss according to the classification prediction result and the classification label; calculating the complement loss according to the complement classification result and the classification label; calculating the difference between the complement loss and the queue loss; when the difference meets the preset difference condition, determining the semantic block label of the semantic block as the first label, the first label indicating that the semantic block is associated with the text classification result; when the difference does not meet the preset difference condition, determining the semantic block label of the semantic block as the second label, the second label indicating that the semantic block is not associated with the text classification result.

[0118] Specifically, the semantic block queue and the complement queue both correspond to the training text and share the classification label. According to the classification prediction results and classification labels, the queue loss loss_classifier(Q) corresponding to the semantic block queue is calculated; according to the complement classification results and classification labels, the complement loss loss_classifier(Q) corresponding to the complement queue is calculated. -Si ), where Q -Si Indicates removing semantic block S from the semantic block queue i The complement queue obtained later.

[0119] The calculation methods of the queue loss and the complement loss are both calculated according to the loss function of the initial classification evaluation model. The initial classification evaluation model is a classifier, and its loss function may be a cross entropy loss function.

[0120] Calculate the difference between the complement loss and the queue loss. Specifically, the difference loss_classifier(Q -Si )-loss_classifier(Q). Then determine whether the difference meets the preset difference condition, which can be that the difference is within the preset difference interval (T d ,T u ), where T d and T u are two preset thresholds.

[0121] If the difference meets the difference condition, that is, the difference is within the preset difference range, the semantic block label is determined as the first label, and the first label indicates that the semantic block is associated with the text classification result. For example, the semantic block label can be set to 1.

[0122] If the difference does not meet the difference condition, that is, the difference is not within the preset difference range, the semantic block label is determined as the second label, and the second label indicates that the semantic block is not associated with the text classification result. For example, the semantic block label can be set to 0.

[0123] The obtained semantic block labels are used to calculate the model loss loss(Q) of the initial value score evaluation model, loss(Q) = CrossEntropy(dis(Q), label(Q)). Among them, CrossEntropy represents the cross entropy loss function, dis(Q) represents the classification value score of each semantic block in the semantic block queue, and label(Q) represents the semantic block label of each semantic block in the semantic block queue.

[0124] In this embodiment, the queue loss is calculated according to the classification prediction result and the classification label, and the complement loss is calculated according to the complement classification result and the classification label; and it is determined whether the difference between the complement loss and the queue loss meets the difference condition, thereby realizing automatic determination of the semantic block label.

[0125] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0126] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0127] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a text classification device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0128] like Figure 3 As shown, the text classification device 300 described in this embodiment includes: a training acquisition module 301, a text segmentation module 302, a semantic block input module 303, a queue generation module 304, a queue input module 305, a label determination module 306, a loss calculation module 307, a loss calculation module 308 and a text classification module 309, wherein:

[0129] The training acquisition module 301 is used to acquire training text with classification labels.

[0130] The text segmentation module 302 is used to segment the training text according to a preset semantic segmentation algorithm to obtain multiple semantic blocks.

[0131] The semantic block input module 303 is used to input each semantic block into the initial classification value evaluation model to obtain the classification value score of each semantic block.

[0132] The queue generation module 304 is used to screen each semantic block according to the classification value score to obtain a semantic block queue containing at least one semantic block.

[0133] The queue input module 305 is used to input the semantic block queue into the initial text classification model to obtain the classification prediction result.

[0134] The label determination module 306 is used to determine the semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result.

[0135] The loss calculation module 307 is used to calculate the first loss based on the semantic block label and the classification value score, and calculate the second loss based on the classification prediction result and the classification label.

[0136] The model adjustment module 308 is used to adjust the initial classification value assessment model according to the first loss, and adjust the initial text classification model according to the second loss, until the first loss and the second loss converge to obtain the classification value assessment model and the text classification model.

[0137] The text classification module 309 is used to obtain the text to be classified, and process the text to be classified through the classification value evaluation model and the text classification model to obtain the text classification result of the text to be classified.

[0138] In this embodiment, a training text with classification labels is obtained, and the training text is segmented according to a semantic segmentation algorithm so that the segmented semantic blocks have sufficiently rich semantic information; each semantic block is input into an initial classification value evaluation model to obtain a classification value score, and the classification value score indicates the value of the semantic block to the text classification; thereby, semantic blocks with higher classification values ​​are selected to form a semantic block queue, and the semantic block queue is input into the initial text classification model to obtain the classification prediction result of the training text; based on the classification prediction result, the classification label and a preset label determination algorithm, the semantic block label of each semantic block in the semantic block queue can be obtained unsupervisedly, and the semantic block label indicates the semantic value of the semantic block. Whether the block is associated with the text classification result; calculating the first loss according to the semantic block label and the classification value score, calculating the second loss according to the classification prediction result and the classification label, optimizing the initial classification value evaluation model according to the first loss, and optimizing the initial text classification model according to the second loss, thereby generating a classification value evaluation model and a text classification model; the present application ensures the semantic information of the semantic block when segmenting the text, selects the semantic block with higher value for text classification for text classification, and improves the accuracy of the final text classification based on the classification value evaluation model and the text classification model. At the same time, due to the improvement of training accuracy, the training process is also accelerated and the training overhead is reduced.

[0139] In some optional implementations of this embodiment, the text segmentation module 302 may include: a target word recognition submodule and a text segmentation submodule, wherein:

[0140] A target word recognition submodule is used to recognize target words in training texts;

[0141] The text segmentation submodule is used to segment the training text according to the target words and the preset text length condition to obtain multiple semantic blocks; wherein the number of target words in the semantic block is equal to the preset number threshold and the text length of the semantic block is within the preset length interval; or, the text length of the semantic block is equal to the value of the right endpoint of the preset length interval.

[0142] In this embodiment, the training text is segmented according to the target words and the text length condition to obtain multiple semantic blocks. The semantic blocks have a sufficient number of target words while meeting the text length condition, ensuring that the semantic blocks have sufficiently rich semantic information.

[0143] In some optional implementations of this embodiment, the semantic block input module 303 may include: a semantic block input submodule and a score calculation submodule, wherein:

[0144] The semantic block input submodule is used to input the semantic block into each sub-model in the initial classification value evaluation model for each semantic block, so as to obtain multiple classification value sub-scores.

[0145] The score calculation submodule is used to calculate the classification value score of the semantic block based on each classification value sub-score.

[0146] In this embodiment, the initial classification value assessment model may include multiple different sub-models, each sub-model outputs a classification value sub-score for the semantic block, and the classification value score of the semantic block is calculated based on the classification value sub-scores output by each sub-model, taking into account the influence of different sub-models to ensure the accuracy of the classification value score.

[0147] In some optional implementations of this embodiment, the queue generation module 304 may include: a descending order arrangement submodule, a semantic block addition submodule, and a semantic block truncation submodule, wherein:

[0148] The descending order submodule is used to arrange each semantic block in descending order according to the classification value score to obtain a candidate queue.

[0149] The semantic block adding submodule is used to add each semantic block to the initial semantic block queue in sequence according to the arrangement order of the semantic blocks in the candidate queue, and to count the current queue length of the initial semantic block queue.

[0150] The semantic block truncation submodule is used to truncate the semantic block added last time according to the length threshold when the current queue length is greater than a preset length threshold, so as to obtain a semantic block queue.

[0151] In this embodiment, the semantic blocks are sorted in descending order according to the classification value scores, and then the semantic blocks sorted in descending order are added one by one to the initial semantic block queue, so that the semantic blocks that are most valuable for text classification are selected; when the current queue length exceeds the length threshold, the semantic block added for the last time is truncated in time to ensure that the length of the semantic block queue does not exceed the maximum text length allowed by the text classification model.

[0152] In some optional implementations of this embodiment, the label determination module 306 may include: a complement generation submodule, a complement input submodule, and a label determination submodule, wherein:

[0153] The complement generation submodule is used to generate, for each semantic block in the semantic block queue, a complement queue of the semantic block relative to the semantic block queue.

[0154] The complement input submodule is used to input the complement queue into the initial text classification model to obtain the complement classification result.

[0155] The label determination submodule is used to determine the semantic block label of the semantic block according to the classification prediction result, the complement classification result and the classification label; the semantic block label identifies whether the semantic block is associated with the text classification result.

[0156] In this embodiment, the semantic block is removed from the semantic block queue to obtain a complement queue, and the complement queue is input into the initial text classification model to obtain the complement classification result. The semantic block label of the semantic block can be automatically determined according to the classification prediction result, the complement classification result and the classification label, thereby reducing the manual workload.

[0157] In some optional implementations of this embodiment, the label determination submodule may include: a queue loss calculation unit, a complement loss calculation unit, a difference calculation unit, a first determination unit, and a second determination unit, wherein:

[0158] The queue loss calculation unit is used to calculate the queue loss according to the classification prediction results and classification labels.

[0159] The complement loss calculation unit is used to calculate the complement loss based on the complement classification result and the classification label.

[0160] The difference calculation unit is used to calculate the difference between the complement loss and the queue loss.

[0161] The first determining unit is used to determine the semantic block label of the semantic block as a first label when the difference meets a preset difference condition, wherein the first label indicates that the semantic block is associated with the text classification result.

[0162] The second determining unit is used to determine the semantic block label of the semantic block as a second label when the difference does not meet the preset difference condition, and the second label indicates that the semantic block is not associated with the text classification result.

[0163] In this embodiment, the queue loss is calculated according to the classification prediction result and the classification label, and the complement loss is calculated according to the complement classification result and the classification label; and it is determined whether the difference between the complement loss and the queue loss meets the difference condition, thereby realizing automatic determination of the semantic block label.

[0164] In some optional implementations of this embodiment, the text classification module 309 may include: a text acquisition submodule, a segmentation submodule, an input submodule, a screening submodule, and a queue input submodule, wherein:

[0165] The text acquisition submodule is used to obtain the text to be classified.

[0166] The segmentation submodule is used to segment the text to be classified according to the semantic segmentation algorithm to obtain multiple semantic blocks.

[0167] The input submodule is used to input each semantic block into the classification value evaluation model to obtain the classification value score of each semantic block.

[0168] The screening submodule is used to screen each semantic block according to the classification value score to obtain a semantic block queue containing at least one semantic block.

[0169] The queue input submodule is used to input the semantic block queue into the text classification model to obtain the text classification result of the text to be classified.

[0170] In this embodiment, the text to be classified is first segmented according to the semantic segmentation algorithm to obtain semantic blocks containing rich semantic information; the semantic blocks are input into the classification value evaluation model to obtain classification value scores; according to the classification value scores, semantic blocks with higher value for text classification are selected to form a semantic block queue, and then input into the text classification model; the text classification model classifies the text according to the text parts with higher value for text classification, thereby improving the accuracy of text classification.

[0171] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0172] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0173] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0174] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the text classification method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0175] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the text classification method.

[0176] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0177] The computer device provided in this embodiment can execute the above text classification method. Here, the text classification method can be the text classification method of each of the above embodiments.

[0178] In this embodiment, a training text with classification labels is obtained, and the training text is segmented according to a semantic segmentation algorithm so that the segmented semantic blocks have sufficiently rich semantic information; each semantic block is input into an initial classification value evaluation model to obtain a classification value score, and the classification value score indicates the value of the semantic block to the text classification; thereby, semantic blocks with higher classification values ​​are selected to form a semantic block queue, and the semantic block queue is input into the initial text classification model to obtain the classification prediction result of the training text; based on the classification prediction result, the classification label and a preset label determination algorithm, the semantic block label of each semantic block in the semantic block queue can be obtained unsupervisedly, and the semantic block label indicates the semantic value of the semantic block. Whether the block is associated with the text classification result; calculating the first loss according to the semantic block label and the classification value score, calculating the second loss according to the classification prediction result and the classification label, optimizing the initial classification value evaluation model according to the first loss, and optimizing the initial text classification model according to the second loss, thereby generating a classification value evaluation model and a text classification model; the present application ensures the semantic information of the semantic block when segmenting the text, selects the semantic block with higher value for text classification for text classification, and improves the accuracy of the final text classification based on the classification value evaluation model and the text classification model. At the same time, due to the improvement of training accuracy, the training process is also accelerated and the training overhead is reduced.

[0179] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the text classification method as described above.

[0180] In this embodiment, a training text with classification labels is obtained, and the training text is segmented according to a semantic segmentation algorithm so that the segmented semantic blocks have sufficiently rich semantic information; each semantic block is input into an initial classification value evaluation model to obtain a classification value score, and the classification value score indicates the value of the semantic block to the text classification; thereby, semantic blocks with higher classification values ​​are selected to form a semantic block queue, and the semantic block queue is input into the initial text classification model to obtain the classification prediction result of the training text; based on the classification prediction result, the classification label and a preset label determination algorithm, the semantic block label of each semantic block in the semantic block queue can be obtained unsupervisedly, and the semantic block label indicates the semantic value of the semantic block. Whether the block is associated with the text classification result; calculating the first loss according to the semantic block label and the classification value score, calculating the second loss according to the classification prediction result and the classification label, optimizing the initial classification value evaluation model according to the first loss, and optimizing the initial text classification model according to the second loss, thereby generating a classification value evaluation model and a text classification model; the present application ensures the semantic information of the semantic block when segmenting the text, selects the semantic block with higher value for text classification for text classification, and improves the accuracy of the final text classification based on the classification value evaluation model and the text classification model. At the same time, due to the improvement of training accuracy, the training process is also accelerated and the training overhead is reduced.

[0181] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0182] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A text classification method, characterized in that: The steps include: Get training text with classification labels; Segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks; Inputting each semantic block into an initial classification value assessment model to obtain a classification value score of each semantic block; Screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block; Inputting the semantic block queue into an initial text classification model to obtain a classification prediction result; Determining a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; the semantic block label identifies whether the semantic block is associated with the text classification result; Calculating a first loss based on the semantic block label and the classification value score, and calculating a second loss based on the classification prediction result and the classification label; Adjusting the initial classification value evaluation model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value evaluation model and a text classification model; The text to be classified is obtained, and the text to be classified is processed by the classification value evaluation model and the text classification model to obtain a text classification result of the text to be classified.

2. The text classification method according to claim 1, characterized in that: The step of segmenting the training text according to a preset semantic segmentation algorithm to obtain a plurality of semantic blocks comprises: identifying target words in the training text; The training text is segmented according to the target words and a preset text length condition to obtain a plurality of semantic blocks; wherein the number of target words in a semantic block is equal to a preset number threshold and the text length of the semantic block is within a preset length interval; or, the text length of the semantic block is equal to the value of the right endpoint of the preset length interval.

3. The text classification method according to claim 1, characterized in that: The step of inputting each semantic block into the initial classification value evaluation model to obtain the classification value score of each semantic block includes: For each semantic block, the semantic block is input into each sub-model in the initial classification value assessment model to obtain a plurality of classification value sub-scores; The classification value score of the semantic block is calculated based on the classification value sub-scores.

4. The text classification method according to claim 1, characterized in that: The step of screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block comprises: Arrange the semantic blocks in descending order according to the classification value scores to obtain a candidate queue; According to the arrangement order of the semantic blocks in the candidate queue, each semantic block is sequentially added to the initial semantic block queue, and the current queue length of the initial semantic block queue is counted; When the current queue length is greater than a preset length threshold, the semantic block added last time is truncated according to the length threshold to obtain a semantic block queue.

5. The text classification method according to claim 1, characterized in that: The step of determining the semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm comprises: For each semantic block in the semantic block queue, generating a complement queue of the semantic block relative to the semantic block queue; Inputting the complement queue into the initial text classification model to obtain a complement classification result; A semantic block label of the semantic block is determined according to the classification prediction result, the complement classification result and the classification label; the semantic block label identifies whether the semantic block is associated with the text classification result.

6. The text classification method according to claim 5, characterized in that: The step of determining the semantic block label of the semantic block according to the classification prediction result, the complement classification result and the classification label comprises: Calculate the queue loss according to the classification prediction result and the classification label; Calculate the complement loss according to the complement classification result and the classification label; Calculating a difference between the complement loss and the queue loss; When the difference meets a preset difference condition, determining the semantic block label of the semantic block as a first label, wherein the first label indicates that the semantic block is associated with a text classification result; When the difference does not meet a preset difference condition, the semantic block label of the semantic block is determined as a second label, and the second label indicates that the semantic block is not associated with the text classification result.

7. The text classification method according to claim 1, characterized in that: The step of obtaining the text to be classified, and processing the text to be classified by the classification value evaluation model and the text classification model to obtain the text classification result of the text to be classified includes: Get the text to be classified; Segment the text to be classified according to the semantic segmentation algorithm to obtain multiple semantic blocks; Inputting each semantic block into the classification value evaluation model to obtain a classification value score of each semantic block; Screening the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block; The semantic block queue is input into the text classification model to obtain a text classification result of the text to be classified.

8. A text classification device, characterized in that: include: A training acquisition module is used to obtain training text with classification labels; A text segmentation module, used to segment the training text according to a preset semantic segmentation algorithm to obtain multiple semantic blocks; A semantic block input module, used to input each semantic block into an initial classification value evaluation model to obtain a classification value score of each semantic block; A queue generation module, configured to screen the semantic blocks according to the classification value scores to obtain a semantic block queue including at least one semantic block; A queue input module, used for inputting the semantic block queue into an initial text classification model to obtain a classification prediction result; A label determination module, used to determine a semantic block label of each semantic block in the semantic block queue based on the classification prediction result, the classification label and a preset label determination algorithm; The semantic block label identifies whether the semantic block is associated with the text classification result; A loss calculation module, configured to calculate a first loss based on the semantic block label and the classification value score, and to calculate a second loss based on the classification prediction result and the classification label; A model adjustment module, used for adjusting the initial classification value assessment model according to the first loss, and adjusting the initial text classification model according to the second loss, until the first loss and the second loss converge, thereby obtaining a classification value assessment model and a text classification model; The text classification module is used to obtain the text to be classified, and process the text to be classified through the classification value evaluation model and the text classification model to obtain the text classification result of the text to be classified.

9. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the text classification method according to any one of claims 1 to 7 when executing the computer-readable instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the text classification method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Text label classification method and system

    CN111782805A

  • Text abstract generation method and device based on semantic chunks, equipment and storage medium

    CN113987169A